1 /* $OpenBSD: comp.h,v 1.8 2014/11/03 16:58:28 tedu Exp $ */
2 module libressl_d.openssl.comp;
3 
4 
5 private static import core.stdc.config;
6 private static import libressl_d.openssl.ossl_typ;
7 private static import libressl_d.openssl.bio;
8 public import libressl_d.openssl.crypto;
9 
10 extern (C):
11 nothrow @nogc:
12 
13 alias COMP_CTX = .comp_ctx_st;
14 
15 struct comp_method_st
16 {
17 	/**
18 	 * NID for compression library
19 	 */
20 	int type;
21 
22 	/**
23 	 * A text string to identify the library
24 	 */
25 	const (char)* name;
26 
27 	int function(.COMP_CTX* ctx) init;
28 	void function(.COMP_CTX* ctx) finish;
29 	int function(.COMP_CTX* ctx, ubyte* out_, uint olen, ubyte* in_, uint ilen) compress;
30 	int function(.COMP_CTX* ctx, ubyte* out_, uint olen, ubyte* in_, uint ilen) expand;
31 	/* The following two do NOTHING, but are kept for backward compatibility */
32 	core.stdc.config.c_long function() ctrl;
33 	core.stdc.config.c_long function() callback_ctrl;
34 }
35 
36 alias COMP_METHOD = .comp_method_st;
37 
38 struct comp_ctx_st
39 {
40 	.COMP_METHOD* meth;
41 	core.stdc.config.c_ulong compress_in;
42 	core.stdc.config.c_ulong compress_out;
43 	core.stdc.config.c_ulong expand_in;
44 	core.stdc.config.c_ulong expand_out;
45 
46 	libressl_d.openssl.ossl_typ.CRYPTO_EX_DATA ex_data;
47 }
48 
49 .COMP_CTX* COMP_CTX_new(.COMP_METHOD* meth);
50 void COMP_CTX_free(.COMP_CTX* ctx);
51 int COMP_compress_block(.COMP_CTX* ctx, ubyte* out_, int olen, ubyte* in_, int ilen);
52 int COMP_expand_block(.COMP_CTX* ctx, ubyte* out_, int olen, ubyte* in_, int ilen);
53 .COMP_METHOD* COMP_rle();
54 .COMP_METHOD* COMP_zlib();
55 void COMP_zlib_cleanup();
56 
57 static assert(libressl_d.openssl.bio.HEADER_BIO_H);
58 
59 version (ZLIB) {
60 	libressl_d.openssl.bio.BIO_METHOD* BIO_f_zlib();
61 }
62 
63 void ERR_load_COMP_strings();
64 
65 /* Error codes for the COMP functions. */
66 
67 /* Function codes. */
68 enum COMP_F_BIO_ZLIB_FLUSH = 99;
69 enum COMP_F_BIO_ZLIB_NEW = 100;
70 enum COMP_F_BIO_ZLIB_READ = 101;
71 enum COMP_F_BIO_ZLIB_WRITE = 102;
72 
73 /* Reason codes. */
74 enum COMP_R_ZLIB_DEFLATE_ERROR = 99;
75 enum COMP_R_ZLIB_INFLATE_ERROR = 100;
76 enum COMP_R_ZLIB_NOT_SUPPORTED = 101;