| 469 | #endif |
| 470 | |
| 471 | int ZEXPORT gzgetc(file) |
| 472 | gzFile file; |
| 473 | { |
| 474 | int ret; |
| 475 | unsigned char buf[1]; |
| 476 | gz_statep state; |
| 477 | |
| 478 | /* get internal structure */ |
| 479 | if (file == NULL) |
| 480 | return -1; |
| 481 | state.file = file; |
| 482 | |
| 483 | /* check that we're reading and that there's no (serious) error */ |
| 484 | if (state.state->mode != GZ_READ || |
| 485 | (state.state->err != Z_OK && state.state->err != Z_BUF_ERROR)) |
| 486 | return -1; |
| 487 | |
| 488 | /* try output buffer (no need to check for skip request) */ |
| 489 | if (state.state->x.have) { |
| 490 | state.state->x.have--; |
| 491 | state.state->x.pos++; |
| 492 | return *(state.state->x.next)++; |
| 493 | } |
| 494 | |
| 495 | /* nothing there -- try gz_read() */ |
| 496 | ret = (int)gz_read(state, buf, 1); |
| 497 | return ret < 1 ? -1 : buf[0]; |
| 498 | } |
| 499 | |
| 500 | int ZEXPORT gzgetc_(file) |
| 501 | gzFile file; |