From 7e0f021a9aec35fd8e6725e87e3313b101d26f5e Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Sun, 27 Jan 2008 11:37:44 +0100 Subject: Initial import (2.0.2-6) --- reference/C/CONTRIB/SNIP/noctrlc.c | 63 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100755 reference/C/CONTRIB/SNIP/noctrlc.c (limited to 'reference/C/CONTRIB/SNIP/noctrlc.c') diff --git a/reference/C/CONTRIB/SNIP/noctrlc.c b/reference/C/CONTRIB/SNIP/noctrlc.c new file mode 100755 index 0000000..bbc8649 --- /dev/null +++ b/reference/C/CONTRIB/SNIP/noctrlc.c @@ -0,0 +1,63 @@ +/****************************************************************/ +/* Name: noctrl() */ +/* Desc: captures interrput 9 so as to ignore ctrl-c,ctrl-break,*/ +/* ctrl-alt-del */ +/****************************************************************/ + +#include + +#if defined(__ZTC__) + #define INTERRUPT + #define FAR _far + #define ENABLE int_on + #define INPORTB inp + #define OUTPORTB outp +#else + #include + #if defined(__TURBOC__) + #define INTERRUPT interrupt + #define FAR far + #define ENABLE enable + #define INPORTB inportb + #define OUTPORTB outportb + #else + #define INTERRUPT _interrupt + #define FAR _far + #define ENABLE _enable + #define INPORTB inp + #define OUTPORTB outp + #endif +#endif + +extern void (INTERRUPT FAR *oldint9)(void); /* Caller must set this */ + +void INTERRUPT FAR noctrl(void) +{ + unsigned char byte; + static int flag; + + ENABLE(); + + if ((byte = (unsigned char)INPORTB(0x60)) == 29) + flag = 1; + + if (byte == 157) + flag = 0; + + if (!flag) + (*oldint9)(); + else switch (byte) + { + case 46 : /* yeah, these should be #defined! */ + case 70 : + case 56 : + case 83 : + byte = (unsigned char)INPORTB(0x61); + OUTPORTB(0x61,byte | 0x80); + OUTPORTB(0x61,byte); + OUTPORTB(0x20,0x20); + break; + default : + (*oldint9)(); + } +} -- cgit v1.2.3-54-g00ecf