sipxportlib  Version 3.3
WinCEFixups.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2006-2008 SIPfoundry Inc.
3 // Licensed by SIPfoundry under the LGPL license.
4 //
5 // Copyright (C) 2006-2008 SIPez LLC.
6 // Licensed to SIPfoundry under a Contributor Agreement.
7 //
8 // $$
10 
11 #ifndef _WINCEFIXUPS_H_
12 #define _WINCEFIXUPS_H_
13 
14 #if _WIN32_WCE >= 0x0600
15 #define _CRT_SECURE_NO_DEPRECATE
16 #endif
17 
18 #include <windows.h>
19 #include <string.h>
20 #include <stdio.h>
21 
22 // GetProcAddress( )
23 #include <winbase.h>
24 #include <assert.h>
25 #include <time.h>
26 #ifdef WINCE
27 #include <crtdefs.h>
28 #endif
29 
30 // The assert( ) macro explicitly uses OutputDebugstringW( ), which explicitly overrides our _MBCS compiler flag.
31 // Therefore, we need to explicitly fix this...
32 #undef ASSERT_PRINT
33 #undef ASSERT_AT
34 #undef assert
35 #define ASSERT_PRINT(exp,file,line) OutputDebugStringB(TEXT("\r\n*** ASSERTION FAILED in ") TEXT(file) TEXT("(") TEXT(#line) TEXT("):\r\n") TEXT(#exp) TEXT("\r\n"))
36 #define ASSERT_AT(exp,file,line) (void)( (exp) || (ASSERT_PRINT(exp,file,line), DebugBreak(), 0 ) )
37 #define assert(exp) ASSERT_AT(exp,__FILE__,__LINE__)
38 
39 #ifndef _WIN32_WCE
40 typedef long intptr_t;
41 #endif
42 
43 #define sprintf_s _snprintf
44 
45 struct _timeb
46 {
47  time_t time;
48  unsigned short millitm;
49  short timezone;
50  short dstflag;
51 };
52 
53 #define stricmp(x, y ) _stricmp( (x), (y) )
54 #define strcasecmp _stricmp
55 #define strncasecmp _strnicmp
56 
57 #undef RegQueryValueEx
58 #define RegQueryValueEx(x,y,z,a,b,c) RegQueryValueExB(x,y,z,a,b,c)
59 #undef FormatMessage
60 #define FormatMessage(x,y,z,a,b,c,d) FormatMessageB(x,y,z,a,b,c,d)
61 #undef CreateMutex
62 #define CreateMutex( x,y,z) CreateMutexB( x,y,z)
63 #undef CreateSemaphore
64 #define CreateSemaphore( x,y,z,a) CreateSemaphoreB( x,y,z,a)
65 #undef CreateProcess
66 #define CreateProcess(x,y,z,a,b,c,d,e,f,g) CreateProcessB(x,y,z,a,b,c,d,e,f,g)
67 #undef CreateFile
68 #define CreateFile(x,y,z,a,b,c,d) CreateFileB(x,y,z,a,b,c,d)
69 #undef OutputDebugString
70 #define OutputDebugString(x) OutputDebugStringB(x)
71 
72 #define SEM_FAILCRITICALERRORS 0
73 
74 #define chdir(x) _chdir(x)
75 #define strdup(x) _strdup(x)
76 #define itoa(x, y, z) _itoa(x, y, z)
77 #define memicmp(x, y, z) _memicmp(x, y, z)
78 #define putenv(x) _putenv(x)
79 
80 #define EACCES 13 // Orig 1
81 #define EMFILE 24 // Orig 2
82 #define ENOENT 2 // Orig 3
83 
84 //#define OutputDebugstringW(x) OutputDebugStringA(x)
85 #define GetProcAddressW(x, y) GetProcAddressA(x, y)
86 
87 // for the file res_query.c
88 #define BUFSIZ 2048
89 #define EINVAL 22 // Orig 1234
90 #define EINTR 4 // Orig 1235
91 
92 //FIXME! Need to be sent with care
93 #define ETIMEDOUT 100
94 #define ECONNRESET 101
95 #define EMSGSIZE 102
96 #define ECONNREFUSED 103
97 
99 {
100  unsigned attrib;
101  time_t time_create;
102  time_t time_access;
103  time_t time_write;
104  // JEP - TODO - fix this
105 // _fsize_t size;
106  int size;
107  char name[ 260 ];
108 };
109 
110 #define _A_NORMAL 0x00
111 #define _A_RDONLY 0x01
112 #define _A_HIDDEN 0x02
113 #define _A_SYSTEM 0x04
114 #define _A_SUBDIR 0x10
115 #define _A_ARCH 0x20
116 
117 typedef struct _xFILETIME {
120 } *xLPFILETIME;
121 //} FILETIME, *PFILETIME, *LPFILETIME;
122 
123 #define O_RDONLY 0x0000
124 #define O_WRONLY 0x0001
125 #define O_RDWR 0x0002
126 #define O_APPEND 0x0008
127 
128 #define O_CREAT 0x0100
129 #define O_TRUNC 0x0200
130 #define O_EXCL 0x0400
131 
132 #define O_TEXT 0x4000 /* file mode is text (translated) */
133 #define O_BINARY 0x8000 /* file mode is binary (untranslated) */
134 
135 #define _S_IFMT 0x0001 // mask type
136 #define _S_IFDIR 0x0002 // directory
137 #define _S_IFCHR 0x0004 // Character special (indicates a device if set)
138 #define _S_IFREG 0x0008 // Regular
139 #define _S_IREAD 0x0010 // Read permission, owner
140 #define _S_IWRITE 0x0020 // Write permission, owner
141 #define _S_IEXEC 0x0040 // Execute/serach permission, owner
142 
143 #define S_IFMT 0x0001 // mask type
144 #define S_IFDIR 0x0002 // directory
145 #define S_IFCHR 0x0004 // Character special (indicates a device if set)
146 #define S_IFREG 0x0008 // Regular
147 #define S_IREAD 0x0010 // Read permission, owner
148 #define S_IWRITE 0x0020 // Write permission, owner
149 #define S_IEXEC 0x0040 // Execute/serach permission, owner
150 
151 struct stat
152 {
153  int st_atime;
154  int st_ctime;
155  int st_dev;
156  int st_mode;
157  int st_mtime;
158  int st_nlink;
159  int st_rdev;
160  int st_size;
161 };
162 
163 
164 
165 #define STARTF_USESTDHANDLES 0x00000100
166 
167 
168 //#define INVALID_HANDLE_VALUE -1
169 #define STD_INPUT_HANDLE -10
170 #define STD_OUTPUT_HANDLE -11
171 #define STD_ERROR_HANDLE -12
172 
173 
174 //
175 // To avoid the 2000+ warning messages at link time
176 // I need to define these functions only once.
177 // So I picked the file PluginHooks.cpp to be my anchor.
178 // The macro PLUGIN_HOOKS is defined only for this file.
179 //
180 
181 
182 extern char *_tzname[ 2 ];
183 
184 #ifdef __cplusplus
185  extern "C" int errno;
186 #else
187  extern int errno;
188 #endif
189 
190 long RegQueryValueExB( HKEY hKey, const char *lpName, DWORD *lpReserved, DWORD *lpType, unsigned char *lpData, DWORD *lpcbData );
191 HANDLE CreateMutexB( LPSECURITY_ATTRIBUTES lpMutexAttr, BOOL bInitialOwner, char *pNme );
192 DWORD FormatMessageB( DWORD dwFlags, void *lpVoid, DWORD dwMessageID, DWORD dwLangID, char *pBuffer, DWORD dwSize, va_list *Args );
193 HANDLE CreateSemaphoreB( LPSECURITY_ATTRIBUTES lpSemaphoreAttr, LONG lInitialCount, LONG lMaxCount, char *pName );
194 HANDLE CreateFileB( const char *pFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
195  LPSECURITY_ATTRIBUTES lpSecAttr, DWORD dwCreationDisp, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile );
196 BOOL CreateProcessB( char *pName,
197  char *pCmdLine,
198  LPSECURITY_ATTRIBUTES lpsaProcess,
199  LPSECURITY_ATTRIBUTES lpsaThread,
200  BOOL fInheritHandles,
201  DWORD dwCreate,
202  LPVOID lpvEnv,
203  char *pCurDir,
204  LPSTARTUPINFO lpStartUpInfo,
205  LPPROCESS_INFORMATION lpProcInfo );
206 
207 HINSTANCE LoadLibraryA( LPCSTR pIn );
208 WINBASEAPI HMODULE WINAPI GetModuleHandleA( LPCSTR pIn );
209 
210 int rmdir( const char * dirname );
211 char * getcwd( char *buffer, int maxlen );
212 unsigned int GetSystemDirectory( char *cP, unsigned int uSize );
213 void _ftime( struct _timeb *);
214 void GetSystemTimeAsFileTime( LPFILETIME pFT );
215 void OutputDebugStringB( const char *pC );
216 //void WINAPI OutputDebugStringW( char *pC );
217 void WINAPI perror( char *pC );
218 int SetErrorMode( int iUnused );
219 char * WINAPI strerror( int iErrNo );
220 int _chdir( const char *p1 );
221 int _mkdir( const char *p1 );
222 int rename( const char *p1, const char *p2 );
223 int remove( const char *p1 );
224 int _open( const char *filename, int oflag );
225 int _close( int fd );
226 void * _findclose( long hFile );
227 intptr_t _findnext( long hFile, struct _finddata_t *pFD );
228 intptr_t _findfirst( const char *pName, struct _finddata_t *pFD );
229 HANDLE GetStdHandle( int nStdHandle );
230 int _putenv( const char *pIn );
231 int write( int fd, const void *buffer, unsigned int count );
232 int open( const char *filename, int oflag );
233 #pragma warning( disable : 4031 )
234 int open( const char *filename, int oflag, int pmode );
235 #pragma warning( default : 4031 )
236 int close( int fd );
237 long lseek( int fd, long offset, int origin );
238 int fstat( int fd, struct stat *buffer );
239 int read( int fd, void *buffer, unsigned int count );
240 
241 #ifdef __cplusplus
242  extern "C" int _getpid();
243 #else
244  extern int _getpid();
245 #endif
246 
247 // Have to build stuff not just from WinBase but also from WinUser.h
248 
249 BOOL PostThreadMessageA(DWORD idThread, UINT Msg,
250  WPARAM wParam,
251  LPARAM lParam);
252 int GetMessageA(LPMSG lpMsg,HWND hWnd,unsigned int wMsgFilterMin,unsigned int wMsgFilterMax) ;
253 
254 
255 /* The following functions have to tobe deffed and undefed this is not a mistake */
256 
257 #undef CreateEventA
258 #define CreateEventA CE_CreateEventA
259 HANDLE CE_CreateEventA(
260  LPSECURITY_ATTRIBUTES lpEventAttributes,
261  BOOL bManualReset,
262  BOOL bInitialState,
263  LPTSTR lpName) ;
264 
265 #undef RegOpenKeyExA
266 #define RegOpenKeyExA CE_RegOpenKeyExA
267 long CE_RegOpenKeyExA ( HKEY hKey,
268  LPCSTR lpSubKey,
269  DWORD ulOptions,
270  REGSAM samDesired,
271  PHKEY phkResult
272  );
273 /* Came from mmsystem.h */
274 
275 WINMMAPI MMRESULT WINAPI timeSetEvent(UINT uDelay, UINT uResolution,
276  LPTIMECALLBACK fptc, DWORD dwUser, UINT fuEvent);
277 
278 /* waveform input device capabilities structure */
279 typedef struct tagWAVEINCAPS_W {
280  WORD wMid; /* manufacturer ID */
281  WORD wPid; /* product ID */
282  MMVERSION vDriverVersion; /* version of the driver */
283  WCHAR szPname[MAXPNAMELEN]; /* product name (NULL terminated string) */
284  DWORD dwFormats; /* formats supported */
285  WORD wChannels; /* number of channels supported */
286  WORD wReserved1; /* structure packing */
287 } WAVEINCAPS_W;
288 
289 #ifdef __cplusplus
290 extern "C" {
291 #endif
292 
293 size_t strftime(char * const s, const size_t maxsize, const char * const format, const struct tm * const t);
294 time_t mktime(struct tm *t);
295 struct tm * __cdecl gmtime( const time_t *timer );
296 struct tm * __cdecl localtime( const time_t *timer );
297 time_t __cdecl time( time_t *ptt );
298 
299 #ifdef __cplusplus
300 }
301 #endif
302 
303 #endif // _WINCEFIXUPS_H_
304 
Definition: WinCEFixups.h:279
void WINAPI perror(char *pC)
WINBASEAPI HMODULE WINAPI GetModuleHandleA(LPCSTR pIn)
int rename(const char *p1, const char *p2)
long intptr_t
Definition: WinCEFixups.h:40
BOOL PostThreadMessageA(DWORD idThread, UINT Msg, WPARAM wParam, LPARAM lParam)
DWORD dwFormats
Definition: WinCEFixups.h:284
HANDLE CreateSemaphoreB(LPSECURITY_ATTRIBUTES lpSemaphoreAttr, LONG lInitialCount, LONG lMaxCount, char *pName)
HINSTANCE LoadLibraryA(LPCSTR pIn)
int st_nlink
Definition: WinCEFixups.h:158
void _ftime(struct _timeb *)
short dstflag
Definition: WinCEFixups.h:50
MMVERSION vDriverVersion
Definition: WinCEFixups.h:282
int read(int fd, void *buffer, unsigned int count)
int open(const char *filename, int oflag)
int size
Definition: WinCEFixups.h:106
int SetErrorMode(int iUnused)
size_t strftime(char *const s, const size_t maxsize, const char *const format, const struct tm *const t)
int st_rdev
Definition: WinCEFixups.h:159
int GetMessageA(LPMSG lpMsg, HWND hWnd, unsigned int wMsgFilterMin, unsigned int wMsgFilterMax)
HANDLE CreateMutexB(LPSECURITY_ATTRIBUTES lpMutexAttr, BOOL bInitialOwner, char *pNme)
struct tagWAVEINCAPS_W WAVEINCAPS_W
long CE_RegOpenKeyExA(HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
void GetSystemTimeAsFileTime(LPFILETIME pFT)
int fstat(int fd, struct stat *buffer)
char *WINAPI strerror(int iErrNo)
WORD wPid
Definition: WinCEFixups.h:281
BOOL CreateProcessB(char *pName, char *pCmdLine, LPSECURITY_ATTRIBUTES lpsaProcess, LPSECURITY_ATTRIBUTES lpsaThread, BOOL fInheritHandles, DWORD dwCreate, LPVOID lpvEnv, char *pCurDir, LPSTARTUPINFO lpStartUpInfo, LPPROCESS_INFORMATION lpProcInfo)
time_t time
Definition: WinCEFixups.h:47
time_t time_create
Definition: WinCEFixups.h:101
HANDLE CE_CreateEventA(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPTSTR lpName)
unsigned attrib
Definition: WinCEFixups.h:100
intptr_t _findnext(long hFile, struct _finddata_t *pFD)
unsigned int GetSystemDirectory(char *cP, unsigned int uSize)
int dwHighDateTime
Definition: WinCEFixups.h:119
int st_atime
Definition: WinCEFixups.h:153
short timezone
Definition: WinCEFixups.h:49
HANDLE GetStdHandle(int nStdHandle)
long RegQueryValueExB(HKEY hKey, const char *lpName, DWORD *lpReserved, DWORD *lpType, unsigned char *lpData, DWORD *lpcbData)
int write(int fd, const void *buffer, unsigned int count)
int _getpid()
int errno
int rmdir(const char *dirname)
char * _tzname[2]
HANDLE CreateFileB(const char *pFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecAttr, DWORD dwCreationDisp, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
time_t time_write
Definition: WinCEFixups.h:103
char * getcwd(char *buffer, int maxlen)
Definition: WinCEFixups.h:151
int _chdir(const char *p1)
struct tm *__cdecl localtime(const time_t *timer)
struct tm *__cdecl gmtime(const time_t *timer)
intptr_t _findfirst(const char *pName, struct _finddata_t *pFD)
void OutputDebugStringB(const char *pC)
struct _xFILETIME * xLPFILETIME
DWORD FormatMessageB(DWORD dwFlags, void *lpVoid, DWORD dwMessageID, DWORD dwLangID, char *pBuffer, DWORD dwSize, va_list *Args)
int close(int fd)
void * _findclose(long hFile)
Definition: WinCEFixups.h:117
int _open(const char *filename, int oflag)
WORD wChannels
Definition: WinCEFixups.h:285
int _close(int fd)
long lseek(int fd, long offset, int origin)
int st_dev
Definition: WinCEFixups.h:155
int st_size
Definition: WinCEFixups.h:160
int st_mode
Definition: WinCEFixups.h:156
time_t time_access
Definition: WinCEFixups.h:102
unsigned short millitm
Definition: WinCEFixups.h:48
int dwLowDateTime
Definition: WinCEFixups.h:118
WORD wMid
Definition: WinCEFixups.h:280
Definition: WinCEFixups.h:98
_W64 signed int intptr_t
Definition: stdint.h:118
int st_ctime
Definition: WinCEFixups.h:154
int st_mtime
Definition: WinCEFixups.h:157
time_t mktime(struct tm *t)
int _putenv(const char *pIn)
int _mkdir(const char *p1)
Definition: WinCEFixups.h:45
WINMMAPI MMRESULT WINAPI timeSetEvent(UINT uDelay, UINT uResolution, LPTIMECALLBACK fptc, DWORD dwUser, UINT fuEvent)
WORD wReserved1
Definition: WinCEFixups.h:286