ReactOS  0.4.13-dev-92-gf251225
bzlib.h File Reference
#include <stdio.h>
Include dependency graph for bzlib.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  bz_stream
 

Macros

#define BZ_RUN   0
 
#define BZ_FLUSH   1
 
#define BZ_FINISH   2
 
#define BZ_OK   0
 
#define BZ_RUN_OK   1
 
#define BZ_FLUSH_OK   2
 
#define BZ_FINISH_OK   3
 
#define BZ_STREAM_END   4
 
#define BZ_SEQUENCE_ERROR   (-1)
 
#define BZ_PARAM_ERROR   (-2)
 
#define BZ_MEM_ERROR   (-3)
 
#define BZ_DATA_ERROR   (-4)
 
#define BZ_DATA_ERROR_MAGIC   (-5)
 
#define BZ_IO_ERROR   (-6)
 
#define BZ_UNEXPECTED_EOF   (-7)
 
#define BZ_OUTBUFF_FULL   (-8)
 
#define BZ_CONFIG_ERROR   (-9)
 
#define BZ_EXPORT
 
#define BZ_API(func)   func
 
#define BZ_EXTERN   extern
 
#define BZ_MAX_UNUSED   5000
 

Typedefs

typedef void BZFILE
 

Functions

BZ_EXTERN int BZ_API() BZ2_bzCompressInit (bz_stream *strm, int blockSize100k, int verbosity, int workFactor)
 
BZ_EXTERN int BZ_API() BZ2_bzCompress (bz_stream *strm, int action)
 
BZ_EXTERN int BZ_API() BZ2_bzCompressEnd (bz_stream *strm)
 
BZ_EXTERN int BZ_API() BZ2_bzDecompressInit (bz_stream *strm, int verbosity, int small)
 
BZ_EXTERN int BZ_API() BZ2_bzDecompress (bz_stream *strm)
 
BZ_EXTERN int BZ_API() BZ2_bzDecompressEnd (bz_stream *strm)
 
BZ_EXTERN BZFILE *BZ_API() BZ2_bzReadOpen (int *bzerror, FILE *f, int verbosity, int small, void *unused, int nUnused)
 
BZ_EXTERN void BZ_API() BZ2_bzReadClose (int *bzerror, BZFILE *b)
 
BZ_EXTERN void BZ_API() BZ2_bzReadGetUnused (int *bzerror, BZFILE *b, void **unused, int *nUnused)
 
BZ_EXTERN int BZ_API() BZ2_bzRead (int *bzerror, BZFILE *b, void *buf, int len)
 
BZ_EXTERN BZFILE *BZ_API() BZ2_bzWriteOpen (int *bzerror, FILE *f, int blockSize100k, int verbosity, int workFactor)
 
BZ_EXTERN void BZ_API() BZ2_bzWrite (int *bzerror, BZFILE *b, void *buf, int len)
 
BZ_EXTERN void BZ_API() BZ2_bzWriteClose (int *bzerror, BZFILE *b, int abandon, unsigned int *nbytes_in, unsigned int *nbytes_out)
 
BZ_EXTERN void BZ_API() BZ2_bzWriteClose64 (int *bzerror, BZFILE *b, int abandon, unsigned int *nbytes_in_lo32, unsigned int *nbytes_in_hi32, unsigned int *nbytes_out_lo32, unsigned int *nbytes_out_hi32)
 
BZ_EXTERN int BZ_API() BZ2_bzBuffToBuffCompress (char *dest, unsigned int *destLen, char *source, unsigned int sourceLen, int blockSize100k, int verbosity, int workFactor)
 
BZ_EXTERN int BZ_API() BZ2_bzBuffToBuffDecompress (char *dest, unsigned int *destLen, char *source, unsigned int sourceLen, int small, int verbosity)
 
BZ_EXTERN const char *BZ_API() BZ2_bzlibVersion (void)
 
BZ_EXTERN BZFILE *BZ_API() BZ2_bzopen (const char *path, const char *mode)
 
BZ_EXTERN BZFILE *BZ_API() BZ2_bzdopen (int fd, const char *mode)
 
BZ_EXTERN int BZ_API() BZ2_bzread (BZFILE *b, void *buf, int len)
 
BZ_EXTERN int BZ_API() BZ2_bzwrite (BZFILE *b, void *buf, int len)
 
BZ_EXTERN int BZ_API() BZ2_bzflush (BZFILE *b)
 
BZ_EXTERN void BZ_API() BZ2_bzclose (BZFILE *b)
 
BZ_EXTERN const char *BZ_API() BZ2_bzerror (BZFILE *b, int *errnum)
 

Macro Definition Documentation

◆ BZ_API

#define BZ_API (   func)    func

Definition at line 93 of file bzlib.h.

◆ BZ_CONFIG_ERROR

#define BZ_CONFIG_ERROR   (-9)

Definition at line 46 of file bzlib.h.

◆ BZ_DATA_ERROR

#define BZ_DATA_ERROR   (-4)

Definition at line 41 of file bzlib.h.

◆ BZ_DATA_ERROR_MAGIC

#define BZ_DATA_ERROR_MAGIC   (-5)

Definition at line 42 of file bzlib.h.

◆ BZ_EXPORT

#define BZ_EXPORT

Definition at line 70 of file bzlib.h.

◆ BZ_EXTERN

#define BZ_EXTERN   extern

Definition at line 94 of file bzlib.h.

◆ BZ_FINISH

#define BZ_FINISH   2

Definition at line 31 of file bzlib.h.

◆ BZ_FINISH_OK

#define BZ_FINISH_OK   3

Definition at line 36 of file bzlib.h.

◆ BZ_FLUSH

#define BZ_FLUSH   1

Definition at line 30 of file bzlib.h.

◆ BZ_FLUSH_OK

#define BZ_FLUSH_OK   2

Definition at line 35 of file bzlib.h.

◆ BZ_IO_ERROR

#define BZ_IO_ERROR   (-6)

Definition at line 43 of file bzlib.h.

◆ BZ_MAX_UNUSED

#define BZ_MAX_UNUSED   5000

Definition at line 135 of file bzlib.h.

◆ BZ_MEM_ERROR

#define BZ_MEM_ERROR   (-3)

Definition at line 40 of file bzlib.h.

◆ BZ_OK

#define BZ_OK   0

Definition at line 33 of file bzlib.h.

◆ BZ_OUTBUFF_FULL

#define BZ_OUTBUFF_FULL   (-8)

Definition at line 45 of file bzlib.h.

◆ BZ_PARAM_ERROR

#define BZ_PARAM_ERROR   (-2)

Definition at line 39 of file bzlib.h.

◆ BZ_RUN

#define BZ_RUN   0

Definition at line 29 of file bzlib.h.

◆ BZ_RUN_OK

#define BZ_RUN_OK   1

Definition at line 34 of file bzlib.h.

◆ BZ_SEQUENCE_ERROR

#define BZ_SEQUENCE_ERROR   (-1)

Definition at line 38 of file bzlib.h.

◆ BZ_STREAM_END

#define BZ_STREAM_END   4

Definition at line 37 of file bzlib.h.

◆ BZ_UNEXPECTED_EOF

#define BZ_UNEXPECTED_EOF   (-7)

Definition at line 44 of file bzlib.h.

Typedef Documentation

◆ BZFILE

typedef void BZFILE

Definition at line 137 of file bzlib.h.

Function Documentation

◆ BZ2_bzBuffToBuffCompress()

BZ_EXTERN int BZ_API() BZ2_bzBuffToBuffCompress ( char dest,
unsigned int destLen,
char source,
unsigned int  sourceLen,
int  blockSize100k,
int  verbosity,
int  workFactor 
)

Definition at line 1264 of file bzlib.c.

