diff options
author | beck <> | 1999-09-29 05:53:45 +0000 |
---|---|---|
committer | beck <> | 1999-09-29 05:53:45 +0000 |
commit | 648e4f0876a3773381cbfff3192dd84dd1c8c925 (patch) | |
tree | bd9d01e3969ffa5aac92128af3e515520c88fc0e /src/lib/libcrypto/comp/c_rle.c | |
parent | 756086c41b0487beefc3d5b3400f80095d0e4157 (diff) | |
download | openbsd-648e4f0876a3773381cbfff3192dd84dd1c8c925.tar.gz openbsd-648e4f0876a3773381cbfff3192dd84dd1c8c925.tar.bz2 openbsd-648e4f0876a3773381cbfff3192dd84dd1c8c925.zip |
new files for OpenSSL 0.9.4
Diffstat (limited to 'src/lib/libcrypto/comp/c_rle.c')
-rw-r--r-- | src/lib/libcrypto/comp/c_rle.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/lib/libcrypto/comp/c_rle.c b/src/lib/libcrypto/comp/c_rle.c new file mode 100644 index 0000000000..1a819e3737 --- /dev/null +++ b/src/lib/libcrypto/comp/c_rle.c | |||
@@ -0,0 +1,61 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <stdlib.h> | ||
3 | #include <string.h> | ||
4 | #include <openssl/objects.h> | ||
5 | #include <openssl/comp.h> | ||
6 | |||
7 | static int rle_compress_block(COMP_CTX *ctx, unsigned char *out, | ||
8 | unsigned int olen, unsigned char *in, unsigned int ilen); | ||
9 | static int rle_expand_block(COMP_CTX *ctx, unsigned char *out, | ||
10 | unsigned int olen, unsigned char *in, unsigned int ilen); | ||
11 | |||
12 | static COMP_METHOD rle_method={ | ||
13 | NID_rle_compression, | ||
14 | LN_rle_compression, | ||
15 | NULL, | ||
16 | NULL, | ||
17 | rle_compress_block, | ||
18 | rle_expand_block, | ||
19 | NULL, | ||
20 | }; | ||
21 | |||
22 | COMP_METHOD *COMP_rle(void) | ||
23 | { | ||
24 | return(&rle_method); | ||
25 | } | ||
26 | |||
27 | static int rle_compress_block(COMP_CTX *ctx, unsigned char *out, | ||
28 | unsigned int olen, unsigned char *in, unsigned int ilen) | ||
29 | { | ||
30 | /* int i; */ | ||
31 | |||
32 | if (olen < (ilen+1)) | ||
33 | { | ||
34 | /* ZZZZZZZZZZZZZZZZZZZZZZ */ | ||
35 | return(-1); | ||
36 | } | ||
37 | |||
38 | *(out++)=0; | ||
39 | memcpy(out,in,ilen); | ||
40 | return(ilen+1); | ||
41 | } | ||
42 | |||
43 | static int rle_expand_block(COMP_CTX *ctx, unsigned char *out, | ||
44 | unsigned int olen, unsigned char *in, unsigned int ilen) | ||
45 | { | ||
46 | int i; | ||
47 | |||
48 | if (olen < (ilen-1)) | ||
49 | { | ||
50 | /* ZZZZZZZZZZZZZZZZZZZZZZ */ | ||
51 | return(-1); | ||
52 | } | ||
53 | |||
54 | i= *(in++); | ||
55 | if (i == 0) | ||
56 | { | ||
57 | memcpy(out,in,ilen-1); | ||
58 | } | ||
59 | return(ilen-1); | ||
60 | } | ||
61 | |||