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>

Include dependency graph for gzfile.c:

Go to the source code of this file.

Functions

FILE * fopen_readfile (char *filename)
int fclose_readfile (FILE *fp)
size_t myfread (void *ptr, size_t size, size_t n, FILE *fp)
int myfgetc (FILE *fp)
int myfeof (FILE *fp)
int myfrewind (FILE *fp)
FILE * fopen_writefile (char *filename)
int fclose_writefile (FILE *fp)
size_t myfwrite (void *ptr, size_t size, size_t n, FILE *fp)


Detailed Description

Read Compressed files using gzip or zlib.

Author:
Akinobu LEE
Date:
Thu Feb 17 15:46:00 2005
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.

Revision
1.5

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 54 of file gzfile.c.

Referenced by adin_file_open(), CMN_load_from_file(), init_dfa(), init_hmminfo(), init_ngram_arpa(), init_ngram_bin(), init_voca(), 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 70 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_bin(), init_voca(), 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 90 of file gzfile.c.

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

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 109 of file gzfile.c.

Referenced by rdn_str().

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 124 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 140 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 341 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 360 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 379 of file gzfile.c.

Referenced by mywrite(), and wrt().


Generated on Tue Dec 26 16:18:19 2006 for Julius by  doxygen 1.5.0