home *** CD-ROM | disk | FTP | other *** search
/ Super Net 1 / SUPERNET_1.iso / PC / OTROS / MSDOS / WATTCP / MSWATTCP.ZIP / SRC / PC_CBRK.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-25  |  1.3 KB  |  66 lines

  1. /***
  2.  *
  3.  * File: pc_cbrk.c
  4.  *
  5.  * 19-Jun-92 lr
  6.  *
  7.  */
  8.  
  9. #define WATTCP_KERNEL
  10. #define PC_CBRK
  11. #include <tcp.h>
  12. #include <signal.h>
  13.  
  14. /*************************** STATICS *****************************/
  15. static char *msgs[] = {
  16.     "\n\rTerminating program\n\r",
  17.     "\n\rCtrl-Breaks ignored\n\r" };
  18. static int cbrkmode = 0;
  19.  
  20. static void handler(int sig);
  21.  
  22. /************************ END OF STATICS *************************/
  23.  
  24. /*
  25.  * tcp_cbreak( mode )
  26.  *     - mode is composed of the following flags
  27.  *       0x01 - disallow breakouts
  28.  *       0x10 - display a message upon Cbreak
  29.  *
  30.  * 18-mar-92 gm modified and now running with Microsoft C 6.00
  31.  */
  32.  
  33. static void
  34. handler(int sig)
  35. {
  36.     signal(SIGINT,SIG_IGN); /* disable interrupt signals */
  37. #ifdef oldversion
  38.     if ( wathndlcbrk ) {
  39.             watcbroke = 1;
  40.             if (cbrkmode & 0x10 ) outs("\n\rInterrupting\n\r");
  41.         signal(SIGINT,handler); /* reenable handler*/
  42.             return;
  43.     }
  44. #endif
  45.     if (cbrkmode & 0x10 ) { 
  46.         outs( msgs[0]);
  47.         tcp_shutdown();  
  48.         signal(SIGINT,SIG_DFL); /* reenable default handler*/
  49.         return;
  50.     }
  51.     signal(SIGINT,handler); /* reenable handler*/
  52. }
  53.  
  54. void
  55. tcp_cbrk( int mode )
  56. {
  57.     cbrkmode = mode;
  58.  
  59.     if(cbrkmode & 0x01) {
  60.         signal(SIGINT,SIG_IGN); /* ctrlbrk(ignored); */
  61.         outs( msgs[1]);
  62.         return;
  63.     }
  64.     signal(SIGINT,handler); /* ctrlbrk(handler); */
  65. }
  66.