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