21 state->in = (
unsigned char *)
malloc(state->want);
22 if (state->in == NULL) {
30 state->out = (
unsigned char *)
malloc(state->want);
31 if (state->out == NULL) {
52 state->size = state->want;
56 strm->avail_out = state->size;
57 strm->next_out = state->out;
58 state->x.next = strm->next_out;
76 if (state->size == 0 &&
gz_init(state) == -1)
81 got = write(state->fd, strm->next_in, strm->avail_in);
82 if (got < 0 || (
unsigned)got != strm->avail_in) {
95 if (strm->avail_out == 0 || (flush !=
Z_NO_FLUSH &&
97 have = (unsigned)(strm->next_out - state->x.next);
98 if (have && ((got = write(state->fd, state->x.next, have)) < 0 ||
99 (
unsigned)got != have)) {
103 if (strm->avail_out == 0) {
104 strm->avail_out = state->size;
105 strm->next_out = state->out;
107 state->x.next = strm->next_out;
111 have = strm->avail_out;
115 "internal error: deflate stream corrupt");
118 have -= strm->avail_out;
143 n =
GT_OFF(state->size) || (z_off64_t)state->size > len ?
144 (
unsigned)len : state->size;
146 memset(state->in, 0, n);
150 strm->next_in = state->in;
171 strm = &(state->strm);
189 if (state->size == 0 &&
gz_init(state) == -1)
195 if (
gz_zero(state, state->skip) == -1)
203 if (strm->avail_in == 0)
204 strm->next_in = state->in;
205 n = state->size - strm->avail_in;
208 memcpy(strm->next_in + strm->avail_in, buf, n);
211 buf = (
char *)buf + n;
223 strm->avail_in =
len;
224 strm->next_in = (z_const Bytef *)buf;
237 unsigned char buf[1];
245 strm = &(state->strm);
254 if (
gz_zero(state, state->skip) == -1)
260 if (strm->avail_in < state->size) {
261 if (strm->avail_in == 0)
262 strm->next_in = state->in;
263 strm->next_in[strm->avail_in++] =
c;
270 if (
gzwrite(file, buf, 1) != 1)
282 len = (unsigned)strlen(str);
284 return ret == 0 && len != 0 ? -1 : ret;
287 #if defined(STDC) || defined(Z_HAVE_STDARG_H)
302 strm = &(state->strm);
309 if (state->size == 0 &&
gz_init(state) == -1)
315 if (
gz_zero(state, state->skip) == -1)
324 size = (
int)(state->size);
325 state->in[size - 1] = 0;
326 va_start(va, format);
328 # ifdef HAS_vsprintf_void
329 (
void)vsprintf((
char *)(state->in), format, va);
331 for (len = 0; len < size; len++)
332 if (state->in[len] == 0)
break;
334 len = vsprintf((
char *)(state->in), format, va);
338 # ifdef HAS_vsnprintf_void
339 (
void)vsnprintf((
char *)(state->in), size, format, va);
341 len = strlen((
char *)(state->in));
343 len = vsnprintf((
char *)(state->in), size, format, va);
353 strm->avail_in = (unsigned)len;
354 strm->next_in = state->in;
363 int a1,
int a2,
int a3,
int a4,
int a5,
int a6,
int a7,
int a8,
int a9,
int a10,
364 int a11,
int a12,
int a13,
int a14,
int a15,
int a16,
int a17,
int a18,
int a19,
int a20)
374 strm = &(state->strm);
377 if (
sizeof(
int) !=
sizeof(
void *))
385 if (state->size == 0 &&
gz_init(state) == -1)
391 if (
gz_zero(state, state->skip) == -1)
400 size = (
int)(state->size);
401 state->in[size - 1] = 0;
403 # ifdef HAS_sprintf_void
404 sprintf((
char *)(state->in), format, a1, a2, a3, a4, a5, a6, a7, a8,
405 a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
406 for (len = 0; len < size; len++)
407 if (state->in[len] == 0)
break;
409 len = sprintf((
char *)(state->in), format, a1, a2, a3, a4, a5, a6, a7, a8,
410 a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
413 # ifdef HAS_snprintf_void
414 snprintf((
char *)(state->in), size, format, a1, a2, a3, a4, a5, a6, a7, a8,
415 a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
416 len = strlen((
char *)(state->in));
418 len = snprintf((
char *)(state->in), size, format, a1, a2, a3, a4, a5, a6,
419 a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18,
429 strm->avail_in = (unsigned)len;
430 strm->next_in = state->in;
458 if (
gz_zero(state, state->skip) == -1)
477 strm = &(state->strm);
484 if (level == state->level && strategy == state->strategy)
490 if (
gz_zero(state, state->skip) == -1)
501 state->level = level;
502 state->strategy = strategy;
524 if (
gz_zero(state, state->skip) == -1)
532 if (!state->direct) {
540 if (
close(state->fd) == -1)
int ZEXPORT deflateEnd(z_streamp strm)
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)
int ZEXPORTVA gzprintf(gzFile file, const char *format, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9, int a10, int a11, int a12, int a13, int a14, int a15, int a16, int a17, int a18, int a19, int a20)
#define deflateInit2(strm, level, method, windowBits, memLevel, strategy)
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
int ZEXPORT gzsetparams(gzFile file, int level, int strategy)
typedef void(XMLCALL *XML_ElementDeclHandler)(void *userData
int ZEXPORT gzputs(gzFile file, const char *str)
int ZEXPORT deflateParams(z_streamp strm, int level, int strategy)
local int gz_comp(gz_statep state, int flush)
int ZEXPORT gzputc(gzFile file, int c)
int ZEXPORT gzclose_w(gzFile file)
int ZEXPORT deflate(z_streamp strm, int flush)
int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len)
void * malloc(size_t __size)
local int gz_init(gz_statep state)
int ZEXPORT deflateReset(z_streamp strm)
local int gz_zero(gz_statep state, z_off64_t len)
voidpf alloc_func OF((voidpf opaque, uInt items, uInt size))
int ZEXPORT gzflush(gzFile file, int flush)