diff options
| author | cvs2svn <admin@example.com> | 2002-05-15 02:29:24 +0000 | 
|---|---|---|
| committer | cvs2svn <admin@example.com> | 2002-05-15 02:29:24 +0000 | 
| commit | 027351f729b9e837200dae6e1520cda6577ab930 (patch) | |
| tree | e25a717057aa4529e433fc3b1fac8d4df8db3a5c /src/lib/libcrypto/comp/c_rle.c | |
| parent | aeeae06a79815dc190061534d47236cec09f9e32 (diff) | |
| download | openbsd-027351f729b9e837200dae6e1520cda6577ab930.tar.gz openbsd-027351f729b9e837200dae6e1520cda6577ab930.tar.bz2 openbsd-027351f729b9e837200dae6e1520cda6577ab930.zip | |
This commit was manufactured by cvs2git to create branch 'unlabeled-1.1.1'.
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 | |||