1271 {
1272  bz_stream strm;
1273  int ret;
1274 
1275  if (dest == NULL || destLen == NULL ||
1276  source == NULL ||
1277  blockSize100k < 1 || blockSize100k > 9 ||
1278  verbosity < 0 || verbosity > 4 ||
1279  workFactor < 0 || workFactor > 250)
1280  return BZ_PARAM_ERROR;
1281 
1282  if (workFactor == 0) workFactor = 30;
1283  strm.bzalloc = NULL;
1284  strm.bzfree = NULL;
1285  strm.opaque = NULL;
1286  ret = BZ2_bzCompressInit ( &strm, blockSize100k,
1287  verbosity, workFactor );
1288  if (ret != BZ_OK) return ret;
1289 
1290  strm.next_in = source;
1291  strm.next_out = dest;
1292  strm.avail_in = sourceLen;
1293  strm.avail_out = *destLen;
1294 
1295  ret = BZ2_bzCompress ( &strm, BZ_FINISH );
1296  if (ret == BZ_FINISH_OK) goto output_overflow;
1297  if (ret != BZ_STREAM_END) goto errhandler;
1298 
1299  /* normal termination */
1300  *destLen -= strm.avail_out;
1301  BZ2_bzCompressEnd ( &strm );
1302  return BZ_OK;
1303 
1304  output_overflow:
1305  BZ2_bzCompressEnd ( &strm );
1306  return BZ_OUTBUFF_FULL;
1307 
1308  errhandler:
1309  BZ2_bzCompressEnd ( &strm );
1310  return ret;
1311 }
int BZ_API() BZ2_bzCompress(bz_stream *strm, int action)
Definition: bzlib.c:414
unsigned int avail_in
Definition: bzlib.h:51
#define BZ_PARAM_ERROR
Definition: bzlib.h:39
Int32 workFactor
Definition: bzip2.c:211
#define BZ_FINISH
Definition: bzlib.h:31
Int32 blockSize100k
Definition: bzip2.c:186
void(* bzfree)(void *, void *)
Definition: bzlib.h:63
int BZ_API() BZ2_bzCompressEnd(bz_stream *strm)
Definition: bzlib.c:475
int BZ_API() BZ2_bzCompressInit(bz_stream *strm, int blockSize100k, int verbosity, int workFactor)
Definition: bzlib.c:156
smooth NULL
Definition: ftsmooth.c:416
#define BZ_OK
Definition: bzlib.h:33
#define BZ_STREAM_END
Definition: bzlib.h:37
int ret
#define BZ_FINISH_OK
Definition: bzlib.h:36
#define BZ_OUTBUFF_FULL
Definition: bzlib.h:45
GLsizei GLsizei GLchar * source
Definition: glext.h:6048
unsigned int avail_out
Definition: bzlib.h:56
void *(* bzalloc)(void *, int, int)
Definition: bzlib.h:62
void * opaque
Definition: bzlib.h:64
char * next_out
Definition: bzlib.h:55
static char * dest
Definition: rtl.c:135
enum @1488 verbosity
char * next_in
Definition: bzlib.h:50

Referenced by main().

◆ BZ2_bzBuffToBuffDecompress()

BZ_EXTERN int BZ_API() BZ2_bzBuffToBuffDecompress ( char dest,
unsigned int destLen,
char source,
unsigned int  sourceLen,
int  small,
int  verbosity 
)

Definition at line 1317 of file bzlib.c.

1323 {
1324  bz_stream strm;
1325  int ret;
1326 
1327  if (dest == NULL || destLen == NULL ||
1328  source == NULL ||
1329  (small != 0 && small != 1) ||
1330  verbosity < 0 || verbosity > 4)
1331  return BZ_PARAM_ERROR;
1332 
1333  strm.bzalloc = NULL;
1334  strm.bzfree = NULL;
1335  strm.opaque = NULL;
1336  ret = BZ2_bzDecompressInit ( &strm, verbosity, small );
1337  if (ret != BZ_OK) return ret;
1338 
1339  strm.next_in = source;
1340  strm.next_out = dest;
1341  strm.avail_in = sourceLen;
1342  strm.avail_out = *destLen;
1343 
1344  ret = BZ2_bzDecompress ( &strm );
1345  if (ret == BZ_OK) goto output_overflow_or_eof;
1346  if (ret != BZ_STREAM_END) goto errhandler;
1347 
1348  /* normal termination */
1349  *destLen -= strm.avail_out;
1350  BZ2_bzDecompressEnd ( &strm );
1351  return BZ_OK;
1352 
1353  output_overflow_or_eof:
1354  if (strm.avail_out > 0) {
1355  BZ2_bzDecompressEnd ( &strm );
1356  return BZ_UNEXPECTED_EOF;
1357  } else {
1358  BZ2_bzDecompressEnd ( &strm );
1359  return BZ_OUTBUFF_FULL;
1360  };
1361 
1362  errhandler:
1363  BZ2_bzDecompressEnd ( &strm );
1364  return ret;
1365 }
int BZ_API() BZ2_bzDecompress(bz_stream *strm)
Definition: bzlib.c:818
unsigned int avail_in
Definition: bzlib.h:51
#define BZ_PARAM_ERROR
Definition: bzlib.h:39
#define small
Definition: rpcndr.h:115
void(* bzfree)(void *, void *)
Definition: bzlib.h:63
smooth NULL
Definition: ftsmooth.c:416
#define BZ_OK
Definition: bzlib.h:33
#define BZ_STREAM_END
Definition: bzlib.h:37
int BZ_API() BZ2_bzDecompressInit(bz_stream *strm, int verbosity, int small)
Definition: bzlib.c:501
int ret
int BZ_API() BZ2_bzDecompressEnd(bz_stream *strm)
Definition: bzlib.c:877
#define BZ_UNEXPECTED_EOF
Definition: bzlib.h:44
#define BZ_OUTBUFF_FULL
Definition: bzlib.h:45
GLsizei GLsizei GLchar * source
Definition: glext.h:6048
unsigned int avail_out
Definition: bzlib.h:56
void *(* bzalloc)(void *, int, int)
Definition: bzlib.h:62
void * opaque
Definition: bzlib.h:64
char * next_out
Definition: bzlib.h:55
static char * dest
Definition: rtl.c:135
enum @1488 verbosity
char * next_in
Definition: bzlib.h:50

Referenced by main().

◆ BZ2_bzclose()

BZ_EXTERN void BZ_API() BZ2_bzclose ( BZFILE b)

Definition at line 1531 of file bzlib.c.

1532 {
1533  int bzerr;
1534  FILE *fp;
1535 
1536  if (b==NULL) {return;}
1537  fp = ((bzFile *)b)->handle;
1538  if(((bzFile*)b)->writing){
1539  BZ2_bzWriteClose(&bzerr,b,0,NULL,NULL);
1540  if(bzerr != BZ_OK){
1542  }
1543  }else{
1544  BZ2_bzReadClose(&bzerr,b);
1545  }
1546  if(fp!=stdin && fp!=stdout){
1547  fclose(fp);
1548  }
1549 }
void BZ_API() BZ2_bzWriteClose(int *bzerror, BZFILE *b, int abandon, unsigned int *nbytes_in, unsigned int *nbytes_out)
Definition: bzlib.c:1025
FILE * stdin
FILE * stdout
void BZ_API() BZ2_bzReadClose(int *bzerror, BZFILE *b)
Definition: bzlib.c:1158
smooth NULL
Definition: ftsmooth.c:416
#define b
Definition: ke_i.h:79
#define BZ_OK
Definition: bzlib.h:33
Definition: bzlib.c:907
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)

◆ BZ2_bzCompress()

BZ_EXTERN int BZ_API() BZ2_bzCompress ( bz_stream strm,
int  action 
)

