2001-05-08 10:21:00 -04:00
|
|
|
#include "xlib.h"
|
2001-08-29 10:54:05 -04:00
|
|
|
#include <stdio.h>
|
2001-05-08 10:21:00 -04:00
|
|
|
|
2001-08-29 10:54:05 -04:00
|
|
|
s48_value internal_x_error_handler_binding = S48_FALSE;
|
|
|
|
s48_value internal_x_fatal_error_handler_binding = S48_FALSE;
|
2001-05-08 10:21:00 -04:00
|
|
|
|
|
|
|
/* Default error handlers of the Xlib */
|
|
|
|
extern int _XDefaultIOError();
|
|
|
|
extern int _XDefaultError();
|
|
|
|
|
2001-08-29 10:54:05 -04:00
|
|
|
static X_Fatal_Error (Display* d) {
|
|
|
|
//Reset_IO (0); //??
|
2001-05-08 10:21:00 -04:00
|
|
|
|
2001-08-29 10:54:05 -04:00
|
|
|
// call the scheme-func internal-x-fatal-error-handler, which does the rest.
|
|
|
|
s48_call_scheme(S48_SHARED_BINDING_REF(internal_x_fatal_error_handler_binding),
|
|
|
|
1, SCX_ENTER_DISPLAY(d));
|
|
|
|
|
|
|
|
// In case the scheme error handler does not exit (or none exists):
|
|
|
|
_XDefaultIOError (d);
|
|
|
|
// And if event the default handler does not exit:
|
|
|
|
exit (1);
|
|
|
|
/*NOTREACHED*/
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2001-08-29 10:54:05 -04:00
|
|
|
static X_Error(Display* d, XErrorEvent* ep) {
|
|
|
|
s48_value args = s48_make_vector(7, S48_FALSE);
|
|
|
|
s48_value a = S48_FALSE, r = S48_FALSE;
|
|
|
|
int max_s = 1024;
|
|
|
|
char s[max_s];
|
|
|
|
S48_DECLARE_GC_PROTECT(2);
|
2001-05-08 10:21:00 -04:00
|
|
|
|
2001-08-29 10:54:05 -04:00
|
|
|
//Reset_IO (0); //??
|
2001-05-08 10:21:00 -04:00
|
|
|
|
2001-08-29 10:54:05 -04:00
|
|
|
S48_GC_PROTECT_2(args, a);
|
|
|
|
S48_VECTOR_SET(args, 0, SCX_ENTER_DISPLAY(d));
|
|
|
|
S48_VECTOR_SET(args, 1, s48_enter_integer(ep->serial));
|
2002-02-08 12:09:43 -05:00
|
|
|
S48_VECTOR_SET(args, 2, s48_enter_integer(ep->error_code));
|
|
|
|
S48_VECTOR_SET(args, 3, s48_enter_integer(ep->request_code));
|
|
|
|
S48_VECTOR_SET(args, 4, s48_enter_integer(ep->minor_code));
|
|
|
|
S48_VECTOR_SET(args, 5, s48_enter_integer((unsigned long)ep->resourceid));
|
2001-08-29 10:54:05 -04:00
|
|
|
XGetErrorText(d, ep->error_code, s, max_s);
|
|
|
|
S48_VECTOR_SET(args, 6, s48_enter_string(s));
|
2001-05-08 10:21:00 -04:00
|
|
|
|
2001-08-29 10:54:05 -04:00
|
|
|
r = s48_call_scheme(S48_SHARED_BINDING_REF(internal_x_error_handler_binding),
|
|
|
|
1, args);
|
2001-05-08 10:21:00 -04:00
|
|
|
|
2001-08-29 10:54:05 -04:00
|
|
|
S48_GC_UNPROTECT();
|
2001-05-08 10:21:00 -04:00
|
|
|
|
2001-08-29 10:54:05 -04:00
|
|
|
if S48_FALSE_P( r )
|
|
|
|
_XDefaultError (d, ep);
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2001-08-29 10:54:05 -04:00
|
|
|
void scx_init_error() {
|
|
|
|
S48_GC_PROTECT_GLOBAL(internal_x_error_handler_binding);
|
|
|
|
S48_GC_PROTECT_GLOBAL(internal_x_fatal_error_handler_binding);
|
|
|
|
internal_x_error_handler_binding =
|
|
|
|
s48_get_imported_binding("internal-x-error-handler");
|
|
|
|
internal_x_fatal_error_handler_binding =
|
|
|
|
s48_get_imported_binding("internal-x-fatal-error-handler");
|
|
|
|
|
|
|
|
(void)XSetIOErrorHandler (X_Fatal_Error);
|
|
|
|
(void)XSetErrorHandler (X_Error);
|
|
|
|
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|