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