ReactOS  0.4.14-dev-342-gdc047f9
gzwrite.c File Reference
#include "gzguts.h"
Include dependency graph for gzwrite.c:

Go to the source code of this file.

Functions

int gz_init OF ((gz_statep))
 
int gz_comp OF ((gz_statep, int))
 
int gz_zero OF ((gz_statep, z_off64_t))
 
z_size_t gz_write OF ((gz_statep, voidpc, z_size_t))
 
int gz_init (gz_statep state)
 
int gz_comp (gz_statep state, int flush)
 
int gz_zero (gz_statep state, z_off64_t len)
 
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 *str)
 
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)
 
int ZEXPORT gzflush (gzFile file, int flush)
 
int ZEXPORT gzsetparams (gzFile file, int level, int strategy)
 
int ZEXPORT gzclose_w (gzFile file)
 

Function Documentation

◆ gz_comp()

int gz_comp ( gz_statep  state,
int  flush 
)

Definition at line 73 of file gzwrite.c.

76 {
77  int ret, writ;
78  unsigned have, put, max = ((unsigned)-1 >> 2) + 1;
79  z_streamp strm = &(state->strm);
80 
81  /* allocate memory if this is the first time through */
82  if (state->size == 0 && gz_init(state) == -1)
83  return -1;
84 
85  /* write directly if requested */
86  if (state->direct) {
87  while (strm->avail_in) {
88  put = strm->avail_in > max ? max : strm->avail_in;
89  writ = write(state->fd, strm->next_in, put);
90  if (writ < 0) {
92  return -1;
93  }
94  strm->avail_in -= (unsigned)writ;
95  strm->next_in += writ;
96  }
97  return 0;
98  }
99 
100  /* run deflate() on provided input until it produces no more output */
101  ret = Z_OK;
102  do {
103  /* write out current buffer contents if full, or if flushing, but if
104  doing Z_FINISH then don't write until we get to Z_STREAM_END */
105  if (strm->avail_out == 0 || (flush != Z_NO_FLUSH &&
106  (flush != Z_FINISH || ret == Z_STREAM_END))) {
107  while (strm->next_out > state->x.next) {
108  put = strm->next_out - state->x.next > (int)max ? max :
109  (unsigned)(strm->next_out - state->x.next);
110  writ = write(state->fd, state->x.next, put);
111  if (writ < 0) {
113  return -1;
114  }
115  state->x.next += writ;
116  }
117  if (strm->avail_out == 0) {
118  strm->avail_out = state->size;
119  strm->next_out = state->out;
120  state->x.next = state->out;
121  }
122  }
123 
124  /* compress */
125  have = strm->avail_out;
126  ret = deflate(strm, flush);
127  if (ret == Z_STREAM_ERROR) {
129  "internal error: deflate stream corrupt");
130  return -1;
131  }
132  have -= strm->avail_out;
133  } while (have);
134 
135  /* if that completed a deflate stream, allow another to start */
136  if (flush == Z_FINISH)
138 
139  /* all done, no errors */
140  return 0;
141 }
#define max(a, b)
Definition: svc.c:63
#define Z_ERRNO
Definition: zlib.h:180
#define Z_STREAM_ERROR
Definition: zlib.h:181
#define Z_STREAM_END
Definition: zlib.h:178
#define put(ret, state, sp, n)
Definition: match.c:105
#define write
Definition: acwin.h:97
z_stream FAR * z_streamp
Definition: zlib.h:108
int gz_init(gz_statep state)
Definition: gzwrite.c:17
#define Z_OK
Definition: zlib.h:177
z_streamp strm
Definition: deflate.h:101
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)
Definition: gzlib.c:579
int flush
Definition: zlib.h:309
#define Z_NO_FLUSH
Definition: zlib.h:168
int ret
int ZEXPORT deflate(z_streamp strm, int flush)
Definition: deflate.c:766
static int state
Definition: maze.c:121
#define Z_FINISH
Definition: zlib.h:172
int ZEXPORT deflateReset(z_streamp strm)
Definition: deflate.c:508
#define zstrerror(errnum)
Definition: zutil.h:152
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by gz_write(), gz_zero(), gzclose_w(), gzflush(), gzprintf(), and gzsetparams().

