1 /* This file contains compatibility routines for systems without Xmu.
2 * You would be better served by installing Xmu on your machine or
3 * yelling at your vendor to ship it.
12 * Copyright 1989 Massachusetts Institute of Technology
14 * Permission to use, copy, modify, and distribute this software and its
15 * documentation for any purpose and without fee is hereby granted, provided
16 * that the above copyright notice appear in all copies and that both that
17 * copyright notice and this permission notice appear in supporting
18 * documentation, and that the name of M.I.T. not be used in advertising
19 * or publicity pertaining to distribution of the software without specific,
20 * written prior permission. M.I.T. makes no representations about the
21 * suitability of this software for any purpose. It is provided "as is"
22 * without express or implied warranty.
24 * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
26 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
27 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
28 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
29 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
35 # define NEED_EVENTS /* to make Xproto.h define xEvent */
38 # include <X11/Xproto.h> /* for xEvent (used by Xlibint.h) */
39 # include <X11/Xlibint.h> /* for _XExtension */
41 # include <X11/Xlib.h>
43 #include <X11/Intrinsic.h> /* for XtSpecificationRelease */
46 * XmuPrintDefaultErrorMessage - print a nice error that looks like the usual
47 * message. Returns 1 if the caller should consider exitting else 0.
49 int XmuPrintDefaultErrorMessage (Display *dpy, XErrorEvent *event, FILE *fp)
54 char *mtype = "XlibMessage";
55 _XExtension *ext = (_XExtension *)NULL;
56 XGetErrorText(dpy, event->error_code, buffer, BUFSIZ);
57 XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ);
58 (void) fprintf(fp, "%s: %s\n ", mesg, buffer);
59 XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d",
61 (void) fprintf(fp, mesg, event->request_code);
62 if (event->request_code < 128) {
63 sprintf(number, "%d", event->request_code);
64 XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ);
66 /* XXX this is non-portable */
67 for (ext = dpy->ext_procs;
68 ext && (ext->codes.major_opcode != event->request_code);
72 strcpy(buffer, ext->name);
76 (void) fprintf(fp, " (%s)", buffer);
78 #if (XtSpecificationRelease >= 5)
79 if (event->request_code >= 128) {
80 XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d",
82 (void) fprintf(fp, mesg, event->minor_code);
84 sprintf(mesg, "%s.%d", ext->name, event->minor_code);
85 XGetErrorDatabaseText(dpy, "XRequest", mesg, "", buffer, BUFSIZ);
86 (void) fprintf(fp, " (%s)", buffer);
90 if (event->error_code >= 128) {
91 /* let extensions try to print the values */
92 /* XXX this is non-portable code */
93 for (ext = dpy->ext_procs; ext; ext = ext->next) {
94 if (ext->error_values)
95 (*ext->error_values)(dpy, event, fp);
97 /* the rest is a fallback, providing a simple default */
98 /* kludge, try to find the extension that caused it */
100 for (ext = dpy->ext_procs; ext; ext = ext->next) {
101 if (ext->error_string)
102 (*ext->error_string)(dpy, event->error_code, &ext->codes,
108 sprintf(buffer, "%s.%d", ext->name,
109 event->error_code - ext->codes.first_error);
111 strcpy(buffer, "Value");
112 XGetErrorDatabaseText(dpy, mtype, buffer, "", mesg, BUFSIZ);
114 (void) fprintf(fp, mesg, event->resourceid);
117 } else if ((event->error_code == BadWindow) ||
118 (event->error_code == BadPixmap) ||
119 (event->error_code == BadCursor) ||
120 (event->error_code == BadFont) ||
121 (event->error_code == BadDrawable) ||
122 (event->error_code == BadColor) ||
123 (event->error_code == BadGC) ||
124 (event->error_code == BadIDChoice) ||
125 (event->error_code == BadValue) ||
126 (event->error_code == BadAtom)) {
127 if (event->error_code == BadValue)
128 XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x",
130 else if (event->error_code == BadAtom)
131 XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x",
134 XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x",
136 (void) fprintf(fp, mesg, event->resourceid);
139 #elif (XtSpecificationRelease == 4)
140 XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d",
142 (void) fprintf(fp, mesg, event->minor_code);
145 sprintf(mesg, "%s.%d", ext->name, event->minor_code);
146 XGetErrorDatabaseText(dpy, "XRequest", mesg, "", buffer, BUFSIZ);
147 (void) fprintf(fp, " (%s)", buffer);
149 XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x",
151 (void) fprintf(fp, mesg, event->resourceid);
154 ERROR! Unsupported release of X11
156 XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d",
158 (void) fprintf(fp, mesg, event->serial);
160 XGetErrorDatabaseText(dpy, mtype, "CurrentSerial", "Current Serial #%d",
162 (void) fprintf(fp, mesg, NextRequest(dpy)-1);
164 if (event->error_code == BadImplementation) return 0;
170 /* Shut up the stupid "gcc -pedantic" warning */
171 int _I_dont_care_that_ISO_C_forbids_an_empty_source_file_ = 1;
173 #endif /* HAVE_XMU */