MCPcopy Create free account
hub / github.com/F-Stack/f-stack / gzputc

Function gzputc

freebsd/contrib/zstd/zlibWrapper/gzwrite.c:310–355  ·  view source on GitHub ↗

-- see zlib.h -- */

(file, c)

Source from the content-addressed store, hash-verified

308
309/* -- see zlib.h -- */
310int ZEXPORT gzputc(file, c)
311 gzFile file;
312 int c;
313{
314 unsigned have;
315 unsigned char buf[1];
316 gz_statep state;
317 z_streamp strm;
318
319 /* get internal structure */
320 if (file == NULL)
321 return -1;
322 state.file = file;
323 strm = &(state.state->strm);
324
325 /* check that we're writing and that there's no error */
326 if (state.state->mode != GZ_WRITE || state.state->err != Z_OK)
327 return -1;
328
329 /* check for seek request */
330 if (state.state->seek) {
331 state.state->seek = 0;
332 if (gz_zero(state, state.state->skip) == -1)
333 return -1;
334 }
335
336 /* try writing to input buffer for speed (state.state->size == 0 if buffer not
337 initialized) */
338 if (state.state->size) {
339 if (strm->avail_in == 0)
340 strm->next_in = state.state->in;
341 have = (unsigned)((strm->next_in + strm->avail_in) - state.state->in);
342 if (have < state.state->size) {
343 state.state->in[have] = (unsigned char)c;
344 strm->avail_in++;
345 state.state->x.pos++;
346 return c & 0xff;
347 }
348 }
349
350 /* no room in buffer or not initialized, use gz_write() */
351 buf[0] = (unsigned char)c;
352 if (gz_write(state, buf, 1) != 1)
353 return -1;
354 return c & 0xff;
355}
356
357/* -- see zlib.h -- */
358int ZEXPORT gzputs(file, str)

Callers 2

test_gzioFunction · 0.50
test_gzioFunction · 0.50

Calls 2

gz_zeroFunction · 0.70
gz_writeFunction · 0.70

Tested by 2

test_gzioFunction · 0.40
test_gzioFunction · 0.40