diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2008-01-27 11:37:44 +0100 |
---|---|---|
committer | Tobias Klauser <tklauser@xenon.tklauser.home> | 2008-01-27 11:37:44 +0100 |
commit | 7e0f021a9aec35fd8e6725e87e3313b101d26f5e (patch) | |
tree | b1cacc4b24393f517aeb4610e9e1021f954307a8 /reference/C/CONTRIB/SNIP/trapdemo.c |
Initial import (2.0.2-6)2.0.2-6
Diffstat (limited to 'reference/C/CONTRIB/SNIP/trapdemo.c')
-rwxr-xr-x | reference/C/CONTRIB/SNIP/trapdemo.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/reference/C/CONTRIB/SNIP/trapdemo.c b/reference/C/CONTRIB/SNIP/trapdemo.c new file mode 100755 index 0000000..68c7387 --- /dev/null +++ b/reference/C/CONTRIB/SNIP/trapdemo.c @@ -0,0 +1,74 @@ +/*
+** Demonstrate TRAPFLAG.ASM
+**
+** public domain by Bob Stout
+*/
+
+#include <stdio.h>
+#include <dos.h>
+#include <int.h>
+
+extern void ins09(void);
+extern void undo09(void);
+
+extern volatile int far ccrcvd;
+
+static void biosprt(char *p)
+{
+ union REGS regs;
+
+ while (*p)
+ {
+ regs.h.ah = 0x0e; /* Low-level services only! */
+ regs.h.al = *p++;
+ regs.x.bx = 0;
+ int86(0x10, ®s, ®s);
+ }
+}
+
+static void far my_cc(void)
+{
+ char *p1 = "Ctrl-";
+ char *p2 = "C";
+ char *p3 = "Break";
+ char *p4 = " received\r\n";
+
+ biosprt(p1);
+ if (1 == ccrcvd)
+ biosprt(p2);
+ else biosprt(p3);
+ biosprt(p4);
+}
+
+main()
+{
+ unsigned seg, ofs;
+ int ch = 0;
+
+ setbuf(stdout, NULL);
+ my_cc();
+ ins09();
+ atexit(undo09);
+ puts("New Ints 09h & 1Bh installed...");
+ puts("Hit Esc to quit...");
+ do
+ {
+ if (kbhit())
+ {
+ if (0x1b != (ch = getch()))
+ {
+ if (0x20 > ch)
+ {
+ fputc('^', stdout);
+ ch += '@';
+ }
+ fputc(ch, stdout);
+ }
+ }
+ if (ccrcvd)
+ {
+ my_cc();
+ ccrcvd = 0;
+ }
+ } while (0x1b != ch);
+}
|