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