home *** CD-ROM | disk | FTP | other *** search
- /*********************
- *
- * in_handl.c - interrupt handler function.
- *
- * Purpose: This file contains the handler functions for general
- * interrupts of the IBM PC.
- *
- * Blackstar C Function Library
- * (c) Copyright 1985,1989 Sterling Castle Software
- *
- *******/
-
- #include <dos.h>
- #include <process.h>
- #include <stdlib.h>
- #include "blackstr.h"
- #include "sc_head.h"
- #include "primitiv.h"
-
-
- /********
- *
- * in_setint(vector,function,stack,type) - set an interrupt
- *
- **/
-
- int in_setint(int vector, int (*function)(), char *stack, int type)
- {
- int stseg,stoff,cseg,off;
- struct SREGS segs;
-
- segread(&segs);
- if(!stack)
- stack = malloc(10); /* create a stack location from heap */
- cseg = sy_pseg(function);
- off = sy_poff(function);
- stseg = sy_dseg(stack);
- stoff = sy_doff(stack);
- return(in_setvec_(vector,off,cseg,stoff,stseg,type));
- }
-
-
- /********
- *
- * in_remint - remove previously set interrupt
- *
- **/
-
- int in_remint(int intno)
- {
- return(in_remvec_(intno)); /* just use primitive */
- }
-
-
- /********
- *
- * in_tsr() - terminate and stay resident
- *
- **/
-
- void in_tsr(void)
- {
- _far char *start;
- _far char *end;
- long length;
- struct SREGS segs;
-
- if (_osmajor < 2) {
- puts("TSR requires DOS version 2 or over.\n");
- exit(-1);
- }
-
- if (sizeof(char *) == 2) /* Small data model */
- length = 65535;
- else {
- FP_SEG(start) = getpid();
- FP_OFF(start) = 0;
-
- segread(&segs);
- FP_SEG(end) = segs.ss;
- FP_OFF(end) = 0xffff;
-
- length = FP_SEG(end) - FP_SEG(start);
- length = (length << 4) + FP_OFF(end) - FP_OFF(start);
- }
-
- if (length & 0xf) /* round up to next 16 byte paragraph */
- length += 0x10;
- length >>= 4; /* convert to paragraphs */
- _dos_keep(0, length);
- }
-
-