Definition at line 414 of file bzlib.c.

415 {
416  Bool progress;
417  EState* s;
418  if (strm == NULL) return BZ_PARAM_ERROR;
419  s = strm->state;
420  if (s == NULL) return BZ_PARAM_ERROR;
421  if (s->strm != strm) return BZ_PARAM_ERROR;
422 
423  preswitch:
424  switch (s->mode) {
425 
426  case BZ_M_IDLE:
427  return BZ_SEQUENCE_ERROR;
428 
429  case BZ_M_RUNNING:
430  if (action == BZ_RUN) {
431  progress = handle_compress ( strm );
432  return progress ? BZ_RUN_OK : BZ_PARAM_ERROR;
433  }
434  else
435  if (action == BZ_FLUSH) {
436  s->avail_in_expect = strm->avail_in;
437  s->mode = BZ_M_FLUSHING;
438  goto preswitch;
439  }
440  else
441  if (action == BZ_FINISH) {
442  s->avail_in_expect = strm->avail_in;
443  s->mode = BZ_M_FINISHING;
444  goto preswitch;
445  }
446  else
447  return BZ_PARAM_ERROR;
448 
449  case BZ_M_FLUSHING:
450  if (action != BZ_FLUSH) return BZ_SEQUENCE_ERROR;
451  if (s->avail_in_expect != s->strm->avail_in)
452  return BZ_SEQUENCE_ERROR;
453  progress = handle_compress ( strm );
454  if (s->avail_in_expect > 0 || !isempty_RL(s) ||
455  s->state_out_pos < s->numZ) return BZ_FLUSH_OK;
456  s->mode = BZ_M_RUNNING;
457  return BZ_RUN_OK;
458 
459  case BZ_M_FINISHING:
460  if (action != BZ_FINISH) return BZ_SEQUENCE_ERROR;
461  if (s->avail_in_expect != s->strm->avail_in)
462  return BZ_SEQUENCE_ERROR;
463  progress = handle_compress ( strm );
464  if (!progress) return BZ_SEQUENCE_ERROR;
465  if (s->avail_in_expect > 0 || !isempty_RL(s) ||
466  s->state_out_pos < s->numZ) return BZ_FINISH_OK;
467  s->mode = BZ_M_IDLE;
468  return BZ_STREAM_END;
469  }
470  return BZ_OK; /*--not reached--*/
471 }
#define BZ_RUN_OK
Definition: bzlib.h:34
#define BZ_FLUSH
Definition: bzlib.h:30
unsigned int avail_in
Definition: bzlib.h:51
#define BZ_PARAM_ERROR
Definition: bzlib.h:39
#define BZ_FINISH
Definition: bzlib.h:31
static Bool isempty_RL(EState *s)
Definition: bzlib.c:146
static Bool handle_compress(bz_stream *strm)
Definition: bzlib.c:368
#define BZ_M_FINISHING
smooth NULL
Definition: ftsmooth.c:416
unsigned char Bool
Definition: bzip2.c:162
#define BZ_OK
Definition: bzlib.h:33
#define BZ_RUN
Definition: bzlib.h:29
#define BZ_STREAM_END
Definition: bzlib.h:37
#define BZ_M_IDLE
#define BZ_FINISH_OK
Definition: bzlib.h:36
GLdouble s
Definition: gl.h:2039
void * state
Definition: bzlib.h:60
#define BZ_M_FLUSHING
#define BZ_M_RUNNING
const WCHAR * action
Definition: action.c:7783
cd_progress_ptr progress
Definition: cdjpeg.h:150
#define BZ_FLUSH_OK
Definition: bzlib.h:35
#define BZ_SEQUENCE_ERROR
Definition: bzlib.h:38

Referenced by BZ2_bzBuffToBuffCompress(), BZ2_bzWrite(), BZ2_bzWriteClose64(), zipCloseFileInZipRaw64(), and zipWriteInFileInZip().

◆ BZ2_bzCompressEnd()

BZ_EXTERN int BZ_API() BZ2_bzCompressEnd ( bz_stream strm)

Definition at line 475 of file bzlib.c.

476 {
477  EState* s;
478  if (strm == NULL) return BZ_PARAM_ERROR;
479  s = strm->state;
480  if (s == NULL) return BZ_PARAM_ERROR;
481  if (s->strm != strm) return BZ_PARAM_ERROR;
482 
483  if (s->arr1 != NULL) BZFREE(s->arr1);
484  if (s->arr2 != NULL) BZFREE(s->arr2);
485  if (s->ftab != NULL) BZFREE(s->ftab);
486  BZFREE(strm->state);
487 
488  strm->state = NULL;
489 
490  return BZ_OK;
491 }
#define BZFREE(ppp)
#define BZ_PARAM_ERROR
Definition: bzlib.h:39
smooth NULL
Definition: ftsmooth.c:416
#define BZ_OK
Definition: bzlib.h:33
GLdouble s
Definition: gl.h:2039
void * state
Definition: bzlib.h:60

Referenced by BZ2_bzBuffToBuffCompress(), BZ2_bzWriteClose64(), and zipCloseFileInZipRaw64().

◆ BZ2_bzCompressInit()

BZ_EXTERN int BZ_API() BZ2_bzCompressInit ( bz_stream strm,
int  blockSize100k,
int  verbosity,
int  workFactor 
)

Definition at line 156 of file bzlib.c.

160 {
161  Int32 n;
162  EState* s;
163 
164  if (!bz_config_ok()) return BZ_CONFIG_ERROR;
165 
166  if (strm == NULL ||
167  blockSize100k < 1 || blockSize100k > 9 ||
168  workFactor < 0 || workFactor > 250)
169  return BZ_PARAM_ERROR;
170 
171  if (workFactor == 0) workFactor = 30;
172  if (strm->bzalloc == NULL) strm->bzalloc = default_bzalloc;
173  if (strm->bzfree == NULL) strm->bzfree = default_bzfree;
174 
175  s = BZALLOC( sizeof(EState) );
176  if (s == NULL) return BZ_MEM_ERROR;
177  s->strm = strm;
178 
179  s->arr1 = NULL;
180  s->arr2 = NULL;
181  s->ftab = NULL;
182 
183  n = 100000 * blockSize100k;
184  s->arr1 = BZALLOC( n * sizeof(UInt32) );
185  s->arr2 = BZALLOC( (n+BZ_N_OVERSHOOT) * sizeof(UInt32) );
186  s->ftab = BZALLOC( 65537 * sizeof(UInt32) );
187 
188  if (s->arr1 == NULL || s->arr2 == NULL || s->ftab == NULL) {
189  if (s->arr1 != NULL) BZFREE(s->arr1);
190  if (s->arr2 != NULL) BZFREE(s->arr2);
191  if (s->ftab != NULL) BZFREE(s->ftab);
192  if (s != NULL) BZFREE(s);
193  return BZ_MEM_ERROR;
194  }
195 
196  s->blockNo = 0;
197  s->state = BZ_S_INPUT;
198  s->mode = BZ_M_RUNNING;
199  s->combinedCRC = 0;
200  s->blockSize100k = blockSize100k;
201  s->nblockMAX = 100000 * blockSize100k - 19;
202  s->verbosity = verbosity;
203  s->workFactor = workFactor;
204 
205  s->block = (UChar*)s->arr2;
206  s->mtfv = (UInt16*)s->arr1;
207  s->zbits = NULL;
208  s->ptr = (UInt32*)s->arr1;
209 
210  strm->state = s;
211  strm->total_in_lo32 = 0;
212  strm->total_in_hi32 = 0;
213  strm->total_out_lo32 = 0;
214  strm->total_out_hi32 = 0;
215  init_RL ( s );
216  prepare_new_block ( s );
217  return BZ_OK;
218 }
#define BZFREE(ppp)
static int bz_config_ok(void)
Definition: bzlib.c:98
#define BZ_MEM_ERROR
Definition: bzlib.h:40
unsigned int total_in_hi32
Definition: bzlib.h:53
DWORD UInt32
Definition: chm_lib.c:106
#define BZ_PARAM_ERROR
Definition: bzlib.h:39
GLdouble n
Definition: glext.h:7729
unsigned int total_out_hi32
Definition: bzlib.h:58
Int32 workFactor
Definition: bzip2.c:211
static void prepare_new_block(EState *s)
Definition: bzlib.c:124
Int32 blockSize100k
Definition: bzip2.c:186
BYTE UChar
Definition: chm_lib.c:102
USHORT UInt16
Definition: chm_lib.c:104
#define BZ_S_INPUT
#define BZALLOC(nnn)
void(* bzfree)(void *, void *)
Definition: bzlib.h:63
#define BZ_N_OVERSHOOT
smooth NULL
Definition: ftsmooth.c:416
unsigned int total_in_lo32
Definition: bzlib.h:52
unsigned int total_out_lo32
Definition: bzlib.h:57
#define BZ_OK
Definition: bzlib.h:33
#define BZ_CONFIG_ERROR
Definition: bzlib.h:46
static void * default_bzalloc(void *opaque, Int32 items, Int32 size)
Definition: bzlib.c:109
GLdouble s
Definition: gl.h:2039
void * state
Definition: bzlib.h:60
#define BZ_M_RUNNING
static void default_bzfree(void *opaque, void *addr)
Definition: bzlib.c:115
void *(* bzalloc)(void *, int, int)
Definition: bzlib.h:62
LONG Int32
Definition: chm_lib.c:105
static void init_RL(EState *s)
Definition: bzlib.c:138
enum @1488 verbosity

