ReactOS  0.4.13-dev-100-gc8611ae
bzlib.c File Reference
#include "bzlib_private.h"
Include dependency graph for bzlib.c:

Go to the source code of this file.

Classes

struct  bzFile
 

Macros

#define ADD_CHAR_TO_BLOCK(zs, zchh0)
 
#define BZ_SETERR(eee)
 
#define SET_BINARY_MODE(file)
 

Functions

void BZ2_bz__AssertH__fail (int errcode)
 
static int bz_config_ok (void)
 
static voiddefault_bzalloc (void *opaque, Int32 items, Int32 size)
 
static void default_bzfree (void *opaque, void *addr)
 
static void prepare_new_block (EState *s)
 
static void init_RL (EState *s)
 
static Bool isempty_RL (EState *s)
 
int BZ_API() BZ2_bzCompressInit (bz_stream *strm, int blockSize100k, int verbosity, int workFactor)
 
static void add_pair_to_block (EState *s)
 
static void flush_RL (EState *s)
 
static Bool copy_input_until_stop (EState *s)
 
static Bool copy_output_until_stop (EState *s)
 
static Bool handle_compress (bz_stream *strm)
 
int BZ_API() BZ2_bzCompress (bz_stream *strm, int action)
 
int BZ_API() BZ2_bzCompressEnd (bz_stream *strm)
 
int BZ_API() BZ2_bzDecompressInit (bz_stream *strm, int verbosity, int small)
 
static Bool unRLE_obuf_to_output_FAST (DState *s)
 
__inline__ Int32 BZ2_indexIntoF (Int32 indx, Int32 *cftab)
 
static Bool unRLE_obuf_to_output_SMALL (DState *s)
 
int BZ_API() BZ2_bzDecompress (bz_stream *strm)
 
int BZ_API() BZ2_bzDecompressEnd (bz_stream *strm)
 
static Bool myfeof (FILE *f)
 
BZFILE *BZ_API() BZ2_bzWriteOpen (int *bzerror, FILE *f, int blockSize100k, int verbosity, int workFactor)
 
void BZ_API() BZ2_bzWrite (int *bzerror, BZFILE *b, void *buf, int len)
 
void BZ_API() BZ2_bzWriteClose (int *bzerror, BZFILE *b, int abandon, unsigned int *nbytes_in, unsigned int *nbytes_out)
 
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)
 
BZFILE *BZ_API() BZ2_bzReadOpen (int *bzerror, FILE *f, int verbosity, int small, void *unused, int nUnused)
 
void BZ_API() BZ2_bzReadClose (int *bzerror, BZFILE *b)
 
int BZ_API() BZ2_bzRead (int *bzerror, BZFILE *b, void *buf, int len)
 
void BZ_API() BZ2_bzReadGetUnused (int *bzerror, BZFILE *b, void **unused, int *nUnused)
 
int BZ_API() BZ2_bzBuffToBuffCompress (char *dest, unsigned int *destLen, char *source, unsigned int sourceLen, int blockSize100k, int verbosity, int workFactor)
 
int BZ_API() BZ2_bzBuffToBuffDecompress (char *dest, unsigned int *destLen, char *source, unsigned int sourceLen, int small, int verbosity)
 
const char *BZ_API() BZ2_bzlibVersion (void)
 
static BZFILEbzopen_or_bzdopen (const char *path, int fd, const char *mode, int open_mode)
 
BZFILE *BZ_API() BZ2_bzopen (const char *path, const char *mode)
 
BZFILE *BZ_API() BZ2_bzdopen (int fd, const char *mode)
 
int BZ_API() BZ2_bzread (BZFILE *b, void *buf, int len)
 
int BZ_API() BZ2_bzwrite (BZFILE *b, void *buf, int len)
 
int BZ_API() BZ2_bzflush (BZFILE *b)
 
void BZ_API() BZ2_bzclose (BZFILE *b)
 
const char *BZ_API() BZ2_bzerror (BZFILE *b, int *errnum)
 

Variables

static const charbzerrorstrings []
 

Macro Definition Documentation

◆ ADD_CHAR_TO_BLOCK

