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