home *** CD-ROM | disk | FTP | other *** search
/ Collection of Internet / Collection of Internet.iso / msdos / lynx / source / wattcp / src / pc_cbrk.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-25  |  1.2 KB  |  62 lines

  1. #ifdef WWW
  2. #include"capalloc.h"
  3. #include"capstdio.h"
  4. #include"msdostcp.h"
  5. #include<dos.h>
  6. #else
  7. #include <copyright.h>
  8. #include <wattcp.h>
  9. #include <dos.h>
  10. #endif /* WWW */
  11.  
  12.  
  13. word wathndlcbrk = 0;    /* changes operation of the
  14.                          * break stuff if in resolve
  15.                          * or something
  16.                          */
  17. word watcbroke = 0;      /* set to non-zero if wathndlcbrk happenned */
  18.  
  19. /*
  20.  * tcp_cbreak( mode )
  21.  *     - mode is composed of the following flags
  22.  *       0x01 - disallow breakouts
  23.  *       0x10 - display a message upon Cbreak
  24.  *
  25.  */
  26.  
  27. static char *msgs[] = {
  28.     "\nTerminating program\n",
  29.     "\nCtrl-Breaks ignored\n" };
  30.  
  31. static cbrkmode = 0;
  32. static int handler()
  33. {
  34. #ifndef WWW
  35.     if ( wathndlcbrk ) {
  36.     watcbroke = 1;
  37.     if (cbrkmode & 0x10 ) outs("\nInterrupting\n");
  38.     return( 1 );
  39.     }
  40.     if (cbrkmode & 0x10 )
  41.     outs( msgs[ cbrkmode & 1 ]);
  42.     if (cbrkmode & 1)
  43.     return( 1 );
  44.     tcp_shutdown();
  45.     return( 0 );
  46. #else
  47.     /*
  48.      *    No matter what, keep the application running.
  49.      */
  50.     if(wathndlcbrk)
  51.         watcbroke = 1;
  52.     return(1);
  53. #endif /* WWW */
  54. }
  55.  
  56.  
  57. tcp_cbrk( int mode )
  58. {
  59.     cbrkmode = mode;
  60.     ctrlbrk(handler);
  61. }
  62.