home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_01_06 / 1n06017a < prev    next >
Text File  |  1990-08-13  |  2KB  |  69 lines

  1. #include <stdio.h>
  2. #include <dos.h>
  3. #include <int.h>
  4.  
  5. extern void ins09(void);
  6. extern void undo09(void);
  7.  
  8. extern volatile int far ccrcvd;
  9.  
  10. static void biosprt(char *p)
  11. {
  12.         union REGS regs;
  13.  
  14.         while (*p)
  15.         {
  16.                 regs.h.ah = 0x0e;       /* Low-level services only!     */
  17.                 regs.h.al = *p++;
  18.                 regs.x.bx = 0;
  19.                 int86(0x10, ®s, ®s);
  20.         }
  21. }
  22.  
  23. static void far my_cc(void)
  24. {
  25.         char *p1 = "Ctrl-";
  26.         char *p2 = "C";
  27.         char *p3 = "Break";
  28.         char *p4 = " received\r\n";
  29.  
  30.         biosprt(p1);
  31.         if (1 == ccrcvd)
  32.                 biosprt(p2);
  33.         else    biosprt(p3);
  34.         biosprt(p4);
  35. }
  36.  
  37. main()
  38. {
  39.         unsigned seg, ofs;
  40.         int ch = 0;
  41.  
  42.         setbuf(stdout, NULL);
  43.         my_cc();
  44.         ins09();
  45.         atexit(undo09);
  46.         puts("New Ints 09h & 1Bh installed...");
  47.         puts("Hit Esc to quit...");
  48.         do
  49.         {
  50.                 if (kbhit())
  51.                 {
  52.                         if (0x1b != (ch = getch()))
  53.                         {
  54.                                 if (0x20 > ch)
  55.                                 {
  56.                                         fputc('^', stdout);
  57.                                         ch += '@';
  58.                                 }
  59.                                 fputc(ch, stdout);
  60.                         }
  61.                 }
  62.                 if (ccrcvd)
  63.                 {
  64.                         my_cc();
  65.                         ccrcvd = 0;
  66.                 }
  67.         } while (0x1b != ch);
  68. }
  69.