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

  1. /**
  2. *
  3. * Name        ivdisabl -- Disable an installed intervention function.
  4. *
  5. * Synopsis    ercode = ivdisabl(pctrl);
  6. *
  7. *        int ercode      Error code.  Possible values include:
  8. *                  0 if successful,
  9. *                  IV_NULL_PTR if pctrl is FARNIL,
  10. *                  IV_NOT_ENABLED if not enabled,
  11. *                  IV_NOT_INSTALLED if the intervention
  12. *                   filters are not currently installed in
  13. *                   the proper interrupt vectors or if
  14. *                   pctrl is not the address of a valid
  15. *                   intervention control block.
  16. *        IV_CTRL far *pctrl
  17. *                  Double word address of the intervention
  18. *                  control block to disable.
  19. *
  20. * Description    This function disables an installed intervention
  21. *        function by reinstalling the former values of the
  22. *        interrupt vectors that point to the intervention
  23. *        filters.
  24. *
  25. *        It will fail if pctrl is not a valid pointer to an
  26. *        installed intervention control block or if the interrupt
  27. *        vectors do not currently point to the associated
  28. *        intervention filters.
  29. *
  30. *        b_ivmask (the bit mask of employed intervention filters)
  31. *        lists the vectors that will be examined for the presence
  32. *        of the intervention function and that will be restored
  33. *        to their previous values.  (However, if the intervention
  34. *        function was installed using fewer filters, no unused
  35. *        vectors will be restored.
  36. *
  37. * Returns    ercode          Error code.  Possible values include:
  38. *                  0 if successful,
  39. *                  IV_NULL_PTR if pctrl is FARNIL,
  40. *                  IV_NOT_ENABLED if not enabled,
  41. *                  IV_NOT_INSTALLED if the intervention
  42. *                   filters are not currently installed in
  43. *                   the proper interrupt vectors or if
  44. *                   pctrl is not the address of a valid
  45. *                   intervention control block.
  46. *
  47. * Version    6.00 (C)Copyright Blaise Computing Inc. 1987,1989
  48. *
  49. **/
  50.  
  51. #include <dos.h>
  52. #include <string.h>
  53.  
  54. #include <binterv.h>
  55. #include <butil.h>
  56.  
  57. #define  OK           0          /* Error codes.              */
  58. #define  IV_NOT_ENABLED    1
  59. #define  IV_NOT_INSTALLED  2
  60. #define  IV_NULL_POINTER   3
  61.  
  62. int ivdisabl(pctrl)
  63. IV_CTRL far *pctrl;
  64. {
  65.     IV_VECTORS vecs;
  66.     unsigned   save_mask;
  67.  
  68.     if (FARNIL == pctrl)
  69.     return IV_NULL_POINTER;
  70.  
  71.     if (!pctrl->enabled)
  72.     return IV_NOT_ENABLED;
  73.  
  74.     ivvecs(IV_RETVEC,&vecs);          /* Check current vectors to be  */
  75.                       /* sure that the intervention   */
  76.                       /* function is installed.       */
  77.     if (pctrl != ivsense(&vecs,pctrl->ident))
  78.     return IV_NOT_INSTALLED;
  79.  
  80.     pctrl->enabled = 0;
  81.  
  82.     save_mask  = b_ivmask;        /* Save b_ivmask.          */
  83.     b_ivmask  &= pctrl->filter_mask;    /* Restore no more vectors    */
  84.                     /*  than were installed.      */
  85.     ivvecs(IV_SETVEC,&pctrl->prev_vec); /* Restore the vectors.       */
  86.     b_ivmask   = save_mask;        /* Restore b_ivmask.          */
  87.  
  88.     return IV_NO_ERROR;
  89. }
  90.