Fossil SCM
| 7ef7284… | drh | 1 | /* gzclose.c -- zlib gzclose() function |
| 7ef7284… | drh | 2 | * Copyright (C) 2004, 2010 Mark Adler |
| 7ef7284… | drh | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
| 7ef7284… | drh | 4 | */ |
| 7ef7284… | drh | 5 | |
| 7ef7284… | drh | 6 | #include "gzguts.h" |
| 7ef7284… | drh | 7 | |
| 7ef7284… | drh | 8 | /* gzclose() is in a separate file so that it is linked in only if it is used. |
| 7ef7284… | drh | 9 | That way the other gzclose functions can be used instead to avoid linking in |
| 7ef7284… | drh | 10 | unneeded compression or decompression routines. */ |
| f1f1d6c… | drh | 11 | int ZEXPORT gzclose(gzFile file) { |
| 7ef7284… | drh | 12 | #ifndef NO_GZCOMPRESS |
| 7ef7284… | drh | 13 | gz_statep state; |
| 7ef7284… | drh | 14 | |
| 7ef7284… | drh | 15 | if (file == NULL) |
| 7ef7284… | drh | 16 | return Z_STREAM_ERROR; |
| 7ef7284… | drh | 17 | state = (gz_statep)file; |
| 7ef7284… | drh | 18 | |
| 7ef7284… | drh | 19 | return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file); |
| 7ef7284… | drh | 20 | #else |
| 7ef7284… | drh | 21 | return gzclose_r(file); |
| 7ef7284… | drh | 22 | #endif |
| 7ef7284… | drh | 23 | } |