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