-- see zlib.h -- */
(buf, size, nitems, file)
| 304 | |
| 305 | /* -- see zlib.h -- */ |
| 306 | z_size_t ZEXPORT gzfwrite(buf, size, nitems, file) |
| 307 | voidpc buf; |
| 308 | z_size_t size; |
| 309 | z_size_t nitems; |
| 310 | |
| 311 | gzFile file; |
| 312 | { |
| 313 | z_size_t len; |
| 314 | gz_statep state; |
| 315 | |
| 316 | /* get internal structure */ |
| 317 | if (file == NULL) |
| 318 | return 0; |
| 319 | state = (gz_statep)file; |
| 320 | |
| 321 | /* check that we're writing and that there's no error */ |
| 322 | if (state->mode != GZ_WRITE || state->err != Z_OK) |
| 323 | return 0; |
| 324 | |
| 325 | /* compute bytes to read -- error on overflow */ |
| 326 | len = nitems * size; |
| 327 | if (size && len / size != nitems) |
| 328 | { |
| 329 | gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t"); |
| 330 | return 0; |
| 331 | } |
| 332 | |
| 333 | /* write len bytes to buf, return the number of full items written */ |
| 334 | return len ? gz_write(state, buf, len) / size : 0; |
| 335 | } |
| 336 | |
| 337 | /* -- see zlib.h -- */ |
| 338 | int ZEXPORT gzputc(file, c) |