/*-------------------------------------------------------------------------*/ /** @file compress_i.h @author N. Devillard @date Mar 2000 @version $Revision: 1.4 $ @brief Interface to files compressed with @c compress. This module enables to read files compressed with the @c compress Unix command (if available on the local system). It does not try to understand the file format, but accesses the file through a pipe to the @c compress command. */ /*--------------------------------------------------------------------------*/ /* $Id: compress_i.h,v 1.4 2001/10/17 10:29:01 ndevilla Exp $ $Author: ndevilla $ $Date: 2001/10/17 10:29:01 $ $Revision: 1.4 $ */ #ifndef _COMPRESS_I_H_ #define _COMPRESS_I_H_ /*--------------------------------------------------------------------------- Includes ---------------------------------------------------------------------------*/ #include #include #include /*--------------------------------------------------------------------------- Function ANSI prototypes ---------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/ /** @brief Find out if a given file name corresponds to a compress'd file. @param filename Name of the file to check out. @return 1 if the file is compress'd, 0 if not, -1 if error. This function finds out if a given character string is the name of a valid compressed file (a file compressed with the 'compress' command). 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 compress'd file is recognized by the fact that the first two bytes in the files are respectively 0x1f and 0x9d (magic number, according to compress documentation). */ /*--------------------------------------------------------------------------*/ int is_compressed_file(char * filename); /*-------------------------------------------------------------------------*/ /** @brief Open a compress'd file in read-only mode as if uncompressed. @param name Name of the compressed file to open. @return FILE pointer to the opened file. This function calls uncompress through a named pipe to get the uncompressed bytes. This means that the 'uncompress' 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 compress_close(). */ /*--------------------------------------------------------------------------*/ FILE * compress_open(char * name); /*-------------------------------------------------------------------------*/ /** @brief Close out named pipe associated to compressed open file. @param p FILE pointer to close. @return void Calls pclose() on the given FILE pointer. */ /*--------------------------------------------------------------------------*/ void compress_close(FILE * p); #endif