home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / viscobv6.zip / vac22os2 / ibmcobol / samples / toolkit / mm / mcdtemp / mcdclose.c next >
C/C++ Source or Header  |  1996-11-19  |  7KB  |  127 lines

  1. /****************************************************************************/
  2. /*                                                                          */
  3. /* SOURCE FILE NAME:  MCDCLOSE.C                                            */
  4. /*                                                                          */
  5. /* DESCRIPTIVE NAME:  MCI_CLOSE MESSAGE HANDLER                             */
  6. /*                                                                          */
  7. /* COPYRIGHT:  (c) IBM Corp. 1991 - 1993                                    */
  8. /*                                                                          */
  9. /* FUNCTION:  This file contains routines to handle the mci_close message.  */
  10. /*            the device is instance is closed and all resources associated */
  11. /*            with the device instance are freed.                           */
  12. /*            See the programming reference and programming examples for    */
  13. /*            more details on the MCI_CLOSE message.                        */
  14. /*                                                                          */
  15. /* ENTRY POINTS:                                                            */
  16. /*       MCIClose() - MCI_CLOSE message handler                             */
  17. /*       MCICloseErr() - Error handler for MCI_CLOSE message                */
  18. /****************************************************************************/
  19. #define INCL_BASE                    // Base OS2 functions
  20. #define INCL_DOSSEMAPHORES           // OS2 Semaphore function
  21. #define INCL_MCIOS2                  // use the OS/2 like MMPM/2 headers
  22.  
  23. #include <os2.h>                     // OS2 defines.
  24. #include <string.h>                  // C string functions
  25. #include <os2me.h>                   // MME includes files.
  26. #include <stdlib.h>                  // Math functions
  27. #include "mcdtemp.h"                 // Function Prototypes.
  28.  
  29.  
  30. /****************************************************************************/
  31. /*                                                                          */
  32. /* SUBROUTINE NAME:  MCIClose                                               */
  33. /*                                                                          */
  34. /* DESCRIPTIVE NAME:  Close an instance.                                    */
  35. /*                                                                          */
  36. /* FUNCTION:  Close and free the given instance.                            */
  37. /*                                                                          */
  38. /* PARAMETERS:                                                              */
  39. /*      FUNCTION_PARM_BLOCK *pFuncBlock - Pointer to call function block    */
  40. /*                                                                          */
  41. /* EXIT CODES:                                                              */
  42. /*      MCIERR_SUCCESS    -- Action completed without error.                */
  43. /*            .                                                             */
  44. /*            .                                                             */
  45. /*            .                                                             */
  46. /*            .                                                             */
  47. /*                                                                          */
  48. /****************************************************************************/
  49. RC MCIClose (FUNCTION_PARM_BLOCK *pFuncBlock)
  50. {
  51.   ULONG                ulrc = MCIERR_SUCCESS;    // Propogated Error Code
  52.   ULONG                ulParam1;                 // Message flags
  53.   PMCI_GENERIC_PARMS   pCloseParms;              // Pointer to GENERIC structure
  54.   PINSTANCE            pInstance;                // Pointer to instance
  55.  
  56.   /*****************************************************/
  57.   /* dereference the values from pFuncBlock            */
  58.   /*****************************************************/
  59.   ulParam1       = pFuncBlock->ulParam1;
  60.   pInstance      = pFuncBlock->pInstance;
  61.   pCloseParms    = (PMCI_GENERIC_PARMS)pFuncBlock->pParam2;
  62.  
  63.  
  64.   /*****************************************************/
  65.   /* NOTE ----->>>                                     */
  66.   /*  This is the basic function that should be        */
  67.   /*  performed.  See the other samples in the toolkit */
  68.   /*  for streaming and MMIO considerations            */
  69.   /*****************************************************/
  70.   DosRequestMutexSem (pInstance->hmtxAccessSem, -2);  // wait for semaphore
  71.   free(pInstance);
  72.   DosReleaseMutexSem (pInstance->hmtxAccessSem);      // release semaphore
  73.  
  74.   /***************************************************************/
  75.   /* Send back a notification if the notify flag was on          */
  76.   /***************************************************************/
  77.   if (ulParam1 & MCI_NOTIFY)
  78.      ulrc = mdmDriverNotify (pInstance->usDeviceID,
  79.                              pCloseParms->hwndCallback,
  80.                              MM_MCINOTIFY,
  81.                              pFuncBlock->usUserParm,
  82.                              MAKEULONG (MCI_CLOSE, MCI_NOTIFY_SUCCESSFUL));
  83.  
  84.  
  85.   return (ulrc);
  86.  
  87. }      /* end of MCIClose */
  88.  
  89.  
  90. /****************************************************************************/
  91. /*                                                                          */
  92. /* SUBROUTINE NAME:  MCICloseErr                                            */
  93. /*                                                                          */
  94. /* DESCRIPTIVE NAME:  Error handler for MCI_CLOSE message.                  */
  95. /*                                                                          */
  96. /* FUNCTION:  Process the close message for errors                          */
  97. /*                                                                          */
  98. /* PARAMETERS:                                                              */
  99. /*      FUNCTION_PARM_BLOCK *pFuncBlock - Pointer to call function block    */
  100. /*                                                                          */
  101. /* EXIT CODES:                                                              */
  102. /*      MCIERR_SUCCESS    -- Action completed without error.                */
  103. /*            .                                                             */
  104. /*            .                                                             */
  105. /*            .                                                             */
  106. /*            .                                                             */
  107. /*                                                                          */
  108. /****************************************************************************/
  109. RC MCICloseErr (FUNCTION_PARM_BLOCK *pFuncBlock)
  110. {
  111.   ULONG                ulrc = MCIERR_SUCCESS;    // Propogated Error Code
  112.   ULONG                ulParam1;                 // Message flags
  113.   PMCI_GENERIC_PARMS   pCloseParms;              // Pointer to GENERIC structure
  114.   PINSTANCE            pInstance;                // Pointer to instance
  115.  
  116.   /*****************************************************/
  117.   /* dereference the values from pFuncBlock            */
  118.   /*****************************************************/
  119.   ulParam1       = pFuncBlock->ulParam1;
  120.   pInstance      = pFuncBlock->pInstance;
  121.   pCloseParms    = (PMCI_GENERIC_PARMS)pFuncBlock->pParam2;
  122.  
  123.  
  124.   return (ulrc);
  125.  
  126. }      /* end of MCICloseErr */
  127.