Referenced by BZ2_bzBuffToBuffCompress(), BZ2_bzWriteOpen(), and zipOpenNewFileInZip4_64().

◆ BZ2_bzDecompress()

BZ_EXTERN int BZ_API() BZ2_bzDecompress ( bz_stream strm)

Definition at line 818 of file bzlib.c.

819 {
820  Bool corrupt;
821  DState* s;
822  if (strm == NULL) return BZ_PARAM_ERROR;
823  s = strm->state;
824  if (s == NULL) return BZ_PARAM_ERROR;
825  if (s->strm != strm) return BZ_PARAM_ERROR;
826 
827  while (True) {
828  if (s->state == BZ_X_IDLE) return BZ_SEQUENCE_ERROR;
829  if (s->state == BZ_X_OUTPUT) {
830 #ifndef BZ_DECOMPRESS_ONLY
831  if (s->smallDecompress)
832  corrupt = unRLE_obuf_to_output_SMALL ( s ); else
833  corrupt = unRLE_obuf_to_output_FAST ( s );
834  if (corrupt) return BZ_DATA_ERROR;
835 #else
836  corrupt = unRLE_obuf_to_output_SMALL ( s );
837  if (corrupt) return BZ_DATA_ERROR;
838 #endif
839  if (s->nblock_used == s->save_nblock+1 && s->state_out_len == 0) {
840  BZ_FINALISE_CRC ( s->calculatedBlockCRC );
841  if (s->verbosity >= 3)
842  VPrintf2 ( " {0x%08x, 0x%08x}", s->storedBlockCRC,
843  s->calculatedBlockCRC );
844  if (s->verbosity >= 2) VPrintf0 ( "]" );
845  if (s->calculatedBlockCRC != s->storedBlockCRC)
846  return BZ_DATA_ERROR;
847  s->calculatedCombinedCRC
848  = (s->calculatedCombinedCRC << 1) |
849  (s->calculatedCombinedCRC >> 31);
850  s->calculatedCombinedCRC ^= s->calculatedBlockCRC;
851  s->state = BZ_X_BLKHDR_1;
852  } else {
853  return BZ_OK;
854  }
855  }
856  if (s->state >= BZ_X_MAGIC_1) {
857  Int32 r = BZ2_decompress ( s );
858  if (r == BZ_STREAM_END) {
859  if (s->verbosity >= 3)
860  VPrintf2 ( "\n combined CRCs: stored = 0x%08x, computed = 0x%08x",
861  s->storedCombinedCRC, s->calculatedCombinedCRC );
862  if (s->calculatedCombinedCRC != s->storedCombinedCRC)
863  return BZ_DATA_ERROR;
864  return r;
865  }
866  if (s->state != BZ_X_OUTPUT) return r;
867  }
868  }
869 
870  AssertH ( 0, 6001 );
871 
872  return 0; /*NOTREACHED*/
873 }
#define BZ_X_MAGIC_1
#define BZ_FINALISE_CRC(crcVar)
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define BZ_PARAM_ERROR
Definition: bzlib.h:39
#define VPrintf2(zf, za1, za2)
Definition: bzlib_private.h:77
#define AssertH(cond, errcode)
Definition: bzlib_private.h:59
static Bool unRLE_obuf_to_output_SMALL(DState *s)
Definition: bzlib.c:716
smooth NULL
Definition: ftsmooth.c:416
unsigned char Bool
Definition: bzip2.c:162
#define BZ_OK
Definition: bzlib.h:33
#define BZ_X_OUTPUT
#define True
Definition: types.h:24
Int32 BZ2_decompress(DState *)
Definition: decompress.c:106
#define BZ_STREAM_END
Definition: bzlib.h:37
static Bool unRLE_obuf_to_output_FAST(DState *s)
Definition: bzlib.c:545
GLdouble s
Definition: gl.h:2039
void * state
Definition: bzlib.h:60
#define VPrintf0(zf)
Definition: bzlib_private.h:73
#define BZ_X_BLKHDR_1
#define BZ_DATA_ERROR
Definition: bzlib.h:41
LONG Int32
Definition: chm_lib.c:105
#define BZ_X_IDLE
#define BZ_SEQUENCE_ERROR
Definition: bzlib.h:38

Referenced by BZ2_bzBuffToBuffDecompress(), BZ2_bzRead(), and unzReadCurrentFile().

◆ BZ2_bzDecompressEnd()

BZ_EXTERN int BZ_API() BZ2_bzDecompressEnd ( bz_stream strm)

Definition at line 877 of file bzlib.c.

878 {
879  DState* s;
880  if (strm == NULL) return BZ_PARAM_ERROR;
881  s = strm->state;
882  if (s == NULL) return BZ_PARAM_ERROR;
883  if (s->strm != strm) return BZ_PARAM_ERROR;
884 
885  if (s->tt != NULL) BZFREE(s->tt);
886  if (s->ll16 != NULL) BZFREE(s->ll16);
887  if (s->ll4 != NULL) BZFREE(s->ll4);
888 
889  BZFREE(strm->state);
890  strm->state = NULL;
891 
892  return BZ_OK;
893 }
#define BZFREE(ppp)
#define BZ_PARAM_ERROR
Definition: bzlib.h:39
smooth NULL
Definition: ftsmooth.c:416
#define BZ_OK
Definition: bzlib.h:33
GLdouble s
Definition: gl.h:2039
void * state
Definition: bzlib.h:60

Referenced by BZ2_bzBuffToBuffDecompress(), BZ2_bzReadClose(), and unzCloseCurrentFile().

◆ BZ2_bzDecompressInit()

BZ_EXTERN int BZ_API() BZ2_bzDecompressInit ( bz_stream strm,
int  verbosity,
int  small 
)

Definition at line 501 of file bzlib.c.

