| 488 | # undef gzgetc |
| 489 | #endif |
| 490 | int ZEXPORT gzgetc(file) |
| 491 | |
| 492 | gzFile file; |
| 493 | { |
| 494 | int ret; |
| 495 | unsigned char buf[1]; |
| 496 | gz_statep state; |
| 497 | |
| 498 | /* get internal structure */ |
| 499 | if (file == NULL) |
| 500 | return -1; |
| 501 | state = (gz_statep)file; |
| 502 | |
| 503 | /* check that we're reading and that there's no (serious) error */ |
| 504 | if (state->mode != GZ_READ || |
| 505 | (state->err != Z_OK && state->err != Z_BUF_ERROR)) |
| 506 | return -1; |
| 507 | |
| 508 | /* try output buffer (no need to check for skip request) */ |
| 509 | if (state->x.have) |
| 510 | { |
| 511 | state->x.have--; |
| 512 | state->x.pos++; |
| 513 | return *(state->x.next)++; |
| 514 | } |
| 515 | |
| 516 | /* nothing there -- try gz_read() */ |
| 517 | ret = gz_read(state, buf, 1); |
| 518 | return ret < 1 ? -1 : buf[0]; |
| 519 | } |
| 520 | |
| 521 | int ZEXPORT gzgetc_(file) |
| 522 | |