2 *Copyright (C) 2001-2004 Harold L Hunt II 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 HAROLD L HUNT II 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 Harold L Hunt II
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 Harold L Hunt II.
28 * Authors: Harold L Hunt II
31 #ifdef HAVE_XWIN_CONFIG_H
32 #include <xwin-config.h>
35 #include <../xfree86/common/xorgVersion.h>
40 OsVendorVErrorF(const char *pszFormat
, va_list va_args
)
42 #if defined(XWIN_CLIPBOARD) || defined (XWIN_MULTIWINDOW)
43 /* make sure the clipboard and multiwindow threads do not interfere the
45 static pthread_mutex_t s_pmPrinting
= PTHREAD_MUTEX_INITIALIZER
;
47 /* Lock the printing mutex */
48 pthread_mutex_lock(&s_pmPrinting
);
51 /* Print the error message to a log file, could be stderr */
52 LogVWrite(0, pszFormat
, va_args
);
54 #if defined(XWIN_CLIPBOARD) || defined (XWIN_MULTIWINDOW)
55 /* Unlock the printing mutex */
56 pthread_mutex_unlock(&s_pmPrinting
);
62 * os/log.c:FatalError () calls our vendor ErrorF, so the message
63 * from a FatalError will be logged.
65 * Attempt to do last-ditch, safe, important cleanup here.
68 OsVendorFatalError(const char *f
, va_list args
)
70 char errormsg
[1024] = "";
72 /* Don't give duplicate warning if UseMsg was called */
73 if (g_fSilentFatalError
)
78 g_pszLogFile
= LogInit(g_pszLogFile
, NULL
);
80 LogClose(EXIT_ERR_ABORT
);
82 /* Format the error message */
83 vsnprintf(errormsg
, sizeof(errormsg
), f
, args
);
86 Sometimes the error message needs a bit of cosmetic cleaning
87 up for use in a dialog box...
92 while ((s
= strstr(errormsg
, "\n\t")) != NULL
) {
98 winMessageBoxF("A fatal error has occurred and " PROJECT_NAME
" will now exit.\n\n"
100 "Please open %s for more information.\n",
103 (g_pszLogFile
? g_pszLogFile
: "the logfile"));
107 * winMessageBoxF - Print a formatted error message in a useful
112 winMessageBoxF(const char *pszError
, UINT uType
, ...)
114 char *pszErrorF
= NULL
;
115 char *pszMsgBox
= NULL
;
119 va_start(args
, uType
);
120 size
= vasprintf(&pszErrorF
, pszError
, args
);
124 goto winMessageBoxF_Cleanup
;
127 #define MESSAGEBOXF \
130 "Release: %d.%d.%d.%d\n" \
133 "XWin was started with the following command-line:\n\n" \
136 size
= asprintf(&pszMsgBox
, MESSAGEBOXF
,
137 pszErrorF
, XVENDORNAME
,
138 XORG_VERSION_MAJOR
, XORG_VERSION_MINOR
, XORG_VERSION_PATCH
,
140 BUILDERADDR
, BUILDERSTRING
, g_pszCommandLine
);
144 goto winMessageBoxF_Cleanup
;
147 /* Display the message box string */
148 MessageBox(NULL
, pszMsgBox
, PROJECT_NAME
, MB_OK
| uType
);
150 winMessageBoxF_Cleanup
: