1 /* $NetBSD: netpgpv-bzlib.h,v 1.1 2020/11/01 11:29:17 wiz Exp $ */ 2 3 4 /*-------------------------------------------------------------*/ 5 /*--- Public header file for the library. ---*/ 6 /*--- bzlib.h ---*/ 7 /*-------------------------------------------------------------*/ 8 9 /* ------------------------------------------------------------------ 10 This file is part of bzip2/libbzip2, a program and library for 11 lossless, block-sorting data compression. 12 13 bzip2/libbzip2 version 1.0.6 of 6 September 2010 14 Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> 15 16 Please read the WARNING, DISCLAIMER and PATENTS sections in the 17 README file. 18 19 This program is released under the terms of the license contained 20 in the file LICENSE. 21 ------------------------------------------------------------------ */ 22 23 24 #ifndef _BZLIB_H 25 #define _BZLIB_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(netpgpv_BZ2_bzDecompressInit) ( 119 bz_stream *strm, 120 int verbosity, 121 int small 122 ); 123 124 BZ_EXTERN int BZ_API(netpgpv_BZ2_bzDecompress) ( 125 bz_stream* strm 126 ); 127 128 BZ_EXTERN int BZ_API(netpgpv_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(netpgpv_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 void BZ_API(netpgpv_BZ2_bzReadClose) ( 151 int* bzerror, 152 BZFILE* b 153 ); 154 155 BZ_EXTERN void BZ_API(netpgpv_BZ2_bzReadGetUnused) ( 156 int* bzerror, 157 BZFILE* b, 158 void** unused, 159 int* nUnused 160 ); 161 162 BZ_EXTERN int BZ_API(netpgpv_BZ2_bzRead) ( 163 int* bzerror, 164 BZFILE* b, 165 void* buf, 166 int len 167 ); 168 169 BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( 170 int* bzerror, 171 FILE* f, 172 int blockSize100k, 173 int verbosity, 174 int workFactor 175 ); 176 177 BZ_EXTERN void BZ_API(BZ2_bzWrite) ( 178 int* bzerror, 179 BZFILE* b, 180 void* buf, 181 int len 182 ); 183 184 BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( 185 int* bzerror, 186 BZFILE* b, 187 int abandon, 188 unsigned int* nbytes_in, 189 unsigned int* nbytes_out 190 ); 191 192 BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( 193 int* bzerror, 194 BZFILE* b, 195 int abandon, 196 unsigned int* nbytes_in_lo32, 197 unsigned int* nbytes_in_hi32, 198 unsigned int* nbytes_out_lo32, 199 unsigned int* nbytes_out_hi32 200 ); 201 #endif 202 203 204 /*-- Utility functions --*/ 205 206 BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( 207 char* dest, 208 unsigned int* destLen, 209 char* source, 210 unsigned int sourceLen, 211 int blockSize100k, 212 int verbosity, 213 int workFactor 214 ); 215 216 BZ_EXTERN int BZ_API(netpgpv_BZ2_bzBuffToBuffDecompress) ( 217 char* dest, 218 unsigned int* destLen, 219 char* source, 220 unsigned int sourceLen, 221 int small, 222 int verbosity 223 ); 224 225 226 /*-- 227 Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp) 228 to support better zlib compatibility. 229 This code is not _officially_ part of libbzip2 (yet); 230 I haven't tested it, documented it, or considered the 231 threading-safeness of it. 232 If this code breaks, please contact both Yoshioka and me. 233 --*/ 234 235 BZ_EXTERN const char * BZ_API(netpgpv_BZ2_bzlibVersion) ( 236 void 237 ); 238 239 #ifndef BZ_NO_STDIO 240 BZ_EXTERN BZFILE * BZ_API(netpgpv_BZ2_bzopen) ( 241 const char *path, 242 const char *mode 243 ); 244 245 BZ_EXTERN BZFILE * BZ_API(netpgpv_BZ2_bzdopen) ( 246 int fd, 247 const char *mode 248 ); 249 250 BZ_EXTERN int BZ_API(netpgpv_BZ2_bzread) ( 251 BZFILE* b, 252 void* buf, 253 int len 254 ); 255 256 BZ_EXTERN int BZ_API(BZ2_bzwrite) ( 257 BZFILE* b, 258 void* buf, 259 int len 260 ); 261 262 BZ_EXTERN int BZ_API(netpgpv_BZ2_bzflush) ( 263 BZFILE* b 264 ); 265 266 BZ_EXTERN void BZ_API(netpgpv_BZ2_bzclose) ( 267 BZFILE* b 268 ); 269 270 BZ_EXTERN const char * BZ_API(netpgpv_BZ2_bzerror) ( 271 BZFILE *b, 272 int *errnum 273 ); 274 #endif 275 276 #ifdef __cplusplus 277 } 278 #endif 279 280 #endif 281 282 /*-------------------------------------------------------------*/ 283 /*--- end bzlib.h ---*/ 284 /*-------------------------------------------------------------*/ 285