home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_06_02 / v6n2012a.txt < prev    next >
Text File  |  1989-09-28  |  2KB  |  66 lines

  1.  
  2. /*  CNTRL_C.C ** Control-C handler within the  program.  
  3.       -- R.D. Allen, 11/12/87
  4. */
  5. #include  <stdio.h>
  6. #include  <stdlib.h>
  7. #include  <dos.h>
  8.  
  9. #include  <wfc.h>
  10.  
  11. #include  "pt.h"
  12.  
  13. int Dev_hndl;
  14.  
  15. /********
  16. *   Name:      CNTRL_C
  17. *    Use:      Handled the control-C problem with MS-DOS. Each time
  18.                this function is called it tells the driver to send
  19.                a control-C character.   This function should be passed 
  20.                to the CTRLBRK function in the TURBO.C library.
  21. *   Input:     void         
  22. *  Output:     returns 0 only if Dev_hndl is zero.
  23. ********/
  24.  
  25. int cntrl_c(void)
  26. {
  27.      if(Dev_hndl)  {
  28.  
  29.             /*  Go  to the trouble of eating  the  ^C displayed */
  30.           _AH = 3;
  31.           _BH = 0;
  32.           geninterrupt(0x10);
  33.           _AH = 2;
  34.           _DH -= 1;
  35.           geninterrupt(0x10);
  36.           _AX = 0xa20;
  37.           _CX = 2;
  38.           geninterrupt (0x10);
  39.           _AH = 2;
  40.           _BH = 0;
  41.           _DX = 0;
  42.           geninterrupt(0x10);
  43.  
  44.           computc(Dev_hndl,  3);
  45.  
  46.             /*  Pass  the  control-c  to  the driver   */
  47.      }
  48.      return(Dev_hndl);
  49. }    
  50.  
  51. /********
  52. *   Name:  FH_SAVE
  53. *    Use:  File handle save. This function saves the file handle for 
  54. *         of the device driver.  This makes it accessible to  
  55. CNTRL_C 
  56. *          handler.
  57. *  Input:  int fh;  -- File Handle of device driver
  58. * Output:  void
  59. ********/
  60.  
  61. void fh_save(int fh)
  62. {
  63.      Dev hndl = fh;
  64.  
  65.