1 2 /*-------------------------------------------------------------*/ 3 /*--- Public header file for the library. ---*/ 4 /*--- bzlib.h ---*/ 5 /*-------------------------------------------------------------*/ 6 7 /* ------------------------------------------------------------------ 8 This file is part of bzip2/libbzip2, a program and library for 9 lossless, block-sorting data compression. 10 11 bzip2/libbzip2 version 1.0.5 of 10 December 2007 12 Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org> 13 14 Please read the WARNING, DISCLAIMER and PATENTS sections in the 15 README file. 16 17 This program is released under the terms of the license contained 18 in the file LICENSE. 19 ------------------------------------------------------------------ */ 20 21 #ifndef _BZLIB_H 22 #define _BZLIB_H 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 #define BZ_RUN 0 29 #define BZ_FLUSH 1 30 #define BZ_FINISH 2 31 #define BZ_OK 0 32 #define BZ_RUN_OK 1 33 #define BZ_FLUSH_OK 2 34 #define BZ_FINISH_OK 3 35 #define BZ_STREAM_END 4 36 #define BZ_SEQUENCE_ERROR (-1) 37 #define BZ_PARAM_ERROR (-2) 38 #define BZ_MEM_ERROR (-3) 39 #define BZ_DATA_ERROR (-4) 40 #define BZ_DATA_ERROR_MAGIC (-5) 41 #define BZ_IO_ERROR (-6) 42 #define BZ_UNEXPECTED_EOF (-7) 43 #define BZ_OUTBUFF_FULL (-8) 44 #define BZ_CONFIG_ERROR (-9) 45 46 typedef 47 struct { 48 char *next_in; 49 unsigned int avail_in; 50 unsigned int total_in_lo32; 51 unsigned int total_in_hi32; 52 53 char *next_out; 54 unsigned int avail_out; 55 unsigned int total_out_lo32; 56 unsigned int total_out_hi32; 57 58 void *state; 59 60 void *(*bzalloc)(void *,int,int); 61 void (*bzfree)(void *,void *); 62 void *opaque; 63 } 64 bz_stream; 65 66 #ifndef BZ_IMPORT 67 #define BZ_EXPORT 68 #endif 69 70 #ifndef BZ_NO_STDIO 71 /* Need a definitition for FILE */ 72 #include <stdio.h> 73 #endif 74 75 #ifdef _WIN32 76 # include <windows.h> 77 # ifdef small 78 /* windows.h define small to char */ 79 # undef small 80 # endif 81 # ifdef BZ_EXPORT 82 # define BZ_API(func) WINAPI func 83 # define BZ_EXTERN extern 84 # else 85 /* import windows dll dynamically */ 86 # define BZ_API(func) (WINAPI * func) 87 # define BZ_EXTERN 88 # endif 89 #else 90 # define BZ_API(func) func 91 # define BZ_EXTERN extern 92 #endif 93 94 /*-- Core (low-level) library functions --*/ 95 96 BZ_EXTERN int BZ_API(BZ2_bzCompressInit) ( 97 bz_stream* strm, 98 int blockSize100k, 99 int verbosity, 100 int workFactor 101 ); 102 103 BZ_EXTERN int BZ_API(BZ2_bzCompress) ( 104 bz_stream* strm, 105 int action 106 ); 107 108 BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) ( 109 bz_stream* strm 110 ); 111 112 BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( 113 bz_stream *strm, 114 int verbosity, 115 int small 116 ); 117 118 BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( 119 bz_stream* strm 120 ); 121 122 BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( 123 bz_stream *strm 124 ); 125 126 /*-- High(er) level library functions --*/ 127 128 #ifndef BZ_NO_STDIO 129 #define BZ_MAX_UNUSED 5000 130 131 typedef void BZFILE; 132 133 BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) ( 134 int* bzerror, 135 FILE* f, 136 int verbosity, 137 int small, 138 void* unused, 139 int nUnused 140 ); 141 142 BZ_EXTERN void BZ_API(BZ2_bzReadClose) ( 143 int* bzerror, 144 BZFILE* b 145 ); 146 147 BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) ( 148 int* bzerror, 149 BZFILE* b, 150 void** unused, 151 int* nUnused 152 ); 153 154 BZ_EXTERN int BZ_API(BZ2_bzRead) ( 155 int* bzerror, 156 BZFILE* b, 157 void* buf, 158 int len 159 ); 160 161 BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( 162 int* bzerror, 163 FILE* f, 164 int blockSize100k, 165 int verbosity, 166 int workFactor 167 ); 168 169 BZ_EXTERN void BZ_API(BZ2_bzWrite) ( 170 int* bzerror, 171 BZFILE* b, 172 void* buf, 173 int len 174 ); 175 176 BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( 177 int* bzerror, 178 BZFILE* b, 179 int abandon, 180 unsigned int* nbytes_in, 181 unsigned int* nbytes_out 182 ); 183 184 BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( 185 int* bzerror, 186 BZFILE* b, 187 int abandon, 188 unsigned int* nbytes_in_lo32, 189 unsigned int* nbytes_in_hi32, 190 unsigned int* nbytes_out_lo32, 191 unsigned int* nbytes_out_hi32 192 ); 193 #endif 194 195 /*-- Utility functions --*/ 196 197 BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( 198 char* dest, 199 unsigned int* destLen, 200 char* source, 201 unsigned int sourceLen, 202 int blockSize100k, 203 int verbosity, 204 int workFactor 205 ); 206 207 BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) ( 208 char* dest, 209 unsigned int* destLen, 210 char* source, 211 unsigned int sourceLen, 212 int small, 213 int verbosity 214 ); 215 216 /*-- 217 Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp) 218 to support better zlib compatibility. 219 This code is not _officially_ part of libbzip2 (yet); 220 I haven't tested it, documented it, or considered the 221 threading-safeness of it. 222 If this code breaks, please contact both Yoshioka and me. 223 --*/ 224 225 BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) ( 226 void 227 ); 228 229 #ifndef BZ_NO_STDIO 230 BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) ( 231 const char *path, 232 const char *mode 233 ); 234 235 BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) ( 236 int fd, 237 const char *mode 238 ); 239 240 BZ_EXTERN int BZ_API(BZ2_bzread) ( 241 BZFILE* b, 242 void* buf, 243 int len 244 ); 245 246 BZ_EXTERN int BZ_API(BZ2_bzwrite) ( 247 BZFILE* b, 248 void* buf, 249 int len 250 ); 251 252 BZ_EXTERN int BZ_API(BZ2_bzflush) ( 253 BZFILE* b 254 ); 255 256 BZ_EXTERN void BZ_API(BZ2_bzclose) ( 257 BZFILE* b 258 ); 259 260 BZ_EXTERN const char * BZ_API(BZ2_bzerror) ( 261 BZFILE *b, 262 int *errnum 263 ); 264 #endif 265 266 #ifdef __cplusplus 267 } 268 #endif 269 270 #endif 271 272 /*-------------------------------------------------------------*/ 273 /*--- end bzlib.h ---*/ 274 /*-------------------------------------------------------------*/ 275