xref: /freebsd/sys/contrib/zlib/gzclose.c (revision ab393e9548f8cc0ee28499c411963b798ebb38a5)
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 /* gzclose() is in a separate file so that it is linked in only if it is used.
9    That way the other gzclose functions can be used instead to avoid linking in
10    unneeded compression or decompression routines. */
11 int ZEXPORT gzclose(gzFile file) {
12 #ifndef NO_GZCOMPRESS
13     gz_statep state;
14 
15     if (file == NULL)
16         return Z_STREAM_ERROR;
17     state = (gz_statep)file;
18 
19     return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file);
20 #else
21     return gzclose_r(file);
22 #endif
23 }
24