xref: /plan9/sys/src/cmd/bzip2/lib/bzlib_stdio_private.h (revision 59cc4ca53493a3c6d2349fe2b7f7c40f7dce7294)
1 /*
2  * THIS FILE IS NOT IDENTICAL TO THE ORIGINAL
3  * FROM THE BZIP2 DISTRIBUTION.
4  *
5  * It has been modified, mainly to break the library
6  * into smaller pieces.
7  *
8  * Russ Cox
9  * rsc@plan9.bell-labs.com
10  * July 2000
11  */
12 
13 extern void BZ2_bz__AssertH__fail ( int errcode );
14 
15 /* undo definitions in bzlib_private.h */
16 #undef AssertH
17 #undef AssertD
18 #undef VPrintf0
19 #undef VPrintf1
20 #undef VPrintf2
21 #undef VPrintf3
22 #undef VPrintf4
23 #undef VPrintf5
24 
25 #define AssertH(cond,errcode) \
26    { if (!(cond)) BZ2_bz__AssertH__fail ( errcode ); }
27 #if BZ_DEBUG
28 #define AssertD(cond,msg) \
29    { if (!(cond)) {       \
30       fprintf ( stderr,   \
31         "\n\nlibbzip2(debug build): internal error\n\t%s\n", msg );\
32       exit(1); \
33    }}
34 #else
35 #define AssertD(cond,msg) /* */
36 #endif
37 #define VPrintf0(zf) \
38    fprintf(stderr,zf)
39 #define VPrintf1(zf,za1) \
40    fprintf(stderr,zf,za1)
41 #define VPrintf2(zf,za1,za2) \
42    fprintf(stderr,zf,za1,za2)
43 #define VPrintf3(zf,za1,za2,za3) \
44    fprintf(stderr,zf,za1,za2,za3)
45 #define VPrintf4(zf,za1,za2,za3,za4) \
46    fprintf(stderr,zf,za1,za2,za3,za4)
47 #define VPrintf5(zf,za1,za2,za3,za4,za5) \
48    fprintf(stderr,zf,za1,za2,za3,za4,za5)
49 
50 #define BZ_SETERR(eee)                    \
51 {                                         \
52    if (bzerror != NULL) *bzerror = eee;   \
53    if (bzf != NULL) bzf->lastErr = eee;   \
54 }
55 
56 typedef
57    struct {
58       FILE*     handle;
59       Char      buf[BZ_MAX_UNUSED];
60       Int32     bufN;
61       Bool      writing;
62       bz_stream strm;
63       Int32     lastErr;
64       Bool      initialisedOk;
65    }
66    bzFile;
67 
68 extern Bool bz_feof( FILE* );
69 
70