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"
41 void winVMsg (int, MessageType
, int verb
, const char *, va_list);
44 winVMsg (int scrnIndex
, MessageType type
, int verb
, const char *format
,
47 LogVMessageVerb(type
, verb
, format
, ap
);
52 winDrvMsg (int scrnIndex
, MessageType type
, const char *format
, ...)
55 va_start (ap
, format
);
56 LogVMessageVerb(type
, 0, format
, ap
);
62 winMsg (MessageType type
, const char *format
, ...)
65 va_start (ap
, format
);
66 LogVMessageVerb(type
, 1, format
, ap
);
72 winDrvMsgVerb (int scrnIndex
, MessageType type
, int verb
, const char *format
,
76 va_start (ap
, format
);
77 LogVMessageVerb(type
, verb
, format
, ap
);
83 winMsgVerb (MessageType type
, int verb
, const char *format
, ...)
86 va_start (ap
, format
);
87 LogVMessageVerb(type
, verb
, format
, ap
);
93 winErrorFVerb (int verb
, const char *format
, ...)
96 va_start (ap
, format
);
97 LogVMessageVerb(X_NONE
, verb
, format
, ap
);
102 winDebug (const char *format
, ...)
105 va_start (ap
, format
);
106 LogVMessageVerb(X_NONE
, 3, format
, ap
);
111 winTrace (const char *format
, ...)
114 va_start (ap
, format
);
115 LogVMessageVerb(X_NONE
, 10, format
, ap
);
120 winW32Error(int verb
, const char *msg
)
122 winW32ErrorEx(verb
, msg
, GetLastError());
126 winW32ErrorEx(int verb
, const char *msg
, DWORD errorcode
)
130 FORMAT_MESSAGE_ALLOCATE_BUFFER
|
131 FORMAT_MESSAGE_FROM_SYSTEM
|
132 FORMAT_MESSAGE_IGNORE_INSERTS
,
135 MAKELANGID(LANG_NEUTRAL
, SUBLANG_DEFAULT
),
140 winErrorFVerb(verb
, "Unknown error in FormatMessage!\n");
144 winErrorFVerb(verb
, "%s %s", msg
, (char *)buffer
);
150 void winDebugWin32Message(const char* function
, HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
152 static int force
= 0;
154 if (message
>= WM_USER
)
156 if (force
|| getenv("WIN_DEBUG_MESSAGES") || getenv("WIN_DEBUG_WM_USER"))
158 winDebug("%s - Message WM_USER + %d\n", function
, message
- WM_USER
);
159 winDebug("\thwnd 0x%x wParam 0x%x lParam 0x%x\n", hwnd
, wParam
, lParam
);
162 else if (message
< MESSAGE_NAMES_LEN
&& MESSAGE_NAMES
[message
])
164 const char *msgname
= MESSAGE_NAMES
[message
];
166 snprintf(buffer
, sizeof(buffer
), "WIN_DEBUG_%s", msgname
);
168 if (force
|| getenv("WIN_DEBUG_MESSAGES") || getenv(buffer
))
170 winDebug("%s - Message %s\n", function
, MESSAGE_NAMES
[message
]);
171 winDebug("\thwnd 0x%x wParam 0x%x lParam 0x%x\n", hwnd
, wParam
, lParam
);
176 void winDebugWin32Message(const char* function
, HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)