22 state->in = malloc(state->want);
23 if (state->in == NULL) {
31 state->out = malloc(state->want);
32 if (state->out == NULL) {
53 state->size = state->want;
57 strm->avail_out = state->size;
58 strm->next_out = state->out;
59 state->x.next = strm->next_out;
79 if (state->size == 0 &&
gz_init(state) == -1)
84 got =
write(state->fd, strm->next_in, strm->avail_in);
85 if (got < 0 || (
unsigned)got != strm->avail_in) {
98 if (strm->avail_out == 0 || (flush !=
Z_NO_FLUSH &&
100 have = (unsigned)(strm->next_out - state->x.next);
101 if (have && ((got =
write(state->fd, state->x.next, have)) < 0 ||
102 (
unsigned)got != have)) {
106 if (strm->avail_out == 0) {
107 strm->avail_out = state->size;
108 strm->next_out = state->out;
110 state->x.next = strm->next_out;
114 have = strm->avail_out;
118 "internal error: deflate stream corrupt");
121 have -= strm->avail_out;
149 (
unsigned)len : state->size;
151 memset(state->in, 0, n);
155 strm->next_in = state->in;
179 strm = &(state->strm);
197 if (state->size == 0 &&
gz_init(state) == -1)
203 if (
gz_zero(state, state->skip) == -1)
208 if (len < state->size) {
211 if (strm->avail_in == 0)
212 strm->next_in = state->in;
213 n = state->size - strm->avail_in;
216 memcpy(strm->next_in + strm->avail_in, buf, n);
219 buf = (
char *)buf + n;
231 strm->avail_in = len;
232 strm->next_in = (
voidp)buf;
247 unsigned char buf[1];
255 strm = &(state->strm);
264 if (
gz_zero(state, state->skip) == -1)
270 if (strm->avail_in < state->size) {
271 if (strm->avail_in == 0)
272 strm->next_in = state->in;
273 strm->next_in[strm->avail_in++] = c;
280 if (
gzwrite(file, buf, 1) != 1)
294 len = (unsigned)strlen(str);
296 return ret == 0 && len != 0 ? -1 : ret;
299 #if defined(STDC) || defined(Z_HAVE_STDARG_H)
314 strm = &(state->strm);
321 if (state->size == 0 &&
gz_init(state) == -1)
327 if (
gz_zero(state, state->skip) == -1)
336 size = (int)(state->size);
337 state->in[size - 1] = 0;
338 va_start(va, format);
340 # ifdef HAS_vsprintf_void
341 (void)vsprintf((
char *)(state->in), format, va);
343 for (len = 0; len < size; len++)
344 if (state->in[len] == 0)
break;
346 len = vsprintf((
char *)(state->in), format, va);
350 # ifdef HAS_vsnprintf_void
351 (void)vsnprintf((
char *)(state->in), size, format, va);
353 len = strlen((
char *)(state->in));
355 len = vsnprintf((
char *)(state->in), size, format, va);
361 if (len <= 0 || len >= (
int)size || state->in[size - 1] != 0)
365 strm->avail_in = (unsigned)len;
366 strm->next_in = state->in;
374 int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
375 a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)
378 int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
379 a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;
389 strm = &(state->strm);
392 if (
sizeof(
int) !=
sizeof(
void *))
400 if (state->size == 0 &&
gz_init(state) == -1)
406 if (
gz_zero(state, state->skip) == -1)
415 size = (int)(state->size);
416 state->in[size - 1] = 0;
418 # ifdef HAS_sprintf_void
419 sprintf((
char *)(state->in), format, a1, a2, a3, a4, a5, a6, a7, a8,
420 a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
421 for (len = 0; len < size; len++)
422 if (state->in[len] == 0)
break;
424 len = sprintf((
char *)(state->in), format, a1, a2, a3, a4, a5, a6, a7, a8,
425 a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
428 # ifdef HAS_snprintf_void
429 snprintf((
char *)(state->in), size, format, a1, a2, a3, a4, a5, a6, a7, a8,
430 a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
431 len = strlen((
char *)(state->in));
433 len = snprintf((
char *)(state->in), size, format, a1, a2, a3, a4, a5, a6,
434 a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18,
440 if (len <= 0 || len >= (
int)size || state->in[size - 1] != 0)
444 strm->avail_in = (unsigned)len;
445 strm->next_in = state->in;
475 if (
gz_zero(state, state->skip) == -1)
497 strm = &(state->strm);
504 if (level == state->level && strategy == state->strategy)
510 if (
gz_zero(state, state->skip) == -1)
521 state->level = level;
522 state->strategy = strategy;
545 if (
gz_zero(state, state->skip) == -1)
553 if (!state->direct) {
561 if (close(state->fd) == -1)