diff options
-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 |