diff options
author | Max Horn | 2003-04-30 11:37:10 +0000 |
---|---|---|
committer | Max Horn | 2003-04-30 11:37:10 +0000 |
commit | 42f156ddada4c6f51e1612e9b0f18ec7c9dd9cee (patch) | |
tree | a2b7ba14f7f919987239902e513c1a646ca2e9f8 /backends/PalmOS/Src/missing | |
parent | 79ebda7613b3280ae644d67af50712deef8819d7 (diff) | |
download | scummvm-rg350-42f156ddada4c6f51e1612e9b0f18ec7c9dd9cee.tar.gz scummvm-rg350-42f156ddada4c6f51e1612e9b0f18ec7c9dd9cee.tar.bz2 scummvm-rg350-42f156ddada4c6f51e1612e9b0f18ec7c9dd9cee.zip |
started to merge in Chrilith's PalmOS port
svn-id: r7219
Diffstat (limited to 'backends/PalmOS/Src/missing')
-rw-r--r-- | backends/PalmOS/Src/missing/_stdio.cpp | 344 | ||||
-rw-r--r-- | backends/PalmOS/Src/missing/_stdlib.cpp | 213 | ||||
-rw-r--r-- | backends/PalmOS/Src/missing/_string.cpp | 86 | ||||
-rw-r--r-- | backends/PalmOS/Src/missing/_time.cpp | 38 | ||||
-rw-r--r-- | backends/PalmOS/Src/missing/_unistd.cpp | 14 | ||||
-rw-r--r-- | backends/PalmOS/Src/missing/assert.h | 1 | ||||
-rw-r--r-- | backends/PalmOS/Src/missing/fcntl.h | 1 | ||||
-rw-r--r-- | backends/PalmOS/Src/missing/math.h | 1 | ||||
-rw-r--r-- | backends/PalmOS/Src/missing/stdio.h | 34 | ||||
-rw-r--r-- | backends/PalmOS/Src/missing/stdlib.h | 38 | ||||
-rw-r--r-- | backends/PalmOS/Src/missing/string.h | 22 | ||||
-rw-r--r-- | backends/PalmOS/Src/missing/sys/stat.h | 1 | ||||
-rw-r--r-- | backends/PalmOS/Src/missing/time.h | 18 | ||||
-rw-r--r-- | backends/PalmOS/Src/missing/unistd.h | 3 |
14 files changed, 814 insertions, 0 deletions
diff --git a/backends/PalmOS/Src/missing/_stdio.cpp b/backends/PalmOS/Src/missing/_stdio.cpp new file mode 100644 index 0000000000..5d22b04bbc --- /dev/null +++ b/backends/PalmOS/Src/missing/_stdio.cpp @@ -0,0 +1,344 @@ +#include "stdio.h" +#include "extend.h" +/////////////////////////////////////////////////////////////////////////////// +//FileRef gLogFile; + +static void DrawStatus(Boolean show) +{ + UInt8 x,y; + UInt8 *screen = (UInt8 *)(BmpGetBits(WinGetBitmap(WinGetDisplayWindow()))); + UInt8 color = (show? gVars->indicator.on : gVars->indicator.off); + + if (gVars->screenLocked) + if (screen == gVars->flipping.pageAddr1) + screen = gVars->flipping.pageAddr2; + else + screen = gVars->flipping.pageAddr1; + + screen += 320 + 305; + for(y=0;y<3;y++) + { + for(x=0;x<14;x++) + screen[x] = color; + screen += 319; + } +} +/////////////////////////////////////////////////////////////////////////////// +UInt16 fclose(FileRef *stream) +{ + Err error = VFSFileClose(*stream); + + if (error == errNone) + MemPtrFree(stream); + +#ifdef DEBUG + FrmCustomAlert(FrmWarnAlert,"error fclose",0,0); +#endif + return error; +} +/////////////////////////////////////////////////////////////////////////////// +UInt16 feof(FileRef *stream) +{ + Err error = VFSFileEOF(*stream); + +#ifdef DEBUG + switch (error) + { + case vfsErrFileEOF: + FrmCustomAlert(FrmWarnAlert,"vfsErrFileEOF",0,0); + break; + case expErrNotOpen: + FrmCustomAlert(FrmWarnAlert,"expErrNotOpen",0,0); + break; + case vfsErrFileBadRef: + FrmCustomAlert(FrmWarnAlert,"vfsErrFileBadRef",0,0); + break; + case vfsErrIsADirectory: + FrmCustomAlert(FrmWarnAlert,"vfsErrIsADirectory",0,0); + break; + case vfsErrNoFileSystem: + FrmCustomAlert(FrmWarnAlert,"vfsErrNoFileSystem",0,0); + break; + } +#endif + + return error; +} +/////////////////////////////////////////////////////////////////////////////// +Char *fgets(Char *s, UInt32 n, FileRef *stream) +{ + UInt32 numBytesRead; + DrawStatus(true); + Err error = VFSFileRead(*stream, n, s, &numBytesRead); + DrawStatus(false); + if (error == errNone || error == vfsErrFileEOF) { + UInt32 reset = 0; + Char *endLine = StrChr(s, '\n'); + + if (endLine >= s) { + reset = (endLine - s); + s[reset] = 0; + reset = numBytesRead - (reset + 1); + VFSFileSeek(*stream, vfsOriginCurrent, -reset); + } + + return s; + } +#ifdef DEBUG + switch (error) + { + case expErrNotOpen: + FrmCustomAlert(FrmWarnAlert,"expErrNotOpen",0,0); + break; + case vfsErrFileBadRef: + FrmCustomAlert(FrmWarnAlert,"vfsErrFileBadRef",0,0); + break; + case vfsErrFileEOF: + FrmCustomAlert(FrmWarnAlert,"vfsErrFileEOF",0,0); + break; + case vfsErrFilePermissionDenied: + FrmCustomAlert(FrmWarnAlert,"vfsErrFilePermissionDenied",0,0); + break; + case vfsErrIsADirectory: + FrmCustomAlert(FrmWarnAlert,"vfsErrIsADirectory",0,0); + break; + case vfsErrNoFileSystem: + FrmCustomAlert(FrmWarnAlert,"vfsErrNoFileSystem",0,0); + break; + } +#endif + + return NULL; +} +/////////////////////////////////////////////////////////////////////////////// +FileRef *fopen(const Char *filename, const Char *type) +{ + Err err; + UInt16 openMode; + FileRef *fileRefP = (FileRef *)MemPtrNew(sizeof(FileRef *)); + + if (StrCompare(type,"r")==0) + openMode = vfsModeRead; + else if (StrCompare(type,"rb")==0) + openMode = vfsModeRead; + else if (StrCompare(type,"w")==0) + openMode = vfsModeCreate|vfsModeWrite; + else if (StrCompare(type,"wb")==0) + openMode = vfsModeCreate|vfsModeWrite; + else + openMode = vfsModeReadWrite; + + if (openMode & vfsModeRead) { + // if read file : + // first try to load from the specfied card + err = VFSFileOpen (gVars->volRefNum, filename, openMode, fileRefP); + //if err (not found ?) parse each avalaible card for the specified file + if (err) { + UInt16 volRefNum; + UInt32 volIterator = vfsIteratorStart; + while (volIterator != vfsIteratorStop) { + err = VFSVolumeEnumerate(&volRefNum, &volIterator); + + if (!err) { + err = VFSFileOpen (volRefNum, filename, openMode, fileRefP); + if (!err) + return fileRefP; + } + } + } else { + return fileRefP; + } + } else { + // if write file : + // use only the specified card + // FIXME : vfsModeCreate|vfsModeWrite will failed on OS3.5 Clié + err = VFSFileDelete(gVars->volRefNum, filename); // delete it if exists + err = VFSFileCreate(gVars->volRefNum, filename); + openMode = vfsModeWrite; + if (!err) { + err = VFSFileOpen (gVars->volRefNum, filename, openMode, fileRefP); + if (!err) + return fileRefP; + } + } + +#ifdef DEBUG + else + { + switch (err) + { + case expErrCardReadOnly: + FrmCustomAlert(FrmWarnAlert,"expErrCardReadOnly",0,0); + break; + case expErrNotOpen: + FrmCustomAlert(FrmWarnAlert,"expErrNotOpen",0,0); + break; + case vfsErrBadName: + FrmCustomAlert(FrmWarnAlert,"vfsErrBadName",0,0); + break; + case vfsErrFileNotFound: + FrmCustomAlert(FrmWarnAlert,"vfsErrFileNotFound",0,0); + break; + case vfsErrFilePermissionDenied: + FrmCustomAlert(FrmWarnAlert,"vfsErrFilePermissionDenied",0,0); + break; + case vfsErrVolumeBadRef: + FrmCustomAlert(FrmWarnAlert,"vfsErrVolumeBadRef",0,0); + break; + default: + FrmCustomAlert(FrmWarnAlert,"unknow",0,0); + break; + } + } +#endif + + MemPtrFree(fileRefP); // prevent memory leak + return NULL; +} +/////////////////////////////////////////////////////////////////////////////// +UInt32 fread(void *ptr, UInt32 size, UInt32 nitems, FileRef *stream) +{ + UInt32 numBytesRead; + DrawStatus(true); + Err error = VFSFileRead(*stream, size*nitems, ptr, &numBytesRead); + DrawStatus(false); + if (error == errNone || error == vfsErrFileEOF) + return (UInt32)(numBytesRead/size); + +#ifdef DEBUG + switch (error) + { + case expErrNotOpen: + FrmCustomAlert(FrmWarn,"expErrNotOpen",0,0); + break; + case vfsErrFileBadRef: + FrmCustomAlert(FrmWarn,"vfsErrFileBadRef",0,0); + break; + case vfsErrFileEOF: + FrmCustomAlert(FrmWarn,"vfsErrFileEOF",0,0); + break; + case vfsErrFilePermissionDenied: + FrmCustomAlert(FrmWarn,"vfsErrFilePermissionDenied",0,0); + break; + case vfsErrIsADirectory: + FrmCustomAlert(FrmWarn,"vfsErrIsADirectory",0,0); + break; + case vfsErrNoFileSystem: + FrmCustomAlert(FrmWarn,"vfsErrNoFileSystem",0,0); + break; + } +#endif + return 0; +} +/////////////////////////////////////////////////////////////////////////////// +UInt32 fwrite(const void *ptr, UInt32 size, UInt32 nitems, FileRef *stream) +{ + UInt32 numBytesWritten; + DrawStatus(true); + Err error = VFSFileWrite(*stream, size*nitems, ptr, &numBytesWritten); + DrawStatus(false); + + if (error == errNone || error == vfsErrFileEOF) + return (UInt32)(numBytesWritten/size); + + return NULL; +} +/////////////////////////////////////////////////////////////////////////////// +Int32 fseek(FileRef *stream, Int32 offset, Int32 whence) +{ + Err error = VFSFileSeek(*stream, whence, offset); + return error; +} +/////////////////////////////////////////////////////////////////////////////// +UInt32 ftell(FileRef *stream) +{ + Err e; + UInt32 filePos; + + e = VFSFileTell(*stream,&filePos); + if (e != errNone) + return e; + + return filePos; +} +/////////////////////////////////////////////////////////////////////////////// +UInt16 fprintf(FileRef *stream, const Char *format, ...) +{ + if (!*stream) + return 0; + + UInt32 numBytesWritten; + Char buf[256]; + va_list va; + + va_start(va, format); + vsprintf(buf, format, va); + va_end(va); + + VFSFileWrite (*stream, StrLen(buf), buf, &numBytesWritten); + return numBytesWritten; +} +/////////////////////////////////////////////////////////////////////////////// +Int16 printf(const Char *format, ...) +{ + if (!*stdout) + return 0; + + UInt32 numBytesWritten; + Char buf[256]; +// Char *buf = (Char *)MemPtrNew(256); + va_list va; + + va_start(va, format); + vsprintf(buf, format, va); + va_end(va); + + VFSFileWrite (*stdout, StrLen(buf), buf, &numBytesWritten); +// MemPtrFree(buf); + return numBytesWritten; +} +/////////////////////////////////////////////////////////////////////////////// +Int16 sprintf(Char* s, const Char* formatStr, ...) +{ + Char buf[256]; +// Char *buf = (Char *)MemPtrNew(256); + Int16 count; + va_list va; + + va_start(va, formatStr); + count = vsprintf(buf, formatStr, va); + va_end(va); + + StrCopy(s,buf); +// MemPtrFree(buf); + return count; +} +/////////////////////////////////////////////////////////////////////////////// +Int16 vsprintf(Char* s, const Char* formatStr, _Palm_va_list argParam) +{ + Char format[256]; + // TODO : need a better modifier + StrCopy(format,formatStr); + StrReplace(format, 256, "%ld", "%d"); + StrReplace(format, 256, "%li", "%i"); + StrReplace(format, 256, "%lx", "%x"); + StrReplace(format, 256, "%lx", "%X"); + StrReplace(format, 256, "%2ld", "%2d"); + StrReplace(format, 256, "%03ld","%.3d"); + StrReplace(format, 256, "%02ld","%.2d"); + StrReplace(format, 256, "%01ld","%.1d"); + StrReplace(format, 256, "%02ld","%02d"); + + StrReplace(format, 256, "%2ld","%2d"); + StrReplace(format, 256, "%3ld","%3d"); + StrReplace(format, 256, "%4ld","%4d"); + StrReplace(format, 256, "%5ld","%5d"); + StrReplace(format, 256, "%6ld","%6d"); + StrReplace(format, 256, "%02lx","%02x"); + + return StrVPrintF(s, format, argParam);; +} +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// diff --git a/backends/PalmOS/Src/missing/_stdlib.cpp b/backends/PalmOS/Src/missing/_stdlib.cpp new file mode 100644 index 0000000000..916987a5ca --- /dev/null +++ b/backends/PalmOS/Src/missing/_stdlib.cpp @@ -0,0 +1,213 @@ +#include "stdlib.h" +#include "MemGlue.h" +/////////////////////////////////////////////////////////////////////////////// +/*void qsort(void *base, UInt32 nmemb, UInt32 size, ComparF *compar) { + + SysQSort(base, nmemb, size, compar); +}*/ +/////////////////////////////////////////////////////////////////////////////// +void *bsearch(const void *key, const void *base, UInt32 nmemb, + UInt32 size, int (*compar)(const void *, const void *)) { + UInt32 i; + + for (i=0; i<nmemb; i++) + if (compar(key, (void*)((UInt32)base + size * i)) == 0) + return (void*)((UInt32)base + size * i); + return NULL; +} +/////////////////////////////////////////////////////////////////////////////// +static DmOpenRef gExtMemory = NULL; + +static UInt16 MemFindHeapID(UInt32 size) +{ + UInt32 nFree, maxChunk ; + UInt16 maxCards = 1; //MemNumCards(); process only first card for now + UInt16 heapID = -1; // no heap avaliable + + UInt16 cardNo; + UInt16 maxHeaps, heapIndex; + + for (cardNo = 0; cardNo < maxCards; cardNo++) + { + if (MemNumRAMHeaps(cardNo) > 0) + { + maxHeaps = MemNumHeaps(cardNo); + for (heapIndex = 0; heapIndex < maxHeaps; heapIndex++) + { + // Obtain the ID of the heap. + heapID = MemHeapID(cardNo, heapIndex); + + if (!(MemHeapFlags(heapID) & memHeapFlagReadOnly)) + { + MemHeapFreeBytes( heapID, &nFree, &maxChunk ); + if (maxChunk > size) + return heapID; + } + } + } + } + + return heapID; +} + +void MemExtInit() +{ + if (!gExtMemory) + { + LocalID localID = DmFindDatabase(0, "ScummVM-Memory"); + if (localID) DmDeleteDatabase(0, localID); + + if (DmCreateDatabase (0, "ScummVM-Memory", 'ScVM', 'DATA', false) != errNone) + return; + + localID = DmFindDatabase(0, "ScummVM-Memory"); + gExtMemory = DmOpenDatabase(0, localID, dmModeReadWrite|dmModeExclusive); + } +} + +void MemExtCleanup() +{ + if (gExtMemory) { + DmCloseDatabase(gExtMemory); + LocalID localID = DmFindDatabase(0, "ScummVM-Memory"); + if (localID) + DmDeleteDatabase(0, localID); + } +} +//#define USE_EXTENDEDMEM +#ifdef USE_EXTENDEDMEM + +MemPtr calloc(UInt32 nelem, UInt32 elsize) +{ + UInt32 size = nelem*elsize; + MemPtr newP = NULL; + UInt16 heapID = MemFindHeapID(size); + + if (heapID != NO_HEAP_FOUND) + { + if (MemHeapDynamic(heapID) && size < 65536-8) // 8 = chunk header size + newP = MemPtrNew(size); + else + { + SysAppInfoPtr appInfoP; + UInt16 ownerID, large, nmovable; + UInt16 attr; + + ownerID = ((SysAppInfoPtr)SysGetAppInfo(&appInfoP, &appInfoP))->memOwnerID; + large = ((size > 65536-8) ? memNewChunkFlagAllowLarge : 0); + nmovable= (MemHeapDynamic(heapID) ? memNewChunkFlagNonMovable : memNewChunkFlagPreLock); + attr = ownerID|large|nmovable; + + //MEMORY_RESERVE_ACCESS + newP = MemChunkNew(heapID, size, attr); + //MEMORY_RELEASE_ACCESS + + if (newP && MemPtrDataStorage(newP)) { // if storage heap ? + if (!gExtMemory) { // if memory DB doesn't exist + MemChunkFree(newP); + return NULL; + } + + UInt16 index = dmMaxRecordIndex; // used for record purpose + MemHandle newH = MemPtrRecoverHandle(newP); // exists + if (DmAttachRecord(gExtMemory, &index, newH, NULL) != errNone) // attach to DB + { + MemChunkFree(newP); // error + return NULL; + } + } + } + } + + if (newP) + MemSet(newP,size,0); + + return newP; +} + +#else + +MemPtr calloc(UInt32 nelem, UInt32 elsize) +{ + UInt32 size = nelem*elsize; + MemPtr newP = NULL; + +/* if (size < 65536-8) // 8 = chunk header size + newP = MemPtrNew(size); + else*/ +/* { + SysAppInfoPtr appInfoP; + UInt16 ownerID; + UInt16 attr; + + ownerID = ((SysAppInfoPtr)SysGetAppInfo(&appInfoP, &appInfoP))->memOwnerID; + attr = ownerID|memNewChunkFlagAllowLarge|memNewChunkFlagNonMovable; + + newP = MemChunkNew(0, size, attr); + } +*/ + newP = MemGluePtrNew(size); + + if (newP) + MemSet(newP,size,0); + + return newP; +} + +#endif +/////////////////////////////////////////////////////////////////////////////// +#ifdef USE_EXTENDEDMEM +Err free(MemPtr memP) +{ + Err err = memErrInvalidParam; + + if (!memP) + return err; + + if (MemPtrDataStorage(memP)) { // if storage heap ? + if (gExtMemory) { // if memory DB exists + DmOpenRef where; + MemHandle newH = MemPtrRecoverHandle(memP); + UInt16 index = DmSearchRecord(newH, &where); + err = DmRemoveRecord(gExtMemory, index); + } + } + else + err = MemChunkFree(memP); + + return err; +} +#else +Err free(MemPtr memP) +{ + if (memP) + return MemPtrFree(memP); + + return memErrInvalidParam; +} +#endif +/////////////////////////////////////////////////////////////////////////////// +MemPtr realloc(MemPtr oldP, UInt32 size) +{ + + if (oldP != NULL) + if (MemPtrResize(oldP,size) == 0) + return oldP; + + MemPtr newP = MemPtrNew(size); + + if (oldP!=NULL) + { + MemMove(newP,oldP,MemPtrSize(oldP)); + MemPtrFree(oldP); + } + return newP; +} +/////////////////////////////////////////////////////////////////////////////// +void exit(Int16 status) +{ + // need to change this + EventType event; + event.eType = appStopEvent; + EvtAddEventToQueue (&event); +}
\ No newline at end of file diff --git a/backends/PalmOS/Src/missing/_string.cpp b/backends/PalmOS/Src/missing/_string.cpp new file mode 100644 index 0000000000..6f7ed9bb77 --- /dev/null +++ b/backends/PalmOS/Src/missing/_string.cpp @@ -0,0 +1,86 @@ +#include "string.h" + +Char *StrTokNext; +/////////////////////////////////////////////////////////////////////////////// +Char *strtok(Char *str, const Char *sep) +{ + Char *position = NULL, + *found, + *end; + + UInt16 loop = 0, + chars= StrLen(sep); + + str = (str)?(str):(StrTokNext); + StrTokNext = NULL; + + if (!str) + return NULL; + + end = str+StrLen(str); + + while (loop<chars) + { + found = StrChr(str,sep[loop]); + loop++; + + if (found == str) + { + str++; + loop = 0; + } + else if (position == NULL || position > found) + position = found; + } + + if (position == NULL) + if (str==end) + return NULL; + else + return str; + + position[0] = 0; + StrTokNext = position+1; + + return str; +} +/////////////////////////////////////////////////////////////////////////////// +Char *strpbrk(const Char *s1, const Char *s2) +{ + Char *found; + UInt32 n; + + for (n=0; n <= StrLen(s2); n++) { + found = StrChr(s1, s2[n]); + if (found) + return found; + } + + return NULL; +} +/////////////////////////////////////////////////////////////////////////////// +Char *strrchr(const Char *s, int c) +{ + UInt32 chr; + UInt32 n = StrLen(s); + + for(chr = n; chr >= 0; chr--) + if ( *((UInt8 *)s+chr) == c) + return (Char *)(s+chr); + + return NULL; +} +/////////////////////////////////////////////////////////////////////////////// +Char *strdup(const Char *s1) +{ + Char* buf = (Char *)MemPtrNew(StrLen(s1)+1); + + if(buf) + StrCopy(buf, s1); + + return buf; +} +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// diff --git a/backends/PalmOS/Src/missing/_time.cpp b/backends/PalmOS/Src/missing/_time.cpp new file mode 100644 index 0000000000..afac9bce10 --- /dev/null +++ b/backends/PalmOS/Src/missing/_time.cpp @@ -0,0 +1,38 @@ +#include "time.h" + +// ignore GMT, only device time + +time_t time(time_t *tloc) { + UInt32 secs = TimGetSeconds(); // since 1/1/1904 12AM. + DateTimeType Epoch = {0, 0, 0, 1, 1, 1970, 0}; // form 1/1/1904 12AM to 1/1/1970 12AM + + secs -= TimDateTimeToSeconds (&Epoch); + + if (tloc) + *tloc = secs; + + return (secs); +} + + +struct tm *localtime(const time_t *timer) { + static struct tm tmDate; + + DateTimeType dt; + UInt32 secs = *timer; + DateTimeType Epoch = {0, 0, 0, 1, 1, 1970, 0}; // form 1/1/1904 12AM to 1/1/1970 12AM + // timer supposed to be based on Epoch + secs += TimDateTimeToSeconds(&Epoch); + + TimSecondsToDateTime (secs, &dt); + + tmDate.tm_sec = dt.second; + tmDate.tm_min = dt.minute; + tmDate.tm_hour = dt.hour; + tmDate.tm_mday = dt.day; + tmDate.tm_mon = dt.month; + tmDate.tm_year = dt.year; + tmDate.tm_wday = dt.weekDay; + + return &tmDate; +}
\ No newline at end of file diff --git a/backends/PalmOS/Src/missing/_unistd.cpp b/backends/PalmOS/Src/missing/_unistd.cpp new file mode 100644 index 0000000000..bf4e0da0d9 --- /dev/null +++ b/backends/PalmOS/Src/missing/_unistd.cpp @@ -0,0 +1,14 @@ +#include "unistd.h" +#include "extend.h" // for SCUMMVM_SAVEPATH + + +// currently used only to retreive savepath +Char *getcwd(Char *buf, UInt32 size) { + Char *copy = buf; + + if (!copy) + copy = (Char *)MemPtrNew(StrLen(SCUMMVM_SAVEPATH)); // this may never occured + + StrCopy(copy, SCUMMVM_SAVEPATH); + return copy; +}
\ No newline at end of file diff --git a/backends/PalmOS/Src/missing/assert.h b/backends/PalmOS/Src/missing/assert.h new file mode 100644 index 0000000000..5f021cd6d3 --- /dev/null +++ b/backends/PalmOS/Src/missing/assert.h @@ -0,0 +1 @@ +#define assert(a)
\ No newline at end of file diff --git a/backends/PalmOS/Src/missing/fcntl.h b/backends/PalmOS/Src/missing/fcntl.h new file mode 100644 index 0000000000..a6b5294568 --- /dev/null +++ b/backends/PalmOS/Src/missing/fcntl.h @@ -0,0 +1 @@ +/* nothing */
\ No newline at end of file diff --git a/backends/PalmOS/Src/missing/math.h b/backends/PalmOS/Src/missing/math.h new file mode 100644 index 0000000000..b527ffcf42 --- /dev/null +++ b/backends/PalmOS/Src/missing/math.h @@ -0,0 +1 @@ +#include "mathlib.h"
\ No newline at end of file diff --git a/backends/PalmOS/Src/missing/stdio.h b/backends/PalmOS/Src/missing/stdio.h new file mode 100644 index 0000000000..5a42917d04 --- /dev/null +++ b/backends/PalmOS/Src/missing/stdio.h @@ -0,0 +1,34 @@ +#include <PalmOS.h> +#include <VFSMgr.h> +#include <stdarg.h> +#include "globals.h" + +//extern UInt16 gVolRefNum; +//extern FileRef gLogFile; + +typedef FileRef FILE; + +#define stdin 0 +#define stdout (&gVars->logFile) +#define stderr (&gVars->logFile) + +#define clearerr(a) +#define fflush(a) +#define vsnprintf(a,b,c,d) vsprintf(a,c,d) + +#define SEEK_SET vfsOriginBeginning +#define SEEK_CUR vfsOriginCurrent +#define SEEK_END vfsOriginEnd + +UInt16 fclose(FileRef *stream); +UInt16 feof(FileRef *stream); +Char *fgets(Char *s, UInt32 n, 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); +Int32 fseek(FileRef *stream, Int32 offset, Int32 whence); +UInt32 ftell(FileRef *stream); +UInt16 fprintf(FileRef *stream, const Char *format, ...); +Int16 printf(const Char* formatStr, ...); +Int16 sprintf(Char* s, const Char* formatStr, ...); +Int16 vsprintf(Char* s, const Char* formatStr, _Palm_va_list argParam); diff --git a/backends/PalmOS/Src/missing/stdlib.h b/backends/PalmOS/Src/missing/stdlib.h new file mode 100644 index 0000000000..b0d0145be0 --- /dev/null +++ b/backends/PalmOS/Src/missing/stdlib.h @@ -0,0 +1,38 @@ +#ifndef STDLIB_H +#define STDLIB_H + +#include <PalmOS.h> +#include "mathlib.h" + +//#define memNewChunkFlagNonMovable 0x0200 +#define memNewChunkFlagAllowLarge 0x1000 // this is not in the sdk *g* +#define memHeapFlagReadOnly 0x0001 + +#define NO_HEAP_FOUND -1 + +SysAppInfoPtr SysGetAppInfo(SysAppInfoPtr *uiAppPP, SysAppInfoPtr *actionCodeAppPP) + SYS_TRAP(sysTrapSysGetAppInfo); + + +#define atoi StrAToI +#define atol StrAToI +#define abs(a) ((a) < 0 ? -(a) : (a)) +//#define abs fabs +#define malloc(a) calloc(a,1) +//#define free MemPtrFree +#define strtol(a,b,c) StrAToI(a) +#define qsort(a,b,c,d) +#define rand() SysRandom(0) + +void MemExtInit(); +void MemExtCleanup(); + +MemPtr realloc(MemPtr oldP, UInt32 size); +MemPtr calloc(UInt32 nelem, UInt32 elsize); +Err free(MemPtr memP); +void exit(Int16 status); +void *bsearch(const void *key, const void *base, UInt32 nmemb, + UInt32 size, int (*compar)(const void *, const void *)); + + +#endif
\ No newline at end of file diff --git a/backends/PalmOS/Src/missing/string.h b/backends/PalmOS/Src/missing/string.h new file mode 100644 index 0000000000..f19e54ffa1 --- /dev/null +++ b/backends/PalmOS/Src/missing/string.h @@ -0,0 +1,22 @@ +#include <PalmOS.h> + +#define memcmp MemCmp +#define memcpy MemMove +#define memmove MemMove +#define memset(a,b,c) MemSet(a,c,b) +#define strcat StrCat +#define strchr StrChr +#define strcmp StrCompare +#define strcpy StrCopy +#define strncpy StrNCopy +#define stricmp StrCaselessCompare +#define strlen StrLen +#define strncmp StrNCompare +#define strstr StrStr + +Char *strtok(Char *str, const Char *sep); +Char *strrchr(const Char *s, int c); +Char *strdup(const Char *strSource); +Char *strpbrk(const Char *s1, const Char *s2); + +#define StrTok strtok
\ No newline at end of file diff --git a/backends/PalmOS/Src/missing/sys/stat.h b/backends/PalmOS/Src/missing/sys/stat.h new file mode 100644 index 0000000000..a6b5294568 --- /dev/null +++ b/backends/PalmOS/Src/missing/sys/stat.h @@ -0,0 +1 @@ +/* nothing */
\ No newline at end of file diff --git a/backends/PalmOS/Src/missing/time.h b/backends/PalmOS/Src/missing/time.h new file mode 100644 index 0000000000..df93e2cdd9 --- /dev/null +++ b/backends/PalmOS/Src/missing/time.h @@ -0,0 +1,18 @@ +#include <PalmOS.h> + +typedef UInt32 time_t; + +struct tm { + Int16 tm_sec; // seconds [0,61] + Int16 tm_min; // minutes [0,59] + Int16 tm_hour; // hour [0,23] + Int16 tm_mday; // day of month [1,31] + Int16 tm_mon; // month of year [0,11] + Int16 tm_year; // years since 1900 + Int16 tm_wday; // day of week [0,6] (Sunday = 0) + Int16 tm_yday; // day of year [0,365] + Int16 tm_isdst; // daylight savings flag +}; + +time_t time(time_t *tloc); +struct tm *localtime(const time_t *timer); diff --git a/backends/PalmOS/Src/missing/unistd.h b/backends/PalmOS/Src/missing/unistd.h new file mode 100644 index 0000000000..b5111cce98 --- /dev/null +++ b/backends/PalmOS/Src/missing/unistd.h @@ -0,0 +1,3 @@ +#include <PalmOS.h> + +Char *getcwd(Char *buf, UInt32 size); |