#define ADD_CHAR_TO_BLOCK (   zs,
  zchh0 
)
Value:
{ \
UInt32 zchh = (UInt32)(zchh0); \
/*-- fast track the common case --*/ \
if (zchh != zs->state_in_ch && \
zs->state_in_len == 1) { \
UChar ch = (UChar)(zs->state_in_ch); \
BZ_UPDATE_CRC( zs->blockCRC, ch ); \
zs->inUse[zs->state_in_ch] = True; \
zs->block[zs->nblock] = (UChar)ch; \
zs->nblock++; \
zs->state_in_ch = zchh; \
} \
else \
/*-- general, uncommon cases --*/ \
if (zchh != zs->state_in_ch || \
zs->state_in_len == 255) { \
if (zs->state_in_ch < 256) \
add_pair_to_block ( zs ); \
zs->state_in_ch = zchh; \
zs->state_in_len = 1; \
} else { \
zs->state_in_len++; \
} \
}
BYTE UChar
Definition: chm_lib.c:102
#define UInt32
Definition: interfaces.hpp:73
#define True
Definition: types.h:24

Definition at line 267 of file bzlib.c.

◆ BZ_SETERR

#define BZ_SETERR (   eee)
Value:
{ \
if (bzerror != NULL) *bzerror = eee; \
if (bzf != NULL) bzf->lastErr = eee; \
}
smooth NULL
Definition: ftsmooth.c:416

Definition at line 901 of file bzlib.c.

◆ SET_BINARY_MODE

#define SET_BINARY_MODE (   file)

Definition at line 1397 of file bzlib.c.

Function Documentation

◆ add_pair_to_block()

static void add_pair_to_block ( EState s)
static

Definition at line 223 of file bzlib.c.

224 {
225  Int32 i;
226  UChar ch = (UChar)(s->state_in_ch);
227  for (i = 0; i < s->state_in_len; i++) {
228  BZ_UPDATE_CRC( s->blockCRC, ch );
229  }
230  s->inUse[s->state_in_ch] = True;
231  switch (s->state_in_len) {
232  case 1:
233  s->block[s->nblock] = (UChar)ch; s->nblock++;
234  break;
235  case 2:
236  s->block[s->nblock] = (UChar)ch; s->nblock++;
237  s->block[s->nblock] = (UChar)ch; s->nblock++;
238  break;
239  case 3:
240  s->block[s->nblock] = (UChar)ch; s->nblock++;
241  s->block[s->nblock] = (UChar)ch; s->nblock++;
242  s->block[s->nblock] = (UChar)ch; s->nblock++;
243  break;
244  default:
245  s->inUse[s->state_in_len-4] = True;
246  s->block[s->nblock] = (UChar)ch; s->nblock++;
247  s->block[s->nblock] = (UChar)ch; s->nblock++;
248  s->block[s->nblock] = (UChar)ch; s->nblock++;
249  s->block[s->nblock] = (UChar)ch; s->nblock++;
250  s->block[s->nblock] = ((UChar)(s->state_in_len-4));
251  s->nblock++;
252  break;
253  }
254 }
#define BZ_UPDATE_CRC(crcVar, cha)
BYTE UChar
Definition: chm_lib.c:102
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define True
Definition: types.h:24
GLdouble s
Definition: gl.h:2039
LONG Int32
Definition: chm_lib.c:105

Referenced by flush_RL().

◆ BZ2_bz__AssertH__fail()

void BZ2_bz__AssertH__fail ( int  errcode)

Definition at line 48 of file bzlib.c.

