/* gzwrite.c -- zlib functions for writing gzip files
* Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#include "gzguts.h"
/* Local functions */
/* Initialize state for writing a gzip file. Mark initialization by setting
state->size to non-zero. Return -1 on failure or 0 on success. */
{
int ret;
/* allocate input buffer */
return -1;
}
/* only need output buffer and deflate state if compressing */
/* allocate output buffer */
return -1;
}
/* allocate deflate memory, set up for gzip compression */
return -1;
}
}
/* mark state as initialized */
/* initialize write buffer if compressing */
}
return 0;
}
/* Compress whatever is at avail_in and next_in and write to the output file.
Return -1 if there is an error writing to the output file, otherwise 0.
flush is assumed to be a valid deflate() flush value. If flush is Z_FINISH,
then the deflate() state is reset to start a new gzip stream. If gz->direct
is true, then simply write to the output file without compressing, and
ignore flush. */
int flush;
{
unsigned have;
/* allocate memory if this is the first time through */
return -1;
/* write directly if requested */
return -1;
}
return 0;
}
/* run deflate() on provided input until it produces no more output */
do {
/* write out current buffer contents if full, or if flushing, but if
doing Z_FINISH then don't write until we get to Z_STREAM_END */
return -1;
}
}
}
/* compress */
if (ret == Z_STREAM_ERROR) {
"internal error: deflate stream corrupt");
return -1;
}
} while (have);
/* if that completed a deflate stream, allow another to start */
/* all done, no errors */
return 0;
}
/* Compress len zeros to output. Return -1 on error, 0 on success. */
{
int first;
unsigned n;
/* consume whatever's left in the input buffer */
return -1;
/* compress len zeros (len guaranteed > 0) */
first = 1;
while (len) {
if (first) {
first = 0;
}
return -1;
len -= n;
}
return 0;
}
/* -- see zlib.h -- */
unsigned len;
{
/* get internal structure */
return 0;
/* check that we're writing and that there's no error */
return 0;
/* since an int is returned, make sure len fits in one, otherwise return
with an error (this avoids the flaw in the interface) */
if ((int)len < 0) {
return 0;
}
/* if len is zero, avoid unnecessary operations */
if (len == 0)
return 0;
/* allocate memory if this is the first time through */
return 0;
/* check for seek request */
return 0;
}
/* for small len, copy to input buffer, otherwise compress directly */
/* copy to input buffer, compress when full */
do {
return 0;
} while (len);
}
else {
/* consume whatever's left in the input buffer */
return 0;
/* directly compress user buffer to file */
return 0;
}
/* input was all buffered or compressed (put will fit in int) */
return (int)put;
}
/* -- see zlib.h -- */
int c;
{
unsigned have;
/* get internal structure */
return -1;
/* check that we're writing and that there's no error */
return -1;
/* check for seek request */
return -1;
}
/* try writing to input buffer for speed (state->size == 0 if buffer not
initialized) */
return c & 0xff;
}
}
/* no room in buffer or not initialized, use gz_write() */
buf[0] = c;
return -1;
return c & 0xff;
}
/* -- see zlib.h -- */
const char *str;
{
int ret;
unsigned len;
/* write string */
}
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
#include <stdarg.h>
/* -- see zlib.h -- */
{
/* get internal structure */
return -1;
/* check that we're writing and that there's no error */
return 0;
/* make sure we have some buffer space */
return 0;
/* check for seek request */
return 0;
}
/* consume whatever's left in the input buffer */
return 0;
/* do the printf() into the input buffer, put length in len */
#ifdef NO_vsnprintf
# ifdef HAS_vsprintf_void
# else
# endif
#else
# ifdef HAS_vsnprintf_void
# else
# endif
#endif
/* check that printf() results fit in buffer */
return 0;
/* update buffer and position, defer compression until needed */
return len;
}
{
int ret;
return ret;
}
#else /* !STDC && !Z_HAVE_STDARG_H */
/* -- see zlib.h -- */
const char *format;
{
/* get internal structure */
return -1;
/* check that can really pass pointer in ints */
if (sizeof(int) != sizeof(void *))
return 0;
/* check that we're writing and that there's no error */
return 0;
/* make sure we have some buffer space */
return 0;
/* check for seek request */
return 0;
}
/* consume whatever's left in the input buffer */
return 0;
/* do the printf() into the input buffer, put length in len */
#ifdef NO_snprintf
# ifdef HAS_sprintf_void
# else
# endif
#else
# ifdef HAS_snprintf_void
# else
# endif
#endif
/* check that printf() results fit in buffer */
return 0;
/* update buffer and position, defer compression until needed */
return len;
}
#endif
/* -- see zlib.h -- */
int flush;
{
/* get internal structure */
return -1;
/* check that we're writing and that there's no error */
return Z_STREAM_ERROR;
/* check flush parameter */
return Z_STREAM_ERROR;
/* check for seek request */
return -1;
}
/* compress remaining data with requested flush */
}
/* -- see zlib.h -- */
int level;
int strategy;
{
/* get internal structure */
return Z_STREAM_ERROR;
/* check that we're writing and that there's no error */
return Z_STREAM_ERROR;
/* if no change is requested, then do nothing */
return Z_OK;
/* check for seek request */
return -1;
}
/* change compression parameters for subsequent input */
/* flush previous input with previous parameters before changing */
}
return Z_OK;
}
/* -- see zlib.h -- */
{
/* get internal structure */
return Z_STREAM_ERROR;
/* check that we're writing */
return Z_STREAM_ERROR;
/* check for seek request */
}
/* flush, free memory, and close file */
}
}
return ret;
}