MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / gzputc

Function gzputc

extern/zlib/src/gzwrite.c:287–329  ·  view source on GitHub ↗

-- see zlib.h -- */

Source from the content-addressed store, hash-verified

285
286/* -- see zlib.h -- */
287int ZEXPORT gzputc(gzFile file, int c) {
288 unsigned have;
289 unsigned char buf[1];
290 gz_statep state;
291 z_streamp strm;
292
293 /* get internal structure */
294 if (file == NULL)
295 return -1;
296 state = (gz_statep)file;
297 strm = &(state->strm);
298
299 /* check that we're writing and that there's no error */
300 if (state->mode != GZ_WRITE || state->err != Z_OK)
301 return -1;
302
303 /* check for seek request */
304 if (state->seek) {
305 state->seek = 0;
306 if (gz_zero(state, state->skip) == -1)
307 return -1;
308 }
309
310 /* try writing to input buffer for speed (state->size == 0 if buffer not
311 initialized) */
312 if (state->size) {
313 if (strm->avail_in == 0)
314 strm->next_in = state->in;
315 have = (unsigned)((strm->next_in + strm->avail_in) - state->in);
316 if (have < state->size) {
317 state->in[have] = (unsigned char)c;
318 strm->avail_in++;
319 state->x.pos++;
320 return c & 0xff;
321 }
322 }
323
324 /* no room in buffer or not initialized, use gz_write() */
325 buf[0] = (unsigned char)c;
326 if (gz_write(state, buf, 1) != 1)
327 return -1;
328 return c & 0xff;
329}
330
331/* -- see zlib.h -- */
332int ZEXPORT gzputs(gzFile file, const char *s) {

Callers

nothing calls this directly

Calls 2

gz_zeroFunction · 0.85
gz_writeFunction · 0.85

Tested by

no test coverage detected