1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/ssl/libcrypto/src/crypto/comp/comp_lib.c Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,72 @@
1.4 +#include <stdio.h>
1.5 +#include <stdlib.h>
1.6 +#include <string.h>
1.7 +#include <openssl/objects.h>
1.8 +#include <openssl/comp.h>
1.9 +
1.10 +EXPORT_C COMP_CTX *COMP_CTX_new(COMP_METHOD *meth)
1.11 + {
1.12 + COMP_CTX *ret;
1.13 +
1.14 + if ((ret=(COMP_CTX *)OPENSSL_malloc(sizeof(COMP_CTX))) == NULL)
1.15 + {
1.16 + /* ZZZZZZZZZZZZZZZZ */
1.17 + return(NULL);
1.18 + }
1.19 + memset(ret,0,sizeof(COMP_CTX));
1.20 + ret->meth=meth;
1.21 + if ((ret->meth->init != NULL) && !ret->meth->init(ret))
1.22 + {
1.23 + OPENSSL_free(ret);
1.24 + ret=NULL;
1.25 + }
1.26 + return(ret);
1.27 + }
1.28 +
1.29 +EXPORT_C void COMP_CTX_free(COMP_CTX *ctx)
1.30 + {
1.31 + if(ctx == NULL)
1.32 + return;
1.33 +
1.34 + if (ctx->meth->finish != NULL)
1.35 + ctx->meth->finish(ctx);
1.36 +
1.37 + OPENSSL_free(ctx);
1.38 + }
1.39 +
1.40 +EXPORT_C int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen,
1.41 + unsigned char *in, int ilen)
1.42 + {
1.43 + int ret;
1.44 + if (ctx->meth->compress == NULL)
1.45 + {
1.46 + /* ZZZZZZZZZZZZZZZZZ */
1.47 + return(-1);
1.48 + }
1.49 + ret=ctx->meth->compress(ctx,out,olen,in,ilen);
1.50 + if (ret > 0)
1.51 + {
1.52 + ctx->compress_in+=ilen;
1.53 + ctx->compress_out+=ret;
1.54 + }
1.55 + return(ret);
1.56 + }
1.57 +
1.58 +EXPORT_C int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen,
1.59 + unsigned char *in, int ilen)
1.60 + {
1.61 + int ret;
1.62 +
1.63 + if (ctx->meth->expand == NULL)
1.64 + {
1.65 + /* ZZZZZZZZZZZZZZZZZ */
1.66 + return(-1);
1.67 + }
1.68 + ret=ctx->meth->expand(ctx,out,olen,in,ilen);
1.69 + if (ret > 0)
1.70 + {
1.71 + ctx->expand_in+=ilen;
1.72 + ctx->expand_out+=ret;
1.73 + }
1.74 + return(ret);
1.75 + }