-- see zlib.h -- */
(file, buf, len)
| 274 | |
| 275 | /* -- see zlib.h -- */ |
| 276 | int ZEXPORT gzwrite(file, buf, len) |
| 277 | gzFile file; |
| 278 | voidpc buf; |
| 279 | |
| 280 | unsigned len; |
| 281 | { |
| 282 | gz_statep state; |
| 283 | |
| 284 | /* get internal structure */ |
| 285 | if (file == NULL) |
| 286 | return 0; |
| 287 | state = (gz_statep)file; |
| 288 | |
| 289 | /* check that we're writing and that there's no error */ |
| 290 | if (state->mode != GZ_WRITE || state->err != Z_OK) |
| 291 | return 0; |
| 292 | |
| 293 | /* since an int is returned, make sure len fits in one, otherwise return |
| 294 | with an error (this avoids a flaw in the interface) */ |
| 295 | if ((int)len < 0) |
| 296 | { |
| 297 | gz_error(state, Z_DATA_ERROR, "requested length does not fit in int"); |
| 298 | return 0; |
| 299 | } |
| 300 | |
| 301 | /* write len bytes from buf (the return value will fit in an int) */ |
| 302 | return (int)gz_write(state, buf, len); |
| 303 | } |
| 304 | |
| 305 | /* -- see zlib.h -- */ |
| 306 | z_size_t ZEXPORT gzfwrite(buf, size, nitems, file) |