-- see zlib.h -- */
| 253 | |
| 254 | /* -- see zlib.h -- */ |
| 255 | int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len) { |
| 256 | gz_statep state; |
| 257 | |
| 258 | /* get internal structure */ |
| 259 | if (file == NULL) |
| 260 | return 0; |
| 261 | state = (gz_statep)file; |
| 262 | |
| 263 | /* check that we're writing and that there's no (serious) error */ |
| 264 | if (state->mode != GZ_WRITE || (state->err != Z_OK && !state->again)) |
| 265 | return 0; |
| 266 | gz_error(state, Z_OK, NULL); |
| 267 | |
| 268 | /* since an int is returned, make sure len fits in one, otherwise return |
| 269 | with an error (this avoids a flaw in the interface) */ |
| 270 | if ((int)len < 0) { |
| 271 | gz_error(state, Z_DATA_ERROR, "requested length does not fit in int"); |
| 272 | return 0; |
| 273 | } |
| 274 | |
| 275 | /* write len bytes from buf (the return value will fit in an int) */ |
| 276 | return (int)gz_write(state, buf, len); |
| 277 | } |
| 278 | |
| 279 | /* -- see zlib.h -- */ |
| 280 | z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size, z_size_t nitems, |
no test coverage detected