1 /*-------------------------------------------------------------*/
2 /*--- Public header file for the library.                   ---*/
3 /*---                                               bzlib.h ---*/
4 /*-------------------------------------------------------------*/
5 /**
6 *   This file is part of bzip2/libbzip2, a program and library for
7 *   lossless, block-sorting data compression.
8 *   
9 *   bzip2/libbzip2 version 1.0.6 of 6 September 2010
10 *   Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
11 *   
12 *   Please read the WARNING, DISCLAIMER and PATENTS sections in the 
13 *   README file.
14 *   
15 *   This program is released under the terms of the license contained
16 *   in the file LICENSE.
17 */
18 module botan.compression.bzip2_hd;
19 
20 import botan.constants;
21 static if (BOTAN_HAS_BZIP2):
22 
23 package extern(C) nothrow:
24 
25 enum BZ_RUN               = 0;
26 enum BZ_FLUSH             = 1;
27 enum BZ_FINISH            = 2;
28 
29 enum BZ_OK                = 0;
30 enum BZ_RUN_OK            = 1;
31 enum BZ_FLUSH_OK          = 2;
32 enum BZ_FINISH_OK         = 3;
33 enum BZ_STREAM_END        = 4;
34 enum BZ_SEQUENCE_ERROR    = -1;
35 enum BZ_PARAM_ERROR       = -2;
36 enum BZ_MEM_ERROR         = -3;
37 enum BZ_DATA_ERROR        = -4;
38 enum BZ_DATA_ERROR_MAGIC  = -5;
39 enum BZ_IO_ERROR          = -6;
40 enum BZ_UNEXPECTED_EOF    = -7;
41 enum BZ_OUTBUFF_FULL      = -8;
42 enum BZ_CONFIG_ERROR      = -9;
43 
44 
45 struct bz_stream
46 {
47     ubyte* next_in;
48     uint   avail_in;
49     uint   total_in_lo32;
50     uint   total_in_hi32;
51     
52     ubyte* next_out;
53     uint   avail_out;
54     uint   total_out_lo32;
55     uint   total_out_hi32;
56     
57     void*  state;
58     
59     void* function(void*, int, int) nothrow bzalloc;
60     void  function(void*, void*) nothrow    bzfree;
61     void* opaque;
62 } 
63 
64 /*-- Core (low-level) library functions --*/
65 
66 int BZ2_bzCompressInit( 
67     bz_stream* strm, 
68     int        blockSize100k, 
69     int        verbosity, 
70     int        workFactor 
71     );
72 
73 int BZ2_bzCompress( 
74     bz_stream* strm, 
75     int action 
76     );
77 
78 int BZ2_bzCompressEnd( 
79     bz_stream* strm 
80     );
81 
82 int BZ2_bzDecompressInit( 
83     bz_stream* strm, 
84     int        verbosity, 
85     int        small
86     );
87 
88 int BZ2_bzDecompress( 
89     bz_stream* strm 
90     );
91 
92 int BZ2_bzDecompressEnd( 
93     bz_stream *strm 
94     );
95 
96 /*--
97    Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp)
98    to support better zlib compatibility.
99    This code is not _officially_ part of libbzip2 (yet);
100    I haven't tested it, documented it, or considered the
101    threading-safeness of it.
102    If this code breaks, please contact both Yoshioka and me.
103 --*/
104 
105 const(char)* BZ2_bzlibVersion();
106 
107 /*-------------------------------------------------------------*/
108 /*--- end                                           bzlib.h ---*/
109 /*-------------------------------------------------------------*/