◆ gz_init()

int gz_init ( gz_statep  state)

Definition at line 17 of file gzwrite.c.

19 {
20  int ret;
21  z_streamp strm = &(state->strm);
22 
23  /* allocate input buffer (double size for gzprintf) */
24  state->in = (unsigned char *)malloc(state->want << 1);
25  if (state->in == NULL) {
26  gz_error(state, Z_MEM_ERROR, "out of memory");
27  return -1;
28  }
29 
30  /* only need output buffer and deflate state if compressing */
31  if (!state->direct) {
32  /* allocate output buffer */
33  state->out = (unsigned char *)malloc(state->want);
34  if (state->out == NULL) {
35  free(state->in);
36  gz_error(state, Z_MEM_ERROR, "out of memory");
37  return -1;
38  }
39 
40  /* allocate deflate memory, set up for gzip compression */
41  strm->zalloc = Z_NULL;
42  strm->zfree = Z_NULL;
43  strm->opaque = Z_NULL;
45  MAX_WBITS + 16, DEF_MEM_LEVEL, state->strategy);
46  if (ret != Z_OK) {
47  free(state->out);
48  free(state->in);
49  gz_error(state, Z_MEM_ERROR, "out of memory");
50  return -1;
51  }
52  strm->next_in = NULL;
53  }
54 
55  /* mark state as initialized */
56  state->size = state->want;
57 
58  /* initialize write buffer if compressing */
59  if (!state->direct) {
60  strm->avail_out = state->size;
61  strm->next_out = state->out;
62  state->x.next = strm->next_out;
63  }
64  return 0;
65 }
#define free
Definition: debug_ros.c:5
#define deflateInit2(strm, level, method, windowBits, memLevel, strategy)
Definition: zlib.h:1797
z_stream FAR * z_streamp
Definition: zlib.h:108
#define Z_OK
Definition: zlib.h:177
smooth NULL
Definition: ftsmooth.c:416
#define Z_DEFLATED
Definition: zlib.h:209
z_streamp strm
Definition: deflate.h:101
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)
Definition: gzlib.c:579
int ret
static int state
Definition: maze.c:121
#define malloc
Definition: debug_ros.c:4
#define DEF_MEM_LEVEL
Definition: zutil.h:53
#define Z_NULL
Definition: zlib.h:212
#define MAX_WBITS
Definition: zconf.h:270
#define Z_MEM_ERROR
Definition: zlib.h:183

Referenced by gz_comp(), gz_write(), and gzprintf().

◆ gz_write()

z_size_t gz_write ( gz_statep  state,
voidpc  buf,
z_size_t  len 
)

Definition at line 178 of file gzwrite.c.

