MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / gzputc

Function gzputc

extlibs/minizip/src/gzwrite.c:338–387  ·  view source on GitHub ↗

-- see zlib.h -- */

(file, c)

Source from the content-addressed store, hash-verified

336
337/* -- see zlib.h -- */
338int ZEXPORT gzputc(file, c)
339gzFile file;
340
341int c;
342{
343 unsigned have;
344 unsigned char buf[1];
345 gz_statep state;
346 z_streamp strm;
347
348 /* get internal structure */
349 if (file == NULL)
350 return -1;
351 state = (gz_statep)file;
352 strm = &(state->strm);
353
354 /* check that we're writing and that there's no error */
355 if (state->mode != GZ_WRITE || state->err != Z_OK)
356 return -1;
357
358 /* check for seek request */
359 if (state->seek)
360 {
361 state->seek = 0;
362 if (gz_zero(state, state->skip) == -1)
363 return -1;
364 }
365
366 /* try writing to input buffer for speed (state->size == 0 if buffer not
367 initialized) */
368 if (state->size)
369 {
370 if (strm->avail_in == 0)
371 strm->next_in = state->in;
372 have = (unsigned)((strm->next_in + strm->avail_in) - state->in);
373 if (have < state->size)
374 {
375 state->in[have] = (unsigned char)c;
376 strm->avail_in++;
377 state->x.pos++;
378 return c & 0xff;
379 }
380 }
381
382 /* no room in buffer or not initialized, use gz_write() */
383 buf[0] = (unsigned char)c;
384 if (gz_write(state, buf, 1) != 1)
385 return -1;
386 return c & 0xff;
387}
388
389/* -- see zlib.h -- */
390int ZEXPORT gzputs(file, str)

Callers

nothing calls this directly

Calls 2

gz_zeroFunction · 0.85
gz_writeFunction · 0.85

Tested by

no test coverage detected