If we have a drive pointing to /, we must not remove the final / or we
[wine.git] / include / windef.h
blob192eff93e9dc1e8c7612ff2939e338e46af4bf2c
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 # undef UNICODE
12 #endif /* __WINE__ */
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
18 /* Misc. constants. */
20 #define WINVER 0x0500
22 #ifdef FALSE
23 #undef FALSE
24 #endif
25 #define FALSE 0
27 #ifdef TRUE
28 #undef TRUE
29 #endif
30 #define TRUE 1
32 #ifdef NULL
33 #undef NULL
34 #endif
35 #define NULL 0
37 /* Macros to map Winelib names to the correct implementation name */
38 /* depending on __WINE__ and UNICODE macros. */
39 /* Note that Winelib is purely Win32. */
41 #ifdef __WINE__
42 # define WINELIB_NAME_AW(func) \
43 func##_must_be_suffixed_with_W_or_A_in_this_context \
44 func##_must_be_suffixed_with_W_or_A_in_this_context
45 #else /* __WINE__ */
46 # ifdef UNICODE
47 # define WINELIB_NAME_AW(func) func##W
48 # else
49 # define WINELIB_NAME_AW(func) func##A
50 # endif /* UNICODE */
51 #endif /* __WINE__ */
53 #ifdef __WINE__
54 # define DECL_WINELIB_TYPE_AW(type) /* nothing */
55 #else /* __WINE__ */
56 # define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type;
57 #endif /* __WINE__ */
59 #ifdef __WINE__
60 # define NONAMELESSSTRUCT
61 # define NONAMELESSUNION
62 #else
63 /* Anonymous struct support starts with gcc/g++ 2.96 */
64 # if !defined(NONAMELESSSTRUCT) && defined(__GNUC__) && ((__GNUC__ < 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ < 96)))
65 # define NONAMELESSSTRUCT
66 # endif
67 /* Anonymous unions support starts with gcc 2.96/g++ 2.95 */
68 # if !defined(NONAMELESSUNION) && defined(__GNUC__) && ((__GNUC__ < 2) || ((__GNUC__ == 2) && ((__GNUC_MINOR__ < 95) || ((__GNUC_MINOR__ == 95) && !defined(__cplusplus)))))
69 # define NONAMELESSUNION
70 # endif
71 #endif
73 #ifndef NONAMELESSSTRUCT
74 #define DUMMYSTRUCTNAME
75 #define DUMMYSTRUCTNAME1
76 #define DUMMYSTRUCTNAME2
77 #define DUMMYSTRUCTNAME3
78 #define DUMMYSTRUCTNAME4
79 #define DUMMYSTRUCTNAME5
80 #else /* !defined(NONAMELESSSTRUCT) */
81 #define DUMMYSTRUCTNAME s
82 #define DUMMYSTRUCTNAME1 s1
83 #define DUMMYSTRUCTNAME2 s2
84 #define DUMMYSTRUCTNAME3 s3
85 #define DUMMYSTRUCTNAME4 s4
86 #define DUMMYSTRUCTNAME5 s5
87 #endif /* !defined(NONAMELESSSTRUCT) */
89 #ifndef NONAMELESSUNION
90 #define DUMMYUNIONNAME
91 #define DUMMYUNIONNAME1
92 #define DUMMYUNIONNAME2
93 #define DUMMYUNIONNAME3
94 #define DUMMYUNIONNAME4
95 #define DUMMYUNIONNAME5
96 #define DUMMYUNIONNAME6
97 #define DUMMYUNIONNAME7
98 #define DUMMYUNIONNAME8
99 #else /* !defined(NONAMELESSUNION) */
100 #define DUMMYUNIONNAME u
101 #define DUMMYUNIONNAME1 u1
102 #define DUMMYUNIONNAME2 u2
103 #define DUMMYUNIONNAME3 u3
104 #define DUMMYUNIONNAME4 u4
105 #define DUMMYUNIONNAME5 u5
106 #define DUMMYUNIONNAME6 u6
107 #define DUMMYUNIONNAME7 u7
108 #define DUMMYUNIONNAME8 u8
109 #endif /* !defined(NONAMELESSUNION) */
111 /* Calling conventions definitions */
113 #ifdef __i386__
114 # ifndef _X86_
115 # define _X86_
116 # endif
117 # if defined(__GNUC__) && ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))
118 # define __stdcall __attribute__((__stdcall__))
119 # define __cdecl __attribute__((__cdecl__))
120 # define __RESTORE_ES __asm__ __volatile__("pushl %ds\n\tpopl %es")
121 # else
122 # error You need gcc >= 2.7 to build Wine on a 386
123 # endif /* __GNUC__ */
124 #else /* __i386__ */
125 # define __stdcall
126 # define __cdecl
127 # define __RESTORE_ES
128 #endif /* __i386__ */
130 #define CALLBACK __stdcall
131 #define WINAPI __stdcall
132 #define APIPRIVATE __stdcall
133 #define PASCAL __stdcall
134 #define pascal __stdcall
135 #define _pascal __stdcall
136 #define _stdcall __stdcall
137 #define _fastcall __stdcall
138 #define __fastcall __stdcall
139 #define __export __stdcall
140 #define CDECL __cdecl
141 #define _CDECL __cdecl
142 #define cdecl __cdecl
143 #define _cdecl __cdecl
144 #define WINAPIV __cdecl
145 #define APIENTRY WINAPI
147 #define _declspec(x)
148 #define __declspec(x)
150 #define CONST const
152 /* Standard data types. These are the same for emulator and library. */
154 typedef void VOID;
155 typedef int INT;
156 typedef unsigned int UINT;
157 typedef unsigned short WORD;
158 typedef unsigned long DWORD;
159 typedef unsigned long ULONG;
160 typedef unsigned char BYTE;
161 typedef long LONG;
162 typedef short SHORT;
163 typedef unsigned short USHORT;
164 typedef char CHAR;
165 typedef unsigned char UCHAR;
166 /* Some systems might have wchar_t, but we really need 16 bit characters */
167 typedef unsigned short WCHAR;
168 typedef int BOOL;
169 typedef double DATE;
170 typedef double DOUBLE;
172 /* FIXME: Wine does not compile with strict on, therefore strict
173 * handles are presently only usable on machines where sizeof(UINT) ==
174 * sizeof(void*). HANDLEs are supposed to be void* but a large amount
175 * of WINE code operates on HANDLES as if they are UINTs. So to WINE
176 * they exist as UINTs but to the Winelib user who turns on strict,
177 * they exist as void*. If there is a size difference between UINT and
178 * void* then things get ugly. */
179 #ifdef STRICT
180 typedef VOID* HANDLE;
181 #else
182 typedef UINT HANDLE;
183 #endif
186 typedef HANDLE *LPHANDLE;
188 /* Integer types. These are the same for emulator and library. */
189 typedef UINT WPARAM;
190 typedef LONG LPARAM;
191 typedef LONG HRESULT;
192 typedef LONG LRESULT;
193 typedef WORD ATOM;
194 typedef WORD CATCHBUF[9];
195 typedef WORD *LPCATCHBUF;
196 typedef HANDLE HHOOK;
197 typedef HANDLE HMONITOR;
198 typedef DWORD LCID;
199 typedef WORD LANGID;
200 typedef float FLOAT;
202 /* Pointers types. These are the same for emulator and library. */
203 /* winnt types */
204 typedef VOID *PVOID;
205 typedef const void *PCVOID;
206 typedef CHAR *PCHAR;
207 typedef UCHAR *PUCHAR;
208 typedef BYTE *PBYTE;
209 typedef WORD *PWORD;
210 typedef USHORT *PUSHORT;
211 typedef SHORT *PSHORT;
212 typedef ULONG *PULONG;
213 typedef LONG *PLONG;
214 typedef DWORD *PDWORD;
215 /* common win32 types */
216 typedef CHAR *LPSTR;
217 typedef CHAR *PSTR;
218 typedef const CHAR *LPCSTR;
219 typedef const CHAR *PCSTR;
220 typedef WCHAR *LPWSTR;
221 typedef WCHAR *PWSTR;
222 typedef const WCHAR *LPCWSTR;
223 typedef const WCHAR *PCWSTR;
224 typedef BYTE *LPBYTE;
225 typedef WORD *LPWORD;
226 typedef DWORD *LPDWORD;
227 typedef LONG *LPLONG;
228 typedef VOID *LPVOID;
229 typedef const VOID *LPCVOID;
230 typedef INT *PINT;
231 typedef INT *LPINT;
232 typedef UINT *PUINT;
233 typedef UINT *LPUINT;
234 typedef FLOAT *PFLOAT;
235 typedef FLOAT *LPFLOAT;
236 typedef BOOL *PBOOL;
237 typedef BOOL *LPBOOL;
239 /* Special case: a segmented pointer is just a pointer in the user's code. */
241 #ifdef __WINE__
242 typedef DWORD SEGPTR;
243 #else
244 typedef void* SEGPTR;
245 #endif /* __WINE__ */
247 /* Handle types that exist both in Win16 and Win32. */
249 #ifdef STRICT
250 #define DECLARE_HANDLE(a) \
251 typedef struct a##__ { int unused; } *a; \
252 typedef a *P##a; \
253 typedef a *LP##a
254 #else /*STRICT*/
255 #define DECLARE_HANDLE(a) \
256 typedef HANDLE a; \
257 typedef a *P##a; \
258 typedef a *LP##a
259 #endif /*STRICT*/
261 DECLARE_HANDLE(HACMDRIVERID);
262 DECLARE_HANDLE(HACMDRIVER);
263 DECLARE_HANDLE(HACMOBJ);
264 DECLARE_HANDLE(HACMSTREAM);
265 DECLARE_HANDLE(HMETAFILEPICT);
267 DECLARE_HANDLE(HACCEL);
268 DECLARE_HANDLE(HBITMAP);
269 DECLARE_HANDLE(HBRUSH);
270 DECLARE_HANDLE(HCOLORSPACE);
271 DECLARE_HANDLE(HCURSOR);
272 DECLARE_HANDLE(HDC);
273 DECLARE_HANDLE(HDROP);
274 DECLARE_HANDLE(HDRVR);
275 DECLARE_HANDLE(HDWP);
276 DECLARE_HANDLE(HENHMETAFILE);
277 typedef int HFILE;
278 DECLARE_HANDLE(HFONT);
279 DECLARE_HANDLE(HICON);
280 DECLARE_HANDLE(HINSTANCE);
281 DECLARE_HANDLE(HKEY);
282 DECLARE_HANDLE(HMENU);
283 DECLARE_HANDLE(HMETAFILE);
284 DECLARE_HANDLE(HMIDI);
285 DECLARE_HANDLE(HMIDIIN);
286 DECLARE_HANDLE(HMIDIOUT);
287 DECLARE_HANDLE(HMIDISTRM);
288 DECLARE_HANDLE(HMIXER);
289 DECLARE_HANDLE(HMIXEROBJ);
290 DECLARE_HANDLE(HMMIO);
291 DECLARE_HANDLE(HPALETTE);
292 DECLARE_HANDLE(HPEN);
293 DECLARE_HANDLE(HQUEUE);
294 DECLARE_HANDLE(HRGN);
295 DECLARE_HANDLE(HRSRC);
296 DECLARE_HANDLE(HTASK);
297 DECLARE_HANDLE(HWAVE);
298 DECLARE_HANDLE(HWAVEIN);
299 DECLARE_HANDLE(HWAVEOUT);
300 DECLARE_HANDLE(HWINSTA);
301 DECLARE_HANDLE(HDESK);
302 DECLARE_HANDLE(HWND);
303 DECLARE_HANDLE(HKL);
304 DECLARE_HANDLE(HRASCONN);
306 /* Handle types that must remain interchangeable even with strict on */
308 typedef HINSTANCE HMODULE;
309 typedef HANDLE HGDIOBJ;
310 typedef HANDLE HGLOBAL;
311 typedef HANDLE HLOCAL;
312 typedef HANDLE GLOBALHANDLE;
313 typedef HANDLE LOCALHANDLE;
315 /* Callback function pointers types */
317 typedef BOOL CALLBACK (*DATEFMT_ENUMPROCA)(LPSTR);
318 typedef BOOL CALLBACK (*DATEFMT_ENUMPROCW)(LPWSTR);
319 DECL_WINELIB_TYPE_AW(DATEFMT_ENUMPROC)
320 typedef BOOL CALLBACK (*DLGPROC)(HWND,UINT,WPARAM,LPARAM);
321 typedef LRESULT CALLBACK (*DRIVERPROC)(DWORD,HDRVR,UINT,LPARAM,LPARAM);
322 typedef INT CALLBACK (*EDITWORDBREAKPROCA)(LPSTR,INT,INT,INT);
323 typedef INT CALLBACK (*EDITWORDBREAKPROCW)(LPWSTR,INT,INT,INT);
324 DECL_WINELIB_TYPE_AW(EDITWORDBREAKPROC)
325 typedef LRESULT CALLBACK (*FARPROC)();
326 typedef INT CALLBACK (*PROC)();
327 typedef BOOL CALLBACK (*GRAYSTRINGPROC)(HDC,LPARAM,INT);
328 typedef LRESULT CALLBACK (*HOOKPROC)(INT,WPARAM,LPARAM);
329 typedef BOOL CALLBACK (*PROPENUMPROCA)(HWND,LPCSTR,HANDLE);
330 typedef BOOL CALLBACK (*PROPENUMPROCW)(HWND,LPCWSTR,HANDLE);
331 DECL_WINELIB_TYPE_AW(PROPENUMPROC)
332 typedef BOOL CALLBACK (*PROPENUMPROCEXA)(HWND,LPCSTR,HANDLE,LPARAM);
333 typedef BOOL CALLBACK (*PROPENUMPROCEXW)(HWND,LPCWSTR,HANDLE,LPARAM);
334 DECL_WINELIB_TYPE_AW(PROPENUMPROCEX)
335 typedef BOOL CALLBACK (*TIMEFMT_ENUMPROCA)(LPSTR);
336 typedef BOOL CALLBACK (*TIMEFMT_ENUMPROCW)(LPWSTR);
337 DECL_WINELIB_TYPE_AW(TIMEFMT_ENUMPROC)
338 typedef VOID CALLBACK (*TIMERPROC)(HWND,UINT,UINT,DWORD);
339 typedef BOOL CALLBACK (*WNDENUMPROC)(HWND,LPARAM);
340 typedef LRESULT CALLBACK (*WNDPROC)(HWND,UINT,WPARAM,LPARAM);
342 /* Define some empty macros for compatibility with Windows code. */
344 #ifndef __WINE__
345 #define NEAR
346 #define FAR
347 #define near
348 #define far
349 #define _near
350 #define _far
351 #define IN
352 #define OUT
353 #define OPTIONAL
354 #endif /* __WINE__ */
356 #include "winnt.h"
358 /* Macro for structure packing. */
360 #ifdef __GNUC__
361 #define WINE_PACKED __attribute__((packed))
362 #define WINE_UNUSED __attribute__((unused))
363 #define WINE_NORETURN __attribute__((noreturn))
364 #else
365 #define WINE_PACKED /* nothing */
366 #define WINE_UNUSED /* nothing */
367 #define WINE_NORETURN /* 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) ((SHORT)(LONG)(l))
379 #define SHIWORD(l) ((SHORT)((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 #ifdef __WINE__
392 /* macros to set parts of a DWORD (not in the Windows API) */
393 #define SET_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD(val))
394 #define SET_LOBYTE(dw,val) ((dw) = ((dw) & 0xffffff00) | LOBYTE(val))
395 #define SET_HIBYTE(dw,val) ((dw) = ((dw) & 0xffff00ff) | (LOBYTE(val) << 8))
396 #define ADD_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD((DWORD)(dw)+(val)))
397 #endif
399 /* Macros to access unaligned or wrong-endian WORDs and DWORDs. */
400 /* Note: These macros are semantically broken, at least for wrc. wrc
401 spits out data in the platform's current binary format, *not* in
402 little-endian format. These macros are used throughout the resource
403 code to load and store data to the resources. Since it is unlikely
404 that we'll ever be dealing with little-endian resource data, the
405 byte-swapping nature of these macros has been disabled. Rather than
406 remove the use of these macros from the resource loading code, the
407 macros have simply been disabled. In the future, someone may want
408 to reactivate these macros for other purposes. In that case, the
409 resource code will have to be modified to use different macros. */
411 #if 1
412 #define PUT_WORD(ptr,w) (*(WORD *)(ptr) = (w))
413 #define GET_WORD(ptr) (*(WORD *)(ptr))
414 #define PUT_DWORD(ptr,dw) (*(DWORD *)(ptr) = (dw))
415 #define GET_DWORD(ptr) (*(DWORD *)(ptr))
416 #else
417 #define PUT_WORD(ptr,w) (*(BYTE *)(ptr) = LOBYTE(w), \
418 *((BYTE *)(ptr) + 1) = HIBYTE(w))
419 #define GET_WORD(ptr) ((WORD)(*(BYTE *)(ptr) | \
420 (WORD)(*((BYTE *)(ptr)+1) << 8)))
421 #define PUT_DWORD(ptr,dw) (PUT_WORD((ptr),LOWORD(dw)), \
422 PUT_WORD((WORD *)(ptr)+1,HIWORD(dw)))
423 #define GET_DWORD(ptr) ((DWORD)(GET_WORD(ptr) | \
424 ((DWORD)GET_WORD((WORD *)(ptr)+1) << 16)))
425 #endif /* 1 */
427 /* min and max macros */
428 #define __max(a,b) (((a) > (b)) ? (a) : (b))
429 #define __min(a,b) (((a) < (b)) ? (a) : (b))
430 #ifndef max
431 #define max(a,b) (((a) > (b)) ? (a) : (b))
432 #endif
433 #ifndef min
434 #define min(a,b) (((a) < (b)) ? (a) : (b))
435 #endif
437 #define _MAX_PATH 260
438 #define MAX_PATH 260
439 #define _MAX_DRIVE 3
440 #define _MAX_DIR 256
441 #define _MAX_FNAME 255
442 #define _MAX_EXT 256
444 #define HFILE_ERROR ((HFILE)-1)
446 /* The SIZE structure */
447 typedef struct tagSIZE
449 LONG cx;
450 LONG cy;
451 } SIZE, *PSIZE, *LPSIZE;
453 typedef SIZE SIZEL, *PSIZEL, *LPSIZEL;
455 /* The POINT structure */
456 typedef struct tagPOINT
458 LONG x;
459 LONG y;
460 } POINT, *PPOINT, *LPPOINT;
462 typedef struct _POINTL
464 LONG x;
465 LONG y;
466 } POINTL;
468 /* The POINTS structure */
470 typedef struct tagPOINTS
472 SHORT x;
473 SHORT y;
474 } POINTS, *PPOINTS, *LPPOINTS;
476 /* The RECT structure */
477 typedef struct tagRECT
479 INT left;
480 INT top;
481 INT right;
482 INT bottom;
483 } RECT, *PRECT, *LPRECT;
484 typedef const RECT *LPCRECT;
487 typedef struct tagRECTL
489 LONG left;
490 LONG top;
491 LONG right;
492 LONG bottom;
493 } RECTL, *PRECTL, *LPRECTL;
495 typedef const RECTL *LPCRECTL;
497 #ifdef __cplusplus
499 #endif
501 #endif /* __WINE_WINDEF_H */