Go to the documentation of this file.
82 #ifndef _LIBUTIL_IO_H_
83 #define _LIBUTIL_IO_H_
86 #if !defined(_WIN32_WCE) && !(defined(__ADSPBLACKFIN__) && !defined(__linux__))
91 #include <sphinxbase/sphinxbase_export.h>
146 FILE *
_myfopen(
const char *file,
const char *mode,
147 const char *pgm, int32 line);
148 #define myfopen(file,mode) _myfopen((file),(mode),__FILE__,__LINE__)
159 int32
fread_retry(
void *pointer, int32 size, int32 num_items, FILE *stream);
172 char *
fread_line(FILE *stream,
size_t *out_len);
226 #if defined(__ADSPBLACKFIN__) && !defined(__linux__)
281 int32
stat_retry (
const char *file,
struct stat *statbuf);
int bit_encode_write(bit_encode_t *be, unsigned char const *bits, int nbits)
Write bits to encoder.
SPHINXBASE_EXPORT lineiter_t * lineiter_start(FILE *fh)
Start reading lines from a file.
Basic type definitions used in Sphinx.
bit_encode_t * bit_encode_retain(bit_encode_t *be)
Retain pointer to a bit encoder.
bit_encode_t * bit_encode_attach(FILE *outfh)
Attach bitstream encoder to a file.
SPHINXBASE_EXPORT FILE * _myfopen(const char *file, const char *mode, const char *pgm, int32 line)
Wrapper around fopen to check for failure and E_FATAL if failed.
SPHINXBASE_EXPORT lineiter_t * lineiter_start_clean(FILE *fh)
Start reading lines from a file, skip comments and trim lines.
SPHINXBASE_EXPORT int32 stat_retry(const char *file, struct stat *statbuf)
There is no bitstream decoder, because a stream abstraction is too slow.
SPHINXBASE_EXPORT char * fread_line(FILE *stream, size_t *out_len)
Read a line of arbitrary length from a file and return it as a newly allocated string.
int bit_encode_write_cw(bit_encode_t *be, uint32 codeword, int nbits)
Write lowest-order bits of codeword to encoder.
SPHINXBASE_EXPORT int32 stat_mtime(const char *file)
Return time of last modification for the given file, or -1 if stat fails.
struct lineiter_t lineiter_t
Line iterator for files.
int bit_encode_flush(bit_encode_t *be)
Flush any unwritten bits, zero-padding if necessary.
SPHINXBASE_EXPORT int lineiter_lineno(lineiter_t *li)
Returns current line number.
int bit_encode_free(bit_encode_t *be)
Release pointer to a bit encoder.
SPHINXBASE_EXPORT lineiter_t * lineiter_next(lineiter_t *li)
Move to the next line in the file.
SPHINXBASE_EXPORT void lineiter_free(lineiter_t *li)
Stop reading lines from a file.
SPHINXBASE_EXPORT int build_directory(const char *path)
Create a directory and all of its parent directories, as needed.
SPHINXBASE_EXPORT FILE * fopen_comp(const char *file, const char *mode, int32 *ispipe)
Like fopen, but use popen and zcat if it is determined that "file" is compressed (i....
SPHINXBASE_EXPORT int32 fread_retry(void *pointer, int32 size, int32 num_items, FILE *stream)
NFS file reads seem to fail now and then.
SPHINXBASE_EXPORT void fclose_comp(FILE *fp, int32 ispipe)
Close a file opened using fopen_comp.
SPHINXBASE_EXPORT FILE * fopen_compchk(const char *file, int32 *ispipe)
Open a file for reading, but if file not present try to open compressed version (if file is uncompres...