celibc.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. #ifndef LUA_WINCE_H
  2. #define LUA_WINCE_H
  3. #ifndef _WIN32_WCE
  4. #error "_WIN32_WCE should be defined first"
  5. #endif
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. #include <stdio.h>
  10. #include <string.h>
  11. #include <math.h>
  12. #include <windef.h>
  13. // these pragmas help Studio to build for some CE platforms - use as necessary
  14. #ifndef __GNUC__
  15. // Number of clock ticks per second. Used by the clock() function.
  16. //
  17. #define CLOCKS_PER_SEC 1000
  18. // Macro for CLK_PER_SEC
  19. //
  20. #define CLK_TICK CLOCKS_PER_SEC
  21. // structure definitions
  22. //
  23. #ifndef _TM_DEFINED
  24. struct tm {
  25. int tm_sec; // seconds
  26. int tm_min; // minutes
  27. int tm_hour; // hours
  28. int tm_mday; // day of the month
  29. int tm_mon; // month
  30. int tm_year; // years since 1900 (from 0)
  31. int tm_wday; // days since Sunday (from 0)
  32. int tm_yday; // days since Jan 1
  33. int tm_isdst; // daylight savings (summertime) flag
  34. };
  35. #define _TM_DEFINED
  36. #endif
  37. // typedefs
  38. //
  39. // since time_t is already defined in CE as a ULONG, we need a new definition
  40. //
  41. typedef LONGLONG time_t;
  42. static struct tm tmbuf;
  43. // Convert tm to a string in the format "Www Mmm dd hh:mm:ss yyyy",
  44. // where Www is the weekday, Mmm the month in letters, dd the day
  45. // of the month, hh:mm:ss the time, and yyyy the year. The string
  46. // is followed by a newline and a terminating null character,
  47. // conforming a total of 26 characters.
  48. //
  49. char *asctime(const struct tm* tmptr);
  50. #endif //__GNUC__
  51. #define clock_t DWORD
  52. // Return number of clock ticks since process start.
  53. //
  54. clock_t clock(void);
  55. #ifndef __GNUC__
  56. // Convert time_t value to string in the same format as asctime.
  57. //
  58. char* ctime(const time_t* timer);
  59. // Convert a time_t value to a tm structure as UTC time.
  60. //
  61. struct tm* gmtime(const time_t* timer);
  62. // Convert a time_t value to a tm structure as local time.
  63. //
  64. struct tm* localtime(const time_t* timer);
  65. // Returns the Unix timestamp corresponding to the arguments given.
  66. // This timestamp is a long integer containing the number of seconds between the Unix Epoch
  67. // (January 1 1970 00:00:00 GMT) and the time specified.
  68. //
  69. time_t mktime(struct tm *tptr);
  70. // Get the current time from the system clock. Stores that value in timer.
  71. // If timer is null, the value is not stored, but it is still returned by
  72. // the function.
  73. //
  74. time_t time(time_t* timer);
  75. // Format tm into a date/time string
  76. //
  77. size_t strftime(char *s, size_t maxs, const char *f, const struct tm *t);
  78. #endif
  79. /* these are terrible, but just for CE quick-dirty (pedro) */
  80. #define strcoll strcmp
  81. #ifndef isalpha
  82. #define isalpha(c) ( ('a' <= (c) && (c) <= 'z') || ('A' <= (c) && (c) <= 'Z') )
  83. #define isdigit(c) ( '0' <= (c) && (c) <= '9' )
  84. #define isalnum(c) ( isalpha(c) || isdigit(c) )
  85. #define isspace(c) ( (c) == ' ' || (c) == '\t' || (c) == '\n' || (c) == '\r' )
  86. #define iscntrl(c) ( (0x00 <= (c) && (c) <= 0x1F) || (c) == 0x7F)
  87. #define islower(c) ( 'a' <= (c) && (c) <= 'z' )
  88. #define isprint(c) ( (0x20 <= (c) && (c) <= 0x7E) )
  89. #define ispunct(c) ( isprint(c) && ( !isalnum(c) && !isspace(c) ))
  90. #define isupper(c) ( 'A' <= (c) && (c) <= 'Z' )
  91. #define isxdigit(c) ( isdigit(c) || ('a' <= (c) && (c) <= 'f') || ('a' <= (c) && (c) <= 'f') )
  92. #endif
  93. #ifndef BUFSIZ
  94. #define BUFSIZ 1024
  95. #endif
  96. #ifndef MAX_PATH
  97. #define MAX_PATH 2048
  98. #endif
  99. #ifndef L_tmpnam
  100. #define L_tmpnam MAX_PATH
  101. #endif
  102. char *strdup( const char *str );
  103. const char *getenv( const char *name );
  104. FILE *tmpfile();
  105. int system( const char * );
  106. int rename( const char *, const char * );
  107. int remove( const char * );
  108. char *tmpnam( char * );
  109. //int chdir(const char *path);
  110. int mkdir(const char *path);
  111. char *setlocale( int category, const char *locale );
  112. struct lconv *localeconv( void );
  113. HINSTANCE LoadLibraryA(LPCSTR);
  114. HMODULE GetModuleHandleA(LPCSTR);
  115. #define strerror(errnum) ("(Error ocurred)")
  116. //extern int errno;
  117. #define errno (GetLastError ())
  118. FILE* _fopen(const char *filename, const char *flags);
  119. #ifdef __cplusplus
  120. }
  121. #endif
  122. #endif