MCPcopy Create free account
hub / github.com/MariaDB/server / gzputc

Function gzputc

zlib/gzwrite.c:307–347  ·  view source on GitHub ↗

-- see zlib.h -- */

Source from the content-addressed store, hash-verified

305
306/* -- see zlib.h -- */
307int ZEXPORT gzputc(gzFile file, int c) {
308 unsigned have;
309 unsigned char buf[1];
310 gz_statep state;
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 (serious) error */
320 if (state->mode != GZ_WRITE || (state->err != Z_OK && !state->again))
321 return -1;
322 gz_error(state, Z_OK, NULL);
323
324 /* check for seek request */
325 if (state->skip && gz_zero(state) == -1)
326 return -1;
327
328 /* try writing to input buffer for speed (state->size == 0 if buffer not
329 initialized) */
330 if (state->size) {
331 if (strm->avail_in == 0)
332 strm->next_in = state->in;
333 have = (unsigned)((strm->next_in + strm->avail_in) - state->in);
334 if (have < state->size) {
335 state->in[have] = (unsigned char)c;
336 strm->avail_in++;
337 state->x.pos++;
338 return c & 0xff;
339 }
340 }
341
342 /* no room in buffer or not initialized, use gz_write() */
343 buf[0] = (unsigned char)c;
344 if (gz_write(state, buf, 1) != 1)
345 return -1;
346 return c & 0xff;
347}
348
349/* -- see zlib.h -- */
350int ZEXPORT gzputs(gzFile file, const char *s) {

Callers

nothing calls this directly

Calls 3

gz_errorFunction · 0.85
gz_zeroFunction · 0.85
gz_writeFunction · 0.85

Tested by

no test coverage detected