Qt 4.8
qfunctions_wince.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtCore module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QFUNCTIONS_WCE_H
43 #define QFUNCTIONS_WCE_H
44 #ifdef Q_OS_WINCE
45 #include <stdio.h>
46 #include <stdlib.h>
47 #include <windows.h>
48 #include <winuser.h>
49 #include <winbase.h>
50 #include <objbase.h>
51 #include <kfuncs.h>
52 #include <ctype.h>
53 #include <time.h>
54 #include <crtdefs.h>
55 #include <altcecrt.h>
56 #include <winsock.h>
57 #include <ceconfig.h>
58 
61 
62 #ifdef QT_BUILD_CORE_LIB
63 #ifdef __cplusplus // zlib is written in C, and does not like about the implementation of QT_MODULE macro
64 QT_MODULE(Core)
65 #endif // __cplusplus
66 #endif // QT_BUILD_CORE_LIB
67 
70 
71 
72 // The standard SDK misses this define...
73 #define _control87 _controlfp
74 
75 #if !defined __cplusplus
76 #define bool int
77 #define true 1
78 #define false 0
79 #endif
80 
81 // Environment ------------------------------------------------------
82 errno_t qt_wince_getenv_s(size_t*, char*, size_t, const char*);
83 errno_t qt_wince__putenv_s(const char*, const char*);
84 
85 // Std --------------------------------------------------------------
86 #ifdef __cplusplus // have this as tiff plugin is written in C
87 namespace std {
88  template <class T> inline T floor(const T& a) {return ::floor(a);}
89 }
90 
91 extern "C" {
92 #endif
93 
94 #if !defined(NO_ERRNO_H)
95 #define NO_ERRNO_H
96 #endif
97 
98 // Environment ------------------------------------------------------
99 int qt_wince__getpid(void);
100 
101 
102 // Time -------------------------------------------------------------
103 #ifndef _TM_DEFINED
104 #define _TM_DEFINED
105 struct tm {
106  int tm_sec; /* seconds after the minute - [0,59] */
107  int tm_min; /* minutes after the hour - [0,59] */
108  int tm_hour; /* hours since midnight - [0,23] */
109  int tm_mday; /* day of the month - [1,31] */
110  int tm_mon; /* months since January - [0,11] */
111  int tm_year; /* years since 1900 */
112  int tm_wday; /* days since Sunday - [0,6] */
113  int tm_yday; /* days since January 1 - [0,365] */
114  int tm_isdst; /* daylight savings time flag */
115 };
116 #endif // _TM_DEFINED
117 
118 FILETIME qt_wince_time_tToFt( time_t tt );
119 
120 // File I/O ---------------------------------------------------------
121 #define _O_RDONLY 0x0001
122 #define _O_RDWR 0x0002
123 #define _O_WRONLY 0x0004
124 #define _O_CREAT 0x0008
125 #define _O_TRUNC 0x0010
126 #define _O_APPEND 0x0020
127 #define _O_EXCL 0x0040
128 
129 #define O_RDONLY _O_RDONLY
130 #define O_RDWR _O_RDWR
131 #define O_WRONLY _O_WRONLY
132 #define O_CREAT _O_CREAT
133 #define O_TRUNC _O_TRUNC
134 #define O_APPEND _O_APPEND
135 #define O_EXCL _O_EXCL
136 
137 #define _S_IFMT 0x0600
138 #define _S_IFDIR 0x0200
139 #define _S_IFCHR 0x0100
140 #define _S_IFREG 0x0400
141 #define _S_IREAD 0x0010
142 #define _S_IWRITE 0x0008
143 
144 #define S_IFMT _S_IFMT
145 #define S_IFDIR _S_IFDIR
146 #define S_IFCHR _S_IFCHR
147 #define S_IFREG _S_IFREG
148 #define S_IREAD _S_IREAD
149 #define S_IWRITE _S_IWRITE
150 
151 #ifndef _IOFBF
152 #define _IOFBF 0x0000
153 #endif
154 
155 #ifndef _IOLBF
156 #define _IOLBF 0x0040
157 #endif
158 
159 #ifndef _IONBF
160 #define _IONBF 0x0004
161 #endif
162 
163 // Regular Berkeley error constants
164 #ifndef _STAT_DEFINED
165 #define _STAT_DEFINED
166 struct stat
167 {
168  int st_mode;
169  int st_size;
170  int st_nlink;
174 };
175 #endif
176 
177 typedef int mode_t;
178 extern int errno;
179 
180 int qt_wince__getdrive( void );
181 int qt_wince__waccess( const wchar_t *path, int pmode );
182 int qt_wince__wopen( const wchar_t *filename, int oflag, int pmode );
183 long qt_wince__lseek( int handle, long offset, int origin );
184 int qt_wince__read( int handle, void *buffer, unsigned int count );
185 int qt_wince__write( int handle, const void *buffer, unsigned int count );
186 int qt_wince__close( int handle );
187 FILE *qt_wince__fdopen(int handle, const char *mode);
188 FILE *qt_wince_fdopen(int handle, const char *mode);
189 void qt_wince_rewind( FILE *stream );
190 int qt_wince___fileno(FILE *);
191 FILE *qt_wince_tmpfile( void );
192 
193 //For zlib we need these helper functions, but they break the build when
194 //set globally, so just set them for zlib use
195 #ifdef ZLIB_H
196 #define open qt_wince_open
197 #define close qt_wince__close
198 #define lseek qt_wince__lseek
199 #define read qt_wince__read
200 #define write qt_wince__write
201 #endif
202 
203 int qt_wince__mkdir(const char *dirname);
204 int qt_wince__rmdir(const char *dirname);
205 int qt_wince__access( const char *path, int pmode );
206 int qt_wince__rename( const char *oldname, const char *newname );
207 int qt_wince__remove( const char *name );
208 #ifdef __cplusplus
209 int qt_wince_open( const char *filename, int oflag, int pmode = 0 );
210 #else
211 int qt_wince_open( const char *filename, int oflag, int pmode );
212 #endif
213 int qt_wince_stat( const char *path, struct stat *buffer );
214 int qt_wince__fstat( int handle, struct stat *buffer);
215 
216 #define SEM_FAILCRITICALERRORS 0x0001
217 #define SEM_NOOPENFILEERRORBOX 0x0002
218 int qt_wince_SetErrorMode(int);
219 #ifndef CoInitialize
220 #define CoInitialize(x) CoInitializeEx(x, COINIT_MULTITHREADED)
221 #endif
222 
223 bool qt_wince__chmod(const char *file, int mode);
224 bool qt_wince__wchmod(const wchar_t *file, int mode);
225 
226 #pragma warning(disable: 4273)
227 HANDLE qt_wince_CreateFileA(LPCSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE);
228 
229 // Printer ----------------------------------------------------------
230 #define ETO_GLYPH_INDEX 0x0010
231 
232 // Graphics ---------------------------------------------------------
233 #ifndef SM_CXCURSOR
234 # define SM_CXCURSOR 13
235 #endif
236 #ifndef SM_CYCURSOR
237 # define SM_CYCURSOR 14
238 #endif
239 BOOL qt_wince_SetWindowOrgEx( HDC hdc, int X, int Y, LPPOINT lpPoint );
240 
241 // Other stuff ------------------------------------------------------
242 #define MWMO_ALERTABLE 0x0002
243 // ### not the real values
244 #define CREATE_NO_WINDOW 2
245 #define CF_HDROP 15
246 
247 void *qt_wince_calloc(size_t num, size_t size);
248 #if !defined(TLS_OUT_OF_INDEXES)
249 # define TLS_OUT_OF_INDEXES 0xffffffff
250 #endif
251 DWORD qt_wince_GetThreadLocale(void);
252 
253 HANDLE qt_wince__beginthread(void( *start_address )( void * ), unsigned stack_size, void *arglist);
254 
255 unsigned long qt_wince__beginthreadex( void *security,
256  unsigned stack_size,
257  unsigned (__stdcall *start_address)(void *),
258  void *arglist,
259  unsigned initflag,
260  unsigned *thrdaddr );
261 void qt_wince__endthreadex(unsigned nExitCode);
262 
263 
264 // bsearch is needed for building the tiff plugin
265 // otherwise it could go into qguifunctions_wce
266 void *qt_wince_bsearch(const void *key,
267  const void *base,
268  size_t num,
269  size_t size,
270  int (__cdecl *compare)(const void *, const void *));
271 
272 // Missing typedefs
273 #ifndef _TIME_T_DEFINED
274 typedef unsigned long time_t;
275 #define _TIME_T_DEFINED
276 #endif
277 typedef HANDLE HDROP;
278 
279 #ifndef WS_THICKFRAME
280 #define WS_THICKFRAME WS_DLGFRAME
281 #endif
282 
283 typedef UINT UWORD;
284 
285 // Missing definitions: not necessary equal to their Win32 values
286 // (the goal is to just have a clean compilation of MFC)
287 #define WS_MAXIMIZE 0
288 #define WS_MINIMIZE 0
289 #ifndef WS_EX_TOOLWINDOW
290 #define WS_EX_TOOLWINDOW 0
291 #endif
292 #define WS_EX_NOPARENTNOTIFY 0
293 #define WM_ENTERIDLE 0x0121
294 #define WM_PRINT WM_PAINT
295 #define WM_NCCREATE (0x0081)
296 #define WM_PARENTNOTIFY 0
297 #define WM_NCDESTROY (WM_APP-1)
298 #ifndef SW_RESTORE
299 #define SW_RESTORE (SW_SHOWNORMAL)
300 #endif
301 #define SW_NORMAL (SW_SHOWNORMAL)
302 #define WAIT_OBJECT_0 0x00000000L
303 #define DEFAULT_GUI_FONT SYSTEM_FONT
304 #ifndef SWP_NOREDRAW
305 #define SWP_NOREDRAW 0
306 #endif
307 #define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
308 #define HWND_TOPMOST ((HWND)-1)
309 #define HWND_NOTOPMOST ((HWND)-2)
310 #define PS_DOT 2
311 #define PD_ALLPAGES 0
312 #define PD_USEDEVMODECOPIES 0
313 #define PD_NOSELECTION 0
314 #define PD_HIDEPRINTTOFILE 0
315 #define PD_NOPAGENUMS 0
316 #define CF_METAFILEPICT 3
317 #define MM_ANISOTROPIC 8
318 #define KF_ALTDOWN 0x2000
319 #define SPI_GETWORKAREA 48
320 
321 #ifndef WM_SETCURSOR
322  #define WM_SETCURSOR 0x0020
323  #define IDC_ARROW MAKEINTRESOURCE(32512)
324  #define IDC_IBEAM MAKEINTRESOURCE(32513)
325  #define IDC_WAIT MAKEINTRESOURCE(32514)
326  #define IDC_CROSS MAKEINTRESOURCE(32515)
327  #define IDC_UPARROW MAKEINTRESOURCE(32516)
328  #define IDC_SIZE MAKEINTRESOURCE(32646)
329  #define IDC_ICON MAKEINTRESOURCE(32512)
330  #define IDC_SIZENWSE MAKEINTRESOURCE(32642)
331  #define IDC_SIZENESW MAKEINTRESOURCE(32643)
332  #define IDC_SIZEWE MAKEINTRESOURCE(32644)
333  #define IDC_SIZENS MAKEINTRESOURCE(32645)
334  #define IDC_SIZEALL MAKEINTRESOURCE(32646)
335  #define IDC_NO MAKEINTRESOURCE(32648)
336  #define IDC_APPSTARTING MAKEINTRESOURCE(32650)
337  #define IDC_HELP MAKEINTRESOURCE(32651)
338  #define IDC_HAND MAKEINTRESOURCE(32649)
339 #endif
340 
341 #define GMEM_MOVEABLE LMEM_MOVEABLE
342 #define GPTR LPTR
343 
344 // WinCE: CESYSGEN prunes the following FRP defines,
345 // and INTERNET_TRANSFER_TYPE_ASCII breaks in wininet.h
346 #undef FTP_TRANSFER_TYPE_ASCII
347 #define FTP_TRANSFER_TYPE_ASCII 0x00000001
348 #undef FTP_TRANSFER_TYPE_BINARY
349 #define FTP_TRANSFER_TYPE_BINARY 0x00000002
350 
351 typedef DWORD OLE_COLOR;
352 
353 // Define the Windows Styles which are not defined by MS
354 #ifndef WS_POPUPWINDOW
355 #define WS_POPUPWINDOW WS_POPUP|WS_BORDER|WS_SYSMENU|WS_CAPTION
356 #endif
357 
358 #ifndef WS_OVERLAPPEDWINDOW
359 #define WS_OVERLAPPEDWINDOW WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_THICKFRAME|WS_MINIMIZEBOX|WS_MAXIMIZEBOX
360 #endif
361 
362 #ifndef WS_TILED
363 #define WS_TILED WS_OVERLAPPED
364 #endif
365 
366 #ifndef WS_TILEDWINDOW
367 #define WS_TILEDWINDOW WS_OVERLAPPEDWINDOW
368 #endif
369 
370 #ifndef WS_EX_CAPTIONOKBTN
371 #define WS_EX_CAPTIONOKBTN 0x80000000L
372 #endif
373 
374 #ifndef WS_EX_NODRAG
375 #define WS_EX_NODRAG 0x40000000L
376 #endif
377 
378 // As Windows CE lacks some standard functions used in Qt, these got
379 // reimplented. Other projects do this as well and to not fill the
380 // global namespace with this implementation, prepend qt_wince* and use
381 // these versions inside of Qt.
382 // The other declarations available in this file are being used per
383 // define inside qplatformdefs.h of the corresponding WinCE mkspec.
384 #define getenv_s(a,b,c,d) qt_wince_getenv_s(a,b,c,d)
385 #define _putenv_s(a,b) qt_wince__putenv_s(a,b)
386 #define _getpid() qt_wince__getpid()
387 #define time_tToFt(a) qt_wince_time_tToFt(a)
388 #define _getdrive() qt_wince__getdrive()
389 #define _waccess(a,b) qt_wince__waccess(a,b)
390 #define _wopen(a,b,c) qt_wince__wopen(a,b,c)
391 #define _fdopen(a,b) qt_wince__fdopen(a,b)
392 #define fdopen(a,b) qt_wince_fdopen(a,b)
393 #define rewind(a) qt_wince_rewind(a)
394 #define tmpfile() qt_wince_tmpfile()
395 #define _rename(a,b) qt_wince__rename(a,b)
396 #define _remove(a) qt_wince__remove(a)
397 #define SetErrorMode(a) qt_wince_SetErrorMode(a)
398 #define _chmod(a,b) qt_wince__chmod(a,b)
399 #define _wchmod(a,b) qt_wince__wchmod(a,b)
400 #define CreateFileA(a,b,c,d,e,f,g) qt_wince_CreateFileA(a,b,c,d,e,f,g)
401 #define SetWindowOrgEx(a,b,c,d) qt_wince_SetWindowOrgEx(a,b,c,d)
402 #define calloc(a,b) qt_wince_calloc(a,b)
403 #define GetThreadLocale() qt_wince_GetThreadLocale()
404 #define _beginthread(a,b,c) qt_wince__beginthread(a,b,c)
405 #define _beginthreadex(a,b,c,d,e,f) qt_wince__beginthreadex(a,b,c,d,e,f)
406 #define _endthreadex(a) qt_wince__endthreadex(a)
407 #define bsearch(a,b,c,d,e) qt_wince_bsearch(a,b,c,d,e)
408 
409 #ifdef __cplusplus
410 } // Extern C.
411 #endif
412 
413 #endif // Q_OS_WINCE
414 #endif // QFUNCTIONS_WCE_H
int tm_min
long qt_wince__lseek(int handle, long offset, int origin)
void * qt_wince_bsearch(const void *key, const void *base, size_t num, size_t size, int(__cdecl *compare)(const void *, const void *))
UINT UWORD
DWORD qt_wince_GetThreadLocale(void)
void qt_wince_rewind(FILE *stream)
int qt_wince__rmdir(const char *dirname)
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QT_MODULE(x)
Definition: qglobal.h:2783
time_t st_ctime
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
errno_t qt_wince_getenv_s(size_t *, char *, size_t, const char *)
int tm_mday
FILETIME qt_wince_time_tToFt(time_t tt)
HANDLE qt_wince__beginthread(void(*start_address)(void *), unsigned stack_size, void *arglist)
bool qt_wince__wchmod(const wchar_t *file, int mode)
int qt_wince___fileno(FILE *)
int tm_year
long ASN1_INTEGER_get ASN1_INTEGER * a
int qt_wince__remove(const char *name)
STL namespace.
int qt_wince__fstat(int handle, struct stat *buffer)
int qt_wince__getdrive(void)
static const uint base
Definition: qurl.cpp:268
int qt_wince_SetErrorMode(int)
void qt_wince__endthreadex(unsigned nExitCode)
int mode_t
FILE * qt_wince__fdopen(int handle, const char *mode)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static bool compare(const QVariant::Private *a, const QVariant::Private *b)
Compares a to b.
Definition: qvariant.cpp:383
static FILE * stream
unsigned long time_t
FILE * qt_wince_tmpfile(void)
int tm_mon
const char * name
int qt_wince__waccess(const wchar_t *path, int pmode)
int qt_wince__close(int handle)
void * HANDLE
Definition: qnamespace.h:1671
BOOL qt_wince_SetWindowOrgEx(HDC hdc, int X, int Y, LPPOINT lpPoint)
HANDLE qt_wince_CreateFileA(LPCSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE)
FILE * qt_wince_fdopen(int handle, const char *mode)
int qt_wince__mkdir(const char *dirname)
int qt_wince__access(const char *path, int pmode)
HANDLE HDROP
bool qt_wince__chmod(const char *file, int mode)
T floor(const T &a)
int qt_wince__wopen(const wchar_t *filename, int oflag, int pmode)
int tm_wday
DWORD OLE_COLOR
int tm_yday
int key
time_t st_atime
int qt_wince_open(const char *filename, int oflag, int pmode=0)
errno_t qt_wince__putenv_s(const char *, const char *)
int tm_sec
int qt_wince__write(int handle, const void *buffer, unsigned int count)
unsigned long qt_wince__beginthreadex(void *security, unsigned stack_size, unsigned(__stdcall *start_address)(void *), void *arglist, unsigned initflag, unsigned *thrdaddr)
int qt_wince_stat(const char *path, struct stat *buffer)
void * qt_wince_calloc(size_t num, size_t size)
int tm_hour
int st_nlink
#define QT_END_HEADER
Definition: qglobal.h:137
time_t st_mtime
int tm_isdst
int qt_wince__getpid(void)
int qt_wince__rename(const char *oldname, const char *newname)
int errno
int qt_wince__read(int handle, void *buffer, unsigned int count)