2 * Basic types definitions
4 * Copyright 1996 Alexandre Julliard
6 * Modified for use with MPlayer, detailed changelog at
7 * http://svn.mplayerhq.hu/mplayer/trunk/
11 #ifndef MPLAYER_WINDEF_H
12 #define MPLAYER_WINDEF_H
16 /* Misc. constants. */
33 /* Macros to map Winelib names to the correct implementation name */
34 /* Note that Winelib is purely Win32. */
36 # define WINELIB_NAME_AW(func) \
37 func##_must_be_suffixed_with_W_or_A_in_this_context \
38 func##_must_be_suffixed_with_W_or_A_in_this_context
40 # define DECL_WINELIB_TYPE_AW(type) /* nothing */
42 #ifndef NONAMELESSSTRUCT
43 # define NONAMELESSSTRUCT
44 #endif /* !defined(NONAMELESSSTRUCT) */
46 #ifndef NONAMELESSUNION
47 # define NONAMELESSUNION
48 #endif /* !defined(NONAMELESSUNION) */
52 #ifndef NONAMELESSSTRUCT
53 #define DUMMYSTRUCTNAME
54 #define DUMMYSTRUCTNAME1
55 #define DUMMYSTRUCTNAME2
56 #define DUMMYSTRUCTNAME3
57 #define DUMMYSTRUCTNAME4
58 #define DUMMYSTRUCTNAME5
59 #else /* !defined(NONAMELESSSTRUCT) */
60 #define DUMMYSTRUCTNAME s
61 #define DUMMYSTRUCTNAME1 s1
62 #define DUMMYSTRUCTNAME2 s2
63 #define DUMMYSTRUCTNAME3 s3
64 #define DUMMYSTRUCTNAME4 s4
65 #define DUMMYSTRUCTNAME5 s5
66 #endif /* !defined(NONAMELESSSTRUCT) */
68 #ifndef NONAMELESSUNION
69 #define DUMMYUNIONNAME
70 #define DUMMYUNIONNAME1
71 #define DUMMYUNIONNAME2
72 #define DUMMYUNIONNAME3
73 #define DUMMYUNIONNAME4
74 #define DUMMYUNIONNAME5
75 #else /* !defined(NONAMELESSUNION) */
76 #define DUMMYUNIONNAME u
77 #define DUMMYUNIONNAME1 u1
78 #define DUMMYUNIONNAME2 u2
79 #define DUMMYUNIONNAME3 u3
80 #define DUMMYUNIONNAME4 u4
81 #define DUMMYUNIONNAME5 u5
82 #endif /* !defined(NONAMELESSUNION) */
86 /* Calling conventions definitions */
89 # if defined(__GNUC__) && ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))
90 #define __stdcall __attribute__((__stdcall__))
91 #define __cdecl __attribute__((__cdecl__))
92 # define RESTORE_ES __asm__ volatile("pushl %ds\n\tpopl %es")
94 // # error You need gcc >= 2.7 to build Wine on a 386
102 #define CALLBACK __stdcall
103 #define WINAPI __stdcall
104 #define APIPRIVATE __stdcall
105 #define PASCAL __stdcall
106 #define pascal __stdcall
107 #define _pascal __stdcall
108 #if !defined(__CYGWIN__) && !defined(__MINGW32__)
109 #define _stdcall __stdcall
110 #define _fastcall __stdcall
111 #define __fastcall __stdcall
113 #define __export __stdcall
114 #define CDECL __cdecl
115 #define _CDECL __cdecl
116 #define cdecl __cdecl
117 #if !defined(__CYGWIN__) && !defined(__MINGW32__)
118 #define _cdecl __cdecl
120 #define WINAPIV __cdecl
121 #define APIENTRY WINAPI
123 #if !defined(__CYGWIN__) && !defined(__MINGW32__)
124 #define __declspec(x)
131 /* Standard data types. These are the same for emulator and library. */
135 typedef unsigned int UINT
;
136 typedef unsigned short WORD
;
137 typedef unsigned long DWORD
;
138 typedef unsigned long ULONG
;
139 typedef unsigned char BYTE
;
142 typedef unsigned short USHORT
;
144 typedef unsigned char UCHAR
;
148 /* Some systems might have wchar_t, but we really need 16 bit characters */
149 typedef unsigned short WCHAR
;
150 typedef int WIN_BOOL
;
152 typedef double DOUBLE
;
153 typedef long long LONGLONG
;
154 typedef unsigned long long ULONGLONG
;
156 /* FIXME: Wine does not compile with strict on, therefore strict
157 * handles are presently only usable on machines where sizeof(UINT) ==
158 * sizeof(void*). HANDLEs are supposed to be void* but a large amount
159 * of WINE code operates on HANDLES as if they are UINTs. So to WINE
160 * they exist as UINTs but to the Winelib user who turns on strict,
161 * they exist as void*. If there is a size difference between UINT and
162 * void* then things get ugly. */
164 typedef VOID
* HANDLE
;
170 typedef HANDLE
*LPHANDLE
;
172 /* Integer types. These are the same for emulator and library. */
175 typedef LONG HRESULT
;
176 typedef LONG LRESULT
;
178 typedef WORD CATCHBUF
[9];
179 typedef WORD
*LPCATCHBUF
;
180 typedef HANDLE HHOOK
;
181 typedef HANDLE HMONITOR
;
184 typedef DWORD LCTYPE
;
187 /* Pointers types. These are the same for emulator and library. */
190 typedef const void *PCVOID
;
192 typedef UCHAR
*PUCHAR
;
195 typedef USHORT
*PUSHORT
;
196 typedef SHORT
*PSHORT
;
197 typedef ULONG
*PULONG
;
199 typedef DWORD
*PDWORD
;
200 /* common win32 types */
203 typedef const CHAR
*LPCSTR
;
204 typedef const CHAR
*PCSTR
;
205 typedef WCHAR
*LPWSTR
;
206 typedef WCHAR
*PWSTR
;
207 typedef const WCHAR
*LPCWSTR
;
208 typedef const WCHAR
*PCWSTR
;
209 typedef BYTE
*LPBYTE
;
210 typedef WORD
*LPWORD
;
211 typedef DWORD
*LPDWORD
;
212 typedef LONG
*LPLONG
;
213 typedef VOID
*LPVOID
;
214 typedef const VOID
*LPCVOID
;
218 typedef UINT
*LPUINT
;
219 typedef FLOAT
*PFLOAT
;
220 typedef FLOAT
*LPFLOAT
;
221 typedef WIN_BOOL
*PWIN_BOOL
;
222 typedef WIN_BOOL
*LPWIN_BOOL
;
224 /* Special case: a segmented pointer is just a pointer in the user's code. */
226 typedef DWORD SEGPTR
;
228 /* Handle types that exist both in Win16 and Win32. */
231 #define DECLARE_HANDLE(a) \
232 typedef struct a##__ { int unused; } *a; \
236 #define DECLARE_HANDLE(a) \
242 DECLARE_HANDLE(HACMDRIVERID
);
243 DECLARE_HANDLE(HACMDRIVER
);
244 DECLARE_HANDLE(HACMOBJ
);
245 DECLARE_HANDLE(HACMSTREAM
);
246 DECLARE_HANDLE(HMETAFILEPICT
);
248 DECLARE_HANDLE(HACCEL
);
249 DECLARE_HANDLE(HBITMAP
);
250 DECLARE_HANDLE(HBRUSH
);
251 DECLARE_HANDLE(HCOLORSPACE
);
252 DECLARE_HANDLE(HCURSOR
);
254 DECLARE_HANDLE(HDROP
);
255 DECLARE_HANDLE(HDRVR
);
256 DECLARE_HANDLE(HDWP
);
257 DECLARE_HANDLE(HENHMETAFILE
);
258 DECLARE_HANDLE(HFILE
);
259 DECLARE_HANDLE(HFONT
);
260 DECLARE_HANDLE(HICON
);
261 DECLARE_HANDLE(HINSTANCE
);
262 DECLARE_HANDLE(HKEY
);
263 DECLARE_HANDLE(HMENU
);
264 DECLARE_HANDLE(HMETAFILE
);
265 DECLARE_HANDLE(HMIDI
);
266 DECLARE_HANDLE(HMIDIIN
);
267 DECLARE_HANDLE(HMIDIOUT
);
268 DECLARE_HANDLE(HMIDISTRM
);
269 DECLARE_HANDLE(HMIXER
);
270 DECLARE_HANDLE(HMIXEROBJ
);
271 DECLARE_HANDLE(HMMIO
);
272 DECLARE_HANDLE(HPALETTE
);
273 DECLARE_HANDLE(HPEN
);
274 DECLARE_HANDLE(HQUEUE
);
275 DECLARE_HANDLE(HRGN
);
276 DECLARE_HANDLE(HRSRC
);
277 DECLARE_HANDLE(HTASK
);
278 DECLARE_HANDLE(HWAVE
);
279 DECLARE_HANDLE(HWAVEIN
);
280 DECLARE_HANDLE(HWAVEOUT
);
281 DECLARE_HANDLE(HWINSTA
);
282 DECLARE_HANDLE(HDESK
);
283 DECLARE_HANDLE(HWND
);
286 DECLARE_HANDLE(HRASCONN
);
288 /* Handle types that must remain interchangeable even with strict on */
290 typedef HINSTANCE HMODULE
;
291 typedef HANDLE HGDIOBJ
;
292 typedef HANDLE HGLOBAL
;
293 typedef HANDLE HLOCAL
;
294 typedef HANDLE GLOBALHANDLE
;
295 typedef HANDLE LOCALHANDLE
;
297 /* Callback function pointers types */
298 //WIN_BOOL CALLBACK DATEFMT_ENUMPROCA(LPSTR);
300 typedef WIN_BOOL
CALLBACK (* DATEFMT_ENUMPROCA
)(LPSTR
);
301 typedef WIN_BOOL
CALLBACK (* DATEFMT_ENUMPROCW
)(LPWSTR
);
302 DECL_WINELIB_TYPE_AW(DATEFMT_ENUMPROC
)
303 typedef WIN_BOOL
CALLBACK (*DLGPROC
)(HWND
,UINT
,WPARAM
,LPARAM
);
304 typedef LRESULT
CALLBACK (*DRIVERPROC
)(DWORD
,HDRVR
,UINT
,LPARAM
,LPARAM
);
305 typedef INT
CALLBACK (*EDITWORDBREAKPROCA
)(LPSTR
,INT
,INT
,INT
);
306 typedef INT
CALLBACK (*EDITWORDBREAKPROCW
)(LPWSTR
,INT
,INT
,INT
);
307 DECL_WINELIB_TYPE_AW(EDITWORDBREAKPROC
)
308 typedef LRESULT
CALLBACK (*FARPROC
)(void);
309 typedef INT
CALLBACK (*PROC
)(void);
310 typedef WIN_BOOL
CALLBACK (*GRAYSTRINGPROC
)(HDC
,LPARAM
,INT
);
311 typedef LRESULT
CALLBACK (*HOOKPROC
)(INT
,WPARAM
,LPARAM
);
312 typedef WIN_BOOL
CALLBACK (*PROPENUMPROCA
)(HWND
,LPCSTR
,HANDLE
);
313 typedef WIN_BOOL
CALLBACK (*PROPENUMPROCW
)(HWND
,LPCWSTR
,HANDLE
);
314 DECL_WINELIB_TYPE_AW(PROPENUMPROC
)
315 typedef WIN_BOOL
CALLBACK (*PROPENUMPROCEXA
)(HWND
,LPCSTR
,HANDLE
,LPARAM
);
316 typedef WIN_BOOL
CALLBACK (*PROPENUMPROCEXW
)(HWND
,LPCWSTR
,HANDLE
,LPARAM
);
317 DECL_WINELIB_TYPE_AW(PROPENUMPROCEX
)
318 typedef WIN_BOOL
CALLBACK (* TIMEFMT_ENUMPROCA
)(LPSTR
);
319 typedef WIN_BOOL
CALLBACK (* TIMEFMT_ENUMPROCW
)(LPWSTR
);
320 DECL_WINELIB_TYPE_AW(TIMEFMT_ENUMPROC
)
321 typedef VOID
CALLBACK (*TIMERPROC
)(HWND
,UINT
,UINT
,DWORD
);
322 typedef WIN_BOOL
CALLBACK (*WNDENUMPROC
)(HWND
,LPARAM
);
323 typedef LRESULT
CALLBACK (*WNDPROC
)(HWND
,UINT
,WPARAM
,LPARAM
);
325 /*----------------------------------------------------------------------------
326 ** FIXME: Better isolate Wine's reliance on the xxx16 type definitions.
327 ** For now, we just isolate them to make the situation clear.
328 **--------------------------------------------------------------------------*/
330 * Basic type definitions for 16 bit variations on Windows types.
331 * These types are provided mostly to insure compatibility with
332 * 16 bit windows code.
335 #ifndef MPLAYER_WINDEF16_H
336 #define MPLAYER_WINDEF16_H
340 /* Standard data types */
343 typedef unsigned short UINT16
;
344 typedef unsigned short WIN_BOOL16
;
346 typedef UINT16 HANDLE16
;
347 typedef HANDLE16
*LPHANDLE16
;
349 typedef UINT16 WPARAM16
;
350 typedef INT16
*LPINT16
;
351 typedef UINT16
*LPUINT16
;
353 #define DECLARE_HANDLE16(a) \
354 typedef HANDLE16 a##16; \
355 typedef a##16 *P##a##16; \
356 typedef a##16 *NP##a##16; \
357 typedef a##16 *LP##a##16
359 DECLARE_HANDLE16(HACMDRIVERID
);
360 DECLARE_HANDLE16(HACMDRIVER
);
361 DECLARE_HANDLE16(HACMOBJ
);
362 DECLARE_HANDLE16(HACMSTREAM
);
363 DECLARE_HANDLE16(HMETAFILEPICT
);
365 DECLARE_HANDLE16(HACCEL
);
366 DECLARE_HANDLE16(HBITMAP
);
367 DECLARE_HANDLE16(HBRUSH
);
368 DECLARE_HANDLE16(HCOLORSPACE
);
369 DECLARE_HANDLE16(HCURSOR
);
370 DECLARE_HANDLE16(HDC
);
371 DECLARE_HANDLE16(HDROP
);
372 DECLARE_HANDLE16(HDRVR
);
373 DECLARE_HANDLE16(HDWP
);
374 DECLARE_HANDLE16(HENHMETAFILE
);
375 DECLARE_HANDLE16(HFILE
);
376 DECLARE_HANDLE16(HFONT
);
377 DECLARE_HANDLE16(HICON
);
378 DECLARE_HANDLE16(HINSTANCE
);
379 DECLARE_HANDLE16(HKEY
);
380 DECLARE_HANDLE16(HMENU
);
381 DECLARE_HANDLE16(HMETAFILE
);
382 DECLARE_HANDLE16(HMIDI
);
383 DECLARE_HANDLE16(HMIDIIN
);
384 DECLARE_HANDLE16(HMIDIOUT
);
385 DECLARE_HANDLE16(HMIDISTRM
);
386 DECLARE_HANDLE16(HMIXER
);
387 DECLARE_HANDLE16(HMIXEROBJ
);
388 DECLARE_HANDLE16(HMMIO
);
389 DECLARE_HANDLE16(HPALETTE
);
390 DECLARE_HANDLE16(HPEN
);
391 DECLARE_HANDLE16(HQUEUE
);
392 DECLARE_HANDLE16(HRGN
);
393 DECLARE_HANDLE16(HRSRC
);
394 DECLARE_HANDLE16(HTASK
);
395 DECLARE_HANDLE16(HWAVE
);
396 DECLARE_HANDLE16(HWAVEIN
);
397 DECLARE_HANDLE16(HWAVEOUT
);
398 DECLARE_HANDLE16(HWINSTA
);
399 DECLARE_HANDLE16(HDESK
);
400 DECLARE_HANDLE16(HWND
);
401 DECLARE_HANDLE16(HKL
);
402 DECLARE_HANDLE16(HIC
);
403 DECLARE_HANDLE16(HRASCONN
);
404 #undef DECLARE_HANDLE16
406 typedef HINSTANCE16 HMODULE16
;
407 typedef HANDLE16 HGDIOBJ16
;
408 typedef HANDLE16 HGLOBAL16
;
409 typedef HANDLE16 HLOCAL16
;
411 /* The SIZE structure */
416 } SIZE16
, *PSIZE16
, *LPSIZE16
;
418 /* The POINT structure */
424 } POINT16
, *PPOINT16
, *LPPOINT16
;
426 /* The RECT structure */
436 /* Callback function pointers types */
438 typedef LRESULT
CALLBACK (*DRIVERPROC16
)(DWORD
,HDRVR16
,UINT16
,LPARAM
,LPARAM
);
439 typedef WIN_BOOL16
CALLBACK (*DLGPROC16
)(HWND16
,UINT16
,WPARAM16
,LPARAM
);
440 typedef INT16
CALLBACK (*EDITWORDBREAKPROC16
)(LPSTR
,INT16
,INT16
,INT16
);
441 typedef LRESULT
CALLBACK (*FARPROC16
)(void);
442 typedef INT16
CALLBACK (*PROC16
)(void);
443 typedef WIN_BOOL16
CALLBACK (*GRAYSTRINGPROC16
)(HDC16
,LPARAM
,INT16
);
444 typedef LRESULT
CALLBACK (*HOOKPROC16
)(INT16
,WPARAM16
,LPARAM
);
445 typedef WIN_BOOL16
CALLBACK (*PROPENUMPROC16
)(HWND16
,SEGPTR
,HANDLE16
);
446 typedef VOID
CALLBACK (*TIMERPROC16
)(HWND16
,UINT16
,UINT16
,DWORD
);
447 typedef LRESULT
CALLBACK (*WNDENUMPROC16
)(HWND16
,LPARAM
);
448 typedef LRESULT
CALLBACK (*WNDPROC16
)(HWND16
,UINT16
,WPARAM16
,LPARAM
);
450 #endif /* MPLAYER_WINDEF16_H */
452 /* Define some empty macros for compatibility with Windows code. */
454 /* Macro for structure packing. */
457 #define WINE_PACKED __attribute__((packed))
458 #define WINE_UNUSED __attribute__((unused))
459 #define WINE_NORETURN __attribute__((noreturn))
461 #define WINE_PACKED /* nothing */
462 #define WINE_UNUSED /* nothing */
463 #define WINE_NORETURN /* nothing */
466 /* Macros to split words and longs. */
468 #define LOBYTE(w) ((BYTE)(WORD)(w))
469 #define HIBYTE(w) ((BYTE)((WORD)(w) >> 8))
471 #define LOWORD(l) ((WORD)(DWORD)(l))
472 #define HIWORD(l) ((WORD)((DWORD)(l) >> 16))
474 #define SLOWORD(l) ((INT16)(LONG)(l))
475 #define SHIWORD(l) ((INT16)((LONG)(l) >> 16))
477 #define MAKEWORD(low,high) ((WORD)(((BYTE)(low)) | ((WORD)((BYTE)(high))) << 8))
478 #define MAKELONG(low,high) ((LONG)(((WORD)(low)) | (((DWORD)((WORD)(high))) << 16)))
479 #define MAKELPARAM(low,high) ((LPARAM)MAKELONG(low,high))
480 #define MAKEWPARAM(low,high) ((WPARAM)MAKELONG(low,high))
481 #define MAKELRESULT(low,high) ((LRESULT)MAKELONG(low,high))
482 #define MAKEINTATOM(atom) ((LPCSTR)MAKELONG((atom),0))
484 #define SELECTOROF(ptr) (HIWORD(ptr))
485 #define OFFSETOF(ptr) (LOWORD(ptr))
487 /* macros to set parts of a DWORD (not in the Windows API) */
488 #define SET_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD(val))
489 #define SET_LOBYTE(dw,val) ((dw) = ((dw) & 0xffffff00) | LOBYTE(val))
490 #define SET_HIBYTE(dw,val) ((dw) = ((dw) & 0xffff00ff) | (LOWORD(val) & 0xff00))
491 #define ADD_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD((DWORD)(dw)+(val)))
493 /* Macros to access unaligned or wrong-endian WORDs and DWORDs. */
494 /* Note: These macros are semantically broken, at least for wrc. wrc
495 spits out data in the platform's current binary format, *not* in
496 little-endian format. These macros are used throughout the resource
497 code to load and store data to the resources. Since it is unlikely
498 that we'll ever be dealing with little-endian resource data, the
499 byte-swapping nature of these macros has been disabled. Rather than
500 remove the use of these macros from the resource loading code, the
501 macros have simply been disabled. In the future, someone may want
502 to reactivate these macros for other purposes. In that case, the
503 resource code will have to be modified to use different macros. */
506 #define PUT_WORD(ptr,w) (*(WORD *)(ptr) = (w))
507 #define GET_WORD(ptr) (*(WORD *)(ptr))
508 #define PUT_DWORD(ptr,dw) (*(DWORD *)(ptr) = (dw))
509 #define GET_DWORD(ptr) (*(DWORD *)(ptr))
511 #define PUT_WORD(ptr,w) (*(BYTE *)(ptr) = LOBYTE(w), \
512 *((BYTE *)(ptr) + 1) = HIBYTE(w))
513 #define GET_WORD(ptr) ((WORD)(*(BYTE *)(ptr) | \
514 (WORD)(*((BYTE *)(ptr)+1) << 8)))
515 #define PUT_DWORD(ptr,dw) (PUT_WORD((ptr),LOWORD(dw)), \
516 PUT_WORD((WORD *)(ptr)+1,HIWORD(dw)))
517 #define GET_DWORD(ptr) ((DWORD)(GET_WORD(ptr) | \
518 ((DWORD)GET_WORD((WORD *)(ptr)+1) << 16)))
521 /* min and max macros */
522 #define __max(a,b) (((a) > (b)) ? (a) : (b))
523 #define __min(a,b) (((a) < (b)) ? (a) : (b))
525 #define max(a,b) (((a) > (b)) ? (a) : (b))
528 #define min(a,b) (((a) < (b)) ? (a) : (b))
532 #define _MAX_PATH 260
544 #define _MAX_FNAME 255
550 #define HFILE_ERROR16 ((HFILE16)-1)
551 #define HFILE_ERROR ((HFILE)-1)
553 /* The SIZE structure */
554 typedef struct tagSIZE
558 } SIZE
, *PSIZE
, *LPSIZE
;
561 typedef SIZE SIZEL
, *PSIZEL
, *LPSIZEL
;
563 #define CONV_SIZE16TO32(s16,s32) \
564 ((s32)->cx = (INT)(s16)->cx, (s32)->cy = (INT)(s16)->cy)
565 #define CONV_SIZE32TO16(s32,s16) \
566 ((s16)->cx = (INT16)(s32)->cx, (s16)->cy = (INT16)(s32)->cy)
568 /* The POINT structure */
569 typedef struct tagPOINT
573 } POINT
, *PPOINT
, *LPPOINT
;
575 typedef struct POINTL
581 #define CONV_POINT16TO32(p16,p32) \
582 ((p32)->x = (INT)(p16)->x, (p32)->y = (INT)(p16)->y)
583 #define CONV_POINT32TO16(p32,p16) \
584 ((p16)->x = (INT16)(p32)->x, (p16)->y = (INT16)(p32)->y)
586 #define MAKEPOINT16(l) (*((POINT16 *)&(l)))
588 /* The POINTS structure */
590 typedef struct tagPOINTS
594 } POINTS
, *PPOINTS
, *LPPOINTS
;
597 #define MAKEPOINTS(l) (*((POINTS *)&(l)))
600 /* The RECT structure */
601 typedef struct tagRECT
607 } RECT
, *PRECT
, *LPRECT
;
608 typedef const RECT
*LPCRECT
;
611 typedef struct tagRECTL
617 } RECTL
, *PRECTL
, *LPRECTL
;
619 typedef const RECTL
*LPCRECTL
;
621 #define CONV_RECT16TO32(r16,r32) \
622 ((r32)->left = (INT)(r16)->left, (r32)->top = (INT)(r16)->top, \
623 (r32)->right = (INT)(r16)->right, (r32)->bottom = (INT)(r16)->bottom)
624 #define CONV_RECT32TO16(r32,r16) \
625 ((r16)->left = (INT16)(r32)->left, (r16)->top = (INT16)(r32)->top, \
626 (r16)->right = (INT16)(r32)->right, (r16)->bottom = (INT16)(r32)->bottom)
628 #endif /* MPLAYER_WINDEF_H */