504 {
505  DState* s;
506 
507  if (!bz_config_ok()) return BZ_CONFIG_ERROR;
508 
509  if (strm == NULL) return BZ_PARAM_ERROR;
510  if (small != 0 && small != 1) return BZ_PARAM_ERROR;
511  if (verbosity < 0 || verbosity > 4) return BZ_PARAM_ERROR;
512 
513  if (strm->bzalloc == NULL) strm->bzalloc = default_bzalloc;
514  if (strm->bzfree == NULL) strm->bzfree = default_bzfree;
515 
516  s = BZALLOC( sizeof(DState) );
517  if (s == NULL) return BZ_MEM_ERROR;
518  s->strm = strm;
519  strm->state = s;
520  s->state = BZ_X_MAGIC_1;
521  s->bsLive = 0;
522  s->bsBuff = 0;
523  s->calculatedCombinedCRC = 0;
524  strm->total_in_lo32 = 0;
525  strm->total_in_hi32 = 0;
526  strm->total_out_lo32 = 0;
527  strm->total_out_hi32 = 0;
528  s->smallDecompress = (Bool)small;
529  s->ll4 = NULL;
530  s->ll16 = NULL;
531  s->tt = NULL;
532  s->currBlockNo = 0;
533  s->verbosity = verbosity;
534 
535  return BZ_OK;
536 }
static int bz_config_ok(void)
Definition: bzlib.c:98
#define BZ_MEM_ERROR
Definition: bzlib.h:40
#define BZ_X_MAGIC_1
unsigned int total_in_hi32
Definition: bzlib.h:53
#define BZ_PARAM_ERROR
Definition: bzlib.h:39
unsigned int total_out_hi32
Definition: bzlib.h:58
#define small
Definition: rpcndr.h:115
#define BZALLOC(nnn)
void(* bzfree)(void *, void *)
Definition: bzlib.h:63
smooth NULL
Definition: ftsmooth.c:416
unsigned int total_in_lo32
Definition: bzlib.h:52
unsigned char Bool
Definition: bzip2.c:162
unsigned int total_out_lo32
Definition: bzlib.h:57
#define BZ_OK
Definition: bzlib.h:33
#define BZ_CONFIG_ERROR
Definition: bzlib.h:46
static void * default_bzalloc(void *opaque, Int32 items, Int32 size)
Definition: bzlib.c:109
GLdouble s
Definition: gl.h:2039
void * state
Definition: bzlib.h:60
static void default_bzfree(void *opaque, void *addr)
Definition: bzlib.c:115
void *(* bzalloc)(void *, int, int)
Definition: bzlib.h:62
enum @1488 verbosity

Referenced by BZ2_bzBuffToBuffDecompress(), BZ2_bzReadOpen(), and unzOpenCurrentFile3().

◆ BZ2_bzdopen()

BZ_EXTERN BZFILE* BZ_API() BZ2_bzdopen ( int  fd,
const char mode 
)

Definition at line 1487 of file bzlib.c.

1489 {
1490  return bzopen_or_bzdopen(NULL,fd,mode,/*bzdopen*/1);
1491 }
static int fd
Definition: io.c:51
smooth NULL
Definition: ftsmooth.c:416
GLenum mode
Definition: glext.h:6217
static BZFILE * bzopen_or_bzdopen(const char *path, int fd, const char *mode, int open_mode)
Definition: bzlib.c:1401

◆ BZ2_bzerror()

BZ_EXTERN const char* BZ_API() BZ2_bzerror ( BZFILE b,
int errnum 
)

Definition at line 1576 of file bzlib.c.

1577 {
1578  int err = ((bzFile *)b)->lastErr;
1579 
1580  if(err>0) err = 0;
1581  *errnum = err;
1582  return bzerrorstrings[err*-1];
1583 }
static const char * bzerrorstrings[]
Definition: bzlib.c:1556
Definition: bzlib.c:907
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define err(...)

◆ BZ2_bzflush()

BZ_EXTERN int BZ_API() BZ2_bzflush ( BZFILE b)

Definition at line 1523 of file bzlib.c.

1524 {
1525  /* do nothing now... */
1526  return 0;
1527 }

◆ BZ2_bzlibVersion()

BZ_EXTERN const char* BZ_API() BZ2_bzlibVersion ( void  )

Definition at line 1383 of file bzlib.c.

1384 {
1385  return BZ_VERSION;
1386 }
#define BZ_VERSION
Definition: bzlib_private.h:39

Referenced by BZ2_bz__AssertH__fail(), license(), and usage().

◆ BZ2_bzopen()

BZ_EXTERN BZFILE* BZ_API() BZ2_bzopen ( const char path,
const char mode 
)

Definition at line 1478 of file bzlib.c.

1480 {
1481  return bzopen_or_bzdopen(path,-1,mode,/*bzopen*/0);
1482 }
GLenum mode
Definition: glext.h:6217
static BZFILE * bzopen_or_bzdopen(const char *path, int fd, const char *mode, int open_mode)
Definition: bzlib.c:1401
Definition: services.c:325

◆ BZ2_bzRead()

BZ_EXTERN int BZ_API() BZ2_bzRead ( int bzerror,
BZFILE b,
void buf,
int  len 
)

Definition at line 1177 of file bzlib.c.

1181 {
1182  Int32 n, ret;
1183  bzFile* bzf = (bzFile*)b;
1184 
1185  BZ_SETERR(BZ_OK);
1186 
1187  if (bzf == NULL || buf == NULL || len < 0)
1188  { BZ_SETERR(BZ_PARAM_ERROR); return 0; };
1189 
1190  if (bzf->writing)
1191  { BZ_SETERR(BZ_SEQUENCE_ERROR); return 0; };
1192 
1193  if (len == 0)
1194  { BZ_SETERR(BZ_OK); return 0; };
1195 
1196  bzf->strm.avail_out = len;
1197  bzf->strm.next_out = buf;
1198 
1199  while (True) {
1200 
1201  if (ferror(bzf->handle))
1202  { BZ_SETERR(BZ_IO_ERROR); return 0; };
1203 
1204  if (bzf->strm.avail_in == 0 && !myfeof(bzf->handle)) {
1205  n = fread ( bzf->buf, sizeof(UChar),
1206  BZ_MAX_UNUSED, bzf->handle );
1207  if (ferror(bzf->handle))
1208  { BZ_SETERR(BZ_IO_ERROR); return 0; };
1209  bzf->bufN = n;
1210  bzf->strm.avail_in = bzf->bufN;
1211  bzf->strm.next_in = bzf->buf;
1212  }
1213 
1214  ret = BZ2_bzDecompress ( &(bzf->strm) );
1215 
1216  if (ret != BZ_OK && ret != BZ_STREAM_END)
1217  { BZ_SETERR(ret); return 0; };
1218 
1219  if (ret == BZ_OK && myfeof(bzf->handle) &&
1220  bzf->strm.avail_in == 0 && bzf->strm.avail_out > 0)
1221  { BZ_SETERR(BZ_UNEXPECTED_EOF); return 0; };
1222 
1223  if (ret == BZ_STREAM_END)
1225  return len - bzf->strm.avail_out; };
1226  if (bzf->strm.avail_out == 0)
1227  { BZ_SETERR(BZ_OK); return len; };
1228 
1229  }
1230 
1231  return 0; /*not reached*/
1232 }
int BZ_API() BZ2_bzDecompress(bz_stream *strm)
Definition: bzlib.c:818
_Check_return_ _CRTIMP int __cdecl ferror(_In_ FILE *_File)
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
unsigned int avail_in
Definition: bzlib.h:51
#define BZ_PARAM_ERROR
Definition: bzlib.h:39
static Bool myfeof(FILE *f)
Definition: bzlib.c:921
GLdouble n
Definition: glext.h:7729
Int32 bufN
Definition: bzlib.c:911
BYTE UChar
Definition: chm_lib.c:102
FILE * handle
Definition: bzlib.c:909
Char buf[BZ_MAX_UNUSED]
Definition: bzlib.c:910
Bool writing
Definition: bzlib.c:912
_Check_return_opt_ _CRTIMP size_t __cdecl fread(_Out_writes_bytes_(_ElementSize *_Count) void *_DstBuf, _In_ size_t _ElementSize, _In_ size_t _Count, _Inout_ FILE *_File)
#define BZ_SETERR(eee)
Definition: bzlib.c:901
smooth NULL
Definition: ftsmooth.c:416
#define BZ_OK
Definition: bzlib.h:33
Definition: bzlib.c:907
#define True
Definition: types.h:24
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define BZ_STREAM_END
Definition: bzlib.h:37
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define BZ_UNEXPECTED_EOF
Definition: bzlib.h:44
bz_stream strm
Definition: bzlib.c:913
#define BZ_MAX_UNUSED
Definition: bzlib.h:135
unsigned int avail_out
Definition: bzlib.h:56
LONG Int32
Definition: chm_lib.c:105
#define BZ_IO_ERROR
Definition: bzlib.h:43
char * next_out
Definition: bzlib.h:55
char * next_in
Definition: bzlib.h:50
#define BZ_SEQUENCE_ERROR
Definition: bzlib.h:38

