22 state->in = (
unsigned char *)
malloc(state->want);
23 if (state->in == NULL) {
31 state->out = (
unsigned char *)
malloc(state->want);
32 if (state->out == NULL) {
53 state->size = state->want;
79 if (state->size == 0 &&
gz_init(state) == -1)
85 if (got < 0 || (
unsigned)got != strm->
avail_in) {
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)) {
118 "internal error: deflate stream corrupt");
149 (
unsigned)len : state->size;
151 memset(state->in, 0, n);
178 strm = &(state->
strm);
207 if (len < state->
size) {
218 memcpy(state->
in + have, buf, copy);
220 state->
x.
pos += copy;
221 buf = (
const char *)buf + copy;
250 unsigned char buf[1];
258 strm = &(state->
strm);
277 if (have < state->
size) {
287 if (
gzwrite(file, buf, 1) != 1)
301 len = (unsigned)strlen(str);
303 return ret == 0 && len != 0 ? -1 : ret;
306 #if defined(STDC) || defined(Z_HAVE_STDARG_H) 310 int ZEXPORTVA gzvprintf(gzFile
file,
const char *format, va_list va)
320 strm = &(state->
strm);
342 size = (int)(state->
size);
343 state->
in[size - 1] = 0;
345 # ifdef HAS_vsprintf_void 346 (void)vsprintf((
char *)(state->
in), format, va);
347 for (len = 0; len <
size; len++)
348 if (state->
in[len] == 0)
break;
350 len = vsprintf((
char *)(state->
in), format, va);
353 # ifdef HAS_vsnprintf_void 354 (void)vsnprintf((
char *)(state->
in), size, format, va);
355 len = strlen((
char *)(state->
in));
357 len = vsnprintf((
char *)(state->
in), size, format, va);
362 if (len <= 0 || len >= (
int)size || state->
in[size - 1] != 0)
377 va_start(va, format);
378 ret = gzvprintf(file, format, va);
386 int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
387 a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)
390 int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
391 a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;
401 strm = &(state->
strm);
404 if (
sizeof(
int) !=
sizeof(
void *))
427 size = (int)(state->
size);
428 state->
in[size - 1] = 0;
430 # ifdef HAS_sprintf_void 431 sprintf((
char *)(state->
in), format, a1, a2, a3, a4, a5, a6, a7, a8,
432 a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
433 for (len = 0; len <
size; len++)
434 if (state->
in[len] == 0)
break;
436 len = sprintf((
char *)(state->
in), format, a1, a2, a3, a4, a5, a6, a7, a8,
437 a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
440 # ifdef HAS_snprintf_void 441 snprintf((
char *)(state->
in), size, format, a1, a2, a3, a4, a5, a6, a7, a8,
442 a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
443 len = strlen((
char *)(state->
in));
445 len = snprintf((
char *)(state->
in), size, format, a1, a2, a3, a4, a5, a6,
446 a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18,
452 if (len <= 0 || len >= (
int)size || state->
in[size - 1] != 0)
509 strm = &(state->
strm);
533 state->
level = level;
573 if (close(state->
fd) == -1)
#define deflateInit2(strm, level, method, windowBits, memLevel, strategy)
int gzflush(gzFile file, int flush)
int deflateEnd(z_streamp strm)
int gzputc(gzFile file, int c)
int gzprintf(gzFile file, 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)
int write(ozstream &zs, const T *x, Items items)
int gzsetparams(gzFile file, int level, int strategy)
int gzclose_w(gzFile file)
int deflateReset(z_streamp strm)
int gzputs(gzFile file, char *str)
int deflateParams(z_streamp strm, int level, int strategy)
int gzwrite(gzFile file, voidpc buf, unsigned len)
int deflate(z_streamp strm, int flush)