From 5fc5d37330d3535a0f421632694d1e7918fc22d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Tue, 8 Apr 2014 11:38:09 +0200 Subject: Compiles correctly: app/build-native + gradle. --- app/openssl/crypto/comp/c_rle.c | 61 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 app/openssl/crypto/comp/c_rle.c (limited to 'app/openssl/crypto/comp/c_rle.c') diff --git a/app/openssl/crypto/comp/c_rle.c b/app/openssl/crypto/comp/c_rle.c new file mode 100644 index 00000000..18bceae5 --- /dev/null +++ b/app/openssl/crypto/comp/c_rle.c @@ -0,0 +1,61 @@ +#include +#include +#include +#include +#include + +static int rle_compress_block(COMP_CTX *ctx, unsigned char *out, + unsigned int olen, unsigned char *in, unsigned int ilen); +static int rle_expand_block(COMP_CTX *ctx, unsigned char *out, + unsigned int olen, unsigned char *in, unsigned int ilen); + +static COMP_METHOD rle_method={ + NID_rle_compression, + LN_rle_compression, + NULL, + NULL, + rle_compress_block, + rle_expand_block, + NULL, + NULL, + }; + +COMP_METHOD *COMP_rle(void) + { + return(&rle_method); + } + +static int rle_compress_block(COMP_CTX *ctx, unsigned char *out, + unsigned int olen, unsigned char *in, unsigned int ilen) + { + /* int i; */ + + if (olen < (ilen+1)) + { + /* ZZZZZZZZZZZZZZZZZZZZZZ */ + return(-1); + } + + *(out++)=0; + memcpy(out,in,ilen); + return(ilen+1); + } + +static int rle_expand_block(COMP_CTX *ctx, unsigned char *out, + unsigned int olen, unsigned char *in, unsigned int ilen) + { + int i; + + if (ilen == 0 || olen < (ilen-1)) + { + /* ZZZZZZZZZZZZZZZZZZZZZZ */ + return(-1); + } + + i= *(in++); + if (i == 0) + { + memcpy(out,in,ilen-1); + } + return(ilen-1); + } -- cgit v1.2.3