/*-------------------------------------------------------------------------*/ /** @file gzip_i.h @author N. Devillard @date Aug 1999 @version $Revision: 1.8 $ @brief Interfaces to gzip through popen(). This module implements a simplistic interface to gzipped files, using Unix's popen() and a locally installed version of the gzip program to do the job. */ /*--------------------------------------------------------------------------*/ /* $Id: gzip_i.h,v 1.8 2001/10/19 10:49:09 ndevilla Exp $ $Author: ndevilla $ $Date: 2001/10/19 10:49:09 $ $Revision: 1.8 $ */ #ifndef _GZIP_I_H_ #define _GZIP_I_H_ /*--------------------------------------------------------------------------- Includes ---------------------------------------------------------------------------*/ #include #include #include /*--------------------------------------------------------------------------- Function codes ---------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/ /** @brief Find out if a given file name corresponds to a gzipped file. @param filename Name of the file to check out. @return 1 if the file is gzipped, 0 if not, -1 if error. This function finds out if a given character string is the name of a valid gzipped file. Be careful that the returned value is more than a true/false flag, it can also be -1 if an error occurred (e.g. the given file name does not correspond to any existing file). A gzipped file is recognized by the fact that the first two bytes in the files are respectively 0x1f and 0x8b (magic number, according to gzip documentation). */ /*--------------------------------------------------------------------------*/ int is_gzipped_file(char * filename); /*-------------------------------------------------------------------------*/ /** @brief Open a gzipped file in read-only mode as if uncompressed. @param name Name of the gzipped file to open. @return FILE pointer to the opened file. This function calls gzip through a named pipe to get the uncompressed bytes. This means that the 'gzip' command must be installed on the local system and available in the user's path. The received bytes are read-only and sequential. The returned FILE pointer corresponds to a non-seekable file because it is created by a popen() call. The returned FILE pointer must be closed using gzclose(). */ /*--------------------------------------------------------------------------*/ FILE * gzopen(char * name); /*-------------------------------------------------------------------------*/ /** @brief Close out named pipe associated to gzipped open file. @param p FILE pointer to close. @return void Calls pclose() on the given FILE pointer. */ /*--------------------------------------------------------------------------*/ void gzclose(FILE * p); #endif