source: trunk/include/win/windef.h@ 4

Last change on this file since 4 was 4, checked in by ktk, 26 years ago

Import

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