home *** CD-ROM | disk | FTP | other *** search
- /* > $.CLIB.C.kernel
- *
- * 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.
- *
- * routines to interface HASWIN to the kernel. This is so designed that
- * ALL kernel calls go via code in this file. Therefore if this file
- * compiles under both Release 2 and 3 of C then the whole library is
- * OK. This is in fact the case!
- */
- #include "includes.h"
-
- int haswin_setexittrap(int (*code)(int)) {
- haswin_exittrap = code;
- return(HASWIN_TRUE);
- }
-
- void haswin_exit(int code) {
-
- if (haswin_exittrap)
- (*haswin_exittrap)(code);
- while (haswin_poptemplate())
- ;
- while (haswin_popcaret())
- ;
- while (haswin_poppointer(HASWIN_FALSE))
- ;
- haswin_pdriverclosedown();
- haswin_restoreerrorhandlers();
- haswin_finishedfonts();
- haswin_taskclosedown();
- haswin_killmemorymanager();
- exit(code);
- }
-
- /*
- * run a command under the WIMP.
- */
- void haswin_execcommand(char *comm) {
-
- _kernel_swi_regs regs;
-
- regs.r[0] = (int)comm;
- haswin_swi(HASWIN_Start_task, ®s);
- }
-
- int haswin_swi(int swi, _kernel_swi_regs *regs) {
-
- _kernel_swi_regs ans;
- _kernel_oserror *err;
-
- if (regs == 0) {
- #ifdef DEBUG
- fprintf(stderr, "\nhaswin_swi(%8.8X, regs=0)\n", swi);
- #endif
- if ((err = _kernel_swi(SWI_X|swi, &ans, &ans)) == 0)
- return(HASWIN_TRUE);
- else {
- haswin_interrorprintf("SWI %8.8X: %s", swi,
- err->errmess);
- return(HASWIN_FALSE);
- }
- }
- #ifdef DEBUG
- fprintf(stderr, "\nhaswin_swi(%8.8X, (%X %X %X %X))\n", swi, regs->r[0], regs->r[1], regs->r[2], regs->r[3]);
- #endif
- if ((err = _kernel_swi(SWI_X|swi, regs, &ans)) == 0) {
- regs->r[0] = ans.r[0]; regs->r[1] = ans.r[1];
- regs->r[2] = ans.r[2]; regs->r[3] = ans.r[3];
- regs->r[4] = ans.r[4]; regs->r[5] = ans.r[5];
- regs->r[6] = ans.r[6]; regs->r[7] = ans.r[7];
- regs->r[8] = ans.r[8]; regs->r[9] = ans.r[9];
- return(HASWIN_TRUE);
- } else {
- haswin_interrorprintf("SWI %8.8X: %s", swi, err->errmess);
- return(HASWIN_FALSE);
- }
- }
-
-