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