]>
Commit | Line | Data |
---|---|---|
dfeab068 RE |
1 | #include <stdio.h> |
2 | #include <stdlib.h> | |
3 | #include <string.h> | |
ec577822 BM |
4 | #include <openssl/objects.h> |
5 | #include <openssl/comp.h> | |
dfeab068 | 6 | |
6b691a5c | 7 | COMP_CTX *COMP_CTX_new(COMP_METHOD *meth) |
dfeab068 RE |
8 | { |
9 | COMP_CTX *ret; | |
10 | ||
26a3a48d | 11 | if ((ret=(COMP_CTX *)OPENSSL_malloc(sizeof(COMP_CTX))) == NULL) |
dfeab068 RE |
12 | { |
13 | /* ZZZZZZZZZZZZZZZZ */ | |
14 | return(NULL); | |
15 | } | |
16 | memset(ret,0,sizeof(COMP_CTX)); | |
17 | ret->meth=meth; | |
18 | if ((ret->meth->init != NULL) && !ret->meth->init(ret)) | |
19 | { | |
26a3a48d | 20 | OPENSSL_free(ret); |
dfeab068 RE |
21 | ret=NULL; |
22 | } | |
23 | #if 0 | |
24 | else | |
25 | CRYPTO_new_ex_data(rsa_meth,(char *)ret,&ret->ex_data); | |
26 | #endif | |
27 | return(ret); | |
28 | } | |
29 | ||
6b691a5c | 30 | void COMP_CTX_free(COMP_CTX *ctx) |
dfeab068 RE |
31 | { |
32 | /* CRYPTO_free_ex_data(rsa_meth,(char *)ctx,&ctx->ex_data); */ | |
33 | ||
e03ddfae BL |
34 | if(ctx == NULL) |
35 | return; | |
36 | ||
dfeab068 RE |
37 | if (ctx->meth->finish != NULL) |
38 | ctx->meth->finish(ctx); | |
39 | ||
26a3a48d | 40 | OPENSSL_free(ctx); |
dfeab068 RE |
41 | } |
42 | ||
6b691a5c UM |
43 | int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen, |
44 | unsigned char *in, int ilen) | |
dfeab068 RE |
45 | { |
46 | int ret; | |
47 | if (ctx->meth->compress == NULL) | |
48 | { | |
49 | /* ZZZZZZZZZZZZZZZZZ */ | |
50 | return(-1); | |
51 | } | |
52 | ret=ctx->meth->compress(ctx,out,olen,in,ilen); | |
53 | if (ret > 0) | |
54 | { | |
55 | ctx->compress_in+=ilen; | |
56 | ctx->compress_out+=ret; | |
57 | } | |
58 | return(ret); | |
59 | } | |
60 | ||
6b691a5c UM |
61 | int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, |
62 | unsigned char *in, int ilen) | |
dfeab068 RE |
63 | { |
64 | int ret; | |
65 | ||
66 | if (ctx->meth->expand == NULL) | |
67 | { | |
68 | /* ZZZZZZZZZZZZZZZZZ */ | |
69 | return(-1); | |
70 | } | |
71 | ret=ctx->meth->expand(ctx,out,olen,in,ilen); | |
72 | if (ret > 0) | |
73 | { | |
74 | ctx->expand_in+=ilen; | |
75 | ctx->expand_out+=ret; | |
76 | } | |
77 | return(ret); | |
78 | } |