Referenced by BZ2_bzread(), testStream(), and uncompressStream().

◆ BZ2_bzread()

BZ_EXTERN int BZ_API() BZ2_bzread ( BZFILE b,
void buf,
int  len 
)

Definition at line 1495 of file bzlib.c.

1496 {
1497  int bzerr, nread;
1498  if (((bzFile*)b)->lastErr == BZ_STREAM_END) return 0;
1499  nread = BZ2_bzRead(&bzerr,b,buf,len);
1500  if (bzerr == BZ_OK || bzerr == BZ_STREAM_END) {
1501  return nread;
1502  } else {
1503  return -1;
1504  }
1505 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define BZ_OK
Definition: bzlib.h:33
Definition: bzlib.c:907
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define BZ_STREAM_END
Definition: bzlib.h:37
int BZ_API() BZ2_bzRead(int *bzerror, BZFILE *b, void *buf, int len)
Definition: bzlib.c:1177
GLenum GLsizei len
Definition: glext.h:6722

◆ BZ2_bzReadClose()

BZ_EXTERN void BZ_API() BZ2_bzReadClose ( int bzerror,
BZFILE b 
)

Definition at line 1158 of file bzlib.c.

1159 {
1160  bzFile* bzf = (bzFile*)b;
1161 
1162  BZ_SETERR(BZ_OK);
1163  if (bzf == NULL)
1164  { BZ_SETERR(BZ_OK); return; };
1165 
1166  if (bzf->writing)
1167  { BZ_SETERR(BZ_SEQUENCE_ERROR); return; };
1168 
1169  if (bzf->initialisedOk)
1170  (void)BZ2_bzDecompressEnd ( &(bzf->strm) );
1171  free ( bzf );
1172 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define free
Definition: debug_ros.c:5
Bool writing
Definition: bzlib.c:912
#define BZ_SETERR(eee)
Definition: bzlib.c:901
smooth NULL
Definition: ftsmooth.c:416
#define BZ_OK
Definition: bzlib.h:33
Definition: bzlib.c:907
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
int BZ_API() BZ2_bzDecompressEnd(bz_stream *strm)
Definition: bzlib.c:877
bz_stream strm
Definition: bzlib.c:913
Bool initialisedOk
Definition: bzlib.c:915
#define BZ_SEQUENCE_ERROR
Definition: bzlib.h:38

Referenced by BZ2_bzclose(), testStream(), and uncompressStream().

◆ BZ2_bzReadGetUnused()

BZ_EXTERN void BZ_API() BZ2_bzReadGetUnused ( int bzerror,
BZFILE b,
void **  unused,
int nUnused 
)

Definition at line 1237 of file bzlib.c.

1241 {
1242  bzFile* bzf = (bzFile*)b;
1243  if (bzf == NULL)
1244  { BZ_SETERR(BZ_PARAM_ERROR); return; };
1245  if (bzf->lastErr != BZ_STREAM_END)
1246  { BZ_SETERR(BZ_SEQUENCE_ERROR); return; };
1247  if (unused == NULL || nUnused == NULL)
1248  { BZ_SETERR(BZ_PARAM_ERROR); return; };
1249 
1250  BZ_SETERR(BZ_OK);
1251  *nUnused = bzf->strm.avail_in;
1252  *unused = bzf->strm.next_in;
1253 }
unsigned int avail_in
Definition: bzlib.h:51
#define BZ_PARAM_ERROR
Definition: bzlib.h:39
WORD unused[29]
Definition: crypt.c:1155
#define BZ_SETERR(eee)
Definition: bzlib.c:901
smooth NULL
Definition: ftsmooth.c:416
#define BZ_OK
Definition: bzlib.h:33
Definition: bzlib.c:907
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define BZ_STREAM_END
Definition: bzlib.h:37
Int32 lastErr
Definition: bzlib.c:914
bz_stream strm
Definition: bzlib.c:913
char * next_in
Definition: bzlib.h:50
#define BZ_SEQUENCE_ERROR
Definition: bzlib.h:38

Referenced by testStream(), and uncompressStream().

◆ BZ2_bzReadOpen()

BZ_EXTERN BZFILE* BZ_API() BZ2_bzReadOpen ( int bzerror,
FILE f,
int  verbosity,
int  small,
void unused,
int  nUnused 
)

Definition at line 1103 of file bzlib.c.

1109 {
1110  bzFile* bzf = NULL;
1111  int ret;
1112 
1113  BZ_SETERR(BZ_OK);
1114 
1115  if (f == NULL ||
1116  (small != 0 && small != 1) ||
1117  (verbosity < 0 || verbosity > 4) ||
1118  (unused == NULL && nUnused != 0) ||
1119  (unused != NULL && (nUnused < 0 || nUnused > BZ_MAX_UNUSED)))
1120  { BZ_SETERR(BZ_PARAM_ERROR); return NULL; };
1121 
1122  if (ferror(f))
1123  { BZ_SETERR(BZ_IO_ERROR); return NULL; };
1124 
1125  bzf = malloc ( sizeof(bzFile) );
1126  if (bzf == NULL)
1127  { BZ_SETERR(BZ_MEM_ERROR); return NULL; };
1128 
1129  BZ_SETERR(BZ_OK);
1130 
1131  bzf->initialisedOk = False;
1132  bzf->handle = f;
1133  bzf->bufN = 0;
1134  bzf->writing = False;
1135  bzf->strm.bzalloc = NULL;
1136  bzf->strm.bzfree = NULL;
1137  bzf->strm.opaque = NULL;
1138 
1139  while (nUnused > 0) {
1140  bzf->buf[bzf->bufN] = *((UChar*)(unused)); bzf->bufN++;
1141  unused = ((void*)( 1 + ((UChar*)(unused)) ));
1142  nUnused--;
1143  }
1144 
1145  ret = BZ2_bzDecompressInit ( &(bzf->strm), verbosity, small );
1146  if (ret != BZ_OK)
1147  { BZ_SETERR(ret); free(bzf); return NULL; };
1148 
1149  bzf->strm.avail_in = bzf->bufN;
1150  bzf->strm.next_in = bzf->buf;
1151 
1152  bzf->initialisedOk = True;
1153  return bzf;
1154 }
_Check_return_ _CRTIMP int __cdecl ferror(_In_ FILE *_File)
#define BZ_MEM_ERROR
Definition: bzlib.h:40
#define free
Definition: debug_ros.c:5
unsigned int avail_in
Definition: bzlib.h:51
#define BZ_PARAM_ERROR
Definition: bzlib.h:39
Int32 bufN
Definition: bzlib.c:911
BYTE UChar
Definition: chm_lib.c:102
#define small
Definition: rpcndr.h:115
FILE * handle
Definition: bzlib.c:909
void(* bzfree)(void *, void *)
Definition: bzlib.h:63
Char buf[BZ_MAX_UNUSED]
Definition: bzlib.c:910
WORD unused[29]
Definition: crypt.c:1155
Bool writing
Definition: bzlib.c:912
#define BZ_SETERR(eee)
Definition: bzlib.c:901
smooth NULL
Definition: ftsmooth.c:416
#define BZ_OK
Definition: bzlib.h:33
Definition: bzlib.c:907
#define True
Definition: types.h:24
GLfloat f
Definition: glext.h:7540
#define False
Definition: types.h:25
int BZ_API() BZ2_bzDecompressInit(bz_stream *strm, int verbosity, int small)
Definition: bzlib.c:501
int ret
bz_stream strm
Definition: bzlib.c:913
#define BZ_MAX_UNUSED
Definition: bzlib.h:135
#define f
Definition: ke_i.h:83
void *(* bzalloc)(void *, int, int)
Definition: bzlib.h:62
void * opaque
Definition: bzlib.h:64
#define BZ_IO_ERROR
Definition: bzlib.h:43
#define malloc
Definition: debug_ros.c:4
Bool initialisedOk
Definition: bzlib.c:915
enum @1488 verbosity
char * next_in
Definition: bzlib.h:50

Referenced by bzopen_or_bzdopen(), testStream(), and uncompressStream().

◆ BZ2_bzWrite()

BZ_EXTERN void BZ_API() BZ2_bzWrite ( int bzerror,
BZFILE b,
void buf,
int  len 
)

Definition at line 980 of file bzlib.c.

984 {
985  Int32 n, n2, ret;
986  bzFile* bzf = (bzFile*)b;
987 
988  BZ_SETERR(BZ_OK);
989  if (bzf == NULL || buf == NULL || len < 0)
990  { BZ_SETERR(BZ_PARAM_ERROR); return; };
991  if (!(bzf->writing))
992  { BZ_SETERR(BZ_SEQUENCE_ERROR); return; };
993  if (ferror(bzf->handle))
994  { BZ_SETERR(BZ_IO_ERROR); return; };
995 
996  if (len == 0)
997  { BZ_SETERR(BZ_OK); return; };
998 
999  bzf->strm.avail_in = len;
1000  bzf->strm.next_in = buf;
1001 
1002  while (True) {
1003  bzf->strm.avail_out = BZ_MAX_UNUSED;
1004  bzf->strm.next_out = bzf->buf;
1005  ret = BZ2_bzCompress ( &(bzf->strm), BZ_RUN );
1006  if (ret != BZ_RUN_OK)
1007  { BZ_SETERR(ret); return; };
1008 
1009  if (bzf->strm.avail_out < BZ_MAX_UNUSED) {
1010  n = BZ_MAX_UNUSED - bzf->strm.avail_out;
1011  n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar),
1012  n, bzf->handle );
1013  if (n != n2 || ferror(bzf->handle))
1014  { BZ_SETERR(BZ_IO_ERROR); return; };
1015  }
1016 
1017  if (bzf->strm.avail_in == 0)
1018  { BZ_SETERR(BZ_OK); return; };
1019  }
1020 }
_Check_return_ _CRTIMP int __cdecl ferror(_In_ FILE *_File)
#define BZ_RUN_OK
Definition: bzlib.h:34
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
int BZ_API() BZ2_bzCompress(bz_stream *strm, int action)
Definition: bzlib.c:414
unsigned int avail_in
Definition: bzlib.h:51
#define BZ_PARAM_ERROR
Definition: bzlib.h:39
GLdouble n
Definition: glext.h:7729
BYTE UChar
Definition: chm_lib.c:102
_Check_return_opt_ _CRTIMP size_t __cdecl fwrite(_In_reads_bytes_(_Size *_Count) const void *_Str, _In_ size_t _Size, _In_ size_t _Count, _Inout_ FILE *_File)
FILE * handle
Definition: bzlib.c:909
Char buf[BZ_MAX_UNUSED]
Definition: bzlib.c:910
Bool writing
Definition: bzlib.c:912
#define BZ_SETERR(eee)
Definition: bzlib.c:901
smooth NULL
Definition: ftsmooth.c:416
#define BZ_OK
Definition: bzlib.h:33
Definition: bzlib.c:907
#define True
Definition: types.h:24
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define BZ_RUN
Definition: bzlib.h:29
int ret
GLenum GLsizei len
Definition: glext.h:6722
int n2
Definition: dwarfget.c:148
bz_stream strm
Definition: bzlib.c:913
#define BZ_MAX_UNUSED
Definition: bzlib.h:135
unsigned int avail_out
Definition: bzlib.h:56
LONG Int32
Definition: chm_lib.c:105
#define BZ_IO_ERROR
Definition: bzlib.h:43
char * next_out
Definition: bzlib.h:55
char * next_in
Definition: bzlib.h:50
#define BZ_SEQUENCE_ERROR
Definition: bzlib.h:38

