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;
170 strm = &(state->strm);
188 if (state->size == 0 &&
gz_init(state) == -1)
194 if (
gz_zero(state, state->skip) == -1)
204 if (strm->avail_in == 0)
205 strm->next_in = state->in;
206 have = (unsigned)((strm->next_in + strm->avail_in) - state->in);
207 copy = state->size -
have;
210 memcpy(state->in + have, buf, copy);
211 strm->avail_in += copy;
212 state->x.pos += copy;
213 buf = (
const char *)buf + copy;
225 strm->avail_in =
len;
226 strm->next_in = (z_const Bytef *)buf;
240 unsigned char buf[1];
248 strm = &(state->strm);
257 if (
gz_zero(state, state->skip) == -1)
264 if (strm->avail_in == 0)
265 strm->next_in = state->in;
266 have = (unsigned)((strm->next_in + strm->avail_in) - state->in);
267 if (have < state->size) {
277 if (
gzwrite(file, buf, 1) != 1)
289 len = (unsigned)strlen(str);
291 return ret == 0 && len != 0 ? -1 : ret;
294 #if defined(STDC) || defined(Z_HAVE_STDARG_H)
298 int ZEXPORTVA gzvprintf(
gzFile file,
const char *format, va_list va)
308 strm = &(state->strm);
315 if (state->size == 0 &&
gz_init(state) == -1)
321 if (
gz_zero(state, state->skip) == -1)
330 size = (
int)(state->size);
331 state->in[size - 1] = 0;
333 # ifdef HAS_vsprintf_void
334 (
void)vsprintf((
char *)(state->in), format, va);
336 for (len = 0; len < size; len++)
337 if (state->in[len] == 0)
break;
339 len = vsprintf((
char *)(state->in), format, va);
343 # ifdef HAS_vsnprintf_void
344 (
void)vsnprintf((
char *)(state->in), size, format, va);
346 len = strlen((
char *)(state->in));
348 len = vsnprintf((
char *)(state->in), size, format, va);
358 strm->avail_in = (unsigned)len;
359 strm->next_in = state->in;
369 va_start(va, format);
370 ret = gzvprintf(file, format, va);
379 int a1,
int a2,
int a3,
int a4,
int a5,
int a6,
int a7,
int a8,
int a9,
int a10,
380 int a11,
int a12,
int a13,
int a14,
int a15,
int a16,
int a17,
int a18,
int a19,
int a20)
390 strm = &(state->strm);
393 if (
sizeof(
int) !=
sizeof(
void *))
401 if (state->size == 0 &&
gz_init(state) == -1)
407 if (
gz_zero(state, state->skip) == -1)
416 size = (
int)(state->size);
417 state->in[size - 1] = 0;
419 # ifdef HAS_sprintf_void
420 sprintf((
char *)(state->in), format, a1, a2, a3, a4, a5, a6, a7, a8,
421 a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
422 for (len = 0; len < size; len++)
423 if (state->in[len] == 0)
break;
425 len = sprintf((
char *)(state->in), format, a1, a2, a3, a4, a5, a6, a7, a8,
426 a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
429 # ifdef HAS_snprintf_void
430 snprintf((
char *)(state->in), size, format, a1, a2, a3, a4, a5, a6, a7, a8,
431 a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
432 len = strlen((
char *)(state->in));
434 len = snprintf((
char *)(state->in), size, format, a1, a2, a3, a4, a5, a6,
435 a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18,
445 strm->avail_in = (unsigned)len;
446 strm->next_in = state->in;
474 if (
gz_zero(state, state->skip) == -1)
493 strm = &(state->strm);
500 if (level == state->level && strategy == state->strategy)
506 if (
gz_zero(state, state->skip) == -1)
517 state->level = level;
518 state->strategy = strategy;
540 if (
gz_zero(state, state->skip) == -1)
548 if (!state->direct) {
556 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)
int ZEXPORT gzsetparams(gzFile file, int level, int strategy)
int ZEXPORT gzputs(gzFile file, const char *str)
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
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)
local int gz_init(gz_statep state)
typedef void(XMLCALL *XML_ElementDeclHandler)(void *userData
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)