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