home *** CD-ROM | disk | FTP | other *** search
- /* > $.CLIB.C.error
- *
- * HASWIN Graphics Library
- * =========================
- *
- * Copyright (C) H.A.Shaw 1990.
- * Howard A. Shaw.
- * The Unit for Space Sciences,
- * Room 165,
- * Physics Building,
- * University of Kent at Canterbury.
- * Canterbury.
- * Kent. CT2 7NJ
- * You may use and distribute this code freely, however please leave
- * it alone. If you find bugs (and there will be many) please contact
- * me and the master source can be modified. If you keep me informed
- * of who you give copies of this to then I can get release upgrades
- * to them.
- *
- * error control routines.
- */
- #include "includes.h"
- #include <signal.h>
- #include <stdarg.h>
-
- int haswin_initerrorhandlers() {
-
- haswin_flags |= HASWIN_FLAGS_EHANDLER;
- return(HASWIN_TRUE);
- }
-
- void haswin_restoreerrorhandlers() {
-
- haswin_flags &= ~HASWIN_FLAGS_EHANDLER;
- return;
- }
-
- int haswin_ok_cancel(char *msg) {
- static char *error = 0;
- int reply;
- _kernel_swi_regs regs, ans;
-
- /* malloc space for the error message */
- error = haswin_realloc(error, asciilen(msg)+5, "haswin_ok_cancel", "error");
- strcpy(&(error[4]), msg);
- *((int *)error) = 0;
- regs.r[0] = (int)error;
- regs.r[1] = 3;
- regs.r[2] = (int)haswin_gettaskname();
- _kernel_swi(HASWIN_Report_error|SWI_X, ®s, &ans);
- reply = ans.r[1];
- return(reply);
- }
-
- /*
- * perform printf() in the errorbox window.
- *
- * The final string is passed to SWI(HASWIN_Report_error) for display.
- */
- int haswin_ok_cancelprintf(char *fmt, ...) {
-
- va_list ap;
- char str[1024];
- int len;
-
- if (!fmt)
- return(HASWIN_FALSE);
- va_start(ap, fmt);
- len = vsprintf(str, fmt, ap);
- haswin_ok_cancel(str);
- va_end(ap);
- return(len);
- }
-
- void haswin_errorbox(char *msg) {
-
- static char error[1024];
- _kernel_swi_regs regs, ans;
-
- strncpy(&(error[4]), msg, 1000);
- *((int *)error) = 0;
- regs.r[0] = (int)error;
- regs.r[1] = 0x00000011;
- regs.r[2] = (int)haswin_gettaskname();
- _kernel_swi(HASWIN_Report_error|SWI_X, ®s, &ans);
- }
-
- /*
- * perform printf() in the errorbox window.
- *
- * The final string is passed to SWI(HASWIN_Report_error) for display.
- */
- int haswin_errorprintf(char *fmt, ...) {
-
- va_list ap;
- char str[1024];
- int len;
-
- if (!fmt)
- return(HASWIN_FALSE);
- va_start(ap, fmt);
- len = vsprintf(str, fmt, ap);
- haswin_errorbox(str);
- va_end(ap);
- return(len);
- }
-
- void haswin_internalerror(char *msg) {
-
- if (haswin_flags & HASWIN_FLAGS_VERBOSE)
- haswin_errorbox(msg);
- return;
- }
-
- int haswin_interrorprintf(char *fmt, ...) {
-
- va_list ap;
- char str[1024];
- int len;
-
- len = HASWIN_FALSE;
- va_start(ap, fmt);
- if ((fmt) && (haswin_flags & HASWIN_FLAGS_VERBOSE)) {
- len=vsprintf(str, fmt, ap);
- haswin_errorbox(str);
- }
- va_end(ap);
- return(len);
- }
-
-