182 {
183  z_size_t put = len;
184 
185  /* if len is zero, avoid unnecessary operations */
186  if (len == 0)
187  return 0;
188 
189  /* allocate memory if this is the first time through */
190  if (state->size == 0 && gz_init(state) == -1)
191  return 0;
192 
193  /* check for seek request */
194  if (state->seek) {
195  state->seek = 0;
196  if (gz_zero(state, state->skip) == -1)
197  return 0;
198  }
199 
200  /* for small len, copy to input buffer, otherwise compress directly */
201  if (len < state->size) {
202  /* copy to input buffer, compress when full */
203  do {
204  unsigned have, copy;
205 
206  if (state->strm.avail_in == 0)
207  state->strm.next_in = state->in;
208  have = (unsigned)((state->strm.next_in + state->strm.avail_in) -
209  state->in);
210  copy = state->size - have;
211  if (copy > len)
212  copy = len;
213  memcpy(state->in + have, buf, copy);
214  state->strm.avail_in += copy;
215  state->x.pos += copy;
216  buf = (const char *)buf + copy;
217  len -= copy;
218  if (len && gz_comp(state, Z_NO_FLUSH) == -1)
219  return 0;
220  } while (len);
221  }
222  else {
223  /* consume whatever's left in the input buffer */
224  if (state->strm.avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
225  return 0;
226 
227  /* directly compress user buffer to file */
228  state->strm.next_in = (z_const Bytef *)buf;
229  do {
230  unsigned n = (unsigned)-1;
231  if (n > len)
232  n = len;
233  state->strm.avail_in = n;
234  state->x.pos += n;
235  if (gz_comp(state, Z_NO_FLUSH) == -1)
236  return 0;
237  len -= n;
238  } while (len);
239  }
240 
241  /* input was all buffered or compressed */
242  return put;
243 }
unsigned long z_size_t
Definition: zconf.h:250
int gz_comp(gz_statep state, int flush)
Definition: gzwrite.c:73
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLdouble n
Definition: glext.h:7729
int gz_zero(gz_statep state, z_off64_t len)
Definition: gzwrite.c:145
#define put(ret, state, sp, n)
Definition: match.c:105
#define z_const
Definition: zconf.h:237
Byte FAR Bytef
Definition: zconf.h:400
int gz_init(gz_statep state)
Definition: gzwrite.c:17
GLsizeiptr size
Definition: glext.h:5919
#define Z_NO_FLUSH
Definition: zlib.h:168
static int state
Definition: maze.c:121
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51

Referenced by gzfwrite(), gzputc(), gzputs(), and gzwrite().

◆ gz_zero()

int gz_zero ( gz_statep  state,
z_off64_t  len 
)

Definition at line 145 of file gzwrite.c.

148 {
149  int first;
150  unsigned n;
151  z_streamp strm = &(state->strm);
152 
153  /* consume whatever's left in the input buffer */
154  if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
155  return -1;
156 
157  /* compress len zeros (len guaranteed > 0) */
158  first = 1;
159  while (len) {
160  n = GT_OFF(state->size) || (z_off64_t)state->size > len ?
161  (unsigned)len : state->size;
162  if (first) {
163  memset(state->in, 0, n);
164  first = 0;
165  }
166  strm->avail_in = n;
167  strm->next_in = state->in;
168  state->x.pos += n;
169  if (gz_comp(state, Z_NO_FLUSH) == -1)
170  return -1;
171  len -= n;
172  }
173  return 0;
174 }
int gz_comp(gz_statep state, int flush)
Definition: gzwrite.c:73
const GLint * first
Definition: glext.h:5794
#define GT_OFF(x)
Definition: gzguts.h:217
GLdouble n
Definition: glext.h:7729
#define z_off64_t
Definition: zconf.h:513
z_stream FAR * z_streamp
Definition: zlib.h:108
z_streamp strm
Definition: deflate.h:101
#define Z_NO_FLUSH
Definition: zlib.h:168
static int state
Definition: maze.c:121
GLenum GLsizei len
Definition: glext.h:6722
#define memset(x, y, z)
Definition: compat.h:39

Referenced by gz_write(), gzclose_w(), gzflush(), gzprintf(), gzputc(), and gzsetparams().

◆ gzclose_w()

int ZEXPORT gzclose_w ( gzFile  file)

Definition at line 627 of file gzwrite.c.

629 {
630  int ret = Z_OK;
632 
633  /* get internal structure */
634  if (file == NULL)
635  return Z_STREAM_ERROR;
636  state = (gz_statep)file;
637 
638  /* check that we're writing */
639  if (state->mode != GZ_WRITE)
640  return Z_STREAM_ERROR;
641 
642  /* check for seek request */
643  if (state->seek) {
644  state->seek = 0;
645  if (gz_zero(state, state->skip) == -1)
646  ret = state->err;
647  }
648 
649  /* flush, free memory, and close file */
650  if (gz_comp(state, Z_FINISH) == -1)
651  ret = state->err;
652  if (state->size) {
653  if (!state->direct) {
654  (void)deflateEnd(&(state->strm));
655  free(state->out);
656  }
657  free(state->in);
658  }
659  gz_error(state, Z_OK, NULL);
660  free(state->path);
661  if (close(state->fd) == -1)
662  ret = Z_ERRNO;
663  free(state);
664  return ret;
665 }
int gz_comp(gz_statep state, int flush)
Definition: gzwrite.c:73
#define Z_ERRNO
Definition: zlib.h:180
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define free
Definition: debug_ros.c:5
#define Z_STREAM_ERROR
Definition: zlib.h:181
int ZEXPORT deflateEnd(z_streamp strm)
Definition: deflate.c:1079
int gz_zero(gz_statep state, z_off64_t len)
Definition: gzwrite.c:145
#define Z_OK
Definition: zlib.h:177
smooth NULL
Definition: ftsmooth.c:416
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)
Definition: gzlib.c:579
#define GZ_WRITE
Definition: gzguts.h:161
if(!(yy_init))
Definition: macro.lex.yy.c:714
int ret
static int state
Definition: maze.c:121
#define close
Definition: acwin.h:98
#define Z_FINISH
Definition: zlib.h:172
gz_state FAR * gz_statep
Definition: gzguts.h:202
Definition: fci.c:126

