SphinxBase
0.6
|
00001 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 00002 /* ==================================================================== 00003 * Copyright (c) 1999-2004 Carnegie Mellon University. All rights 00004 * reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions 00008 * are met: 00009 * 00010 * 1. Redistributions of source code must retain the above copyright 00011 * notice, this list of conditions and the following disclaimer. 00012 * 00013 * 2. Redistributions in binary form must reproduce the above copyright 00014 * notice, this list of conditions and the following disclaimer in 00015 * the documentation and/or other materials provided with the 00016 * distribution. 00017 * 00018 * This work was supported in part by funding from the Defense Advanced 00019 * Research Projects Agency and the National Science Foundation of the 00020 * United States of America, and the CMU Sphinx Speech Consortium. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 00023 * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 00024 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00025 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 00026 * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00027 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00028 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00029 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00030 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00031 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00032 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00033 * 00034 * ==================================================================== 00035 * 00036 */ 00037 /* 00038 * pio.h -- Packaged I/O routines. 00039 * 00040 * ********************************************** 00041 * CMU ARPA Speech Project 00042 * 00043 * Copyright (c) 1999 Carnegie Mellon University. 00044 * ALL RIGHTS RESERVED. 00045 * ********************************************** 00046 * 00047 * HISTORY 00048 * $Log: pio.h,v $ 00049 * Revision 1.3 2005/06/22 08:00:09 arthchan2003 00050 * Completed all doxygen documentation on file description for libs3decoder/libutil/libs3audio and programs. 00051 * 00052 * Revision 1.2 2005/06/22 03:09:52 arthchan2003 00053 * 1, Fixed doxygen documentation, 2, Added keyword. 00054 * 00055 * Revision 1.2 2005/06/16 00:14:08 archan 00056 * Added const keyword to file argument for file_open 00057 * 00058 * Revision 1.1 2005/06/15 06:11:03 archan 00059 * sphinx3 to s3.generic: change io.[ch] to pio.[ch] 00060 * 00061 * Revision 1.5 2005/06/15 04:21:46 archan 00062 * 1, Fixed doxygen-documentation, 2, Add keyword such that changes will be logged into a file. 00063 * 00064 * Revision 1.4 2005/04/20 03:49:32 archan 00065 * Add const to string argument of myfopen. 00066 * 00067 * Revision 1.3 2005/03/30 01:22:48 archan 00068 * Fixed mistakes in last updates. Add 00069 * 00070 * 00071 * 08-Dec-1999 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University 00072 * Added stat_mtime(). 00073 * 00074 * 11-Mar-1999 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University 00075 * Added _myfopen() and myfopen macro. 00076 * 00077 * 05-Sep-97 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University 00078 * Started. 00079 */ 00080 00081 00082 #ifndef _LIBUTIL_IO_H_ 00083 #define _LIBUTIL_IO_H_ 00084 00085 #include <stdio.h> 00086 #if !defined(_WIN32_WCE) && !(defined(__ADSPBLACKFIN__) && !defined(__linux__)) 00087 #include <sys/stat.h> 00088 #endif 00089 00090 /* Win32/WinCE DLL gunk */ 00091 #include <sphinxbase/sphinxbase_export.h> 00092 #include <sphinxbase/prim_type.h> 00093 00104 #ifdef __cplusplus 00105 extern "C" { 00106 #endif 00107 #if 0 00108 /* Fool Emacs. */ 00109 } 00110 #endif 00111 00116 SPHINXBASE_EXPORT 00117 FILE *fopen_comp (const char *file, 00118 const char *mode, 00119 int32 *ispipe 00121 ); 00122 00126 SPHINXBASE_EXPORT 00127 void fclose_comp (FILE *fp, 00128 int32 ispipe 00130 ); 00131 00136 SPHINXBASE_EXPORT 00137 FILE *fopen_compchk (const char *file, 00138 int32 *ispipe 00140 ); 00141 00145 SPHINXBASE_EXPORT 00146 FILE *_myfopen(const char *file, const char *mode, 00147 const char *pgm, int32 line); /* In: __FILE__, __LINE__ from where called */ 00148 #define myfopen(file,mode) _myfopen((file),(mode),__FILE__,__LINE__) 00149 00150 00158 SPHINXBASE_EXPORT 00159 int32 fread_retry(void *pointer, int32 size, int32 num_items, FILE *stream); 00160 00171 SPHINXBASE_EXPORT 00172 char *fread_line(FILE *stream, size_t *out_len); 00173 00177 typedef struct lineiter_t { 00178 char *buf; 00179 size_t bsiz; 00180 size_t len; 00181 FILE *fh; 00182 } lineiter_t; 00183 00187 SPHINXBASE_EXPORT 00188 lineiter_t *lineiter_start(FILE *fh); 00189 00193 SPHINXBASE_EXPORT 00194 lineiter_t *lineiter_next(lineiter_t *li); 00195 00199 SPHINXBASE_EXPORT 00200 void lineiter_free(lineiter_t *li); 00201 00202 00203 #ifdef _WIN32_WCE 00204 /* Fake this for WinCE which has no stat() */ 00205 #include <windows.h> 00206 struct stat { 00207 DWORD st_mtime; 00208 DWORD st_size; 00209 }; 00210 #endif /* _WIN32_WCE */ 00211 00212 #if defined(__ADSPBLACKFIN__) && !defined(__linux__) 00213 struct stat { 00214 int32 st_mtime; 00215 int32 st_size; 00216 }; 00217 00218 #endif 00219 00223 typedef struct bit_encode_s bit_encode_t; 00224 00228 bit_encode_t *bit_encode_attach(FILE *outfh); 00229 00233 bit_encode_t *bit_encode_retain(bit_encode_t *be); 00234 00240 int bit_encode_free(bit_encode_t *be); 00241 00245 int bit_encode_write(bit_encode_t *be, unsigned char const *bits, int nbits); 00246 00250 int bit_encode_write_cw(bit_encode_t *be, uint32 codeword, int nbits); 00251 00255 int bit_encode_flush(bit_encode_t *be); 00256 00266 SPHINXBASE_EXPORT 00267 int32 stat_retry (const char *file, struct stat *statbuf); 00268 00273 SPHINXBASE_EXPORT 00274 int32 stat_mtime (const char *file); 00275 00281 SPHINXBASE_EXPORT 00282 int build_directory(const char *path); 00283 00284 #ifdef __cplusplus 00285 } 00286 #endif 00287 00288 #endif