28 state->in = (
unsigned char *)
malloc(state->want);
29 state->out = (
unsigned char *)
malloc(state->want);
30 if (state->in == NULL || state->out == NULL) {
31 if (state->out != NULL)
33 if (state->in != NULL)
44 15 + 16, 8, state->strategy);
52 state->size = state->want;
55 strm->avail_out = state->size;
56 strm->next_out = state->out;
57 state->next = strm->next_out;
72 if (state->size == 0 &&
gz_init(state) == -1)
80 if (strm->avail_out == 0 || (flush !=
Z_NO_FLUSH &&
82 have = (unsigned)(strm->next_out - state->next);
83 if (have && ((got = write(state->fd, state->next, have)) < 0 ||
84 (unsigned)got != have)) {
88 if (strm->avail_out == 0) {
89 strm->avail_out = state->size;
90 strm->next_out = state->out;
92 state->next = strm->next_out;
96 have = strm->avail_out;
100 "internal error: deflate stream corrupt");
103 have -= strm->avail_out;
129 (
unsigned)len : state->size;
135 strm->next_in = state->in;
156 strm = &(state->strm);
174 if (state->size == 0 &&
gz_init(state) == -1)
180 if (
gz_zero(state, state->skip) == -1)
185 if (len < state->
size) {
188 if (strm->avail_in == 0)
189 strm->next_in = state->in;
190 n = state->size - strm->avail_in;
193 memcpy(strm->next_in + strm->avail_in, buf, n);
196 buf = (
char *)buf + n;
208 strm->avail_in = len;
209 strm->next_in = (
unsigned char *)(
voidp)buf;
222 unsigned char buf[1];
230 strm = &(state->strm);
239 if (
gz_zero(state, state->skip) == -1)
245 if (strm->avail_in < state->size) {
246 if (strm->avail_in == 0)
247 strm->next_in = state->in;
248 strm->next_in[strm->avail_in++] = c;
255 if (
gzwrite(file, buf, 1) != 1)
267 len = (unsigned)
strlen(str);
269 return ret == 0 && len != 0 ? -1 : ret;
287 strm = &(state->strm);
294 if (state->size == 0 &&
gz_init(state) == -1)
300 if (
gz_zero(state, state->skip) == -1)
309 size = (int)(state->size);
310 state->in[size - 1] = 0;
311 va_start(va, format);
313 # ifdef HAS_vsprintf_void
314 (void)vsprintf(state->in, format, va);
316 for (len = 0; len <
size; len++)
317 if (state->in[len] == 0)
break;
319 len = vsprintf(state->in, format, va);
323 # ifdef HAS_vsnprintf_void
324 (void)vsnprintf(state->in, size, format, va);
328 len = vsnprintf((
char *)(state->in), size, format, va);
334 if (len <= 0 || len >= (
int)size || state->in[size - 1] != 0)
338 strm->avail_in = (unsigned)len;
339 strm->next_in = state->in;
347 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,
348 int a11,
int a12,
int a13,
int a14,
int a15,
int a16,
int a17,
int a18,
int a19,
int a20)
358 strm = &(state->strm);
365 if (state->size == 0 &&
gz_init(state) == -1)
371 if (
gz_zero(state, state->skip) == -1)
380 size = (int)(state->size);
381 state->in[size - 1] = 0;
383 # ifdef HAS_sprintf_void
384 sprintf(state->in, format, a1, a2, a3, a4, a5, a6, a7, a8,
385 a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
386 for (len = 0; len <
size; len++)
387 if (state->in[len] == 0)
break;
389 len =
sprintf(state->in, format, a1, a2, a3, a4, a5, a6, a7, a8,
390 a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
393 # ifdef HAS_snprintf_void
394 snprintf(state->in, size, format, a1, a2, a3, a4, a5, a6, a7, a8,
395 a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
398 len = snprintf(state->in, size, format, a1, a2, a3, a4, a5, a6, a7, a8,
399 a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
404 if (len <= 0 || len >= (
int)size || state->in[size - 1] != 0)
408 strm->avail_in = (unsigned)len;
409 strm->next_in = state->in;
437 if (
gz_zero(state, state->skip) == -1)
456 strm = &(state->strm);
463 if (level == state->level && strategy == state->strategy)
469 if (
gz_zero(state, state->skip) == -1)
480 state->level = level;
481 state->strategy = strategy;
503 ret +=
gz_zero(state, state->skip);
513 ret += close(state->fd);
int ZEXPORT deflateParams(z_streamp strm, int level, int strategy)
#define deflateInit2(strm, level, method, windowBits, memLevel, strategy)
int ZEXPORT gzsetparams(gzFile file, int level, int strategy)
int ZEXPORT deflateEnd(z_streamp strm)
int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len)
local int gz_init(gz_statep state)
int ZEXPORT gzputc(gzFile file, int c)
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)
#define ABC_NAMESPACE_IMPL_END
local int gz_zero(gz_statep state, z_off64_t len)
int ZEXPORT gzclose_w(gzFile file)
int ZEXPORT gzputs(gzFile file, const char *str)
local int gz_comp(gz_statep state, int flush)
ABC_NAMESPACE_IMPL_START local int gz_init OF((gz_statep))
int ZEXPORT deflate(z_streamp strm, int flush)
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 ABC_NAMESPACE_IMPL_START
int ZEXPORT gzflush(gzFile file, int flush)
int ZEXPORT deflateReset(z_streamp strm)