Referenced by gzclose().

◆ gzflush()

int ZEXPORT gzflush ( gzFile  file,
int  flush 
)

Definition at line 553 of file gzwrite.c.

556 {
558 
559  /* get internal structure */
560  if (file == NULL)
561  return Z_STREAM_ERROR;
562  state = (gz_statep)file;
563 
564  /* check that we're writing and that there's no error */
565  if (state->mode != GZ_WRITE || state->err != Z_OK)
566  return Z_STREAM_ERROR;
567 
568  /* check flush parameter */
569  if (flush < 0 || flush > Z_FINISH)
570  return Z_STREAM_ERROR;
571 
572  /* check for seek request */
573  if (state->seek) {
574  state->seek = 0;
575  if (gz_zero(state, state->skip) == -1)
576  return state->err;
577  }
578 
579  /* compress remaining data with requested flush */
580  (void)gz_comp(state, flush);
581  return state->err;
582 }
int gz_comp(gz_statep state, int flush)
Definition: gzwrite.c:73
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define Z_STREAM_ERROR
Definition: zlib.h:181
int gz_zero(gz_statep state, z_off64_t len)
Definition: gzwrite.c:145
#define Z_OK
Definition: zlib.h:177
smooth NULL
Definition: ftsmooth.c:416
#define GZ_WRITE
Definition: gzguts.h:161
int flush
Definition: zlib.h:309
static int state
Definition: maze.c:121
#define Z_FINISH
Definition: zlib.h:172
gz_state FAR * gz_statep
Definition: gzguts.h:202
Definition: fci.c:126

◆ gzfwrite()

z_size_t ZEXPORT gzfwrite ( voidpc  buf,
z_size_t  size,
z_size_t  nitems,
gzFile  file 
)

Definition at line 274 of file gzwrite.c.

279 {
280  z_size_t len;
282 
283  /* get internal structure */
284  if (file == NULL)
285  return 0;
286  state = (gz_statep)file;
287 
288  /* check that we're writing and that there's no error */
289  if (state->mode != GZ_WRITE || state->err != Z_OK)
290  return 0;
291 
292  /* compute bytes to read -- error on overflow */
293  len = nitems * size;
294  if (size && len / size != nitems) {
295  gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t");
296  return 0;
297  }
298 
299  /* write len bytes to buf, return the number of full items written */
300  return len ? gz_write(state, buf, len) / size : 0;
301 }
unsigned long z_size_t
Definition: zconf.h:250
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define Z_STREAM_ERROR
Definition: zlib.h:181
z_size_t gz_write(gz_statep state, voidpc buf, z_size_t len)
Definition: gzwrite.c:178
#define Z_OK
Definition: zlib.h:177
smooth NULL
Definition: ftsmooth.c:416
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)
Definition: gzlib.c:579
#define GZ_WRITE
Definition: gzguts.h:161
GLsizeiptr size
Definition: glext.h:5919
static int state
Definition: maze.c:121
GLenum GLsizei len
Definition: glext.h:6722
gz_state FAR * gz_statep
Definition: gzguts.h:202
Definition: fci.c:126

