Add a few more 32->16 Escape conversions.
[wine/hacks.git] / include / windef.h
blobb6057c6590c17493f60acf08c8ec711276e67262
1 /*
2 * Basic types definitions
4 * Copyright 1996 Alexandre Julliard
5 */
7 #ifndef __WINE_WINDEF_H
8 #define __WINE_WINDEF_H
10 #ifdef __WINE__
11 # include "config.h"
12 # undef UNICODE
13 #endif /* __WINE__ */
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
19 /* Misc. constants. */
21 #ifdef FALSE
22 #undef FALSE
23 #endif
24 #define FALSE 0
26 #ifdef TRUE
27 #undef TRUE
28 #endif
29 #define TRUE 1
31 #ifdef NULL
32 #undef NULL
33 #endif
34 #define NULL 0
36 /* Macros to map Winelib names to the correct implementation name */
37 /* depending on __WINE__ and UNICODE macros. */
38 /* Note that Winelib is purely Win32. */
40 #ifdef __WINE__
41 # define WINELIB_NAME_AW(func) this_is_a_syntax_error this_is_a_syntax_error
42 #else /* __WINE__ */
43 # ifdef UNICODE
44 # define WINELIB_NAME_AW(func) func##W
45 # else
46 # define WINELIB_NAME_AW(func) func##A
47 # endif /* UNICODE */
48 #endif /* __WINE__ */
50 #ifdef __WINE__
51 # define DECL_WINELIB_TYPE_AW(type) /* nothing */
52 #else /* __WINE__ */
53 # define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type;
54 #endif /* __WINE__ */
57 /* Calling conventions definitions */
59 #ifdef __i386__
60 # if defined(__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)
61 # define __stdcall __attribute__((__stdcall__))
62 # define __cdecl __attribute__((__cdecl__))
63 # define __RESTORE_ES __asm__ __volatile__("pushl %ds\n\tpopl %es")
64 # else
65 # error You need gcc >= 2.7 to build Wine on a 386
66 # endif /* __GNUC__ */
67 #else /* __i386__ */
68 # define __stdcall
69 # define __cdecl
70 # define __RESTORE_ES
71 #endif /* __i386__ */
73 #define CALLBACK __stdcall
74 #define WINAPI __stdcall
75 #define APIPRIVATE __stdcall
76 #define PASCAL __stdcall
77 #define pascal __stdcall
78 #define _pascal __stdcall
79 #define _stdcall __stdcall
80 #define _fastcall __stdcall
81 #define __export __stdcall
82 #define CDECL __cdecl
83 #define _CDECL __cdecl
84 #define cdecl __cdecl
85 #define _cdecl __cdecl
86 #define WINAPIV __cdecl
87 #define APIENTRY WINAPI
89 #define __declspec(x)
90 #define dllimport
91 #define dllexport
93 #define CONST const
95 /* Standard data types. These are the same for emulator and library. */
97 typedef void VOID;
98 typedef short INT16;
99 typedef unsigned short UINT16;
100 typedef int INT;
101 typedef unsigned int UINT;
102 typedef unsigned short WORD;
103 typedef unsigned long DWORD;
104 typedef unsigned long ULONG;
105 typedef unsigned char BYTE;
106 typedef long LONG;
107 typedef short SHORT;
108 typedef unsigned short USHORT;
109 typedef char CHAR;
110 typedef unsigned char UCHAR;
111 /* Some systems might have wchar_t, but we really need 16 bit characters */
112 typedef unsigned short WCHAR;
113 typedef unsigned short BOOL16;
114 typedef int BOOL;
115 typedef double DATE;
116 typedef long LONG_PTR;
117 typedef unsigned long ULONG_PTR;
118 typedef double DOUBLE;
119 typedef double LONGLONG;
120 typedef double ULONGLONG;
122 /* FIXME: Wine does not compile with strict on, therefore strict
123 * handles are presently only usable on machines where sizeof(UINT) ==
124 * sizeof(void*). HANDLEs are supposed to be void* but a large amount
125 * of WINE code operates on HANDLES as if they are UINTs. So to WINE
126 * they exist as UINTs but to the Winelib user who turns on strict,
127 * they exist as void*. If there is a size difference between UINT and
128 * void* then things get ugly. */
129 #ifdef STRICT
130 typedef UINT16 HANDLE16;
131 typedef VOID* HANDLE;
132 #else
133 typedef UINT16 HANDLE16;
134 typedef UINT HANDLE;
135 #endif
137 typedef HANDLE16 *LPHANDLE16;
138 typedef HANDLE *LPHANDLE;
140 /* Integer types. These are the same for emulator and library. */
141 typedef UINT16 WPARAM16;
142 typedef UINT WPARAM;
143 typedef LONG LPARAM;
144 typedef LONG HRESULT;
145 typedef LONG LRESULT;
146 typedef WORD ATOM;
147 typedef WORD CATCHBUF[9];
148 typedef WORD *LPCATCHBUF;
149 typedef DWORD ACCESS_MASK;
150 typedef ACCESS_MASK REGSAM;
151 typedef HANDLE HHOOK;
152 typedef HANDLE HKEY;
153 typedef HANDLE HMONITOR;
154 typedef DWORD LCID;
155 typedef WORD LANGID;
156 typedef DWORD LCTYPE;
157 typedef float FLOAT;
158 typedef long long __int64;
160 /* Pointers types. These are the same for emulator and library. */
161 /* winnt types */
162 typedef VOID *PVOID;
163 typedef const void *PCVOID;
164 typedef CHAR *PCHAR;
165 typedef UCHAR *PUCHAR;
166 typedef BYTE *PBYTE;
167 typedef ULONG *PULONG;
168 typedef LONG *PLONG;
169 typedef DWORD *PDWORD;
170 /* common win32 types */
171 typedef CHAR *LPSTR;
172 typedef CHAR *PSTR;
173 typedef const CHAR *LPCSTR;
174 typedef const CHAR *PCSTR;
175 typedef WCHAR *LPWSTR;
176 typedef WCHAR *PWSTR;
177 typedef const WCHAR *LPCWSTR;
178 typedef const WCHAR *PCWSTR;
179 typedef BYTE *LPBYTE;
180 typedef WORD *LPWORD;
181 typedef DWORD *LPDWORD;
182 typedef LONG *LPLONG;
183 typedef VOID *LPVOID;
184 typedef const VOID *LPCVOID;
185 typedef INT16 *LPINT16;
186 typedef UINT16 *LPUINT16;
187 typedef INT *PINT;
188 typedef INT *LPINT;
189 typedef UINT *PUINT;
190 typedef UINT *LPUINT;
191 typedef HKEY *LPHKEY;
192 typedef HKEY *PHKEY;
193 typedef FLOAT *PFLOAT;
194 typedef FLOAT *LPFLOAT;
195 typedef BOOL *PBOOL;
196 typedef BOOL *LPBOOL;
198 /* Special case: a segmented pointer is just a pointer in the user's code. */
200 #ifdef __WINE__
201 typedef DWORD SEGPTR;
202 #else
203 typedef void* SEGPTR;
204 #endif /* __WINE__ */
206 /* Handle types that exist both in Win16 and Win32. */
208 #ifdef STRICT
209 #define DECLARE_HANDLE(a) \
210 typedef HANDLE16 a##16; \
211 typedef a##16 *P##a##16; \
212 typedef a##16 *NP##a##16; \
213 typedef a##16 *LP##a##16; \
214 typedef struct a##__ { int unused; } *a; \
215 typedef a *P##a; \
216 typedef a *LP##a
217 #else /*STRICT*/
218 #define DECLARE_HANDLE(a) \
219 typedef HANDLE16 a##16; \
220 typedef a##16 *P##a##16; \
221 typedef a##16 *NP##a##16; \
222 typedef a##16 *LP##a##16; \
223 typedef HANDLE a; \
224 typedef a *P##a; \
225 typedef a *LP##a
226 #endif /*STRICT*/
228 DECLARE_HANDLE(HACMDRIVERID);
229 DECLARE_HANDLE(HACMDRIVER);
230 DECLARE_HANDLE(HACMOBJ);
231 DECLARE_HANDLE(HACMSTREAM);
232 DECLARE_HANDLE(HMETAFILEPICT);
234 DECLARE_HANDLE(HACCEL);
235 DECLARE_HANDLE(HBITMAP);
236 DECLARE_HANDLE(HBRUSH);
237 DECLARE_HANDLE(HCOLORSPACE);
238 DECLARE_HANDLE(HCURSOR);
239 DECLARE_HANDLE(HDC);
240 DECLARE_HANDLE(HDROP);
241 DECLARE_HANDLE(HDRVR);
242 DECLARE_HANDLE(HDWP);
243 DECLARE_HANDLE(HENHMETAFILE);
244 DECLARE_HANDLE(HFILE);
245 DECLARE_HANDLE(HFONT);
246 DECLARE_HANDLE(HICON);
247 DECLARE_HANDLE(HINSTANCE);
248 DECLARE_HANDLE(HMENU);
249 DECLARE_HANDLE(HMETAFILE);
250 DECLARE_HANDLE(HMIDI);
251 DECLARE_HANDLE(HMIDIIN);
252 DECLARE_HANDLE(HMIDIOUT);
253 DECLARE_HANDLE(HMIDISTRM);
254 DECLARE_HANDLE(HMIXER);
255 DECLARE_HANDLE(HMIXEROBJ);
256 DECLARE_HANDLE(HMMIO);
257 DECLARE_HANDLE(HPALETTE);
258 DECLARE_HANDLE(HPEN);
259 DECLARE_HANDLE(HQUEUE);
260 DECLARE_HANDLE(HRGN);
261 DECLARE_HANDLE(HRSRC);
262 DECLARE_HANDLE(HTASK);
263 DECLARE_HANDLE(HWAVE);
264 DECLARE_HANDLE(HWAVEIN);
265 DECLARE_HANDLE(HWAVEOUT);
266 DECLARE_HANDLE(HWINSTA);
267 DECLARE_HANDLE(HDESK);
268 DECLARE_HANDLE(HWND);
269 DECLARE_HANDLE(HKL);
270 DECLARE_HANDLE(HIC);
271 DECLARE_HANDLE(HRASCONN);
272 #undef DECLARE_HANDLE
274 /* Handle types that must remain interchangeable even with strict on */
276 typedef HINSTANCE16 HMODULE16;
277 typedef HINSTANCE HMODULE;
278 typedef HANDLE16 HGDIOBJ16;
279 typedef HANDLE16 HGLOBAL16;
280 typedef HANDLE16 HLOCAL16;
281 typedef HANDLE HGDIOBJ;
282 typedef HANDLE HGLOBAL;
283 typedef HANDLE HLOCAL;
285 /* Callback function pointers types */
287 typedef BOOL (CALLBACK* DATEFMT_ENUMPROCA)(LPSTR);
288 typedef BOOL (CALLBACK* DATEFMT_ENUMPROCW)(LPWSTR);
289 DECL_WINELIB_TYPE_AW(DATEFMT_ENUMPROC)
290 typedef BOOL16 (CALLBACK *DLGPROC16)(HWND16,UINT16,WPARAM16,LPARAM);
291 typedef BOOL (CALLBACK *DLGPROC)(HWND,UINT,WPARAM,LPARAM);
292 typedef LRESULT (CALLBACK *DRIVERPROC16)(DWORD,HDRVR16,UINT16,LPARAM,LPARAM);
293 typedef LRESULT (CALLBACK *DRIVERPROC)(DWORD,HDRVR,UINT,LPARAM,LPARAM);
294 typedef INT16 (CALLBACK *EDITWORDBREAKPROC16)(LPSTR,INT16,INT16,INT16);
295 typedef INT (CALLBACK *EDITWORDBREAKPROCA)(LPSTR,INT,INT,INT);
296 typedef INT (CALLBACK *EDITWORDBREAKPROCW)(LPWSTR,INT,INT,INT);
297 DECL_WINELIB_TYPE_AW(EDITWORDBREAKPROC)
298 typedef LRESULT (CALLBACK *FARPROC16)();
299 typedef LRESULT (CALLBACK *FARPROC)();
300 typedef INT16 (CALLBACK *PROC16)();
301 typedef INT (CALLBACK *PROC)();
302 typedef BOOL16 (CALLBACK *GRAYSTRINGPROC16)(HDC16,LPARAM,INT16);
303 typedef BOOL (CALLBACK *GRAYSTRINGPROC)(HDC,LPARAM,INT);
304 typedef LRESULT (CALLBACK *HOOKPROC16)(INT16,WPARAM16,LPARAM);
305 typedef LRESULT (CALLBACK *HOOKPROC)(INT,WPARAM,LPARAM);
306 typedef BOOL16 (CALLBACK *PROPENUMPROC16)(HWND16,SEGPTR,HANDLE16);
307 typedef BOOL (CALLBACK *PROPENUMPROCA)(HWND,LPCSTR,HANDLE);
308 typedef BOOL (CALLBACK *PROPENUMPROCW)(HWND,LPCWSTR,HANDLE);
309 DECL_WINELIB_TYPE_AW(PROPENUMPROC)
310 typedef BOOL (CALLBACK *PROPENUMPROCEXA)(HWND,LPCSTR,HANDLE,LPARAM);
311 typedef BOOL (CALLBACK *PROPENUMPROCEXW)(HWND,LPCWSTR,HANDLE,LPARAM);
312 DECL_WINELIB_TYPE_AW(PROPENUMPROCEX)
313 typedef BOOL (CALLBACK* TIMEFMT_ENUMPROCA)(LPSTR);
314 typedef BOOL (CALLBACK* TIMEFMT_ENUMPROCW)(LPWSTR);
315 DECL_WINELIB_TYPE_AW(TIMEFMT_ENUMPROC)
316 typedef VOID (CALLBACK *TIMERPROC16)(HWND16,UINT16,UINT16,DWORD);
317 typedef VOID (CALLBACK *TIMERPROC)(HWND,UINT,UINT,DWORD);
318 typedef LRESULT (CALLBACK *WNDENUMPROC16)(HWND16,LPARAM);
319 typedef LRESULT (CALLBACK *WNDENUMPROC)(HWND,LPARAM);
320 typedef LRESULT (CALLBACK *WNDPROC16)(HWND16,UINT16,WPARAM16,LPARAM);
321 typedef LRESULT (CALLBACK *WNDPROC)(HWND,UINT,WPARAM,LPARAM);
323 /* TCHAR data types definitions for Winelib. */
324 /* These types are _not_ defined for the emulator, because they */
325 /* depend on the UNICODE macro that only exists in user's code. */
327 #ifndef __WINE__
328 # ifdef UNICODE
329 typedef WCHAR TCHAR;
330 typedef LPWSTR LPTSTR;
331 typedef LPCWSTR LPCTSTR;
332 #define __TEXT(string) L##string /*probably wrong */
333 # else /* UNICODE */
334 typedef CHAR TCHAR;
335 typedef LPSTR LPTSTR;
336 typedef LPCSTR LPCTSTR;
337 #define __TEXT(string) string
338 # endif /* UNICODE */
339 #endif /* __WINE__ */
340 #define TEXT(quote) __TEXT(quote)
342 /* Data types specific to the library. These do _not_ exist in the emulator. */
346 /* Define some empty macros for compatibility with Windows code. */
348 #ifndef __WINE__
349 #define NEAR
350 #define FAR
351 #define near
352 #define far
353 #define _near
354 #define _far
355 #define IN
356 #define OUT
357 #define OPTIONAL
358 #endif /* __WINE__ */
360 /* Macro for structure packing. */
362 #ifdef __GNUC__
363 #define WINE_PACKED __attribute__ ((packed))
364 #define WINE_UNUSED __attribute__ ((unused))
365 #else
366 #define WINE_PACKED /* nothing */
367 #define WINE_UNUSED /* nothing */
368 #endif
370 /* Macros to split words and longs. */
372 #define LOBYTE(w) ((BYTE)(WORD)(w))
373 #define HIBYTE(w) ((BYTE)((WORD)(w) >> 8))
375 #define LOWORD(l) ((WORD)(DWORD)(l))
376 #define HIWORD(l) ((WORD)((DWORD)(l) >> 16))
378 #define SLOWORD(l) ((INT16)(LONG)(l))
379 #define SHIWORD(l) ((INT16)((LONG)(l) >> 16))
381 #define MAKEWORD(low,high) ((WORD)(((BYTE)(low)) | ((WORD)((BYTE)(high))) << 8))
382 #define MAKELONG(low,high) ((LONG)(((WORD)(low)) | (((DWORD)((WORD)(high))) << 16)))
383 #define MAKELPARAM(low,high) ((LPARAM)MAKELONG(low,high))
384 #define MAKEWPARAM(low,high) ((WPARAM)MAKELONG(low,high))
385 #define MAKELRESULT(low,high) ((LRESULT)MAKELONG(low,high))
386 #define MAKEINTATOM(atom) ((LPCSTR)MAKELONG((atom),0))
388 #define SELECTOROF(ptr) (HIWORD(ptr))
389 #define OFFSETOF(ptr) (LOWORD(ptr))
391 /* Macros to access unaligned or wrong-endian WORDs and DWORDs. */
392 /* Note: These macros are semantically broken, at least for wrc. wrc
393 spits out data in the platform's current binary format, *not* in
394 little-endian format. These macros are used throughout the resource
395 code to load and store data to the resources. Since it is unlikely
396 that we'll ever be dealing with little-endian resource data, the
397 byte-swapping nature of these macros has been disabled. Rather than
398 remove the use of these macros from the resource loading code, the
399 macros have simply been disabled. In the future, someone may want
400 to reactivate these macros for other purposes. In that case, the
401 resource code will have to be modified to use different macros. */
403 #if 1
404 #define PUT_WORD(ptr,w) (*(WORD *)(ptr) = (w))
405 #define GET_WORD(ptr) (*(WORD *)(ptr))
406 #define PUT_DWORD(ptr,dw) (*(DWORD *)(ptr) = (dw))
407 #define GET_DWORD(ptr) (*(DWORD *)(ptr))
408 #else
409 #define PUT_WORD(ptr,w) (*(BYTE *)(ptr) = LOBYTE(w), \
410 *((BYTE *)(ptr) + 1) = HIBYTE(w))
411 #define GET_WORD(ptr) ((WORD)(*(BYTE *)(ptr) | \
412 (WORD)(*((BYTE *)(ptr)+1) << 8)))
413 #define PUT_DWORD(ptr,dw) (PUT_WORD((ptr),LOWORD(dw)), \
414 PUT_WORD((WORD *)(ptr)+1,HIWORD(dw)))
415 #define GET_DWORD(ptr) ((DWORD)(GET_WORD(ptr) | \
416 ((DWORD)GET_WORD((WORD *)(ptr)+1) << 16)))
417 #endif /* 1 */
419 /* MIN and MAX macros */
421 #ifdef MAX
422 #undef MAX
423 #endif
424 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
426 #ifdef MIN
427 #undef MIN
428 #endif
429 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
431 #define __max(a,b) MAX(a,b)
432 #define __min(a,b) MIN(a,b)
433 #define max(a,b) MAX(a,b)
434 #define min(a,b) MIN(a,b)
436 #define _MAX_PATH 260
437 #define MAX_PATH 260
438 #define _MAX_DRIVE 3
439 #define _MAX_DIR 256
440 #define _MAX_FNAME 255
441 #define _MAX_EXT 256
443 #define HFILE_ERROR16 ((HFILE16)-1)
444 #define HFILE_ERROR ((HFILE)-1)
446 /* Winelib run-time flag */
448 #ifdef __WINE__
449 extern int __winelib;
450 #endif /* __WINE__ */
452 /* The SIZE structure */
454 typedef struct
456 INT16 cx;
457 INT16 cy;
458 } SIZE16, *PSIZE16, *LPSIZE16;
460 typedef struct tagSIZE
462 INT cx;
463 INT cy;
464 } SIZE, *PSIZE, *LPSIZE;
467 typedef SIZE SIZEL, *PSIZEL, *LPSIZEL;
469 #define CONV_SIZE16TO32(s16,s32) \
470 ((s32)->cx = (INT)(s16)->cx, (s32)->cy = (INT)(s16)->cy)
471 #define CONV_SIZE32TO16(s32,s16) \
472 ((s16)->cx = (INT16)(s32)->cx, (s16)->cy = (INT16)(s32)->cy)
474 /* The POINT structure */
476 typedef struct
478 INT16 x;
479 INT16 y;
480 } POINT16, *PPOINT16, *LPPOINT16;
482 typedef struct tagPOINT
484 LONG x;
485 LONG y;
486 } POINT, *PPOINT, *LPPOINT;
488 typedef struct _POINTL
490 LONG x;
491 LONG y;
492 } POINTL;
494 #define CONV_POINT16TO32(p16,p32) \
495 ((p32)->x = (INT)(p16)->x, (p32)->y = (INT)(p16)->y)
496 #define CONV_POINT32TO16(p32,p16) \
497 ((p16)->x = (INT16)(p32)->x, (p16)->y = (INT16)(p32)->y)
499 #define MAKEPOINT16(l) (*((POINT16 *)&(l)))
501 /* The POINTS structure */
503 typedef struct tagPOINTS
505 SHORT x;
506 SHORT y;
507 } POINTS, *PPOINTS, *LPPOINTS;
510 #define MAKEPOINTS(l) (*((POINTS *)&(l)))
513 /* The RECT structure */
515 typedef struct
517 INT16 left;
518 INT16 top;
519 INT16 right;
520 INT16 bottom;
521 } RECT16, *LPRECT16;
523 typedef struct tagRECT
525 INT left;
526 INT top;
527 INT right;
528 INT bottom;
529 } RECT, *PRECT, *LPRECT;
530 typedef const RECT *LPCRECT;
533 typedef struct tagRECTL
535 LONG left;
536 LONG top;
537 LONG right;
538 LONG bottom;
539 } RECTL, *PRECTL, *LPRECTL;
541 typedef const RECTL *LPCRECTL;
543 #define CONV_RECT16TO32(r16,r32) \
544 ((r32)->left = (INT)(r16)->left, (r32)->top = (INT)(r16)->top, \
545 (r32)->right = (INT)(r16)->right, (r32)->bottom = (INT)(r16)->bottom)
546 #define CONV_RECT32TO16(r32,r16) \
547 ((r16)->left = (INT16)(r32)->left, (r16)->top = (INT16)(r32)->top, \
548 (r16)->right = (INT16)(r32)->right, (r16)->bottom = (INT16)(r32)->bottom)
550 #ifdef __cplusplus
552 #endif
554 #endif /* __WINE_WINDEF_H */