Referenced by BZ2_bzwrite(), and compressStream().

◆ BZ2_bzwrite()

BZ_EXTERN int BZ_API() BZ2_bzwrite ( BZFILE b,
void buf,
int  len 
)

Definition at line 1509 of file bzlib.c.

1510 {
1511  int bzerr;
1512 
1513  BZ2_bzWrite(&bzerr,b,buf,len);
1514  if(bzerr == BZ_OK){
1515  return len;
1516  }else{
1517  return -1;
1518  }
1519 }
void BZ_API() BZ2_bzWrite(int *bzerror, BZFILE *b, void *buf, int len)
Definition: bzlib.c:980
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define BZ_OK
Definition: bzlib.h:33
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLenum GLsizei len
Definition: glext.h:6722

◆ BZ2_bzWriteClose()

BZ_EXTERN void BZ_API() BZ2_bzWriteClose ( int bzerror,
BZFILE b,
int  abandon,
unsigned int nbytes_in,
unsigned int nbytes_out 
)

Definition at line 1025 of file bzlib.c.

1030 {
1031  BZ2_bzWriteClose64 ( bzerror, b, abandon,
1032  nbytes_in, NULL, nbytes_out, NULL );
1033 }
smooth NULL
Definition: ftsmooth.c:416
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
void BZ_API() BZ2_bzWriteClose64(int *bzerror, BZFILE *b, int abandon, unsigned int *nbytes_in_lo32, unsigned int *nbytes_in_hi32, unsigned int *nbytes_out_lo32, unsigned int *nbytes_out_hi32)
Definition: bzlib.c:1037

Referenced by BZ2_bzclose().

◆ BZ2_bzWriteClose64()

BZ_EXTERN void BZ_API() BZ2_bzWriteClose64 ( int bzerror,
BZFILE b,
int  abandon,
unsigned int nbytes_in_lo32,
unsigned int nbytes_in_hi32,
unsigned int nbytes_out_lo32,
unsigned int nbytes_out_hi32 
)

Definition at line 1037 of file bzlib.c.