49 {
50  fprintf(stderr,
51  "\n\nbzip2/libbzip2: internal error number %d.\n"
52  "This is a bug in bzip2/libbzip2, %s.\n"
53  "Please report it to me at: jseward@bzip.org. If this happened\n"
54  "when you were using some program which uses libbzip2 as a\n"
55  "component, you should also report this bug to the author(s)\n"
56  "of that program. Please make an effort to report this bug;\n"
57  "timely and accurate bug reports eventually lead to higher\n"
58  "quality software. Thanks. Julian Seward, 10 December 2007.\n\n",
59  errcode,
61  );
62 
63  if (errcode == 1007) {
65  "\n*** A special note about internal error number 1007 ***\n"
66  "\n"
67  "Experience suggests that a common cause of i.e. 1007\n"
68  "is unreliable memory or other hardware. The 1007 assertion\n"
69  "just happens to cross-check the results of huge numbers of\n"
70  "memory reads/writes, and so acts (unintendedly) as a stress\n"
71  "test of your memory system.\n"
72  "\n"
73  "I suggest the following: try compressing the file again,\n"
74  "possibly monitoring progress in detail with the -vv flag.\n"
75  "\n"
76  "* If the error cannot be reproduced, and/or happens at different\n"
77  " points in compression, you may have a flaky memory system.\n"
78  " Try a memory-test program. I have used Memtest86\n"
79  " (www.memtest86.com). At the time of writing it is free (GPLd).\n"
80  " Memtest86 tests memory much more thorougly than your BIOSs\n"
81  " power-on test, and may find failures that the BIOS doesn't.\n"
82  "\n"
83  "* If the error can be repeatably reproduced, this is a bug in\n"
84  " bzip2, and I would very much like to hear about it. Please\n"
85  " let me know, and, ideally, save a copy of the file causing the\n"
86  " problem -- without which I will be unable to investigate it.\n"
87  "\n"
88  );
89  }
90 
91  exit(3);
92 }
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
int errcode
Definition: crtdefs.h:352
const char *BZ_API() BZ2_bzlibVersion(void)
Definition: bzlib.c:1383
FILE * stderr
void exit(int exitcode)
Definition: _exit.c:33

◆ BZ2_bzBuffToBuffCompress()

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()

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()

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()

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()

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()

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()

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()

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()

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()

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()

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()

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()

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()

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()

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()

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()

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()

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()

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()

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()

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()

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()

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()

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().

◆ BZ2_indexIntoF()

__inline__ Int32 BZ2_indexIntoF ( Int32  indx,
Int32 cftab 
)

Definition at line 697 of file bzlib.c.

698 {
699  Int32 nb, na, mid;
700  nb = 0;
701  na = 256;
702  do {
703  mid = (nb + na) >> 1;
704  if (indx >= cftab[mid]) nb = mid; else na = mid;
705  }
706  while (na - nb != 1);
707  return nb;
708 }
LONG Int32
Definition: chm_lib.c:105

◆ bz_config_ok()

static int bz_config_ok ( void  )
static

Definition at line 98 of file bzlib.c.

99 {
100  if (sizeof(int) != 4) return 0;
101  if (sizeof(short) != 2) return 0;
102  if (sizeof(char) != 1) return 0;
103  return 1;
104 }

Referenced by BZ2_bzCompressInit(), and BZ2_bzDecompressInit().

◆ bzopen_or_bzdopen()

static BZFILE* bzopen_or_bzdopen ( const char path,
int  fd,
const char mode,
int  open_mode 
)
static

Definition at line 1401 of file bzlib.c.

