aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/wince/missing
diff options
context:
space:
mode:
authorKostas Nakos2006-07-01 08:13:46 +0000
committerKostas Nakos2006-07-01 08:13:46 +0000
commit6a8749ace05649fdf69593c76a75c322f34a5bfa (patch)
treeda214254c9ca56ded22af377fe0763ad73dd7bb5 /backends/platform/wince/missing
parent294dcea3ef063ee4ec95f3f418af4534445da1c6 (diff)
downloadscummvm-rg350-6a8749ace05649fdf69593c76a75c322f34a5bfa.tar.gz
scummvm-rg350-6a8749ace05649fdf69593c76a75c322f34a5bfa.tar.bz2
scummvm-rg350-6a8749ace05649fdf69593c76a75c322f34a5bfa.zip
move ce port to its new home
svn-id: r23366
Diffstat (limited to 'backends/platform/wince/missing')
-rw-r--r--backends/platform/wince/missing/assert.h9
-rw-r--r--backends/platform/wince/missing/conio.h2
-rw-r--r--backends/platform/wince/missing/dir.h1
-rw-r--r--backends/platform/wince/missing/direct.h1
-rw-r--r--backends/platform/wince/missing/dirent.h52
-rw-r--r--backends/platform/wince/missing/errno.h1
-rw-r--r--backends/platform/wince/missing/fcntl.h1
-rw-r--r--backends/platform/wince/missing/io.h15
-rw-r--r--backends/platform/wince/missing/missing.cpp644
-rw-r--r--backends/platform/wince/missing/signal.h3
-rw-r--r--backends/platform/wince/missing/sys/stat.h23
-rw-r--r--backends/platform/wince/missing/sys/time.h10
-rw-r--r--backends/platform/wince/missing/sys/types.h5
-rw-r--r--backends/platform/wince/missing/time.h24
-rw-r--r--backends/platform/wince/missing/unistd.h1
15 files changed, 792 insertions, 0 deletions
diff --git a/backends/platform/wince/missing/assert.h b/backends/platform/wince/missing/assert.h
new file mode 100644
index 0000000000..0a9dc23bb8
--- /dev/null
+++ b/backends/platform/wince/missing/assert.h
@@ -0,0 +1,9 @@
+/* Header is not present in Windows CE SDK */
+
+// defined in common/util.h
+void CDECL _declspec(noreturn) error(const char *s, ...);
+
+#define assert(e) ((e) ? 0 : (::error("Assertion failed " #e " (%s, %d)", __FILE__, __LINE__)))
+
+#define abort() ::error("Abort (%s, %d)", __FILE__, __LINE__)
+
diff --git a/backends/platform/wince/missing/conio.h b/backends/platform/wince/missing/conio.h
new file mode 100644
index 0000000000..0cb5c297ea
--- /dev/null
+++ b/backends/platform/wince/missing/conio.h
@@ -0,0 +1,2 @@
+/* Header is not present in Windows CE SDK */
+
diff --git a/backends/platform/wince/missing/dir.h b/backends/platform/wince/missing/dir.h
new file mode 100644
index 0000000000..7ee9f5e5ba
--- /dev/null
+++ b/backends/platform/wince/missing/dir.h
@@ -0,0 +1 @@
+/* Header is not present in Windows CE SDK */
diff --git a/backends/platform/wince/missing/direct.h b/backends/platform/wince/missing/direct.h
new file mode 100644
index 0000000000..7ee9f5e5ba
--- /dev/null
+++ b/backends/platform/wince/missing/direct.h
@@ -0,0 +1 @@
+/* Header is not present in Windows CE SDK */
diff --git a/backends/platform/wince/missing/dirent.h b/backends/platform/wince/missing/dirent.h
new file mode 100644
index 0000000000..82dd0b2ee7
--- /dev/null
+++ b/backends/platform/wince/missing/dirent.h
@@ -0,0 +1,52 @@
+/* Header is not present in Windows CE SDK */
+/* It would not be a bad idea to take this thing from gcc distro and port
+ it properly. For now only required part is ported. */
+
+struct dirent
+{
+ long d_ino; /* Always zero. */
+ unsigned short d_reclen; /* Always zero. */
+ unsigned short d_namlen; /* Length of name in d_name. */
+ char* d_name; /* File name. */
+ /* NOTE: The name in the dirent structure points to the name in the
+ * finddata_t structure in the DIR. */
+};
+
+/*
+ * This is an internal data structure. Good programmers will not use it
+ * except as an argument to one of the functions below.
+ */
+typedef struct
+{
+ /* disk transfer area for this dir */
+/* struct _finddata_t dd_dta; */
+
+ /* dirent struct to return from dir (NOTE: this makes this thread
+ * safe as long as only one thread uses a particular DIR struct at
+ * a time) */
+ struct dirent dd_dir;
+
+ /* _findnext handle */
+ long dd_handle;
+
+ /*
+ * Status of search:
+ * 0 = not started yet (next entry to read is first entry)
+ * -1 = off the end
+ * positive = 0 based index of next entry
+ */
+ short dd_stat;
+
+ /* given path for dir with search pattern (struct is extended) */
+ char dd_name[1];
+} DIR;
+
+
+DIR* opendir (const char*);
+struct dirent* readdir (DIR*);
+int closedir (DIR*);
+/*
+void rewinddir (DIR*);
+long telldir (DIR*);
+void seekdir (DIR*, long);
+*/
diff --git a/backends/platform/wince/missing/errno.h b/backends/platform/wince/missing/errno.h
new file mode 100644
index 0000000000..7ee9f5e5ba
--- /dev/null
+++ b/backends/platform/wince/missing/errno.h
@@ -0,0 +1 @@
+/* Header is not present in Windows CE SDK */
diff --git a/backends/platform/wince/missing/fcntl.h b/backends/platform/wince/missing/fcntl.h
new file mode 100644
index 0000000000..7ee9f5e5ba
--- /dev/null
+++ b/backends/platform/wince/missing/fcntl.h
@@ -0,0 +1 @@
+/* Header is not present in Windows CE SDK */
diff --git a/backends/platform/wince/missing/io.h b/backends/platform/wince/missing/io.h
new file mode 100644
index 0000000000..a7b74c71b7
--- /dev/null
+++ b/backends/platform/wince/missing/io.h
@@ -0,0 +1,15 @@
+/* Header is not present in Windows CE SDK */
+
+/* This stuff will live here until port configuration file is in place */
+#define stricmp _stricmp
+#define strdup _strdup
+#define _HEAPOK 0
+#define _heapchk() 0
+
+#ifndef _FILE_DEFINED
+ typedef void FILE;
+ #define _FILE_DEFINED
+#endif
+FILE* wce_fopen(const char* fname, const char* fmode);
+#define fopen wce_fopen
+
diff --git a/backends/platform/wince/missing/missing.cpp b/backends/platform/wince/missing/missing.cpp
new file mode 100644
index 0000000000..e85babc13f
--- /dev/null
+++ b/backends/platform/wince/missing/missing.cpp
@@ -0,0 +1,644 @@
+/* MISSING.C
+ Implementation for standard and semi-standard C library calls missing in WinCE
+ environment.
+ by Vasyl Tsvirkunov
+*/
+
+#include <windows.h>
+#include <tchar.h>
+#include <string.h>
+#include <stdlib.h>
+#include "sys/stat.h"
+#include "sys/time.h"
+#include "time.h"
+#include "dirent.h"
+
+/* forward declaration */
+
+#if _WIN32_WCE < 300
+
+#define _STDAFX_H
+#include "portdefs.h"
+
+#else
+
+char *strdup(const char *strSource);
+
+#endif
+
+/* Limited dirent implementation. Used by UI.C and DEVICES.C */
+static WIN32_FIND_DATA wfd;
+
+DIR* opendir(const char* fname)
+{
+ DIR* pdir;
+ char fnameMask[MAX_PATH+1];
+ TCHAR fnameUnc[MAX_PATH+1];
+ char nameFound[MAX_PATH+1];
+
+ if(fname == NULL)
+ return NULL;
+
+ strcpy(fnameMask, fname);
+ if(!strlen(fnameMask) || fnameMask[strlen(fnameMask)-1] != '\\')
+ strncat(fnameMask, "\\", MAX_PATH-strlen(fnameMask)-1);
+ strncat(fnameMask, "*.*", MAX_PATH-strlen(fnameMask)-4);
+
+ pdir = (DIR*)malloc(sizeof(DIR)+strlen(fname));
+ pdir->dd_dir.d_ino = 0;
+ pdir->dd_dir.d_reclen = 0;
+ pdir->dd_dir.d_name = 0;
+ pdir->dd_dir.d_namlen = 0;
+
+ pdir->dd_handle = 0;
+ pdir->dd_stat = 0;
+ strcpy(pdir->dd_name, fname); /* it has exactly enough space for fname and nul char */
+
+ MultiByteToWideChar(CP_ACP, 0, fnameMask, -1, fnameUnc, MAX_PATH);
+ if((pdir->dd_handle = (long)FindFirstFile(fnameUnc, &wfd)) == (long)INVALID_HANDLE_VALUE)
+ {
+ free(pdir);
+ return NULL;
+ }
+ else
+ {
+ WideCharToMultiByte(CP_ACP, 0, wfd.cFileName, -1, nameFound, MAX_PATH, NULL, NULL);
+
+ pdir->dd_dir.d_name = strdup(nameFound);
+ pdir->dd_dir.d_namlen = strlen(nameFound);
+ }
+ return pdir;
+}
+
+struct dirent* readdir(DIR* dir)
+{
+ char nameFound[MAX_PATH+1];
+ static struct dirent dummy;
+
+ if(dir->dd_stat == 0)
+ {
+ dummy.d_name = ".";
+ dummy.d_namlen = 1;
+ dir->dd_stat ++;
+ return &dummy;
+ }
+ else if(dir->dd_stat == 1)
+ {
+ dummy.d_name = "..";
+ dummy.d_namlen = 2;
+ dir->dd_stat ++;
+ return &dummy;
+ }
+ else if(dir->dd_stat == 2)
+ {
+ dir->dd_stat++;
+ return &dir->dd_dir;
+ }
+ else
+ {
+ if(FindNextFile((HANDLE)dir->dd_handle, &wfd) == 0)
+ {
+ dir->dd_stat = -1;
+ return NULL;
+ }
+ WideCharToMultiByte(CP_ACP, 0, wfd.cFileName, -1, nameFound, MAX_PATH, NULL, NULL);
+
+ if(dir->dd_dir.d_name)
+ free(dir->dd_dir.d_name);
+
+ dir->dd_dir.d_name = strdup(nameFound);
+ dir->dd_dir.d_namlen = strlen(nameFound);
+
+ dir->dd_stat ++;
+
+ return &dir->dd_dir;
+ }
+}
+
+int closedir(DIR* dir)
+{
+ if(dir == NULL)
+ return 0;
+
+ if(dir->dd_handle)
+ FindClose((HANDLE)dir->dd_handle);
+
+ if(dir->dd_dir.d_name)
+ free(dir->dd_dir.d_name);
+ free(dir);
+ return 1;
+}
+
+/* Very limited implementation of stat. Used by UI.C, MEMORY-P.C (latter is not critical) */
+int stat(const char *fname, struct stat *ss)
+{
+ TCHAR fnameUnc[MAX_PATH+1];
+ HANDLE handle;
+ int len;
+
+ if(fname == NULL || ss == NULL)
+ return -1;
+
+ /* Special case (dummy on WinCE) */
+ len = strlen(fname);
+ if(len >= 2 && fname[len-1] == '.' && fname[len-2] == '.' &&
+ (len == 2 || fname[len-3] == '\\'))
+ {
+ /* That's everything implemented so far */
+ memset(ss, 0, sizeof(struct stat));
+ ss->st_size = 1024;
+ ss->st_mode |= S_IFDIR;
+ return 0;
+ }
+
+ MultiByteToWideChar(CP_ACP, 0, fname, -1, fnameUnc, MAX_PATH);
+ handle = FindFirstFile(fnameUnc, &wfd);
+ if(handle == INVALID_HANDLE_VALUE)
+ return -1;
+ else
+ {
+ /* That's everything implemented so far */
+ memset(ss, 0, sizeof(struct stat));
+ ss->st_size = wfd.nFileSizeLow;
+ if(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ ss->st_mode |= S_IFDIR;
+
+ FindClose(handle);
+ }
+ return 0;
+}
+
+/* Remove file by name */
+int remove(const char* path)
+{
+ TCHAR pathUnc[MAX_PATH+1];
+ MultiByteToWideChar(CP_ACP, 0, path, -1, pathUnc, MAX_PATH);
+ return !DeleteFile(pathUnc);
+}
+
+/* in our case unlink is the same as remove */
+int unlink(const char* path)
+{
+ return remove(path);
+}
+
+/* Make directory, Unix style */
+void mkdir(char* dirname, int mode)
+{
+ char path[MAX_PATH+1];
+ TCHAR pathUnc[MAX_PATH+1];
+ char* ptr;
+ strncpy(path, dirname, MAX_PATH);
+ if(*path == '/')
+ *path = '\\';
+ /* Run through the string and attempt creating all subdirs on the path */
+ for(ptr = path+1; *ptr; ptr ++)
+ {
+ if(*ptr == '\\' || *ptr == '/')
+ {
+ *ptr = 0;
+ MultiByteToWideChar(CP_ACP, 0, path, -1, pathUnc, MAX_PATH);
+ CreateDirectory(pathUnc, 0);
+ *ptr = '\\';
+ }
+ }
+ MultiByteToWideChar(CP_ACP, 0, path, -1, pathUnc, MAX_PATH);
+ CreateDirectory(pathUnc, 0);
+}
+
+/* Used in DEVICES.C and UI.C for some purpose. Not critical in this port */
+int system(const char* path) { return 0; }
+
+#if 0
+
+char *tmpnam(char *string)
+{
+ TCHAR pTemp[MAX_PATH+1];
+ static char buffer[MAX_PATH+1];
+ GetTempFileName(TEXT("."), TEXT("A8_"), 0, pTemp);
+ WideCharToMultiByte(CP_ACP, 0, pTemp, -1, buffer, MAX_PATH, NULL, NULL);
+
+ if(string)
+ {
+ strcpy(string, buffer);
+ return string;
+ }
+ else
+ return buffer;
+}
+
+FILE *tmpfile()
+{
+ TCHAR pTemp[MAX_PATH+1];
+ if(!GetTempFileName(TEXT("."), TEXT("A8_"), 0, pTemp))
+ return _wfopen(pTemp, TEXT("w+b"));
+ else
+ return 0;
+}
+
+#endif
+
+void rewind(FILE *stream)
+{
+ fseek(stream, 0, SEEK_SET);
+}
+
+
+#if _WIN32_WCE < 300
+
+int isalnum(int c) {
+ return ((c >= 'A' && c <= 'Z') ||
+ (c >= 'a' && c <= 'z') ||
+ (c >= '0' && c <= '9'));
+}
+
+char *_strdup(const char *strSource)
+#else
+char *strdup(const char *strSource)
+#endif
+{
+ char* buffer;
+ buffer = (char*)malloc(strlen(strSource)+1);
+ if(buffer)
+ strcpy(buffer, strSource);
+ return buffer;
+}
+
+/* Used in UI.C */
+char cwd[MAX_PATH+1] = "";
+char *getcwd(char *buffer, int maxlen)
+{
+ TCHAR fileUnc[MAX_PATH+1];
+ char* plast;
+
+ if(cwd[0] == 0)
+ {
+ GetModuleFileName(NULL, fileUnc, MAX_PATH);
+ WideCharToMultiByte(CP_ACP, 0, fileUnc, -1, cwd, MAX_PATH, NULL, NULL);
+ plast = strrchr(cwd, '\\');
+ if(plast)
+ *plast = 0;
+ /* Special trick to keep start menu clean... */
+ if(_stricmp(cwd, "\\windows\\start menu") == 0)
+ strcpy(cwd, "\\Apps");
+ }
+ if(buffer)
+ strncpy(buffer, cwd, maxlen);
+ return cwd;
+}
+
+void GetCurrentDirectory(int len, char *buf)
+{
+ getcwd(buf,len);
+};
+
+/* Limited implementation of time.h. time_t formula is possibly incorrect. */
+time_t time(time_t* res)
+{
+ time_t t;
+ SYSTEMTIME st;
+ GetLocalTime(&st);
+
+ t = (time_t)(((((((st.wYear-1970)*12+st.wMonth)*31+st.wDay)*7+st.wDayOfWeek)*24+st.wHour)*60+st.wMinute)*60+st.wSecond);
+
+ if(res)
+ *res = t;
+ return t;
+}
+
+struct tm* localtime(time_t* timer)
+{
+ static struct tm tmLocalTime;
+ unsigned long rem = *timer;
+
+ tmLocalTime.tm_sec = (short)(rem % 60);
+ rem /= 60;
+ tmLocalTime.tm_min = (short)(rem % 60);
+ rem /= 60;
+ tmLocalTime.tm_hour = (short)(rem % 24);
+ rem /= 24;
+ tmLocalTime.tm_mday = (short)(rem % 7);
+ rem /= 7;
+ tmLocalTime.tm_mday = (short)(rem % 31);
+ rem /= 31;
+ tmLocalTime.tm_mon = (short)(rem % 12);
+ rem /= 12;
+ tmLocalTime.tm_year = (short)(rem+1970);
+
+ return &tmLocalTime;
+}
+
+/* Very limited implementation of sys/time.h */
+void gettimeofday(struct timeval* tp, void* dummy)
+{
+ DWORD dt = GetTickCount();
+ tp->tv_sec = dt/1000;
+ tp->tv_usec = dt*1000;
+}
+
+void usleep(long usec)
+{
+ long msec = usec/1000;
+ if(msec <= 0)
+ Sleep(0);
+ else
+ Sleep(msec);
+}
+
+/*
+Windows CE fopen has non-standard behavior -- not
+fully qualified paths refer to root folder rather
+than current folder (concept not implemented in CE).
+*/
+#undef fopen
+
+FILE* wce_fopen(const char* fname, const char* fmode)
+{
+ char fullname[MAX_PATH+1];
+
+ if(!fname || fname[0] == '\0')
+ return NULL;
+ if(fname[0] != '\\' && fname[0] != '/')
+ {
+ getcwd(fullname, MAX_PATH);
+ strncat(fullname, "\\", MAX_PATH-strlen(fullname)-1);
+ strncat(fullname, fname, MAX_PATH-strlen(fullname)-strlen(fname));
+ return fopen(fullname, fmode);
+ }
+ else
+ return fopen(fname, fmode);
+}
+
+/* This may provide for better sync mechanism */
+unsigned int clock()
+{
+ return GetTickCount();
+}
+
+/* And why do people use this? */
+#if _WIN32_WCE >= 300
+void abort()
+{
+ exit(1);
+}
+#endif
+
+/*
+IMHO, no project should use this one, it is not portable at all. This implementation
+at least allows some projects to work.
+*/
+char* getenv(char* name)
+{
+ static char buffer[MAX_PATH+1];
+ if(strcmp(name, "HOME") == 0 || strcmp(name, "HOMEDIR") == 0)
+ {
+ getcwd(buffer, MAX_PATH);
+ return buffer;
+ }
+ else
+ return "";
+}
+
+void *bsearch(const void *key, const void *base, size_t nmemb,
+ size_t size, int (*compar)(const void *, const void *)) {
+ size_t i;
+
+ for (i=0; i<nmemb; i++)
+ if (compar(key, (void*)((size_t)base + size * i)) == 0)
+ return (void*)((size_t)base + size * i);
+ return NULL;
+}
+
+#if _WIN32_WCE < 300 || defined(_TEST_HPC_STDIO)
+
+void *calloc(size_t n, size_t s) {
+ void *result = malloc(n * s);
+ if (result)
+ memset(result, 0, n * s);
+
+ return result;
+}
+
+char *strpbrk(const char *s, const char *accept) {
+ int i;
+
+ if (!s || !accept)
+ return NULL;
+
+ for (i=0; i<strlen(s); i++) {
+ int j;
+ for (j=0; j<strlen(accept); j++)
+ if (s[i] == accept[j])
+ return (char*)&s[i];
+ }
+
+ return NULL;
+}
+
+#ifndef _TEST_HPC_STDIO
+
+int isdigit(int c) {
+ return (c >='0' && c <= '9');
+}
+
+int isprint(int c) {
+ return (c >= ' ' && c <= '~');
+}
+
+int isspace(int c) {
+ return (c == ' ');
+}
+
+#endif
+
+#ifndef WIN32_PLATFORM_HPCPRO
+
+
+int printf(const char *format, ...) {
+ // useless anyway :)
+ return 0;
+}
+
+FILE *fopen(const char *path, const char *mode) {
+ TCHAR tempo[MAX_PATH];
+ HANDLE result;
+ bool writeAccess = (mode[0] == 'W' || mode[0] == 'w');
+
+ MultiByteToWideChar(CP_ACP, 0, path, strlen(path) + 1, tempo, sizeof(tempo));
+
+ result = CreateFile(tempo, ( writeAccess ? GENERIC_WRITE : GENERIC_READ), 0, NULL, (writeAccess ? CREATE_ALWAYS : OPEN_EXISTING), FILE_ATTRIBUTE_NORMAL, NULL);
+ if (result == INVALID_HANDLE_VALUE)
+ return NULL;
+ else
+ return (FILE*)result;
+}
+
+FILE * _wfopen(const TCHAR *path, const TCHAR *mode) {
+ HANDLE result;
+ bool writeAccess = (mode[0] == 'W' || mode[0] == 'w');
+ result = CreateFile(path, ( writeAccess ? GENERIC_WRITE : GENERIC_READ), 0, NULL, (writeAccess ? CREATE_ALWAYS : OPEN_EXISTING), FILE_ATTRIBUTE_NORMAL, NULL);
+ if (result == INVALID_HANDLE_VALUE)
+ return NULL;
+ else
+ return (FILE*)result;
+}
+
+FILE *_wfreopen(const TCHAR *path, const TCHAR *mode, FILE *stream) {
+ fclose(stream);
+ stream = _wfopen(path, mode);
+ return stream;
+}
+
+int fclose(FILE *stream) {
+ CloseHandle((HANDLE)stream);
+ return 1;
+}
+
+int fseek(FILE *stream, long offset, int whence) {
+ SetFilePointer((HANDLE)stream, offset, NULL, (whence == SEEK_CUR ? FILE_CURRENT : whence == SEEK_END ? FILE_END : FILE_BEGIN));
+ return 0;
+}
+
+long ftell(FILE *stream) {
+ return (SetFilePointer((HANDLE)stream, 0, NULL, FILE_CURRENT));
+}
+
+size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) {
+ DWORD sizeWritten;
+
+ WriteFile((HANDLE)stream, ptr, size * nmemb, &sizeWritten, NULL);
+
+ if (size != 0)
+ return sizeWritten / size;
+ else
+ return 0;
+}
+
+size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream) {
+ DWORD sizeRead;
+
+ ReadFile((HANDLE)stream, ptr, size * nmemb, &sizeRead, NULL);
+
+ if (size != 0)
+ return sizeRead / size;
+ else
+ return 0;
+}
+
+int fgetc(FILE *stream) {
+ unsigned char c;
+ if (fread(&c, 1, 1, stream) != 1)
+ return -1;
+ else
+ return c;
+}
+
+char *fgets(char *s, int size, FILE *stream) {
+ int i = 0;
+ char tempo[1];
+
+ memset(s, 0, size);
+ while (fread(tempo, 1, 1, stream)) {
+ //if (tempo[0] == '\r')
+ // break;
+ if (tempo[0] == '\r')
+ continue;
+ s[i++] = tempo[0];
+ if (tempo[0] == '\n')
+ break;
+ if (i == size)
+ break;
+ }
+ if (!i)
+ return NULL;
+ else
+ return s;
+}
+
+int feof(FILE *stream) {
+ DWORD fileSize;
+ DWORD filePos;
+ fileSize = GetFileSize((HANDLE)stream, NULL);
+ filePos = SetFilePointer((HANDLE)stream, 0, 0, FILE_CURRENT);
+ return (filePos == 0xFFFFFFFF || filePos > (fileSize - 1));
+}
+
+int ferror(FILE *stream) {
+ return 0; // FIXME !
+}
+
+int fprintf(FILE *stream, const char *format, ...) {
+ char buf[1024];
+ va_list va;
+
+ va_start(va, format);
+ vsnprintf(buf, 1024, format, va);
+ va_end(va);
+
+ if (buf[strlen(buf) - 1] == '\n') {
+ int i = strlen(buf) - 1;
+ buf[i] = '\r';
+ buf[i + 1] = '\n';
+ buf[i + 2] = 0;
+ }
+
+ return fwrite(buf, 1, strlen(buf), stream);
+}
+
+FILE* _getstdfilex(int) {
+ return NULL;
+}
+
+void clearerr(FILE *stream) {
+}
+
+int fflush(FILE *stream) {
+ return 0;
+}
+
+#endif
+
+int stricmp( const char *string1, const char *string2 ) {
+ char src[4096];
+ char dest[4096];
+ int i;
+
+ for (i=0; i<strlen(string1); i++)
+ if (string1[i] >= 'A' && string1[i] <= 'Z')
+ src[i] = string1[i] + 32;
+ else
+ src[i] = string1[i];
+ src[i] = 0;
+
+ for (i=0; i<strlen(string2); i++)
+ if (string2[i] >= 'A' && string2[i] <= 'Z')
+ dest[i] = string2[i] + 32;
+ else
+ dest[i] = string2[i];
+ dest[i] = 0;
+
+ return strcmp(src, dest);
+}
+
+char *strrchr(const char *s, int c) {
+ int i;
+
+ for (i = strlen(s) - 1; i > 0; i--)
+ if (s[i] == c)
+ return (char*)(s + i);
+
+ return NULL;
+}
+
+long int strtol(const char *nptr, char **endptr, int base) {
+ // not correct but that's all we are using
+
+ long int result;
+ sscanf(nptr, "%ld", &result);
+ return result;
+}
+
+
+#endif
+
+
diff --git a/backends/platform/wince/missing/signal.h b/backends/platform/wince/missing/signal.h
new file mode 100644
index 0000000000..128d6bf1db
--- /dev/null
+++ b/backends/platform/wince/missing/signal.h
@@ -0,0 +1,3 @@
+/* Header is not present in Windows CE SDK */
+/* Functionality is not critical -- Pocket PC devices do not have Ctrl+C */
+#define signal(a,b)
diff --git a/backends/platform/wince/missing/sys/stat.h b/backends/platform/wince/missing/sys/stat.h
new file mode 100644
index 0000000000..d9eef1318d
--- /dev/null
+++ b/backends/platform/wince/missing/sys/stat.h
@@ -0,0 +1,23 @@
+/* Header is not present in Windows CE SDK */
+
+#include <sys/types.h>
+
+struct stat {
+ _dev_t st_dev;
+ _ino_t st_ino;
+ unsigned short st_mode;
+ short st_nlink;
+ short st_uid;
+ short st_gid;
+ _dev_t st_rdev;
+ _off_t st_size;
+ time_t st_atime;
+ time_t st_mtime;
+ time_t st_ctime;
+};
+
+
+#define _S_IFDIR 0040000 /* directory */
+#define S_IFDIR _S_IFDIR
+
+int stat(const char *, struct stat *);
diff --git a/backends/platform/wince/missing/sys/time.h b/backends/platform/wince/missing/sys/time.h
new file mode 100644
index 0000000000..ded29bb009
--- /dev/null
+++ b/backends/platform/wince/missing/sys/time.h
@@ -0,0 +1,10 @@
+/* Header is not present in Windows CE SDK */
+
+struct timeval
+{
+ int tv_sec;
+ int tv_usec;
+};
+
+void gettimeofday(struct timeval* tp, void* dummy);
+void usleep(long usec);
diff --git a/backends/platform/wince/missing/sys/types.h b/backends/platform/wince/missing/sys/types.h
new file mode 100644
index 0000000000..b6c05e3958
--- /dev/null
+++ b/backends/platform/wince/missing/sys/types.h
@@ -0,0 +1,5 @@
+/* Header is not present in Windows CE SDK */
+
+typedef unsigned short _ino_t;
+typedef unsigned int _dev_t;
+typedef long _off_t;
diff --git a/backends/platform/wince/missing/time.h b/backends/platform/wince/missing/time.h
new file mode 100644
index 0000000000..40c2894dca
--- /dev/null
+++ b/backends/platform/wince/missing/time.h
@@ -0,0 +1,24 @@
+/* Header is not present in Windows CE SDK */
+
+#ifndef A800_TIME_H
+#define A800_TIME_H
+
+#include <stdlib.h>
+
+struct tm
+{
+ short tm_year;
+ short tm_mon;
+ short tm_mday;
+ short tm_wday;
+ short tm_hour;
+ short tm_min;
+ short tm_sec;
+};
+
+time_t time(time_t* dummy);
+struct tm* localtime(time_t* dummy);
+
+unsigned int clock();
+
+#endif
diff --git a/backends/platform/wince/missing/unistd.h b/backends/platform/wince/missing/unistd.h
new file mode 100644
index 0000000000..7ee9f5e5ba
--- /dev/null
+++ b/backends/platform/wince/missing/unistd.h
@@ -0,0 +1 @@
+/* Header is not present in Windows CE SDK */