]> git.ipfire.org Git - thirdparty/openssl.git/blob - crypto/comp/comp_lib.c
Import of old SSLeay release: SSLeay 0.9.1b (unreleased)
[thirdparty/openssl.git] / crypto / comp / comp_lib.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include "objects.h"
5 #include "comp.h"
6
7 COMP_CTX *COMP_CTX_new(meth)
8 COMP_METHOD *meth;
9 {
10 COMP_CTX *ret;
11
12 if ((ret=(COMP_CTX *)Malloc(sizeof(COMP_CTX))) == NULL)
13 {
14 /* ZZZZZZZZZZZZZZZZ */
15 return(NULL);
16 }
17 memset(ret,0,sizeof(COMP_CTX));
18 ret->meth=meth;
19 if ((ret->meth->init != NULL) && !ret->meth->init(ret))
20 {
21 Free(ret);
22 ret=NULL;
23 }
24 #if 0
25 else
26 CRYPTO_new_ex_data(rsa_meth,(char *)ret,&ret->ex_data);
27 #endif
28 return(ret);
29 }
30
31 void COMP_CTX_free(ctx)
32 COMP_CTX *ctx;
33 {
34 /* CRYPTO_free_ex_data(rsa_meth,(char *)ctx,&ctx->ex_data); */
35
36 if (ctx->meth->finish != NULL)
37 ctx->meth->finish(ctx);
38
39 Free(ctx);
40 }
41
42 int COMP_compress_block(ctx,out,olen,in,ilen)
43 COMP_CTX *ctx;
44 unsigned char *out;
45 int olen;
46 unsigned char *in;
47 int ilen;
48 {
49 int ret;
50 if (ctx->meth->compress == NULL)
51 {
52 /* ZZZZZZZZZZZZZZZZZ */
53 return(-1);
54 }
55 ret=ctx->meth->compress(ctx,out,olen,in,ilen);
56 if (ret > 0)
57 {
58 ctx->compress_in+=ilen;
59 ctx->compress_out+=ret;
60 }
61 return(ret);
62 }
63
64 int COMP_expand_block(ctx,out,olen,in,ilen)
65 COMP_CTX *ctx;
66 unsigned char *out;
67 int olen;
68 unsigned char *in;
69 int ilen;
70 {
71 int ret;
72
73 if (ctx->meth->expand == NULL)
74 {
75 /* ZZZZZZZZZZZZZZZZZ */
76 return(-1);
77 }
78 ret=ctx->meth->expand(ctx,out,olen,in,ilen);
79 if (ret > 0)
80 {
81 ctx->expand_in+=ilen;
82 ctx->expand_out+=ret;
83 }
84 return(ret);
85 }