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