1381716e9396b55b1adb8235b020c37344f60ab07Elliott Hughes/* gzclose.c -- zlib gzclose() function 2381716e9396b55b1adb8235b020c37344f60ab07Elliott Hughes * Copyright (C) 2004, 2010 Mark Adler 3381716e9396b55b1adb8235b020c37344f60ab07Elliott Hughes * For conditions of distribution and use, see copyright notice in zlib.h 4381716e9396b55b1adb8235b020c37344f60ab07Elliott Hughes */ 5381716e9396b55b1adb8235b020c37344f60ab07Elliott Hughes 6381716e9396b55b1adb8235b020c37344f60ab07Elliott Hughes#include "gzguts.h" 7381716e9396b55b1adb8235b020c37344f60ab07Elliott Hughes 8381716e9396b55b1adb8235b020c37344f60ab07Elliott Hughes/* gzclose() is in a separate file so that it is linked in only if it is used. 9381716e9396b55b1adb8235b020c37344f60ab07Elliott Hughes That way the other gzclose functions can be used instead to avoid linking in 10381716e9396b55b1adb8235b020c37344f60ab07Elliott Hughes unneeded compression or decompression routines. */ 11381716e9396b55b1adb8235b020c37344f60ab07Elliott Hughesint ZEXPORT gzclose(file) 12381716e9396b55b1adb8235b020c37344f60ab07Elliott Hughes gzFile file; 13381716e9396b55b1adb8235b020c37344f60ab07Elliott Hughes{ 14381716e9396b55b1adb8235b020c37344f60ab07Elliott Hughes#ifndef NO_GZCOMPRESS 15381716e9396b55b1adb8235b020c37344f60ab07Elliott Hughes gz_statep state; 16381716e9396b55b1adb8235b020c37344f60ab07Elliott Hughes 17381716e9396b55b1adb8235b020c37344f60ab07Elliott Hughes if (file == NULL) 18381716e9396b55b1adb8235b020c37344f60ab07Elliott Hughes return Z_STREAM_ERROR; 19381716e9396b55b1adb8235b020c37344f60ab07Elliott Hughes state = (gz_statep)file; 20381716e9396b55b1adb8235b020c37344f60ab07Elliott Hughes 21381716e9396b55b1adb8235b020c37344f60ab07Elliott Hughes return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file); 22381716e9396b55b1adb8235b020c37344f60ab07Elliott Hughes#else 23381716e9396b55b1adb8235b020c37344f60ab07Elliott Hughes return gzclose_r(file); 24381716e9396b55b1adb8235b020c37344f60ab07Elliott Hughes#endif 25381716e9396b55b1adb8235b020c37344f60ab07Elliott Hughes} 26