#include "gzguts.h"
local int gz_init(gz_statep state) { … }
local int gz_comp(gz_statep state, int flush) { … }
local int gz_zero(gz_statep state, z_off64_t len) { … }
local z_size_t gz_write(gz_statep state, voidpc buf, z_size_t len) { … }
int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len) { … }
z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size, z_size_t nitems,
gzFile file) { … }
int ZEXPORT gzputc(gzFile file, int c) { … }
int ZEXPORT gzputs(gzFile file, const char *s) { … }
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
#include <stdarg.h>
int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) { … }
int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) { … }
#else
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) {
unsigned len, left;
char *next;
gz_statep state;
z_streamp strm;
if (file == NULL)
return Z_STREAM_ERROR;
state = (gz_statep)file;
strm = &(state->strm);
if (sizeof(int) != sizeof(void *))
return Z_STREAM_ERROR;
if (state->mode != GZ_WRITE || state->err != Z_OK)
return Z_STREAM_ERROR;
if (state->size == 0 && gz_init(state) == -1)
return state->error;
if (state->seek) {
state->seek = 0;
if (gz_zero(state, state->skip) == -1)
return state->error;
}
if (strm->avail_in == 0)
strm->next_in = state->in;
next = (char *)(strm->next_in + strm->avail_in);
next[state->size - 1] = 0;
#ifdef NO_snprintf
# ifdef HAS_sprintf_void
sprintf(next, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12,
a13, a14, a15, a16, a17, a18, a19, a20);
for (len = 0; len < size; len++)
if (next[len] == 0)
break;
# else
len = sprintf(next, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11,
a12, a13, a14, a15, a16, a17, a18, a19, a20);
# endif
#else
# ifdef HAS_snprintf_void
snprintf(next, state->size, format, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
len = strlen(next);
# else
len = snprintf(next, state->size, format, a1, a2, a3, a4, a5, a6, a7, a8,
a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
# endif
#endif
if (len == 0 || len >= state->size || next[state->size - 1] != 0)
return 0;
strm->avail_in += len;
state->x.pos += len;
if (strm->avail_in >= state->size) {
left = strm->avail_in - state->size;
strm->avail_in = state->size;
if (gz_comp(state, Z_NO_FLUSH) == -1)
return state->err;
memmove(state->in, state->in + state->size, left);
strm->next_in = state->in;
strm->avail_in = left;
}
return (int)len;
}
#endif
int ZEXPORT gzflush(gzFile file, int flush) { … }
int ZEXPORT gzsetparams(gzFile file, int level, int strategy) { … }
int ZEXPORT gzclose_w(gzFile file) { … }