1205194Sdelphij/* gzclose.c -- zlib gzclose() function
2205194Sdelphij * Copyright (C) 2004, 2010 Mark Adler
3205194Sdelphij * For conditions of distribution and use, see copyright notice in zlib.h
4205194Sdelphij */
5205194Sdelphij
6205194Sdelphij#include "gzguts.h"
7205194Sdelphij
8205194Sdelphij/* gzclose() is in a separate file so that it is linked in only if it is used.
9205194Sdelphij   That way the other gzclose functions can be used instead to avoid linking in
10205194Sdelphij   unneeded compression or decompression routines. */
11205194Sdelphijint ZEXPORT gzclose(file)
12205194Sdelphij    gzFile file;
13205194Sdelphij{
14205194Sdelphij#ifndef NO_GZCOMPRESS
15205194Sdelphij    gz_statep state;
16205194Sdelphij
17205194Sdelphij    if (file == NULL)
18205194Sdelphij        return Z_STREAM_ERROR;
19205194Sdelphij    state = (gz_statep)file;
20205194Sdelphij
21205194Sdelphij    return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file);
22205194Sdelphij#else
23205194Sdelphij    return gzclose_r(file);
24205194Sdelphij#endif
25205194Sdelphij}
26