1*01826a49SYabin Cui /* gzclose.c contains minimal changes required to be compiled with zlibWrapper: 2*01826a49SYabin Cui * - gz_statep was converted to union to work with -Wstrict-aliasing=1 */ 3*01826a49SYabin Cui 4*01826a49SYabin Cui /* gzclose.c -- zlib gzclose() function 5*01826a49SYabin Cui * Copyright (C) 2004, 2010 Mark Adler 6*01826a49SYabin Cui * For conditions of distribution and use, see https://www.zlib.net/zlib_license.html 7*01826a49SYabin Cui */ 8*01826a49SYabin Cui 9*01826a49SYabin Cui #include "gzguts.h" 10*01826a49SYabin Cui 11*01826a49SYabin Cui /* gzclose() is in a separate file so that it is linked in only if it is used. 12*01826a49SYabin Cui That way the other gzclose functions can be used instead to avoid linking in 13*01826a49SYabin Cui unneeded compression or decompression routines. */ gzclose(gzFile file)14*01826a49SYabin Cuiint ZEXPORT gzclose(gzFile file) { 15*01826a49SYabin Cui #ifndef NO_GZCOMPRESS 16*01826a49SYabin Cui gz_statep state; 17*01826a49SYabin Cui 18*01826a49SYabin Cui if (file == NULL) 19*01826a49SYabin Cui return Z_STREAM_ERROR; 20*01826a49SYabin Cui state.file = file; 21*01826a49SYabin Cui 22*01826a49SYabin Cui return state.state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file); 23*01826a49SYabin Cui #else 24*01826a49SYabin Cui return gzclose_r(file); 25*01826a49SYabin Cui #endif 26*01826a49SYabin Cui } 27