◆ gzprintf()

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 
)

Definition at line 465 of file gzwrite.c.

471 {
472  unsigned len, left;
473  char *next;
475  z_streamp strm;
476 
477  /* get internal structure */
478  if (file == NULL)
479  return Z_STREAM_ERROR;
480  state = (gz_statep)file;
481  strm = &(state->strm);
482 
483  /* check that can really pass pointer in ints */
484  if (sizeof(int) != sizeof(void *))
485  return Z_STREAM_ERROR;
486 
487  /* check that we're writing and that there's no error */
488  if (state->mode != GZ_WRITE || state->err != Z_OK)
489  return Z_STREAM_ERROR;
490 
491  /* make sure we have some buffer space */
492  if (state->size == 0 && gz_init(state) == -1)
493  return state->error;
494 
495  /* check for seek request */
496  if (state->seek) {
497  state->seek = 0;
498  if (gz_zero(state, state->skip) == -1)
499  return state->error;
500  }
501 
502  /* do the printf() into the input buffer, put length in len -- the input
503  buffer is double-sized just for this function, so there is guaranteed to
504  be state->size bytes available after the current contents */
505  if (strm->avail_in == 0)
506  strm->next_in = state->in;
507  next = (char *)(strm->next_in + strm->avail_in);
508  next[state->size - 1] = 0;
509 #ifdef NO_snprintf
510 # ifdef HAS_sprintf_void
511  sprintf(next, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12,
512  a13, a14, a15, a16, a17, a18, a19, a20);
513  for (len = 0; len < size; len++)
514  if (next[len] == 0)
515  break;
516 # else
517  len = sprintf(next, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11,
518  a12, a13, a14, a15, a16, a17, a18, a19, a20);
519 # endif
520 #else
521 # ifdef HAS_snprintf_void
522  snprintf(next, state->size, format, a1, a2, a3, a4, a5, a6, a7, a8, a9,
523  a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
524  len = strlen(next);
525 # else
526  len = snprintf(next, state->size, format, a1, a2, a3, a4, a5, a6, a7, a8,
527  a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
528 # endif
529 #endif
530 
531  /* check that printf() results fit in buffer */
532  if (len == 0 || len >= state->size || next[state->size - 1] != 0)
533  return 0;
534 
535  /* update buffer and position, compress first half if past that */
536  strm->avail_in += len;
537  state->x.pos += len;
538  if (strm->avail_in >= state->size) {
539  left = strm->avail_in - state->size;
540  strm->avail_in = state->size;
541  if (gz_comp(state, Z_NO_FLUSH) == -1)
542  return state->err;
543  memcpy(state->in, state->in + state->size, left);
544  strm->next_in = state->in;
545  strm->avail_in = left;
546  }
547  return (int)len;
548 }
int gz_comp(gz_statep state, int flush)
Definition: gzwrite.c:73
static const struct update_accum a3
Definition: msg.c:600
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define snprintf
Definition: wintirpc.h:48
static const struct update_accum a4
Definition: msg.c:2285
#define Z_STREAM_ERROR
Definition: zlib.h:181
int gz_zero(gz_statep state, z_off64_t len)
Definition: gzwrite.c:145
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define sprintf(buf, format,...)
Definition: sprintf.c:55
z_stream FAR * z_streamp
Definition: zlib.h:108
int gz_init(gz_statep state)
Definition: gzwrite.c:17
#define Z_OK
Definition: zlib.h:177
smooth NULL
Definition: ftsmooth.c:416
z_streamp strm
Definition: deflate.h:101
#define GZ_WRITE
Definition: gzguts.h:161
GLsizeiptr size
Definition: glext.h:5919
if(!(yy_init))
Definition: macro.lex.yy.c:714
static const struct update_accum a2
Definition: msg.c:586
GLint left
Definition: glext.h:7726
#define Z_NO_FLUSH
Definition: zlib.h:168
static int state
Definition: maze.c:121
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
static unsigned __int64 next
Definition: rand_nt.c:6
gz_state FAR * gz_statep
Definition: gzguts.h:202
static const struct update_accum a1
Definition: msg.c:578
Definition: fci.c:126

◆ gzputc()

int ZEXPORT gzputc ( gzFile  file,
int  c 
)

Definition at line 304 of file gzwrite.c.

307 {
308  unsigned have;
309  unsigned char buf[1];
311  z_streamp strm;
312 
313  /* get internal structure */
314  if (file == NULL)
315  return -1;
316  state = (gz_statep)file;
317  strm = &(state->strm);
318 
319  /* check that we're writing and that there's no error */
320  if (state->mode != GZ_WRITE || state->err != Z_OK)
321  return -1;
322 
323  /* check for seek request */
324  if (state->seek) {
325  state->seek = 0;
326  if (gz_zero(state, state->skip) == -1)
327  return -1;
328  }
329 
330  /* try writing to input buffer for speed (state->size == 0 if buffer not
331  initialized) */
332  if (state->size) {
333  if (strm->avail_in == 0)
334  strm->next_in = state->in;
335  have = (unsigned)((strm->next_in + strm->avail_in) - state->in);
336  if (have < state->size) {
337  state->in[have] = (unsigned char)c;
338  strm->avail_in++;
339  state->x.pos++;
340  return c & 0xff;
341  }
342  }
343 
344  /* no room in buffer or not initialized, use gz_write() */
345  buf[0] = (unsigned char)c;
346  if (gz_write(state, buf, 1) != 1)
347  return -1;
348  return c & 0xff;
349 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
z_size_t gz_write(gz_statep state, voidpc buf, z_size_t len)
Definition: gzwrite.c:178
int gz_zero(gz_statep state, z_off64_t len)
Definition: gzwrite.c:145
z_stream FAR * z_streamp
Definition: zlib.h:108
#define Z_OK
Definition: zlib.h:177
smooth NULL
Definition: ftsmooth.c:416
unsigned char
Definition: typeof.h:29
z_streamp strm
Definition: deflate.h:101
#define GZ_WRITE
Definition: gzguts.h:161
GLsizeiptr size
Definition: glext.h:5919
const GLubyte * c
Definition: glext.h:8905
static int state
Definition: maze.c:121
gz_state FAR * gz_statep
Definition: gzguts.h:202
Definition: fci.c:126

◆ gzputs()

int ZEXPORT gzputs ( gzFile  file,
const char str 
)

Definition at line 352 of file gzwrite.c.

355 {
356  int ret;
357  z_size_t len;
359 
360  /* get internal structure */
361  if (file == NULL)
362  return -1;
363  state = (gz_statep)file;
364 
365  /* check that we're writing and that there's no error */
366  if (state->mode != GZ_WRITE || state->err != Z_OK)
367  return -1;
368 
369  /* write string */
370  len = strlen(str);
371  ret = gz_write(state, str, len);
372  return ret == 0 && len != 0 ? -1 : ret;
373 }
unsigned long z_size_t
Definition: zconf.h:250
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
z_size_t gz_write(gz_statep state, voidpc buf, z_size_t len)
Definition: gzwrite.c:178
#define Z_OK
Definition: zlib.h:177
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
#define GZ_WRITE
Definition: gzguts.h:161
int ret
static int state
Definition: maze.c:121
GLenum GLsizei len
Definition: glext.h:6722
gz_state FAR * gz_statep
Definition: gzguts.h:202
Definition: fci.c:126

◆ gzsetparams()

int ZEXPORT gzsetparams ( gzFile  file,
int  level,
int  strategy 
)

Definition at line 585 of file gzwrite.c.

589 {
591  z_streamp strm;
592 
593  /* get internal structure */
594  if (file == NULL)
595  return Z_STREAM_ERROR;
596  state = (gz_statep)file;
597  strm = &(state->strm);
598 
599  /* check that we're writing and that there's no error */
600  if (state->mode != GZ_WRITE || state->err != Z_OK)
601  return Z_STREAM_ERROR;
602 
603  /* if no change is requested, then do nothing */
604  if (level == state->level && strategy == state->strategy)
605  return Z_OK;
606 
607  /* check for seek request */
608  if (state->seek) {
609  state->seek = 0;
610  if (gz_zero(state, state->skip) == -1)
611  return state->err;
612  }
613 
614  /* change compression parameters for subsequent input */
615  if (state->size) {
616  /* flush previous input with previous parameters before changing */
617  if (strm->avail_in && gz_comp(state, Z_BLOCK) == -1)
618  return state->err;
620  }
621  state->level = level;
622  state->strategy = strategy;
623  return Z_OK;
624 }
int gz_comp(gz_statep state, int flush)
Definition: gzwrite.c:73
GLint level
Definition: gl.h:1546
int ZEXPORT deflateParams(z_streamp strm, int level, int strategy)
Definition: deflate.c:571
#define Z_STREAM_ERROR
Definition: zlib.h:181
int gz_zero(gz_statep state, z_off64_t len)
Definition: gzwrite.c:145
z_stream FAR * z_streamp
Definition: zlib.h:108
#define Z_OK
Definition: zlib.h:177
smooth NULL
Definition: ftsmooth.c:416
z_streamp strm
Definition: deflate.h:101
#define GZ_WRITE
Definition: gzguts.h:161
static int state
Definition: maze.c:121
gz_state FAR * gz_statep
Definition: gzguts.h:202
#define Z_BLOCK
Definition: zlib.h:173
Definition: fci.c:126

◆ gzwrite()

int ZEXPORT gzwrite ( gzFile  file,
voidpc  buf,
unsigned  len 
)

Definition at line 246 of file gzwrite.c.

250 {
252 
253  /* get internal structure */
254  if (file == NULL)
255  return 0;
256  state = (gz_statep)file;
257 
258  /* check that we're writing and that there's no error */
259  if (state->mode != GZ_WRITE || state->err != Z_OK)
260  return 0;
261 
262  /* since an int is returned, make sure len fits in one, otherwise return
263  with an error (this avoids a flaw in the interface) */
264  if ((int)len < 0) {
265  gz_error(state, Z_DATA_ERROR, "requested length does not fit in int");
266  return 0;
267  }
268 
269  /* write len bytes from buf (the return value will fit in an int) */
270  return (int)gz_write(state, buf, len);
271 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
z_size_t gz_write(gz_statep state, voidpc buf, z_size_t len)
Definition: gzwrite.c:178
#define Z_OK
Definition: zlib.h:177
smooth NULL
Definition: ftsmooth.c:416
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)
Definition: gzlib.c:579
#define GZ_WRITE
Definition: gzguts.h:161
#define Z_DATA_ERROR
Definition: zlib.h:182
static int state
Definition: maze.c:121
GLenum GLsizei len
Definition: glext.h:6722
gz_state FAR * gz_statep
Definition: gzguts.h:202
Definition: fci.c:126

◆ OF() [1/4]

int gz_init OF ( (gz_statep )

◆ OF() [2/4]

int gz_comp OF ( (gz_statep, int )

◆ OF() [3/4]

◆ OF() [4/4]