Initial commit
[xorg_rtime.git] / xorg-server-1.4 / hw / xwin / winmsg.c
blobd0464f71b4456a3665e78ca0d41ddbea64e95688
1 /*
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>
33 #endif
34 #include "win.h"
35 #include "winmsg.h"
36 #if CYGDEBUG
37 #include "winmessages.h"
38 #endif
39 #include <stdarg.h>
41 void winVMsg (int, MessageType, int verb, const char *, va_list);
43 void
44 winVMsg (int scrnIndex, MessageType type, int verb, const char *format,
45 va_list ap)
47 LogVMessageVerb(type, verb, format, ap);
51 void
52 winDrvMsg (int scrnIndex, MessageType type, const char *format, ...)
54 va_list ap;
55 va_start (ap, format);
56 LogVMessageVerb(type, 0, format, ap);
57 va_end (ap);
61 void
62 winMsg (MessageType type, const char *format, ...)
64 va_list ap;
65 va_start (ap, format);
66 LogVMessageVerb(type, 1, format, ap);
67 va_end (ap);
71 void
72 winDrvMsgVerb (int scrnIndex, MessageType type, int verb, const char *format,
73 ...)
75 va_list ap;
76 va_start (ap, format);
77 LogVMessageVerb(type, verb, format, ap);
78 va_end (ap);
82 void
83 winMsgVerb (MessageType type, int verb, const char *format, ...)
85 va_list ap;
86 va_start (ap, format);
87 LogVMessageVerb(type, verb, format, ap);
88 va_end (ap);
92 void
93 winErrorFVerb (int verb, const char *format, ...)
95 va_list ap;
96 va_start (ap, format);
97 LogVMessageVerb(X_NONE, verb, format, ap);
98 va_end (ap);
101 void
102 winDebug (const char *format, ...)
104 va_list ap;
105 va_start (ap, format);
106 LogVMessageVerb(X_NONE, 3, format, ap);
107 va_end (ap);
110 void
111 winTrace (const char *format, ...)
113 va_list ap;
114 va_start (ap, format);
115 LogVMessageVerb(X_NONE, 10, format, ap);
116 va_end (ap);
119 void
120 winW32Error(int verb, const char *msg)
122 winW32ErrorEx(verb, msg, GetLastError());
125 void
126 winW32ErrorEx(int verb, const char *msg, DWORD errorcode)
128 LPVOID buffer;
129 if (!FormatMessage(
130 FORMAT_MESSAGE_ALLOCATE_BUFFER |
131 FORMAT_MESSAGE_FROM_SYSTEM |
132 FORMAT_MESSAGE_IGNORE_INSERTS,
133 NULL,
134 errorcode,
135 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
136 (LPTSTR) &buffer,
138 NULL ))
140 winErrorFVerb(verb, "Unknown error in FormatMessage!\n");
142 else
144 winErrorFVerb(verb, "%s %s", msg, (char *)buffer);
145 LocalFree(buffer);
149 #if CYGDEBUG
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];
165 char buffer[64];
166 snprintf(buffer, sizeof(buffer), "WIN_DEBUG_%s", msgname);
167 buffer[63] = 0;
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);
175 #else
176 void winDebugWin32Message(const char* function, HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
179 #endif