home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c070 / 4.ddi / TOOLS.4 / TCTSRC1.EXE / UTCTLBRK.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-31  |  1.7 KB  |  61 lines

  1. /**
  2. *
  3. * Name        utctlbrk -- Set or return state of CTRL-BREAK checking.
  4. *
  5. * Synopsis    old_state = utctlbrk(set,new_state);
  6. *
  7. *        int old_state      The previous CTRL-BREAK state:
  8. *                  CBRK_ON  (1) if checking is enabled,
  9. *                  CBRK_OFF (0) if not.
  10. *        int set       CBRK_SET (1) to set the state,
  11. *                  CBRK_GET (0) to return it.
  12. *        int new_state      If "set" is nonzero, this is the new
  13. *                  CTRL-BREAK state:
  14. *                  CBRK_ON  (1) to enable checking,
  15. *                  CBRK_OFF (0) to disable it.
  16. *
  17. * Description    UTCTLBRK returns the state of DOS CTRL-BREAK checking
  18. *        and optionally sets that state.
  19. *
  20. *        If the state is "off" (i.e., checking is disabled), then
  21. *        DOS will check for a CTRL-BREAK only when I/O is
  22. *        performed to the standard input, output, print, or
  23. *        auxiliary devices.  If the state is "on", then DOS will
  24. *        check for CTRL-BREAK whenever most DOS functions are
  25. *        called.  (DOS does not check for CTRL-BREAK during the
  26. *        operation of UTCTLBRK.)
  27. *
  28. * Returns    old_state      The previous CTRL-BREAK state:
  29. *                  CBRK_ON  (1) if checking is enabled,
  30. *                  CBRK_OFF (0) if not.
  31. *
  32. * Version    6.00 (C)Copyright Blaise Computing Inc.  1983,1987,1989
  33. *
  34. **/
  35.  
  36. #include <dos.h>
  37.  
  38. #include <butil.h>
  39.  
  40. int utctlbrk(set,new_state)
  41. int set,new_state;
  42. {
  43.     union REGS regs;
  44.     int        old_state;
  45.  
  46.     regs.x.ax = 0x3300;           /* DOS function 0x33, return    */
  47.                       /* CTRL-BREAK state.          */
  48.     intdos(®s,®s);
  49.     old_state = regs.h.dl;
  50.  
  51.     if (set != CBRK_GET && new_state != old_state)
  52.     {
  53.     regs.h.al = 0x01;          /* DOS function 0x33, set       */
  54.                       /* CTRL-BREAK state.          */
  55.     regs.h.dl = (unsigned char) new_state;
  56.     intdos(®s,®s);
  57.     }
  58.  
  59.     return(old_state);
  60. }
  61.