xref: /reactos/dll/win32/wininet/zlib.h (revision 682f85ad)
1 /* zlib.h -- interface of the 'zlib' general purpose compression library
2  * version 1.2.11, January 15th, 2017
3  *
4  * Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
5  *
6  * This software is provided 'as-is', without any express or implied
7  * warranty.  In no event will the authors be held liable for any damages
8  * arising from the use of this software.
9  *
10  * Permission is granted to anyone to use this software for any purpose,
11  * including commercial applications, and to alter it and redistribute it
12  * freely, subject to the following restrictions:
13  *
14  * 1. The origin of this software must not be misrepresented; you must not
15  *    claim that you wrote the original software. If you use this software
16  *    in a product, an acknowledgment in the product documentation would be
17  *    appreciated but is not required.
18  * 2. Altered source versions must be plainly marked as such, and must not be
19  *    misrepresented as being the original software.
20  * 3. This notice may not be removed or altered from any source distribution.
21  *
22  * Jean-loup Gailly        Mark Adler
23  * jloup@gzip.org          madler@alumni.caltech.edu
24  */
25 
26 #ifndef ZLIB_H
27 #define ZLIB_H
28 
29 #include "windef.h"
30 
31 #undef FAR
32 #define FAR
33 #define z_const const
34 
35 typedef unsigned char  Byte;  /* 8 bits */
36 typedef unsigned int   uInt;  /* 16 bits or more */
37 typedef unsigned long  uLong; /* 32 bits or more */
38 
39 typedef Byte  FAR Bytef;
40 typedef void  FAR *voidpf;
41 
42 typedef char  FAR charf;
43 typedef int   FAR intf;
44 
45 typedef unsigned char  uch;
46 typedef uch FAR uchf;
47 typedef unsigned short ush;
48 typedef ush FAR ushf;
49 typedef unsigned long  ulg;
50 
51 typedef voidpf (*alloc_func)(voidpf opaque, uInt items, uInt size);
52 typedef void   (*free_func)(voidpf opaque, voidpf address);
53 
54 struct internal_state;
55 
56 typedef struct z_stream_s {
57     z_const Bytef *next_in;     /* next input byte */
58     uInt     avail_in;  /* number of bytes available at next_in */
59     uLong    total_in;  /* total number of input bytes read so far */
60 
61     Bytef    *next_out; /* next output byte will go here */
62     uInt     avail_out; /* remaining free space at next_out */
63     uLong    total_out; /* total number of bytes output so far */
64 
65     z_const char *msg;  /* last error message, NULL if no error */
66     struct internal_state FAR *state; /* not visible by applications */
67 
68     alloc_func zalloc;  /* used to allocate the internal state */
69     free_func  zfree;   /* used to free the internal state */
70     voidpf     opaque;  /* private data object passed to zalloc and zfree */
71 
72     int     data_type;  /* best guess about the data type: binary or text
73                            for deflate, or the decoding state for inflate */
74     uLong   adler;      /* Adler-32 or CRC-32 value of the uncompressed data */
75     uLong   reserved;   /* reserved for future use */
76 } z_stream;
77 
78 typedef z_stream FAR *z_streamp;
79 
80 /*
81      gzip header information passed to and from zlib routines.  See RFC 1952
82   for more details on the meanings of these fields.
83 */
84 typedef struct gz_header_s {
85     int     text;       /* true if compressed data believed to be text */
86     uLong   time;       /* modification time */
87     int     xflags;     /* extra flags (not used when writing a gzip file) */
88     int     os;         /* operating system */
89     Bytef   *extra;     /* pointer to extra field or Z_NULL if none */
90     uInt    extra_len;  /* extra field length (valid if extra != Z_NULL) */
91     uInt    extra_max;  /* space at extra (only when reading header) */
92     Bytef   *name;      /* pointer to zero-terminated file name or Z_NULL */
93     uInt    name_max;   /* space at name (only when reading header) */
94     Bytef   *comment;   /* pointer to zero-terminated comment or Z_NULL */
95     uInt    comm_max;   /* space at comment (only when reading header) */
96     int     hcrc;       /* true if there was or will be a header crc */
97     int     done;       /* true when done reading gzip header (not used
98                            when writing a gzip file) */
99 } gz_header;
100 
101 typedef gz_header FAR *gz_headerp;
102 
103 #define Z_NO_FLUSH      0
104 #define Z_PARTIAL_FLUSH 1
105 #define Z_SYNC_FLUSH    2
106 #define Z_FULL_FLUSH    3
107 #define Z_FINISH        4
108 #define Z_BLOCK         5
109 #define Z_TREES         6
110 /* Allowed flush values; see deflate() and inflate() below for details */
111 
112 #define Z_OK            0
113 #define Z_STREAM_END    1
114 #define Z_NEED_DICT     2
115 #define Z_ERRNO        (-1)
116 #define Z_STREAM_ERROR (-2)
117 #define Z_DATA_ERROR   (-3)
118 #define Z_MEM_ERROR    (-4)
119 #define Z_BUF_ERROR    (-5)
120 #define Z_VERSION_ERROR (-6)
121 /* Return codes for the compression/decompression functions. Negative values
122  * are errors, positive values are used for special but normal events.
123  */
124 
125 #define Z_NO_COMPRESSION         0
126 #define Z_BEST_SPEED             1
127 #define Z_BEST_COMPRESSION       9
128 #define Z_DEFAULT_COMPRESSION  (-1)
129 /* compression levels */
130 
131 #define Z_FILTERED            1
132 #define Z_HUFFMAN_ONLY        2
133 #define Z_RLE                 3
134 #define Z_FIXED               4
135 #define Z_DEFAULT_STRATEGY    0
136 /* compression strategy; see deflateInit2() below for details */
137 
138 #define Z_BINARY   0
139 #define Z_TEXT     1
140 #define Z_ASCII    Z_TEXT   /* for compatibility with 1.2.2 and earlier */
141 #define Z_UNKNOWN  2
142 /* Possible values of the data_type field for deflate() */
143 
144 #define Z_DEFLATED   8
145 /* The deflate compression method (the only one supported in this version) */
146 
147 #define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
148 
149 #define MAX_WBITS   15 /* 32K LZ77 window */
150 #define MAX_MEM_LEVEL 9
151 
152 extern int inflateInit(z_streamp strm) DECLSPEC_HIDDEN;
153 extern int inflateInit2(z_streamp strm, int windowBits) DECLSPEC_HIDDEN;
154 extern int inflate(z_streamp strm, int flush) DECLSPEC_HIDDEN;
155 extern int inflateEnd(z_streamp strm) DECLSPEC_HIDDEN;
156 
157 extern int deflateInit(z_streamp strm, int level) DECLSPEC_HIDDEN;
158 extern int deflateInit2(z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy) DECLSPEC_HIDDEN;
159 extern int deflate(z_streamp strm, int flush) DECLSPEC_HIDDEN;
160 extern int deflateEnd(z_streamp strm) DECLSPEC_HIDDEN;
161 
162 #endif /* ZLIB_H */
163