pstream.h

00001 /*---------------------------------------------------------------------------*
00002  *  pstream.h  *
00003  *                                                                           *
00004  *  Copyright 2007 Nuance Communciations, Inc.                               *
00005  *                                                                           *
00006  *  Licensed under the Apache License, Version 2.0 (the 'License');          *
00007  *  you may not use this file except in compliance with the License.         *
00008  *                                                                           *
00009  *  You may obtain a copy of the License at                                  *
00010  *      http://www.apache.org/licenses/LICENSE-2.0                           *
00011  *                                                                           *
00012  *  Unless required by applicable law or agreed to in writing, software      *
00013  *  distributed under the License is distributed on an 'AS IS' BASIS,        *
00014  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 
00015  *  See the License for the specific language governing permissions and      *
00016  *  limitations under the License.                                           *
00017  *                                                                           *
00018  *---------------------------------------------------------------------------*/
00019 
00020 
00021 
00022 #ifndef _PORTSTREAM_H_
00023 #define _PORTSTREAM_H_
00024 
00025 #ifdef __cplusplus
00026 extern "C"
00027 {
00028 #endif
00029 
00030 #include <stdio.h>
00031 #include "ptypes.h"
00032 
00033 #ifdef PFILE_VIRTUAL_SUPPORT
00034 
00035   struct FileBufferFrame;
00036   typedef struct PORT_FILE_HANDLE
00037   {
00038     const char              *filename;
00039     struct FileBufferFrame  *startFrame;
00040     struct FileBufferFrame  *endFrame;
00041     struct FileBufferFrame  *curFrame;  /* current buffer; useful for writable file */
00042     const unsigned char     *curPos;
00043     const unsigned char     *endPos;
00044     unsigned int            size;       /* total buffer size; useful for writable file */
00045     unsigned int            frame_size; /* buffer size in current frame; useful for writable file */
00046     int                     eof;
00047     int                     mode;      /* 0 readonly text; 1 readonly binary; 2 writable text; 3 writalbe binary */
00048   }
00049   PORT_FILE_HANDLE;
00050   
00051   typedef PORT_FILE_HANDLE* PORT_FILE;
00052   
00053   typedef struct _FileRecord
00054   {
00055     char name[80];
00056     unsigned char *start;
00057     int end;              /* offset of the end of the file */
00058     int size;             /* total buffer size */
00059     int mode;
00060   }
00061   FileRecord;
00062   
00063   typedef struct VirtualFileTable_t
00064   {
00065     const FileRecord* pFileTable;
00066     const unsigned char* pFirstFile;
00067   }
00068   VirtualFileTable;
00069   
00070   /* Function prototypes */
00071   PORTABLE_API void    PortFileInit(void);
00072   PORTABLE_API PORT_FILE PortFopen(const char* filename, const char* mode);
00073   PORTABLE_API int   PortFclose(PORT_FILE PortFile);
00074   PORTABLE_API size_t  PortFread(void* buffer, size_t size, size_t count, PORT_FILE PortFile);
00075   PORTABLE_API size_t  PortFwrite(const void* buffer, size_t size, size_t count, PORT_FILE PortFile);
00076   PORTABLE_API int   PortFseek(PORT_FILE PortFile, long offset, int origin);
00077   PORTABLE_API long    PortFtell(PORT_FILE PortFile);
00078   PORTABLE_API int   PortFprintf(PORT_FILE PortFile, const char* format, ...);
00079   PORTABLE_API char*  PortFgets(char* string, int n, PORT_FILE PortFile);
00080   PORTABLE_API int   PortFflush(PORT_FILE PortFile);
00081   PORTABLE_API int   PortFeof(PORT_FILE PortFile);
00082   PORTABLE_API int   PortFgetc(PORT_FILE PortFile);
00083   PORTABLE_API int   PortFscanf(PORT_FILE PortFile, const char *format, ...);
00084   PORTABLE_API int   PortFerror(PORT_FILE PortFile);
00085   PORTABLE_API void   PortClearerr(PORT_FILE PortFile);
00086   PORTABLE_API void    PortRewind(PORT_FILE PortFile);
00087   PORTABLE_API PORT_FILE PortFreopen(const char *path, const char *mode, PORT_FILE PortFile);
00088   PORTABLE_API char*    PortGetcwd(char *buffer, int maxlen);
00089   PORTABLE_API int      PortMkdir(const char *dirname);
00090   
00091   /* this function is to create a file with the limit size */
00092   PORTABLE_API int      PortFcreate(const char *fname, void *pBuffer, int size);
00093   PORTABLE_API void     PortFdelete(const char *fname);
00094   
00095   PORTABLE_API void     PortSetFileTable(const FileRecord* pFileTable, const unsigned char* pFirstFile);
00096   
00097   void     SetFileTable(VirtualFileTable *table);
00098   
00099 #endif /* #ifdef PFILE_VIRTUAL_SUPPORT */
00100   
00101 #ifdef __cplusplus
00102 }
00103 #endif
00104 
00105 #endif /* _PORTSTREAM_H */

Generated on Thu May 1 15:37:25 2008 for SREC by  doxygen 1.5.3