1405 {
1406  int bzerr;
1407  char unused[BZ_MAX_UNUSED];
1408  int blockSize100k = 9;
1409  int writing = 0;
1410  char mode2[10] = "";
1411  FILE *fp = NULL;
1412  BZFILE *bzfp = NULL;
1413  int verbosity = 0;
1414  int workFactor = 30;
1415  int smallMode = 0;
1416  int nUnused = 0;
1417 
1418  if (mode == NULL) return NULL;
1419  while (*mode) {
1420  switch (*mode) {
1421  case 'r':
1422  writing = 0; break;
1423  case 'w':
1424  writing = 1; break;
1425  case 's':
1426  smallMode = 1; break;
1427  default:
1428  if (isdigit((int)(*mode))) {
1430  }
1431  }
1432  mode++;
1433  }
1434  strcat(mode2, writing ? "w" : "r" );
1435  strcat(mode2,"b"); /* binary mode */
1436 
1437  if (open_mode==0) {
1438  if (path==NULL || strcmp(path,"")==0) {
1439  fp = (writing ? stdout : stdin);
1440  SET_BINARY_MODE(fp);
1441  } else {
1442  fp = fopen(path,mode2);
1443  }
1444  } else {
1445 #ifdef BZ_STRICT_ANSI
1446  fp = NULL;
1447 #else
1448  fp = fdopen(fd,mode2);
1449 #endif
1450  }
1451  if (fp == NULL) return NULL;
1452 
1453  if (writing) {
1454  /* Guard against total chaos and anarchy -- JRS */
1455  if (blockSize100k < 1) blockSize100k = 1;
1456  if (blockSize100k > 9) blockSize100k = 9;
1457  bzfp = BZ2_bzWriteOpen(&bzerr,fp,blockSize100k,
1459  } else {
1460  bzfp = BZ2_bzReadOpen(&bzerr,fp,verbosity,smallMode,
1461  unused,nUnused);
1462  }
1463  if (bzfp == NULL) {
1464  if (fp != stdin && fp != stdout) fclose(fp);
1465  return NULL;
1466  }
1467  return bzfp;
1468 }
#define SET_BINARY_MODE(file)
Definition: bzlib.c:1397
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
Int32 workFactor
Definition: bzip2.c:211
static int fd
Definition: io.c:51
FILE * stdin
Int32 blockSize100k
Definition: bzip2.c:186
FILE * stdout
#define BZ_HDR_0
Definition: bzip2recover.c:77
WORD unused[29]
Definition: crypt.c:1155
BZFILE *BZ_API() BZ2_bzWriteOpen(int *bzerror, FILE *f, int blockSize100k, int verbosity, int workFactor)
Definition: bzlib.c:932
smooth NULL
Definition: ftsmooth.c:416
#define isdigit(c)
Definition: acclib.h:68
Bool smallMode
Definition: bzip2.c:184
BZFILE *BZ_API() BZ2_bzReadOpen(int *bzerror, FILE *f, int verbosity, int small, void *unused, int nUnused)
Definition: bzlib.c:1103
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
GLenum mode
Definition: glext.h:6217
#define BZ_MAX_UNUSED
Definition: bzlib.h:135
Definition: services.c:325
_Check_return_ _CRTIMP FILE *__cdecl fdopen(_In_ int _FileHandle, _In_z_ const char *_Format)
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
enum @1488 verbosity

Referenced by BZ2_bzdopen(), and BZ2_bzopen().

◆ copy_input_until_stop()

static Bool copy_input_until_stop ( EState s)
static

Definition at line 296 of file bzlib.c.

297 {
298  Bool progress_in = False;
299 
300  if (s->mode == BZ_M_RUNNING) {
301 
302  /*-- fast track the common case --*/
303  while (True) {
304  /*-- block full? --*/
305  if (s->nblock >= s->nblockMAX) break;
306  /*-- no input? --*/
307  if (s->strm->avail_in == 0) break;
308  progress_in = True;
309  ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) );
310  s->strm->next_in++;
311  s->strm->avail_in--;
312  s->strm->total_in_lo32++;
313  if (s->strm->total_in_lo32 == 0) s->strm->total_in_hi32++;
314  }
315 
316  } else {
317 
318  /*-- general, uncommon case --*/
319  while (True) {
320  /*-- block full? --*/
321  if (s->nblock >= s->nblockMAX) break;
322  /*-- no input? --*/
323  if (s->strm->avail_in == 0) break;
324  /*-- flush/finish end? --*/
325  if (s->avail_in_expect == 0) break;
326  progress_in = True;
327  ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) );
328  s->strm->next_in++;
329  s->strm->avail_in--;
330  s->strm->total_in_lo32++;
331  if (s->strm->total_in_lo32 == 0) s->strm->total_in_hi32++;
332  s->avail_in_expect--;
333  }
334  }
335  return progress_in;
336 }
DWORD UInt32
Definition: chm_lib.c:106
BYTE UChar
Definition: chm_lib.c:102
unsigned char Bool
Definition: bzip2.c:162
#define True
Definition: types.h:24
#define False
Definition: types.h:25
#define ADD_CHAR_TO_BLOCK(zs, zchh0)
Definition: bzlib.c:267
GLdouble s
Definition: gl.h:2039
#define BZ_M_RUNNING

Referenced by handle_compress().

◆ copy_output_until_stop()

static Bool copy_output_until_stop ( EState s)
static

Definition at line 341 of file bzlib.c.

342 {
343  Bool progress_out = False;
344 
345  while (True) {
346 
347  /*-- no output space? --*/
348  if (s->strm->avail_out == 0) break;
349 
350  /*-- block done? --*/
351  if (s->state_out_pos >= s->numZ) break;
352 
353  progress_out = True;
354  *(s->strm->next_out) = s->zbits[s->state_out_pos];
355  s->state_out_pos++;
356  s->strm->avail_out--;
357  s->strm->next_out++;
358  s->strm->total_out_lo32++;
359  if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
360  }
361 
362  return progress_out;
363 }
unsigned char Bool
Definition: bzip2.c:162
#define True
Definition: types.h:24
#define False
Definition: types.h:25
if(!(yy_init))
Definition: macro.lex.yy.c:714
GLdouble s
Definition: gl.h:2039

