home *** CD-ROM | disk | FTP | other *** search
/ ftp.wwiv.com / ftp.wwiv.com.zip / ftp.wwiv.com / pub / CEREBRUM / WAT9609.ZIP / SRC / PC_CBRK.C < prev    next >
Text File  |  1994-11-28  |  997b  |  46 lines

  1. #include <copyright.h>
  2. #include <wattcp.h>
  3. #include <dos.h>
  4.  
  5.  
  6. word wathndlcbrk = 0;    /* changes operation of the
  7.                          * break stuff if in resolve
  8.                          * or something
  9.                          */
  10. word watcbroke = 0;      /* set to non-zero if wathndlcbrk happenned */
  11.  
  12. /*
  13.  * tcp_cbreak( mode )
  14.  *     - mode is composed of the following flags
  15.  *       0x01 - disallow breakouts
  16.  *       0x10 - display a message upon Cbreak
  17.  *
  18.  */
  19.  
  20. static char *msgs[] = {
  21.     "\n\rTerminating program\n\r",
  22.     "\n\rCtrl-Breaks ignored\n\r" };
  23.  
  24. static cbrkmode = 0;
  25.  
  26. static int handler( void )
  27. {
  28.     if ( wathndlcbrk ) {
  29.         watcbroke = 1;
  30.         if (cbrkmode & 0x10 ) outs("\n\rInterrupting\n\r");
  31.         return( 1 );
  32.     }
  33.     if (cbrkmode & 0x10 )
  34.     outs( msgs[ cbrkmode & 1 ]);
  35.     if (cbrkmode & 1)
  36.     return( 1 );
  37.     tcp_shutdown();
  38.     return( 0 );
  39. }
  40.  
  41. void tcp_cbrk( int mode )
  42. {
  43.     cbrkmode = mode;
  44.     ctrlbrk(handler);
  45. }
  46.