2 *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
4 *Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 *"Software"), to deal in the Software without restriction, including
7 *without limitation the rights to use, copy, modify, merge, publish,
8 *distribute, sublicense, and/or sell copies of the Software, and to
9 *permit persons to whom the Software is furnished to do so, subject to
10 *the following conditions:
12 *The above copyright notice and this permission notice shall be
13 *included in all copies or substantial portions of the Software.
15 *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
19 *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
20 *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 *Except as contained in this notice, the name of the XFree86 Project
24 *shall not be used in advertising or otherwise to promote the sale, use
25 *or other dealings in this Software without prior written authorization
26 *from the XFree86 Project.
28 * Authors: Alexander Gottwald
31 #ifdef HAVE_XWIN_CONFIG_H
32 #include <xwin-config.h>
37 #include "winmessages.h"
42 winVMsg(int, MessageType
, int verb
, const char *, va_list)
43 _X_ATTRIBUTE_PRINTF(4, 0);
46 winVMsg(int scrnIndex
, MessageType type
, int verb
, const char *format
,
49 LogVMessageVerb(type
, verb
, format
, ap
);
53 winDrvMsg(int scrnIndex
, MessageType type
, const char *format
, ...)
58 LogVMessageVerb(type
, 0, format
, ap
);
63 winMsg(MessageType type
, const char *format
, ...)
68 LogVMessageVerb(type
, 1, format
, ap
);
73 winDrvMsgVerb(int scrnIndex
, MessageType type
, int verb
, const char *format
,
79 LogVMessageVerb(type
, verb
, format
, ap
);
84 winMsgVerb(MessageType type
, int verb
, const char *format
, ...)
89 LogVMessageVerb(type
, verb
, format
, ap
);
94 winErrorFVerb(int verb
, const char *format
, ...)
99 LogVMessageVerb(X_NONE
, verb
, format
, ap
);
104 winDebug(const char *format
, ...)
108 va_start(ap
, format
);
109 LogVMessageVerb(X_NONE
, 3, format
, ap
);
114 winTrace(const char *format
, ...)
118 va_start(ap
, format
);
119 LogVMessageVerb(X_NONE
, 10, format
, ap
);
124 winW32Error(int verb
, const char *msg
)
126 winW32ErrorEx(verb
, msg
, GetLastError());
130 winW32ErrorEx(int verb
, const char *msg
, DWORD errorcode
)
134 if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
|
135 FORMAT_MESSAGE_FROM_SYSTEM
|
136 FORMAT_MESSAGE_IGNORE_INSERTS
,
139 MAKELANGID(LANG_NEUTRAL
, SUBLANG_DEFAULT
),
140 (LPTSTR
) &buffer
, 0, NULL
)) {
141 winErrorFVerb(verb
, "Unknown error in FormatMessage!\n");
144 winErrorFVerb(verb
, "%s %s", msg
, (char *) buffer
);
151 winDebugWin32Message(const char *function
, HWND hwnd
, UINT message
,
152 WPARAM wParam
, LPARAM lParam
)
154 static int force
= 0;
156 if (message
>= WM_USER
) {
157 if (force
|| getenv("WIN_DEBUG_MESSAGES") ||
158 getenv("WIN_DEBUG_WM_USER")) {
159 winDebug("%s - Message WM_USER + %d\n", function
,
161 winDebug("\thwnd 0x%x wParam 0x%x lParam 0x%x\n", hwnd
, wParam
,
165 else if (message
< MESSAGE_NAMES_LEN
&& MESSAGE_NAMES
[message
]) {
166 const char *msgname
= MESSAGE_NAMES
[message
];
169 snprintf(buffer
, sizeof(buffer
), "WIN_DEBUG_%s", msgname
);
171 if (force
|| getenv("WIN_DEBUG_MESSAGES") || getenv(buffer
)) {
172 winDebug("%s - Message %s\n", function
, MESSAGE_NAMES
[message
]);
173 winDebug("\thwnd 0x%x wParam 0x%x lParam 0x%x\n", hwnd
, wParam
,
180 winDebugWin32Message(const char *function
, HWND hwnd
, UINT message
,
181 WPARAM wParam
, LPARAM lParam
)