Referenced by handle_compress().

◆ default_bzalloc()

static void* default_bzalloc ( void opaque,
Int32  items,
Int32  size 
)
static

Definition at line 109 of file bzlib.c.

110 {
111  return ExAllocatePool( PagedPool, items * size );
112 }
GLsizeiptr size
Definition: glext.h:5919
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
static TCHAR * items[]
Definition: page1.c:45

Referenced by BZ2_bzCompressInit(), and BZ2_bzDecompressInit().

◆ default_bzfree()

static void default_bzfree ( void opaque,
void addr 
)
static

Definition at line 115 of file bzlib.c.

116 {
117  ExFreePool( addr );
118 }
GLenum const GLvoid * addr
Definition: glext.h:9621
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by BZ2_bzCompressInit(), and BZ2_bzDecompressInit().

◆ flush_RL()

static void flush_RL ( EState s)
static

Definition at line 259 of file bzlib.c.

260 {
261  if (s->state_in_ch < 256) add_pair_to_block ( s );
262  init_RL ( s );
263 }
GLdouble s
Definition: gl.h:2039
static void add_pair_to_block(EState *s)
Definition: bzlib.c:223
static void init_RL(EState *s)
Definition: bzlib.c:138

Referenced by handle_compress().

◆ handle_compress()

static Bool handle_compress ( bz_stream strm)
static

Definition at line 368 of file bzlib.c.

369 {
370  Bool progress_in = False;
371  Bool progress_out = False;
372  EState* s = strm->state;
373 
374  while (True) {
375 
376  if (s->state == BZ_S_OUTPUT) {
377  progress_out |= copy_output_until_stop ( s );
378  if (s->state_out_pos < s->numZ) break;
379  if (s->mode == BZ_M_FINISHING &&
380  s->avail_in_expect == 0 &&
381  isempty_RL(s)) break;
382  prepare_new_block ( s );
383  s->state = BZ_S_INPUT;
384  if (s->mode == BZ_M_FLUSHING &&
385  s->avail_in_expect == 0 &&
386  isempty_RL(s)) break;
387  }
388 
389  if (s->state == BZ_S_INPUT) {
390  progress_in |= copy_input_until_stop ( s );
391  if (s->mode != BZ_M_RUNNING && s->avail_in_expect == 0) {
392  flush_RL ( s );
393  BZ2_compressBlock ( s, (Bool)(s->mode == BZ_M_FINISHING) );
394  s->state = BZ_S_OUTPUT;
395  }
396  else
397  if (s->nblock >= s->nblockMAX) {
399  s->state = BZ_S_OUTPUT;
400  }
401  else
402  if (s->strm->avail_in == 0) {
403  break;
404  }
405  }
406 
407  }
408 
409  return progress_in || progress_out;
410 }
void BZ2_compressBlock(EState *, Bool)
Definition: compress.c:602
static Bool copy_output_until_stop(EState *s)
Definition: bzlib.c:341
static void prepare_new_block(EState *s)
Definition: bzlib.c:124
static Bool isempty_RL(EState *s)
Definition: bzlib.c:146
#define BZ_S_INPUT
#define BZ_S_OUTPUT
#define BZ_M_FINISHING
static void flush_RL(EState *s)
Definition: bzlib.c:259
unsigned char Bool
Definition: bzip2.c:162
#define True
Definition: types.h:24
#define False
Definition: types.h:25
GLdouble s
Definition: gl.h:2039
void * state
Definition: bzlib.h:60
#define BZ_M_FLUSHING
#define BZ_M_RUNNING
static Bool copy_input_until_stop(EState *s)
Definition: bzlib.c:296

Referenced by BZ2_bzCompress().

◆ init_RL()

static void init_RL ( EState s)
static

Definition at line 138 of file bzlib.c.

139 {
140  s->state_in_ch = 256;
141  s->state_in_len = 0;
142 }
GLdouble s
Definition: gl.h:2039

Referenced by BZ2_bzCompressInit(), and flush_RL().

◆ isempty_RL()

static Bool isempty_RL ( EState s)
static

Definition at line 146 of file bzlib.c.

