home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v6.zip / MMPM2TK / TK / MCDTEMP / MCDINFO.C < prev    next >
C/C++ Source or Header  |  1993-03-22  |  8KB  |  155 lines

  1. /****************************************************************************/
  2. /*                                                                          */
  3. /* SOURCE FILE NAME:  MCDINFO.C                                             */
  4. /*                                                                          */
  5. /* DESCRIPTIVE NAME:  MCI_INFO MESSAGE HANDLER                              */
  6. /*                                                                          */
  7. /* COPYRIGHT:  (c) IBM Corp. 1991 - 1993                                    */
  8. /*                                                                          */
  9. /* FUNCTION:  This file contains routines to handle the mci_info message.   */
  10. /*            The two items shown here are infor file name and info product */
  11. /*            See the programming reference for details of the info message.*/
  12. /*                                                                          */
  13. /* ENTRY POINTS:                                                            */
  14. /*       MCIInfo() - MCI_INFO message handler                               */
  15. /*       MCIInfoErr() - Error handler for MCI_INFO message                  */
  16. /****************************************************************************/
  17. #define INCL_BASE                    // Base OS2 functions
  18. #define INCL_DOSSEMAPHORES           // OS2 Semaphore function
  19. #define INCL_MCIOS2                  // use the OS/2 like MMPM/2 headers
  20.  
  21. #include <os2.h>                     // OS2 defines.
  22. #include <string.h>                  // C string functions
  23. #include <os2me.h>                   // MME includes files.
  24. #include <stdlib.h>                  // Math functions
  25. #include "mcdtemp.h"                 // Function Prototypes.
  26.  
  27. /****************************************************************************/
  28. /*                                                                          */
  29. /* SUBROUTINE NAME:  MCIInfo                                                */
  30. /*                                                                          */
  31. /* DESCRIPTIVE NAME:  MCI_INFO message processor                            */
  32. /*                                                                          */
  33. /* FUNCTION:  Process the MCI_INFO message.                                 */
  34. /*                                                                          */
  35. /* PARAMETERS:                                                              */
  36. /*      FUNCTION_PARM_BLOCK  *pFuncBlock -- Pointer to function parameter   */
  37. /*                                          block.                          */
  38. /* EXIT CODES:                                                              */
  39. /*      MCIERR_SUCCESS    -- Action completed without error.                */
  40. /*            .                                                             */
  41. /*            .                                                             */
  42. /*            .                                                             */
  43. /*            .                                                             */
  44. /*                                                                          */
  45. /****************************************************************************/
  46. RC MCIInfo   (FUNCTION_PARM_BLOCK *pFuncBlock)
  47. {
  48.   ULONG                ulrc = MCIERR_SUCCESS;    // Propogated Error Code
  49.   ULONG                ulParam1;                 // Message flags
  50.   PMCI_INFO_PARMS      pInfoParms;               // Pointer to info structure
  51.   PINSTANCE            pInstance;                // Pointer to instance
  52.  
  53.   /*****************************************************/
  54.   /* dereference the values from pFuncBlock            */
  55.   /*****************************************************/
  56.   ulParam1       = pFuncBlock->ulParam1;
  57.   pInstance      = pFuncBlock->pInstance;
  58.   pInfoParms     = (PMCI_INFO_PARMS)pFuncBlock->pParam2;
  59.  
  60.  
  61.   /**********************************************************/
  62.   /* Lock access to this instance until this command is done*/
  63.   /**********************************************************/
  64.   DosRequestMutexSem (pInstance->hmtxAccessSem, -2);  // wait for semaphore
  65.  
  66.   switch (ulParam1 & MCD_INFO_FLAGS)
  67.     {
  68.     /**********************************************************/
  69.     /* Return a description of the hardware this device       */
  70.     /*   represents                                           */
  71.     /**********************************************************/
  72.     case MCI_INFO_PRODUCT:
  73.      if (pInfoParms->ulRetSize < MAX_PRODINFO)
  74.         strncpy(pInfoParms->pszReturn, pInstance->szProductInfo, pInfoParms->ulRetSize);
  75.      else
  76.         strncpy(pInfoParms->pszReturn, pInstance->szProductInfo, MAX_PRODINFO);
  77.      break;
  78.  
  79.     /**********************************************************/
  80.     /* Return the file name associated with this device       */
  81.     /*   instance                                             */
  82.     /**********************************************************/
  83.     case MCI_INFO_FILE:
  84.      if (pInfoParms->ulRetSize < MAX_FILE_NAME)
  85.         strncpy(pInfoParms->pszReturn, pInstance->szFileName, pInfoParms->ulRetSize);
  86.      else
  87.         strncpy(pInfoParms->pszReturn, pInstance->szFileName, MAX_FILE_NAME);
  88.      break;
  89.  
  90.     default:
  91.       ulrc = MCIERR_UNSUPPORTED_FLAG;
  92.       break;
  93.  
  94.  
  95.     }   /* Switch */
  96.  
  97.   DosReleaseMutexSem (pInstance->hmtxAccessSem);      // release semaphore
  98.  
  99.   /***************************************************************/
  100.   /* Send back a notification if the notify flag was on          */
  101.   /*   and no error                                              */
  102.   /***************************************************************/
  103.   if ((ulParam1 & MCI_NOTIFY) & (!ulrc))
  104.      mdmDriverNotify (pInstance->usDeviceID,
  105.                       pInfoParms->hwndCallback,
  106.                       MM_MCINOTIFY,
  107.                       pFuncBlock->usUserParm,
  108.                       MAKEULONG (MCI_INFO, MCI_NOTIFY_SUCCESSFUL));
  109.  
  110.  
  111.   return (ulrc);
  112.  
  113. }      /* end of MCIInfo */
  114.  
  115.  
  116. /****************************************************************************/
  117. /*                                                                          */
  118. /* SUBROUTINE NAME:  MCIInfoErr                                             */
  119. /*                                                                          */
  120. /* DESCRIPTIVE NAME:  MCI_INFO message error processor                      */
  121. /*                                                                          */
  122. /* FUNCTION:  Process the MCI_INFO message for errors.                      */
  123. /*                                                                          */
  124. /* PARAMETERS:                                                              */
  125. /*      FUNCTION_PARM_BLOCK  *pFuncBlock -- Pointer to function parameter   */
  126. /*                                          block.                          */
  127. /* EXIT CODES:                                                              */
  128. /*      MCIERR_SUCCESS    -- Action completed without error.                */
  129. /*            .                                                             */
  130. /*            .                                                             */
  131. /*            .                                                             */
  132. /*            .                                                             */
  133. /*                                                                          */
  134. /****************************************************************************/
  135. RC MCIInfoErr (FUNCTION_PARM_BLOCK *pFuncBlock)
  136. {
  137.   ULONG                ulrc = MCIERR_SUCCESS;    // Propogated Error Code
  138.   ULONG                ulParam1;                 // Message flags
  139.   PMCI_INFO_PARMS      pInfoParms;               // Pointer to info structure
  140.   PINSTANCE            pInstance;                // Pointer to instance
  141.  
  142.   /*****************************************************/
  143.   /* dereference the values from pFuncBlock            */
  144.   /*****************************************************/
  145.   ulParam1       = pFuncBlock->ulParam1;
  146.   pInstance      = pFuncBlock->pInstance;
  147.   pInfoParms     = (PMCI_INFO_PARMS)pFuncBlock->pParam2;
  148.  
  149.  
  150.   return (ulrc);
  151.  
  152. }      /* end of MCIInfoErr */
  153.  
  154.  
  155.