wincecompat.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * wincecompat.c : wince compatiblity module
  3. *
  4. * See Copyright for the status of this software.
  5. *
  6. * javier@tiresiassoft.com
  7. *
  8. * 17 Sep 2002 created
  9. */
  10. #include "wincecompat.h"
  11. char *strError[]= {"Error 0","","No such file or directory","","","","","Arg list too long",
  12. "Exec format error","Bad file number","","","Not enough core","Permission denied","","",
  13. "","File exists","Cross-device link","","","","Invalid argument","","Too many open files",
  14. "","","","No space left on device","","","","","Math argument","Result too large","",
  15. "Resource deadlock would occur", "Unknown error under wince"};
  16. int errno=0;
  17. int read(int handle, char *buffer, unsigned int len)
  18. {
  19. return(fread(&buffer[0], len, 1, (FILE *) handle));
  20. }
  21. int write(int handle, const char *buffer, unsigned int len)
  22. {
  23. return(fwrite(&buffer[0], len,1,(FILE *) handle));
  24. }
  25. int open(const char *filename,int oflag, ...)
  26. {
  27. char mode[3]; /* mode[0] ="w/r/a" mode[1]="+" */
  28. mode[2]=0;
  29. if ( oflag==(O_WRONLY|O_CREAT) )
  30. mode[0]="w";
  31. else if (oflag==O_RDONLY)
  32. mode[0]="r";
  33. return fopen(filename, mode);
  34. }
  35. int close(int handle)
  36. {
  37. return ( fclose((FILE *) handle) );
  38. }
  39. char *getcwd( char *buffer, unsigned int size)
  40. {
  41. /* Windows CE don't have the concept of a current directory
  42. * so we just return NULL to indicate an error
  43. */
  44. return NULL;
  45. }
  46. char *getenv( const char *varname )
  47. {
  48. return NULL;
  49. }
  50. char *strerror(int errnum)
  51. {
  52. if (errnum>MAX_STRERROR)
  53. return strError[MAX_STRERROR];
  54. else
  55. return strError[errnum];
  56. }