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