libsent/src/util/gzfile.c File Reference

Read Compressed files using gzip or zlib. More...

#include <sent/stddefs.h>
#include <errno.h>
#include <zlib.h>

Go to the source code of this file.

Functions

FILE * fopen_readfile (char *filename)
 Open a file with zlib.
int fclose_readfile (FILE *fp)
 Close a file previously opened by fopen_readfile().
size_t myfread (void *ptr, size_t size, size_t n, FILE *fp)
 Read data from input stream opened by fopen_readfile().
int myfgetc (FILE *fp)
 Read one character from input stream opened by fopen_readfile().
int myfeof (FILE *fp)
 Test if reached end of file, for files opened by fopen_readfile().
int myfrewind (FILE *fp)
 Seek to the first of the file.
FILE * fopen_writefile (char *filename)
 Open or create a file for writing (no compression supported),.
int fclose_writefile (FILE *fp)
 Close file previously opened by open_writefile().
size_t myfwrite (void *ptr, size_t size, size_t n, FILE *fp)
 Write data.


Detailed Description

Read Compressed files using gzip or zlib.

These are functions to enable open/close/reading of gzipped files.

If zlib library and header are not found, the gzip executables will be used to uncompress the input file. In the latter case, opening multiple files with these functions is not allowed.

Author:
Akinobu LEE
Date:
Thu Feb 17 15:46:00 2005
Revision
1.1.1.1

Definition in file gzfile.c.


Function Documentation

FILE* fopen_readfile ( char *  filename  ) 

Open a file with zlib.

Parameters:
filename [in] file name to open
Returns:
gzFile pointer if succeed, NULL on failure.

Definition at line 55 of file gzfile.c.

Referenced by adin_file_open(), CMN_load_from_file(), init_dfa(), init_hmminfo(), init_ngram_arpa(), init_ngram_arpa_additional(), init_ngram_bin(), init_voca(), init_wordlist(), new_SS_load_from_file(), and rdparam().

int fclose_readfile ( FILE *  fp  ) 

Close a file previously opened by fopen_readfile().

Parameters:
fp [in] gzFile pointer
Returns:
0 on success, -1 on error.

Definition at line 73 of file gzfile.c.

Referenced by adin_file_close(), adin_file_open(), CMN_load_from_file(), init_dfa(), init_hmminfo(), init_ngram_arpa(), init_ngram_arpa_additional(), init_ngram_bin(), init_voca(), init_wordlist(), new_SS_load_from_file(), rdparam(), and setup_wav().

size_t myfread ( void *  ptr,
size_t  size,
size_t  n,
FILE *  fp 
)

Read data from input stream opened by fopen_readfile().

Parameters:
ptr [out] data buffer
size [in] size of unit in bytes
n [in] number of unit to be read
fp [in] gzFile pointer
Returns:
number of read units or EOF, -1 on error.

Definition at line 93 of file gzfile.c.

Referenced by adin_file_open(), adin_file_read(), adin_stdin_read(), myread(), and rdnfunc().

int myfgetc ( FILE *  fp  ) 

Read one character from input stream opened by fopen_readfile().

Parameters:
fp [in] gzFile pointer
Returns:
the read character, or -1 on EOF or error.

Definition at line 112 of file gzfile.c.

Referenced by rdn_strfunc().

int myfeof ( FILE *  fp  ) 

Test if reached end of file, for files opened by fopen_readfile().

Parameters:
fp [in] gzFile pointer.
Returns:
1 if already on EOF, 0 if otherwise.

Definition at line 127 of file gzfile.c.

Referenced by adin_file_read().

int myfrewind ( FILE *  fp  ) 

Seek to the first of the file.

Parameters:
fp [in] gzFile pointer.
Returns:
0 on success, -1 on error.

Definition at line 143 of file gzfile.c.

FILE* fopen_writefile ( char *  filename  ) 

Open or create a file for writing (no compression supported),.

Parameters:
filename [in] filename
Returns:
the file pointer or NULL on failure.

Definition at line 326 of file gzfile.c.

Referenced by wrwav_open().

int fclose_writefile ( FILE *  fp  ) 

Close file previously opened by open_writefile().

Parameters:
fp [in] file pointer
Returns:
0 on success, -1 on failure.

Definition at line 345 of file gzfile.c.

Referenced by wrwav_close().

size_t myfwrite ( void *  ptr,
size_t  size,
size_t  n,
FILE *  fp 
)

Write data.

Parameters:
ptr [in] data buffer
size [in] size of unit in bytes
n [in] number of unit to write
fp [in] file pointer
Returns:
the number of units successfully written, or 0 if EOF or failed.

Definition at line 364 of file gzfile.c.

Referenced by mywrite(), and wrtfunc().


Generated on Tue Dec 18 16:01:40 2007 for Julius by  doxygen 1.5.4