| 448 | # undef gzgetc |
| 449 | #endif |
| 450 | int ZEXPORT gzgetc(file) |
| 451 | gzFile file; |
| 452 | { |
| 453 | int ret; |
| 454 | unsigned char buf[1]; |
| 455 | gz_statep state; |
| 456 | |
| 457 | /* get internal structure */ |
| 458 | if (file == NULL) |
| 459 | return -1; |
| 460 | state = (gz_statep)file; |
| 461 | |
| 462 | /* check that we're reading and that there's no (serious) error */ |
| 463 | if (state->mode != GZ_READ || |
| 464 | (state->err != Z_OK && state->err != Z_BUF_ERROR)) |
| 465 | return -1; |
| 466 | |
| 467 | /* try output buffer (no need to check for skip request) */ |
| 468 | if (state->x.have) { |
| 469 | state->x.have--; |
| 470 | state->x.pos++; |
| 471 | return *(state->x.next)++; |
| 472 | } |
| 473 | |
| 474 | /* nothing there -- try gz_read() */ |
| 475 | ret = gz_read(state, buf, 1); |
| 476 | return ret < 1 ? -1 : buf[0]; |
| 477 | } |
| 478 | |
| 479 | int ZEXPORT gzgetc_(file) |
| 480 | gzFile file; |