diff options
author | Chris Apers | 2004-10-20 09:17:46 +0000 |
---|---|---|
committer | Chris Apers | 2004-10-20 09:17:46 +0000 |
commit | a635831b1f16214f6f4f83c33a4eb58d37cb587d (patch) | |
tree | b6014c84c46a4df6dd9189eed8dedefecf39f700 /backends/PalmOS | |
parent | 72df42e0475f6f32425ba0e969e1c1b5a7b21646 (diff) | |
download | scummvm-rg350-a635831b1f16214f6f4f83c33a4eb58d37cb587d.tar.gz scummvm-rg350-a635831b1f16214f6f4f83c33a4eb58d37cb587d.tar.bz2 scummvm-rg350-a635831b1f16214f6f4f83c33a4eb58d37cb587d.zip |
Added fgetc/getc function
svn-id: r15619
Diffstat (limited to 'backends/PalmOS')
-rw-r--r-- | backends/PalmOS/Src/missing/_stdio.cpp | 22 | ||||
-rw-r--r-- | backends/PalmOS/Src/missing/stdio.h | 4 |
2 files changed, 19 insertions, 7 deletions
diff --git a/backends/PalmOS/Src/missing/_stdio.cpp b/backends/PalmOS/Src/missing/_stdio.cpp index 9987084fd7..9f23cb301d 100644 --- a/backends/PalmOS/Src/missing/_stdio.cpp +++ b/backends/PalmOS/Src/missing/_stdio.cpp @@ -29,6 +29,8 @@ static UInt16 gStdioVolRefNum = sysInvalidRefNum; static void dummy(Boolean){}; +// TODO : implement "errno" + void StdioInit(UInt16 volRefNum, const Char *output, LedProc ledProc) { gStdioVolRefNum = volRefNum; @@ -37,7 +39,6 @@ void StdioInit(UInt16 volRefNum, const Char *output, LedProc ledProc) { else gStdioLedProc = dummy; - VFSFileDelete(gStdioVolRefNum, output); VFSFileCreate(gStdioVolRefNum, output); VFSFileOpen (gStdioVolRefNum, output,vfsModeWrite, &gStdioOutput); @@ -53,7 +54,7 @@ UInt16 fclose(FileRef *stream) { if (error == errNone) MemPtrFree(stream); -#ifdef DEBUG +#ifdef _DEBUG_STDIO FrmCustomAlert(FrmWarnAlert,"error fclose",0,0); #endif return error; @@ -62,7 +63,7 @@ UInt16 fclose(FileRef *stream) { UInt16 feof(FileRef *stream) { Err error = VFSFileEOF(*stream); -#ifdef DEBUG +#ifdef _DEBUG_STDIO switch (error) { case vfsErrFileEOF: @@ -86,6 +87,15 @@ UInt16 feof(FileRef *stream) { return error; } +Int16 fgetc(FileRef *stream) { + UInt32 numBytesRead; + Err e; + Char c; + + e = VFSFileRead(*stream, 1, &c, &numBytesRead); + return (int)(!e ? c : EOF); +} + Char *fgets(Char *s, UInt32 n, FileRef *stream) { UInt32 numBytesRead; gStdioLedProc(true); @@ -104,7 +114,7 @@ Char *fgets(Char *s, UInt32 n, FileRef *stream) { return s; } -#ifdef DEBUG +#ifdef _DEBUG_STDIO switch (error) { case expErrNotOpen: @@ -180,7 +190,7 @@ FileRef *fopen(const Char *filename, const Char *type) { } } -#ifdef DEBUG +#ifdef _DEBUG_STDIO else { switch (err) @@ -222,7 +232,7 @@ UInt32 fread(void *ptr, UInt32 size, UInt32 nitems, FileRef *stream) { if (error == errNone || error == vfsErrFileEOF) return (UInt32)(numBytesRead/size); -#ifdef DEBUG +#ifdef _DEBUG_STDIO switch (error) { case expErrNotOpen: diff --git a/backends/PalmOS/Src/missing/stdio.h b/backends/PalmOS/Src/missing/stdio.h index 393229c165..667a7dde69 100644 --- a/backends/PalmOS/Src/missing/stdio.h +++ b/backends/PalmOS/Src/missing/stdio.h @@ -41,6 +41,7 @@ typedef UInt32 size_t; #define clearerr(a) #define fflush(a) #define vsnprintf(a,b,c,d) vsprintf(a,c,d) +#define getc(a) fgetc(a) #define SEEK_SET vfsOriginBeginning #define SEEK_CUR vfsOriginCurrent @@ -49,6 +50,7 @@ typedef UInt32 size_t; UInt16 fclose (FileRef *stream); UInt16 feof (FileRef *stream); Char * fgets (Char *s, UInt32 n, FileRef *stream); +Int16 fgetc (FileRef *stream); FileRef * fopen (const Char *filename, const Char *type); UInt32 fread (void *ptr, UInt32 size, UInt32 nitems, FileRef *stream); UInt32 fwrite (const void *ptr, UInt32 size, UInt32 nitems, FileRef *stream); @@ -64,4 +66,4 @@ Int32 vsprintf(Char* s, const Char* formatStr, _Palm_va_list argParam); void StdioInit (UInt16 volRefNum, const Char *output, LedProc ledProc); void StdioRelease(); -#endif
\ No newline at end of file +#endif |