home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / c / mscwattc / src / pc_cbrk.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-13  |  1.2 KB  |  59 lines

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