-- see zlib.h -- */
| 278 | |
| 279 | /* -- see zlib.h -- */ |
| 280 | z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size, z_size_t nitems, |
| 281 | gzFile file) { |
| 282 | z_size_t len; |
| 283 | gz_statep state; |
| 284 | |
| 285 | /* get internal structure */ |
| 286 | if (file == NULL) |
| 287 | return 0; |
| 288 | state = (gz_statep)file; |
| 289 | |
| 290 | /* check that we're writing and that there's no (serious) error */ |
| 291 | if (state->mode != GZ_WRITE || (state->err != Z_OK && !state->again)) |
| 292 | return 0; |
| 293 | gz_error(state, Z_OK, NULL); |
| 294 | |
| 295 | /* compute bytes to read -- error on overflow */ |
| 296 | len = nitems * size; |
| 297 | if (size && len / size != nitems) { |
| 298 | gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t"); |
| 299 | return 0; |
| 300 | } |
| 301 | |
| 302 | /* write len bytes to buf, return the number of full items written */ |
| 303 | return len ? gz_write(state, buf, len) / size : 0; |
| 304 | } |
| 305 | |
| 306 | /* -- see zlib.h -- */ |
| 307 | int ZEXPORT gzputc(gzFile file, int c) { |