147 {
148  if (s->state_in_ch < 256 && s->state_in_len > 0)
149  return False; else
150  return True;
151 }
#define True
Definition: types.h:24
#define False
Definition: types.h:25
GLdouble s
Definition: gl.h:2039

Referenced by BZ2_bzCompress(), and handle_compress().

◆ myfeof()

static Bool myfeof ( FILE f)
static

Definition at line 921 of file bzlib.c.

922 {
923  Int32 c = fgetc ( f );
924  if (c == EOF) return True;
925  ungetc ( c, f );
926  return False;
927 }
_Check_return_opt_ _CRTIMP_ALT int __cdecl ungetc(_In_ int _Ch, _Inout_ FILE *_File)
#define True
Definition: types.h:24
GLfloat f
Definition: glext.h:7540
#define False
Definition: types.h:25
const GLubyte * c
Definition: glext.h:8905
LONG Int32
Definition: chm_lib.c:105
#define EOF
Definition: stdio.h:24
_Check_return_opt_ _CRTIMP int __cdecl fgetc(_Inout_ FILE *_File)

Referenced by BZ2_bzRead().

◆ prepare_new_block()

static void prepare_new_block ( EState s)
static

Definition at line 124 of file bzlib.c.

125 {
126  Int32 i;
127  s->nblock = 0;
128  s->numZ = 0;
129  s->state_out_pos = 0;
130  BZ_INITIALISE_CRC ( s->blockCRC );
131  for (i = 0; i < 256; i++) s->inUse[i] = False;
132  s->blockNo++;
133 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define False
Definition: types.h:25
GLdouble s
Definition: gl.h:2039
#define BZ_INITIALISE_CRC(crcVar)
LONG Int32
Definition: chm_lib.c:105

Referenced by BZ2_bzCompressInit(), and handle_compress().

◆ unRLE_obuf_to_output_FAST()

static Bool unRLE_obuf_to_output_FAST ( DState s)
static

Definition at line 545 of file bzlib.c.

546 {
547  UChar k1;
548 
549  if (s->blockRandomised) {
550 
551  while (True) {
552  /* try to finish existing run */
553  while (True) {
554  if (s->strm->avail_out == 0) return False;
555  if (s->state_out_len == 0) break;
556  *( (UChar*)(s->strm->next_out) ) = s->state_out_ch;
557  BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch );
558  s->state_out_len--;
559  s->strm->next_out++;
560  s->strm->avail_out--;
561  s->strm->total_out_lo32++;
562  if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
563  }
564 
565  /* can a new run be started? */
566  if (s->nblock_used == s->save_nblock+1) return False;
567 
568  /* Only caused by corrupt data stream? */
569  if (s->nblock_used > s->save_nblock+1)
570  return True;
571 
572  s->state_out_len = 1;
573  s->state_out_ch = s->k0;
575  k1 ^= BZ_RAND_MASK; s->nblock_used++;
576  if (s->nblock_used == s->save_nblock+1) continue;
577  if (k1 != s->k0) { s->k0 = k1; continue; };
578 
579  s->state_out_len = 2;
581  k1 ^= BZ_RAND_MASK; s->nblock_used++;
582  if (s->nblock_used == s->save_nblock+1) continue;
583  if (k1 != s->k0) { s->k0 = k1; continue; };
584 
585  s->state_out_len = 3;
587  k1 ^= BZ_RAND_MASK; s->nblock_used++;
588  if (s->nblock_used == s->save_nblock+1) continue;
589  if (k1 != s->k0) { s->k0 = k1; continue; };
590 
592  k1 ^= BZ_RAND_MASK; s->nblock_used++;
593  s->state_out_len = ((Int32)k1) + 4;
595  s->k0 ^= BZ_RAND_MASK; s->nblock_used++;
596  }
597 
598  } else {
599 
600  /* restore */
601  UInt32 c_calculatedBlockCRC = s->calculatedBlockCRC;
602  UChar c_state_out_ch = s->state_out_ch;
603  Int32 c_state_out_len = s->state_out_len;
604  Int32 c_nblock_used = s->nblock_used;
605  Int32 c_k0 = s->k0;
606  UInt32* c_tt = s->tt;
607  UInt32 c_tPos = s->tPos;
608  char* cs_next_out = s->strm->next_out;
609  unsigned int cs_avail_out = s->strm->avail_out;
610  Int32 ro_blockSize100k = s->blockSize100k;
611  /* end restore */
612 
613  UInt32 avail_out_INIT = cs_avail_out;
614  Int32 s_save_nblockPP = s->save_nblock+1;
615  unsigned int total_out_lo32_old;
616 
617  while (True) {
618 
619  /* try to finish existing run */
620  if (c_state_out_len > 0) {
621  while (True) {
622  if (cs_avail_out == 0) goto return_notr;
623  if (c_state_out_len == 1) break;
624  *( (UChar*)(cs_next_out) ) = c_state_out_ch;
625  BZ_UPDATE_CRC ( c_calculatedBlockCRC, c_state_out_ch );
626  c_state_out_len--;
627  cs_next_out++;
628  cs_avail_out--;
629  }
630  s_state_out_len_eq_one:
631  {
632  if (cs_avail_out == 0) {
633  c_state_out_len = 1; goto return_notr;
634  };
635  *( (UChar*)(cs_next_out) ) = c_state_out_ch;
636  BZ_UPDATE_CRC ( c_calculatedBlockCRC, c_state_out_ch );
637  cs_next_out++;
638  cs_avail_out--;
639  }
640  }
641  /* Only caused by corrupt data stream? */
642  if (c_nblock_used > s_save_nblockPP)
643  return True;
644 
645  /* can a new run be started? */
646  if (c_nblock_used == s_save_nblockPP) {
647  c_state_out_len = 0; goto return_notr;
648  };
649  c_state_out_ch = c_k0;
650  BZ_GET_FAST_C(k1); c_nblock_used++;
651  if (k1 != c_k0) {
652  c_k0 = k1; goto s_state_out_len_eq_one;
653  };
654  if (c_nblock_used == s_save_nblockPP)
655  goto s_state_out_len_eq_one;
656 
657  c_state_out_len = 2;
658  BZ_GET_FAST_C(k1); c_nblock_used++;
659  if (c_nblock_used == s_save_nblockPP) continue;
660  if (k1 != c_k0) { c_k0 = k1; continue; };
661 
662  c_state_out_len = 3;
663  BZ_GET_FAST_C(k1); c_nblock_used++;
664  if (c_nblock_used == s_save_nblockPP) continue;
665  if (k1 != c_k0) { c_k0 = k1; continue; };
666 
667  BZ_GET_FAST_C(k1); c_nblock_used++;
668  c_state_out_len = ((Int32)k1) + 4;
669  BZ_GET_FAST_C(c_k0); c_nblock_used++;
670  }
671 
672  return_notr:
673  total_out_lo32_old = s->strm->total_out_lo32;
674  s->strm->total_out_lo32 += (avail_out_INIT - cs_avail_out);
675  if (s->strm->total_out_lo32 < total_out_lo32_old)
676  s->strm->total_out_hi32++;
677 
678  /* save */
679  s->calculatedBlockCRC = c_calculatedBlockCRC;
680  s->state_out_ch = c_state_out_ch;
681  s->state_out_len = c_state_out_len;
682  s->nblock_used = c_nblock_used;
683  s->k0 = c_k0;
684  s->tt = c_tt;
685  s->tPos = c_tPos;
686  s->strm->next_out = cs_next_out;
687  s->strm->avail_out = cs_avail_out;
688  /* end save */
689  }
690  return False;
691 }
DWORD UInt32
Definition: chm_lib.c:106
#define Int32
Definition: interfaces.hpp:76
#define BZ_UPDATE_CRC(crcVar, cha)
#define BZ_GET_FAST(cccc)
#define BZ_GET_FAST_C(cccc)
#define BZ_RAND_MASK
BYTE UChar
Definition: chm_lib.c:102
#define True
Definition: types.h:24
#define False
Definition: types.h:25
#define BZ_RAND_UPD_MASK
GLdouble s
Definition: gl.h:2039
LONG Int32
Definition: chm_lib.c:105

