home *** CD-ROM | disk | FTP | other *** search
/ Super Net 1 / SUPERNET_1.iso / PC / OTROS / MSDOS / WATTCP / WNWATTCP.ZIP / SRC / PC_CBRK.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-20  |  1021 b   |  50 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. static int handler()
  26. {
  27.     if ( wathndlcbrk ) {
  28.     watcbroke = 1;
  29. #ifndef WINDOWS
  30.     if (cbrkmode & 0x10 ) outs("\n\rInterrupting\n\r");
  31. #endif
  32.         return( 1 );
  33.     }
  34. #ifndef WINDOWS
  35.     if (cbrkmode & 0x10 )
  36.     outs( msgs[ cbrkmode & 1 ]);
  37. #endif
  38.     if (cbrkmode & 1)
  39.     return( 1 );
  40.     tcp_shutdown();
  41.     return( 0 );
  42. }
  43.  
  44.  
  45. tcp_cbrk( int mode )
  46. {
  47.     cbrkmode = mode;
  48.     ctrlbrk(handler);
  49. }
  50.