-- see zlib.h -- */
(buf, size, nitems, file)
| 450 | |
| 451 | /* -- see zlib.h -- */ |
| 452 | z_size_t ZEXPORT gzfread(buf, size, nitems, file) |
| 453 | voidp buf; |
| 454 | z_size_t size; |
| 455 | z_size_t nitems; |
| 456 | |
| 457 | gzFile file; |
| 458 | { |
| 459 | z_size_t len; |
| 460 | gz_statep state; |
| 461 | |
| 462 | /* get internal structure */ |
| 463 | if (file == NULL) |
| 464 | return 0; |
| 465 | state = (gz_statep)file; |
| 466 | |
| 467 | /* check that we're reading and that there's no (serious) error */ |
| 468 | if (state->mode != GZ_READ || |
| 469 | (state->err != Z_OK && state->err != Z_BUF_ERROR)) |
| 470 | return 0; |
| 471 | |
| 472 | /* compute bytes to read -- error on overflow */ |
| 473 | len = nitems * size; |
| 474 | if (size && len / size != nitems) |
| 475 | { |
| 476 | gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t"); |
| 477 | return 0; |
| 478 | } |
| 479 | |
| 480 | /* read len or fewer bytes to buf, return the number of full items read */ |
| 481 | return len ? gz_read(state, buf, len) / size : 0; |
| 482 | } |
| 483 | |
| 484 | /* -- see zlib.h -- */ |
| 485 | #ifdef Z_PREFIX_SET |