home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c005 / 4.ddi / C / QYCTLBRK.C < prev    next >
Encoding:
C/C++ Source or Header  |  1986-08-05  |  1.6 KB  |  57 lines

  1. /**
  2. *
  3. * Name        qyctlbrk -- Set or return state of CTRL-BREAK checking.
  4. *
  5. * Synopsis    old_state = qyctlbrk(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    This function returns the state of DOS CTRL-BREAK
  18. *        checking 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 a DOS function is called.
  25. *
  26. * Returns    old_state      The previous CTRL-BREAK state:
  27. *                  CBRK_ON  (1) if checking is enabled,
  28. *                  CBRK_OFF (0) if not.
  29. *
  30. * Version    3.0  (C)Copyright Blaise Computing Inc.  1983, 1984, 1986
  31. *
  32. **/
  33.  
  34. #include <bquery.h>
  35.  
  36. int qyctlbrk(set,new_state)
  37. int set,new_state;
  38. {
  39.     DOSREG dos_reg;
  40.     int    old_state;
  41.  
  42.     dos_reg.ax = 0x3300;          /* DOS function 0x33, return    */
  43.                       /* CTRL-BREAK state.          */
  44.     dos(&dos_reg);
  45.     old_state = utlobyte(dos_reg.dx);
  46.  
  47.     if (set != CBRK_GET)
  48.     {
  49.     dos_reg.ax = 0x3301;          /* DOS function 0x33, set       */
  50.                       /* CTRL-BREAK state.          */
  51.     dos_reg.dx = new_state;
  52.     dos(&dos_reg);
  53.     }
  54.  
  55.     return(old_state);
  56. }
  57.