1044 {
1045  Int32 n, n2, ret;
1046  bzFile* bzf = (bzFile*)b;
1047 
1048  if (bzf == NULL)
1049  { BZ_SETERR(BZ_OK); return; };
1050  if (!(bzf->writing))
1051  { BZ_SETERR(BZ_SEQUENCE_ERROR); return; };
1052  if (ferror(bzf->handle))
1053  { BZ_SETERR(BZ_IO_ERROR); return; };
1054 
1055  if (nbytes_in_lo32 != NULL) *nbytes_in_lo32 = 0;
1056  if (nbytes_in_hi32 != NULL) *nbytes_in_hi32 = 0;
1057  if (nbytes_out_lo32 != NULL) *nbytes_out_lo32 = 0;
1058  if (nbytes_out_hi32 != NULL) *nbytes_out_hi32 = 0;
1059 
1060  if ((!abandon) && bzf->lastErr == BZ_OK) {
1061  while (True) {
1062  bzf->strm.avail_out = BZ_MAX_UNUSED;
1063  bzf->strm.next_out = bzf->buf;
1064  ret = BZ2_bzCompress ( &(bzf->strm), BZ_FINISH );
1065  if (ret != BZ_FINISH_OK && ret != BZ_STREAM_END)
1066  { BZ_SETERR(ret); return; };
1067 
1068  if (bzf->strm.avail_out < BZ_MAX_UNUSED) {
1069  n = BZ_MAX_UNUSED - bzf->strm.avail_out;
1070  n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar),
1071  n, bzf->handle );
1072  if (n != n2 || ferror(bzf->handle))
1073  { BZ_SETERR(BZ_IO_ERROR); return; };
1074  }
1075 
1076  if (ret == BZ_STREAM_END) break;
1077  }
1078  }
1079 
1080  if ( !abandon && !ferror ( bzf->handle ) ) {
1081  fflush ( bzf->handle );
1082  if (ferror(bzf->handle))
1083  { BZ_SETERR(BZ_IO_ERROR); return; };
1084  }
1085 
1086  if (nbytes_in_lo32 != NULL)
1087  *nbytes_in_lo32 = bzf->strm.total_in_lo32;
1088  if (nbytes_in_hi32 != NULL)
1089  *nbytes_in_hi32 = bzf->strm.total_in_hi32;
1090  if (nbytes_out_lo32 != NULL)
1091  *nbytes_out_lo32 = bzf->strm.total_out_lo32;
1092  if (nbytes_out_hi32 != NULL)
1093  *nbytes_out_hi32 = bzf->strm.total_out_hi32;
1094 
1095  BZ_SETERR(BZ_OK);
1096  BZ2_bzCompressEnd ( &(bzf->strm) );
1097  free ( bzf );
1098 }
_Check_return_ _CRTIMP int __cdecl ferror(_In_ FILE *_File)
unsigned int total_in_hi32
Definition: bzlib.h:53
int BZ_API() BZ2_bzCompress(bz_stream *strm, int action)
Definition: bzlib.c:414
#define free
Definition: debug_ros.c:5
GLdouble n
Definition: glext.h:7729
unsigned int total_out_hi32
Definition: bzlib.h:58
#define BZ_FINISH
Definition: bzlib.h:31
BYTE UChar
Definition: chm_lib.c:102
_Check_return_opt_ _CRTIMP size_t __cdecl fwrite(_In_reads_bytes_(_Size *_Count) const void *_Str, _In_ size_t _Size, _In_ size_t _Count, _Inout_ FILE *_File)
FILE * handle
Definition: bzlib.c:909
int BZ_API() BZ2_bzCompressEnd(bz_stream *strm)
Definition: bzlib.c:475
Char buf[BZ_MAX_UNUSED]
Definition: bzlib.c:910
Bool writing
Definition: bzlib.c:912
#define BZ_SETERR(eee)
Definition: bzlib.c:901
smooth NULL
Definition: ftsmooth.c:416
unsigned int total_in_lo32
Definition: bzlib.h:52
unsigned int total_out_lo32
Definition: bzlib.h:57
#define BZ_OK
Definition: bzlib.h:33
Definition: bzlib.c:907
#define True
Definition: types.h:24
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define BZ_STREAM_END
Definition: bzlib.h:37
Int32 lastErr
Definition: bzlib.c:914
int ret
#define BZ_FINISH_OK
Definition: bzlib.h:36
int n2
Definition: dwarfget.c:148
bz_stream strm
Definition: bzlib.c:913
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
#define BZ_MAX_UNUSED
Definition: bzlib.h:135
unsigned int avail_out
Definition: bzlib.h:56
LONG Int32
Definition: chm_lib.c:105
#define BZ_IO_ERROR
Definition: bzlib.h:43
char * next_out
Definition: bzlib.h:55
#define BZ_SEQUENCE_ERROR
Definition: bzlib.h:38

Referenced by BZ2_bzWriteClose(), and compressStream().

◆ BZ2_bzWriteOpen()

BZ_EXTERN BZFILE* BZ_API() BZ2_bzWriteOpen ( int bzerror,
FILE f,
int  blockSize100k,
int  verbosity,
int  workFactor 
)

Definition at line 932 of file bzlib.c.

937 {
938  Int32 ret;
939  bzFile* bzf = NULL;
940 
941  BZ_SETERR(BZ_OK);
942 
943  if (f == NULL ||
944  (blockSize100k < 1 || blockSize100k > 9) ||
945  (workFactor < 0 || workFactor > 250) ||
946  (verbosity < 0 || verbosity > 4))
947  { BZ_SETERR(BZ_PARAM_ERROR); return NULL; };
948 
949  if (ferror(f))
950  { BZ_SETERR(BZ_IO_ERROR); return NULL; };
951 
952  bzf = malloc ( sizeof(bzFile) );
953  if (bzf == NULL)
954  { BZ_SETERR(BZ_MEM_ERROR); return NULL; };
955 
956  BZ_SETERR(BZ_OK);
957  bzf->initialisedOk = False;
958  bzf->bufN = 0;
959  bzf->handle = f;
960  bzf->writing = True;
961  bzf->strm.bzalloc = NULL;
962  bzf->strm.bzfree = NULL;
963  bzf->strm.opaque = NULL;
964 
965  if (workFactor == 0) workFactor = 30;
968  if (ret != BZ_OK)
969  { BZ_SETERR(ret); free(bzf); return NULL; };
970 
971  bzf->strm.avail_in = 0;
972  bzf->initialisedOk = True;
973  return bzf;
974 }
_Check_return_ _CRTIMP int __cdecl ferror(_In_ FILE *_File)
#define BZ_MEM_ERROR
Definition: bzlib.h:40
#define free
Definition: debug_ros.c:5
unsigned int avail_in
Definition: bzlib.h:51
#define BZ_PARAM_ERROR
Definition: bzlib.h:39
Int32 workFactor
Definition: bzip2.c:211
Int32 blockSize100k
Definition: bzip2.c:186
Int32 bufN
Definition: bzlib.c:911
FILE * handle
Definition: bzlib.c:909
void(* bzfree)(void *, void *)
Definition: bzlib.h:63
Bool writing
Definition: bzlib.c:912
#define BZ_SETERR(eee)
Definition: bzlib.c:901
int BZ_API() BZ2_bzCompressInit(bz_stream *strm, int blockSize100k, int verbosity, int workFactor)
Definition: bzlib.c:156
smooth NULL
Definition: ftsmooth.c:416
#define BZ_OK
Definition: bzlib.h:33
Definition: bzlib.c:907
#define True
Definition: types.h:24
GLfloat f
Definition: glext.h:7540
#define False
Definition: types.h:25
int ret
bz_stream strm
Definition: bzlib.c:913
#define f
Definition: ke_i.h:83
void *(* bzalloc)(void *, int, int)
Definition: bzlib.h:62
LONG Int32
Definition: chm_lib.c:105
void * opaque
Definition: bzlib.h:64
#define BZ_IO_ERROR
Definition: bzlib.h:43
#define malloc
Definition: debug_ros.c:4
Bool initialisedOk
Definition: bzlib.c:915
enum @1488 verbosity

Referenced by bzopen_or_bzdopen(), and compressStream().