/* This file contains compatibility routines for systems without Xmu.
* You would be better served by installing Xmu on your machine or
* yelling at your vendor to ship it.
* Copyright 1989 Massachusetts Institute of Technology
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in advertising
* or publicity pertaining to distribution of the software without specific,
* written prior permission. M.I.T. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
* M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# define NEED_EVENTS /* to make Xproto.h define xEvent */
# include <X11/Xproto.h> /* for xEvent (used by Xlibint.h) */
# include <X11/Xlibint.h> /* for _XExtension */
#include <X11/Intrinsic.h> /* for XtSpecificationRelease */
* XmuPrintDefaultErrorMessage - print a nice error that looks like the usual
* message. Returns 1 if the caller should consider exitting else 0.
int XmuPrintDefaultErrorMessage (Display
*dpy
, XErrorEvent
*event
, FILE *fp
)
char *mtype
= "XlibMessage";
_XExtension
*ext
= (_XExtension
*)NULL
;
XGetErrorText(dpy
, event
->error_code
, buffer
, BUFSIZ
);
XGetErrorDatabaseText(dpy
, mtype
, "XError", "X Error", mesg
, BUFSIZ
);
(void) fprintf(fp
, "%s: %s\n ", mesg
, buffer
);
XGetErrorDatabaseText(dpy
, mtype
, "MajorCode", "Request Major code %d",
(void) fprintf(fp
, mesg
, event
->request_code
);
if (event
->request_code
< 128) {
sprintf(number
, "%d", event
->request_code
);
XGetErrorDatabaseText(dpy
, "XRequest", number
, "", buffer
, BUFSIZ
);
/* XXX this is non-portable */
for (ext
= dpy
->ext_procs
;
ext
&& (ext
->codes
.major_opcode
!= event
->request_code
);
strcpy(buffer
, ext
->name
);
(void) fprintf(fp
, " (%s)", buffer
);
#if (XtSpecificationRelease >= 5)
if (event
->request_code
>= 128) {
XGetErrorDatabaseText(dpy
, mtype
, "MinorCode", "Request Minor code %d",
(void) fprintf(fp
, mesg
, event
->minor_code
);
sprintf(mesg
, "%s.%d", ext
->name
, event
->minor_code
);
XGetErrorDatabaseText(dpy
, "XRequest", mesg
, "", buffer
, BUFSIZ
);
(void) fprintf(fp
, " (%s)", buffer
);
if (event
->error_code
>= 128) {
/* let extensions try to print the values */
/* XXX this is non-portable code */
for (ext
= dpy
->ext_procs
; ext
; ext
= ext
->next
) {
(*ext
->error_values
)(dpy
, event
, fp
);
/* the rest is a fallback, providing a simple default */
/* kludge, try to find the extension that caused it */
for (ext
= dpy
->ext_procs
; ext
; ext
= ext
->next
) {
(*ext
->error_string
)(dpy
, event
->error_code
, &ext
->codes
,
sprintf(buffer
, "%s.%d", ext
->name
,
event
->error_code
- ext
->codes
.first_error
);
XGetErrorDatabaseText(dpy
, mtype
, buffer
, "", mesg
, BUFSIZ
);
(void) fprintf(fp
, mesg
, event
->resourceid
);
} else if ((event
->error_code
== BadWindow
) ||
(event
->error_code
== BadPixmap
) ||
(event
->error_code
== BadCursor
) ||
(event
->error_code
== BadFont
) ||
(event
->error_code
== BadDrawable
) ||
(event
->error_code
== BadColor
) ||
(event
->error_code
== BadGC
) ||
(event
->error_code
== BadIDChoice
) ||
(event
->error_code
== BadValue
) ||
(event
->error_code
== BadAtom
)) {
if (event
->error_code
== BadValue
)
XGetErrorDatabaseText(dpy
, mtype
, "Value", "Value 0x%x",
else if (event
->error_code
== BadAtom
)
XGetErrorDatabaseText(dpy
, mtype
, "AtomID", "AtomID 0x%x",
XGetErrorDatabaseText(dpy
, mtype
, "ResourceID", "ResourceID 0x%x",
(void) fprintf(fp
, mesg
, event
->resourceid
);
#elif (XtSpecificationRelease == 4)
XGetErrorDatabaseText(dpy
, mtype
, "MinorCode", "Request Minor code %d",
(void) fprintf(fp
, mesg
, event
->minor_code
);
sprintf(mesg
, "%s.%d", ext
->name
, event
->minor_code
);
XGetErrorDatabaseText(dpy
, "XRequest", mesg
, "", buffer
, BUFSIZ
);
(void) fprintf(fp
, " (%s)", buffer
);
XGetErrorDatabaseText(dpy
, mtype
, "ResourceID", "ResourceID 0x%x",
(void) fprintf(fp
, mesg
, event
->resourceid
);
ERROR
! Unsupported release of X11
XGetErrorDatabaseText(dpy
, mtype
, "ErrorSerial", "Error Serial #%d",
(void) fprintf(fp
, mesg
, event
->serial
);
XGetErrorDatabaseText(dpy
, mtype
, "CurrentSerial", "Current Serial #%d",
(void) fprintf(fp
, mesg
, NextRequest(dpy
)-1);
if (event
->error_code
== BadImplementation
) return 0;
/* Shut up the stupid "gcc -pedantic" warning */
int _I_dont_care_that_ISO_C_forbids_an_empty_source_file_
= 1;