1 /* 2 Copyright (c) 1990-2009 Info-ZIP. All rights reserved. 3 4 See the accompanying file LICENSE, version 2009-Jan-02 or later 5 (the contents of which are also included in unzip.h) for terms of use. 6 If, for some reason, all these files are missing, the Info-ZIP license 7 also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html 8 */ 9 //****************************************************************************** 10 // 11 // File: WINCE.H 12 // 13 // Description: This file declares all the Win32 APIs and C runtime functions 14 // that the Info-ZIP code calls, but are not implemented natively 15 // on Windows CE. See WINCE.CPP for the implementation. 16 // 17 // Copyright: All the source files for Pocket UnZip, except for components 18 // written by the Info-ZIP group, are copyrighted 1997 by Steve P. 19 // Miller. The product "Pocket UnZip" itself is property of the 20 // author and cannot be altered in any way without written consent 21 // from Steve P. Miller. 22 // 23 // Disclaimer: All project files are provided "as is" with no guarantee of 24 // their correctness. The authors are not liable for any outcome 25 // that is the result of using this source. The source for Pocket 26 // UnZip has been placed in the public domain to help provide an 27 // understanding of its implementation. You are hereby granted 28 // full permission to use this source in any way you wish, except 29 // to alter Pocket UnZip itself. For comments, suggestions, and 30 // bug reports, please write to stevemil@pobox.com. 31 // 32 // 33 // Date Name History 34 // -------- ------------ ----------------------------------------------------- 35 // 02/01/97 Steve Miller Created (Version 1.0 using Info-ZIP UnZip 5.30) 36 // 37 //****************************************************************************** 38 39 #ifndef __WINCE_H__ 40 #define __WINCE_H__ 41 42 #ifdef __cplusplus 43 extern "C" { 44 #endif 45 46 //****************************************************************************** 47 //***** For all platforms - Our debug output function 48 //****************************************************************************** 49 50 // If we are building for debug, we implement the DebugOut() function. If we are 51 // building for release, then we turn all calls to DebugOut() into no-ops. The 52 // Microsoft compiler (and hopefully others) will not generate any code at all 53 // for the retail version of DebugOut() defined here. This works much better 54 // than trying to create a variable argument macro - something C/C++ does not 55 // support cleanly. 56 57 #ifdef DEBUG 58 void DebugOut(LPCTSTR szFormat, ...); 59 #else 60 __inline void DebugOut(LPCTSTR szFormat, ...) {} 61 #endif 62 63 64 //****************************************************************************** 65 //***** Windows NT Native 66 //****************************************************************************** 67 68 #if !defined(_WIN32_WCE) 69 #ifndef UNICODE 70 #include <stdio.h> 71 #endif 72 #include <io.h> 73 #include <time.h> 74 #include <fcntl.h> 75 #include <sys\stat.h> 76 #endif 77 78 //****************************************************************************** 79 //***** Windows CE Native 80 //****************************************************************************** 81 82 #if defined(_WIN32_WCE) 83 84 #if defined(__WINCE_CPP) 85 // internal, suppress "import linkage" specifier 86 # define ZCRTIMP 87 #else 88 // do not use import linkage specifier either; symbols are provided locally 89 # define ZCRTIMP 90 #endif 91 92 #ifndef ZeroMemory 93 #define ZeroMemory(Destination,Length) memset(Destination, 0, Length) 94 #endif 95 96 #ifdef _MBCS 97 // WinCE C RTL does not provide the setlocale function 98 # define setlocale(category, locale) 99 #endif 100 101 // A few forgotten defines in Windows CE's TCHAR.H 102 #ifndef _stprintf 103 #define _stprintf wsprintf 104 #endif 105 106 #if _WIN32_WCE < 211 //sr551b functions in stdlib CE300 107 #ifndef _vsntprintf 108 #define _vsntprintf(d,c,f,a) wvsprintf(d,f,a) 109 #endif 110 #ifndef _vsnwprintf 111 #define _vsnwprintf(d,c,f,a) wvsprintf(d,f,a) 112 #endif 113 #endif //end sr551b 114 115 //****************************************************************************** 116 //***** SYS\TYPES.H functions 117 //****************************************************************************** 118 119 #ifndef _OFF_T_DEFINED 120 typedef long _off_t; 121 #define _OFF_T_DEFINED 122 #endif 123 #ifndef _TIME_T_DEFINED 124 typedef long time_t; 125 #define _TIME_T_DEFINED 126 #endif 127 128 //****************************************************************************** 129 //***** CTYPE.H functions 130 //****************************************************************************** 131 #if _WIN32_WCE < 300 132 ZCRTIMP int __cdecl isupper(int); 133 #endif 134 _CRTIMP int __cdecl tolower(int); 135 // This is a coarse approximation to ASCII isalpha(), it returns TRUE not only 136 // on all ASCII letters but also on punctuation chars in the range of 0x40-0x7F 137 #ifndef isalpha 138 #define isalpha(c) (((c) & 0xC0) == 0xC0) 139 #endif 140 141 //****************************************************************************** 142 //***** FCNTL.H functions 143 //****************************************************************************** 144 145 #ifndef _O_RDONLY // do not redefine existing FCNTL.H constants 146 147 #define _O_RDONLY 0x0000 // open for reading only 148 #define _O_WRONLY 0x0001 // open for writing only 149 #define _O_RDWR 0x0002 // open for reading and writing 150 #define _O_APPEND 0x0008 // writes done at eof 151 152 #define _O_CREAT 0x0100 // create and open file 153 #define _O_TRUNC 0x0200 // open and truncate 154 #define _O_EXCL 0x0400 // open only if file doesn't already exist 155 156 157 //# define _O_TEXT 0x4000 // file mode is text (translated) 158 #define _O_BINARY 0x8000 // file mode is binary (untranslated) 159 160 #endif // _O_RDONLY (and alikes...) undefined 161 162 #ifndef O_RDONLY // do not redefine existing FCNTL.H constants 163 164 #define O_RDONLY _O_RDONLY 165 #define O_WRONLY _O_WRONLY 166 #define O_RDWR _O_RDWR 167 #define O_APPEND _O_APPEND 168 #define O_CREAT _O_CREAT 169 #define O_TRUNC _O_TRUNC 170 #define O_EXCL _O_EXCL 171 #define O_TEXT _O_TEXT 172 #define O_BINARY _O_BINARY 173 //#define O_RAW _O_BINARY 174 //#define O_TEMPORARY _O_TEMPORARY 175 //#define O_NOINHERIT _O_NOINHERIT 176 //#define O_SEQUENTIAL _O_SEQUENTIAL 177 //#define O_RANDOM _O_RANDOM 178 179 #endif // O_RDONLY (and other old-fashioned constants) undefined 180 181 //****************************************************************************** 182 //***** IO.H functions 183 //****************************************************************************** 184 185 ZCRTIMP int __cdecl chmod(const char *, int); 186 ZCRTIMP int __cdecl close(int); 187 ZCRTIMP int __cdecl isatty(int); 188 ZCRTIMP long __cdecl lseek(int, long, int); 189 ZCRTIMP int __cdecl open(const char *, int, ...); 190 ZCRTIMP int __cdecl read(int, void *, unsigned int); 191 #if _WIN32_WCE < 211 192 ZCRTIMP int __cdecl setmode(int, int); 193 #else 194 # define setmode _setmode 195 #endif 196 ZCRTIMP int __cdecl unlink(const char *); 197 198 199 //****************************************************************************** 200 //***** STDIO.H functions 201 //****************************************************************************** 202 203 #if _WIN32_WCE < 211 //sr551b functions in stdlib CE300 204 //typedef struct _iobuf FILE; 205 typedef int FILE; 206 207 #define stdin ((int*)-2) 208 #define stdout ((int*)-3) 209 #define stderr ((int*)-4) 210 211 #define EOF (-1) 212 213 ZCRTIMP int __cdecl fflush(FILE *); 214 ZCRTIMP char * __cdecl fgets(char *, int, FILE *); 215 ZCRTIMP int __cdecl fileno(FILE *); 216 ZCRTIMP FILE * __cdecl fopen(const char *, const char *); 217 ZCRTIMP int __cdecl fprintf(FILE *, const char *, ...); 218 ZCRTIMP int __cdecl fclose(FILE *); 219 ZCRTIMP int __cdecl putc(int, FILE *); 220 ZCRTIMP int __cdecl sprintf(char *, const char *, ...); 221 #endif // _WIN32_WCE < 211 222 #if _WIN32_WCE >= 211 223 // CE falsely uses (FILE *) pointer args for UNIX style I/O functions that 224 // normally expect numeric file handles (e.g. setmode()) 225 # undef fileno 226 # define fileno(strm) (strm) 227 #endif // _WIN32_WCE < 211 228 #ifndef POCKET_UNZIP 229 ZCRTIMP void __cdecl perror(const char* errorText); 230 #endif 231 #ifdef USE_FWRITE 232 ZCRTIMP void __cdecl setbuf(FILE *, char *); 233 #endif 234 235 236 //****************************************************************************** 237 //***** STDLIB.H functions 238 //****************************************************************************** 239 240 #ifdef _MBCS 241 #ifndef MB_CUR_MAX 242 # define MB_CUR_MAX 2 243 #endif 244 ZCRTIMP int __cdecl mblen(const char *mbc, size_t mbszmax); 245 #endif /* _MBCS */ 246 #if _WIN32_WCE >= 211 247 # define errno ((int)GetLastError()) 248 #endif 249 #ifdef _WIN32_WCE_EMULATION 250 // The emulation runtime library lacks a required element for setjmp/longjmp, 251 // disable the recovery functionality for now. 252 # undef setjmp 253 # define setjmp(buf) 0 254 # undef longjmp 255 # define longjmp(buf, rv) 256 #endif 257 258 //****************************************************************************** 259 //***** STRING.H functions 260 //****************************************************************************** 261 262 ZCRTIMP int __cdecl _stricmp(const char *, const char *); 263 ZCRTIMP char * __cdecl _strupr(char *); 264 ZCRTIMP char * __cdecl strerror(int errnum); 265 ZCRTIMP char * __cdecl strrchr(const char *, int); 266 267 268 //****************************************************************************** 269 //***** TIME.H functions 270 //****************************************************************************** 271 272 #ifndef _TM_DEFINED 273 struct tm { 274 int tm_sec; // seconds after the minute - [0,59] 275 int tm_min; // minutes after the hour - [0,59] 276 int tm_hour; // hours since midnight - [0,23] 277 int tm_mday; // day of the month - [1,31] 278 int tm_mon; // months since January - [0,11] 279 int tm_year; // years since 1900 280 // int tm_wday; // days since Sunday - [0,6] 281 // int tm_yday; // days since January 1 - [0,365] 282 int tm_isdst; // daylight savings time flag 283 }; 284 #define _TM_DEFINED 285 #endif 286 287 ZCRTIMP struct tm * __cdecl localtime(const time_t *); 288 // tzset is not supported on native WCE, define it as a NOP macro 289 #ifndef tzset 290 # define tzset() 291 #endif 292 293 //****************************************************************************** 294 //***** SYS\STAT.H functions 295 //****************************************************************************** 296 297 struct stat { 298 // _dev_t st_dev; 299 // _ino_t st_ino; 300 unsigned short st_mode; 301 // short st_nlink; 302 // short st_uid; 303 // short st_gid; 304 // _dev_t st_rdev; 305 _off_t st_size; 306 // time_t st_atime; 307 time_t st_mtime; 308 // time_t st_ctime; 309 }; 310 311 #define _S_IFMT 0170000 // file type mask 312 #define _S_IFDIR 0040000 // directory 313 //#define _S_IFCHR 0020000 // character special 314 //#define _S_IFIFO 0010000 // pipe 315 #define _S_IFREG 0100000 // regular 316 #define _S_IREAD 0000400 // read permission, owner 317 #define _S_IWRITE 0000200 // write permission, owner 318 #define _S_IEXEC 0000100 // execute/search permission, owner 319 320 #define S_IFMT _S_IFMT 321 #define S_IFDIR _S_IFDIR 322 //#define S_IFCHR _S_IFCHR 323 //#define S_IFREG _S_IFREG 324 #define S_IREAD _S_IREAD 325 #define S_IWRITE _S_IWRITE 326 #define S_IEXEC _S_IEXEC 327 328 ZCRTIMP int __cdecl stat(const char *, struct stat *); 329 330 331 //****************************************************************************** 332 333 #endif // _WIN32_WCE 334 335 #ifdef __cplusplus 336 } // extern "C" 337 #endif 338 339 #endif // __WINCE_H__ 340