summaryrefslogtreecommitdiff
path: root/hw/xwin/winerror.c
diff options
context:
space:
mode:
authorAlexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de>2004-06-21 13:19:32 +0000
committerAlexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de>2004-06-21 13:19:32 +0000
commitd6e8b1affec7351549c0006cc63b6923091cdd68 (patch)
tree6e5e9dd1c1ec6e141349337df844b649bbf4277d /hw/xwin/winerror.c
parentdfdbb60bf5f613b3554d5435f08f16bde72aa353 (diff)
Bug 777: Merge from CYGWIN branch
Diffstat (limited to 'hw/xwin/winerror.c')
-rw-r--r--hw/xwin/winerror.c96
1 files changed, 89 insertions, 7 deletions
diff --git a/hw/xwin/winerror.c b/hw/xwin/winerror.c
index fa6687c1b..968467026 100644
--- a/hw/xwin/winerror.c
+++ b/hw/xwin/winerror.c
@@ -1,5 +1,5 @@
/*
- *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
*
*Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@@ -15,23 +15,31 @@
*THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
*EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
*MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
*ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
*CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
*WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
- *Except as contained in this notice, the name of the XFree86 Project
+ *Except as contained in this notice, the name of Harold L Hunt II
*shall not be used in advertising or otherwise to promote the sale, use
*or other dealings in this Software without prior written authorization
- *from the XFree86 Project.
+ *from Harold L Hunt II.
*
* Authors: Harold L Hunt II
*/
-/* $XFree86: xc/programs/Xserver/hw/xwin/winerror.c,v 1.3 2001/10/23 22:22:47 alanh Exp $ */
#include "win.h"
+/* References to external symbols */
+extern char * g_pszCommandLine;
+extern Bool g_fUseMsg;
+
+
#ifdef DDXOSVERRORF
+/* Prototype */
+void
+OsVendorVErrorF (const char *pszFormat, va_list va_args);
+
void
OsVendorVErrorF (const char *pszFormat, va_list va_args)
{
@@ -41,7 +49,7 @@ OsVendorVErrorF (const char *pszFormat, va_list va_args)
pthread_mutex_lock (&s_pmPrinting);
/* Print the error message to a log file, could be stderr */
- LogVWrite(0, pszFormat, va_args);
+ LogVWrite (0, pszFormat, va_args);
/* Unlock the printing mutex */
pthread_mutex_unlock (&s_pmPrinting);
@@ -60,6 +68,80 @@ OsVendorVErrorF (const char *pszFormat, va_list va_args)
void
OsVendorFatalError (void)
{
-
+ /* Don't give duplicate warning if UseMsg was called */
+ if (g_fUseMsg)
+ return;
+
+ winMessageBoxF ("A fatal error has occurred and Cygwin/X will now exit.\n" \
+ "Please open /tmp/XWin.log for more information.\n",
+ MB_ICONERROR);
}
#endif
+
+
+/*
+ * winMessageBoxF - Print a formatted error message in a useful
+ * message box.
+ */
+
+void
+winMessageBoxF (const char *pszError, UINT uType, ...)
+{
+ int i;
+ char * pszErrorF = NULL;
+ char * pszMsgBox = NULL;
+ va_list args;
+
+ /* Get length of formatted error string */
+ va_start (args, uType);
+ i = sprintf (NULL, pszError, args);
+ va_end (args);
+
+ /* Allocate memory for formatted error string */
+ pszErrorF = malloc (i);
+ if (!pszErrorF)
+ goto winMessageBoxF_Cleanup;
+
+ /* Create the formatted error string */
+ va_start (args, uType);
+ sprintf (pszErrorF, pszError, args);
+ va_end (args);
+
+#define MESSAGEBOXF \
+ "%s\n" \
+ "Vendor: %s\n" \
+ "Release: %s\n" \
+ "Contact: %s\n" \
+ "XWin was started with the following command-line:\n\n" \
+ "%s\n"
+
+ /* Get length of message box string */
+ i = sprintf (NULL, MESSAGEBOXF,
+ pszErrorF,
+ VENDOR_STRING, VERSION_STRING, VENDOR_CONTACT,
+ g_pszCommandLine);
+
+ /* Allocate memory for message box string */
+ pszMsgBox = malloc (i);
+ if (!pszMsgBox)
+ goto winMessageBoxF_Cleanup;
+
+ /* Format the message box string */
+ sprintf (pszMsgBox, MESSAGEBOXF,
+ pszErrorF,
+ VENDOR_STRING, VERSION_STRING, VENDOR_CONTACT,
+ g_pszCommandLine);
+
+ /* Display the message box string */
+ MessageBox (NULL,
+ pszMsgBox,
+ "Cygwin/X",
+ MB_OK | uType);
+
+ winMessageBoxF_Cleanup:
+ if (pszErrorF)
+ free (pszErrorF);
+ if (pszMsgBox)
+ free (pszMsgBox);
+#undef MESSAGEBOXF
+}