home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / hamradio / wattcp.zip / PC_CBRK.C < prev    next >
C/C++ Source or Header  |  1991-11-13  |  985b  |  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. static int handler()
  26. {
  27.     if ( wathndlcbrk ) {
  28.         watcbroke = 1;
  29.         if (cbrkmode & 0x10 ) outs("\n\rInterrupting\n\r");
  30.         return( 1 );
  31.     }
  32.     if (cbrkmode & 0x10 )
  33.     outs( msgs[ cbrkmode & 1 ]);
  34.     if (cbrkmode & 1)
  35.     return( 1 );
  36.     tcp_shutdown();
  37.     return( 0 );
  38. }
  39.  
  40.  
  41. tcp_cbrk( int mode )
  42. {
  43.     cbrkmode = mode;
  44.     ctrlbrk(handler);
  45. }
  46.