xref: /openbsd-src/lib/libcrypto/comp/comp.h (revision 5ad04d351680822078003e2b066cfc9680d6157d)
1 
2 #ifndef HEADER_COMP_H
3 #define HEADER_COMP_H
4 
5 #include <openssl/crypto.h>
6 
7 #ifdef  __cplusplus
8 extern "C" {
9 #endif
10 
11 typedef struct comp_ctx_st COMP_CTX;
12 
13 typedef struct comp_method_st {
14 	int type;		/* NID for compression library */
15 	const char *name;	/* A text string to identify the library */
16 	int (*init)(COMP_CTX *ctx);
17 	void (*finish)(COMP_CTX *ctx);
18 	int (*compress)(COMP_CTX *ctx, unsigned char *out, unsigned int olen,
19 	    unsigned char *in, unsigned int ilen);
20 	int (*expand)(COMP_CTX *ctx, unsigned char *out, unsigned int olen,
21 	    unsigned char *in, unsigned int ilen);
22 	/* The following two do NOTHING, but are kept for backward compatibility */
23 	long (*ctrl)(void);
24 	long (*callback_ctrl)(void);
25 } COMP_METHOD;
26 
27 struct comp_ctx_st {
28 	COMP_METHOD *meth;
29 	unsigned long compress_in;
30 	unsigned long compress_out;
31 	unsigned long expand_in;
32 	unsigned long expand_out;
33 
34 	CRYPTO_EX_DATA	ex_data;
35 };
36 
37 
38 COMP_CTX *COMP_CTX_new(COMP_METHOD *meth);
39 void COMP_CTX_free(COMP_CTX *ctx);
40 int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen,
41     unsigned char *in, int ilen);
42 int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen,
43     unsigned char *in, int ilen);
44 COMP_METHOD *COMP_rle(void );
45 COMP_METHOD *COMP_zlib(void );
46 void COMP_zlib_cleanup(void);
47 
48 #ifdef HEADER_BIO_H
49 #ifdef ZLIB
50 BIO_METHOD *BIO_f_zlib(void);
51 #endif
52 #endif
53 
54 /* BEGIN ERROR CODES */
55 /* The following lines are auto generated by the script mkerr.pl. Any changes
56  * made after this point may be overwritten when the script is next run.
57  */
58 void ERR_load_COMP_strings(void);
59 
60 /* Error codes for the COMP functions. */
61 
62 /* Function codes. */
63 #define COMP_F_BIO_ZLIB_FLUSH				 99
64 #define COMP_F_BIO_ZLIB_NEW				 100
65 #define COMP_F_BIO_ZLIB_READ				 101
66 #define COMP_F_BIO_ZLIB_WRITE				 102
67 
68 /* Reason codes. */
69 #define COMP_R_ZLIB_DEFLATE_ERROR			 99
70 #define COMP_R_ZLIB_INFLATE_ERROR			 100
71 #define COMP_R_ZLIB_NOT_SUPPORTED			 101
72 
73 #ifdef  __cplusplus
74 }
75 #endif
76 #endif
77