]>
Commit | Line | Data |
---|---|---|
dfeab068 RE |
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 | ||
e03ddfae BL |
36 | if(ctx == NULL) |
37 | return; | |
38 | ||
dfeab068 RE |
39 | if (ctx->meth->finish != NULL) |
40 | ctx->meth->finish(ctx); | |
41 | ||
42 | Free(ctx); | |
43 | } | |
44 | ||
45 | int COMP_compress_block(ctx,out,olen,in,ilen) | |
46 | COMP_CTX *ctx; | |
47 | unsigned char *out; | |
48 | int olen; | |
49 | unsigned char *in; | |
50 | int ilen; | |
51 | { | |
52 | int ret; | |
53 | if (ctx->meth->compress == NULL) | |
54 | { | |
55 | /* ZZZZZZZZZZZZZZZZZ */ | |
56 | return(-1); | |
57 | } | |
58 | ret=ctx->meth->compress(ctx,out,olen,in,ilen); | |
59 | if (ret > 0) | |
60 | { | |
61 | ctx->compress_in+=ilen; | |
62 | ctx->compress_out+=ret; | |
63 | } | |
64 | return(ret); | |
65 | } | |
66 | ||
67 | int COMP_expand_block(ctx,out,olen,in,ilen) | |
68 | COMP_CTX *ctx; | |
69 | unsigned char *out; | |
70 | int olen; | |
71 | unsigned char *in; | |
72 | int ilen; | |
73 | { | |
74 | int ret; | |
75 | ||
76 | if (ctx->meth->expand == NULL) | |
77 | { | |
78 | /* ZZZZZZZZZZZZZZZZZ */ | |
79 | return(-1); | |
80 | } | |
81 | ret=ctx->meth->expand(ctx,out,olen,in,ilen); | |
82 | if (ret > 0) | |
83 | { | |
84 | ctx->expand_in+=ilen; | |
85 | ctx->expand_out+=ret; | |
86 | } | |
87 | return(ret); | |
88 | } |