home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_02_01 / 2n01058a < prev    next >
Text File  |  1990-12-04  |  2KB  |  79 lines

  1. #include <process.h>
  2. #include <stdio.h>
  3. #include <dos.h>
  4. #include "redirector.h"
  5.  
  6. void interrupt do_nothing();
  7.  
  8. /******************************************************************
  9. *      test_share() - test to see if share is installed
  10. *
  11. *      Parameters
  12. *            flag (in) - set to INSTALL or RESTORE
  13. *
  14. *      Global
  15. *            Turbo C global variables for register values
  16. *
  17. *      Returns:
  18. *            0 for success, -1 for failure
  19. *
  20. *      Notes:
  21. *            This function tests for share.exe.  
  22. *            If share is successfully
  23. *            installed, it disables interrupt 0x23 to prevent
  24. *            abnormal termination (leaving locks in place).  This interrupt
  25. *            is re-enabled by calling this function with the flag set to
  26. *            RESTORE.
  27. *
  28. *      History:
  29. *            Original code by William H. Roetzheim
  30. **********************************************************************/
  31.  
  32. int    test_share(int flag)
  33. {
  34.        void        (*interrupt_function);
  35.        void        interrupt do_nothing();
  36.        static      *old_interrupt;
  37.  
  38.        if (flag == RESTORE)
  39.        {
  40.              if (old_interrupt == NULL) return -1;
  41.              else
  42.              {
  43.                    _AH = 0x25;
  44.                    _AL = 0x23;
  45.                    _DS = FP_SEG(old_interrupt);
  46.                    _DX = FP_OFF(old_interrupt);
  47.                    geninterrupt(0x21);
  48.                    return 0;
  49.              }
  50.        }
  51.  
  52.        _AH = 0x10;              /* test for share */
  53.        _AL = 0x00;              /* get installed state */
  54.        geninterrupt(0x2F);
  55.  
  56.        if (_AL == 0xFF)   /* successfully installed */
  57.        {
  58.              /* get original value for abnormal termination */
  59.              _AH = 0x35;
  60.              _AL = 0x23;
  61.              old_interrupt = MK_FP(_ES, _BX);
  62.  
  63.              /* set new value */
  64.              interrupt_function = do_nothing;
  65.              _AH = 0x25;
  66.              _AL = 0x23;
  67.              _DS = FP_SEG(interrupt_function);
  68.              _DX = FP_OFF(interrupt_function);
  69.              geninterrupt(0x21);
  70.              return 0;
  71.        }
  72.        else return -1;
  73. }
  74.  
  75. void interrupt do_nothing()
  76. {
  77.        return;
  78. }
  79.