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