Referenced by BZ2_bzDecompress().

◆ unRLE_obuf_to_output_SMALL()

static Bool unRLE_obuf_to_output_SMALL ( DState s)
static

Definition at line 716 of file bzlib.c.

717 {
718  UChar k1;
719 
720  if (s->blockRandomised) {
721 
722  while (True) {
723  /* try to finish existing run */
724  while (True) {
725  if (s->strm->avail_out == 0) return False;
726  if (s->state_out_len == 0) break;
727  *( (UChar*)(s->strm->next_out) ) = s->state_out_ch;
728  BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch );
729  s->state_out_len--;
730  s->strm->next_out++;
731  s->strm->avail_out--;
732  s->strm->total_out_lo32++;
733  if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
734  }
735 
736  /* can a new run be started? */
737  if (s->nblock_used == s->save_nblock+1) return False;
738 
739  /* Only caused by corrupt data stream? */
740  if (s->nblock_used > s->save_nblock+1)
741  return True;
742 
743  s->state_out_len = 1;
744  s->state_out_ch = s->k0;
746  k1 ^= BZ_RAND_MASK; s->nblock_used++;
747  if (s->nblock_used == s->save_nblock+1) continue;
748  if (k1 != s->k0) { s->k0 = k1; continue; };
749 
750  s->state_out_len = 2;
752  k1 ^= BZ_RAND_MASK; s->nblock_used++;
753  if (s->nblock_used == s->save_nblock+1) continue;
754  if (k1 != s->k0) { s->k0 = k1; continue; };
755 
756  s->state_out_len = 3;
758  k1 ^= BZ_RAND_MASK; s->nblock_used++;
759  if (s->nblock_used == s->save_nblock+1) continue;
760  if (k1 != s->k0) { s->k0 = k1; continue; };
761 
763  k1 ^= BZ_RAND_MASK; s->nblock_used++;
764  s->state_out_len = ((Int32)k1) + 4;
766  s->k0 ^= BZ_RAND_MASK; s->nblock_used++;
767  }
768 
769  } else {
770 
771  while (True) {
772  /* try to finish existing run */
773  while (True) {
774  if (s->strm->avail_out == 0) return False;
775  if (s->state_out_len == 0) break;
776  *( (UChar*)(s->strm->next_out) ) = s->state_out_ch;
777  BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch );
778  s->state_out_len--;
779  s->strm->next_out++;
780  s->strm->avail_out--;
781  s->strm->total_out_lo32++;
782  if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
783  }
784 
785  /* can a new run be started? */
786  if (s->nblock_used == s->save_nblock+1) return False;
787 
788  /* Only caused by corrupt data stream? */
789  if (s->nblock_used > s->save_nblock+1)
790  return True;
791 
792  s->state_out_len = 1;
793  s->state_out_ch = s->k0;
794  BZ_GET_SMALL(k1); s->nblock_used++;
795  if (s->nblock_used == s->save_nblock+1) continue;
796  if (k1 != s->k0) { s->k0 = k1; continue; };
797 
798  s->state_out_len = 2;
799  BZ_GET_SMALL(k1); s->nblock_used++;
800  if (s->nblock_used == s->save_nblock+1) continue;
801  if (k1 != s->k0) { s->k0 = k1; continue; };
802 
803  s->state_out_len = 3;
804  BZ_GET_SMALL(k1); s->nblock_used++;
805  if (s->nblock_used == s->save_nblock+1) continue;
806  if (k1 != s->k0) { s->k0 = k1; continue; };
807 
808  BZ_GET_SMALL(k1); s->nblock_used++;
809  s->state_out_len = ((Int32)k1) + 4;
810  BZ_GET_SMALL(s->k0); s->nblock_used++;
811  }
812 
813  }
814 }
#define Int32
Definition: interfaces.hpp:76
#define BZ_UPDATE_CRC(crcVar, cha)
#define BZ_RAND_MASK
BYTE UChar
Definition: chm_lib.c:102
#define True
Definition: types.h:24
#define False
Definition: types.h:25
#define BZ_RAND_UPD_MASK
GLdouble s
Definition: gl.h:2039
#define BZ_GET_SMALL(cccc)

Referenced by BZ2_bzDecompress().

Variable Documentation

◆ bzerrorstrings

const char* bzerrorstrings[]
static
Initial value:
= {
"OK"
,"SEQUENCE_ERROR"
,"PARAM_ERROR"
,"MEM_ERROR"
,"DATA_ERROR"
,"DATA_ERROR_MAGIC"
,"IO_ERROR"
,"UNEXPECTED_EOF"
,"OUTBUFF_FULL"
,"CONFIG_ERROR"
,"???"
,"???"
,"???"
,"???"
,"???"
,"???"
}

Definition at line 1556 of file bzlib.c.

Referenced by BZ2_bzerror().