summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorAlexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de>2004-04-27 18:07:15 +0000
committerAlexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de>2004-04-27 18:07:15 +0000
commit9a6e22ebfb4f93b240e42249a230d76afc041216 (patch)
tree1f78bec1d11d713495284d798114d5e88bc84ac2 /hw
parent11fb48f46349feb0520c95f957cfa326dd50ca0f (diff)
new function winW32Error which prints the error string with FormatMessage
Diffstat (limited to 'hw')
-rw-r--r--hw/xwin/winmsg.c24
-rw-r--r--hw/xwin/winmsg.h1
2 files changed, 25 insertions, 0 deletions
diff --git a/hw/xwin/winmsg.c b/hw/xwin/winmsg.c
index e9d72b7f6..23252612c 100644
--- a/hw/xwin/winmsg.c
+++ b/hw/xwin/winmsg.c
@@ -101,3 +101,27 @@ winDebug (const char *format, ...)
LogVMessageVerb(X_NONE, 3, format, ap);
va_end (ap);
}
+
+void
+winW32Error(int verb, DWORD errorcode, const char *format)
+{
+ LPVOID buffer;
+ if (!FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ errorcode,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR) &buffer,
+ 0,
+ NULL ))
+ {
+ winErrorFVerb(verb, "Unknown error in FormatMessage!\n");
+ }
+ else
+ {
+ winErrorFVerb(verb, format, (char *)buffer);
+ LocalFree(buffer);
+ }
+}
diff --git a/hw/xwin/winmsg.h b/hw/xwin/winmsg.h
index 7ceb73858..a42d6467c 100644
--- a/hw/xwin/winmsg.h
+++ b/hw/xwin/winmsg.h
@@ -44,5 +44,6 @@ void winMsg (MessageType type, const char *format, ...);
void winDebug (const char *format, ...);
void winErrorFVerb (int verb, const char *format, ...);
+void winW32Error(int verb, DWORD errorcode, const char *format);
#endif