-- see zlib.h -- */
(buf, size, nitems, file)
| 412 | |
| 413 | /* -- see zlib.h -- */ |
| 414 | z_size_t ZEXPORT gzfread(buf, size, nitems, file) |
| 415 | voidp buf; |
| 416 | z_size_t size; |
| 417 | z_size_t nitems; |
| 418 | gzFile file; |
| 419 | { |
| 420 | z_size_t len; |
| 421 | gz_statep state; |
| 422 | |
| 423 | /* get internal structure */ |
| 424 | if (file == NULL) |
| 425 | return 0; |
| 426 | state = (gz_statep)file; |
| 427 | |
| 428 | /* check that we're reading and that there's no (serious) error */ |
| 429 | if (state->mode != GZ_READ || |
| 430 | (state->err != Z_OK && state->err != Z_BUF_ERROR)) |
| 431 | return 0; |
| 432 | |
| 433 | /* compute bytes to read -- error on overflow */ |
| 434 | len = nitems * size; |
| 435 | if (size && len / size != nitems) { |
| 436 | gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t"); |
| 437 | return 0; |
| 438 | } |
| 439 | |
| 440 | /* read len or fewer bytes to buf, return the number of full items read */ |
| 441 | return len ? gz_read(state, buf, len) / size : 0; |
| 442 | } |
| 443 | |
| 444 | /* -- see zlib.h -- */ |
| 445 | #ifdef Z_PREFIX_SET |