home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tolkit45.zip / os2tk45 / samples / mm / mcdtemp / mcdstat.c < prev    next >
C/C++ Source or Header  |  1999-05-11  |  9KB  |  185 lines

  1. /****************************************************************************/
  2. /*                                                                          */
  3. /* SOURCE FILE NAME:  MCISTAT.C                                             */
  4. /*                                                                          */
  5. /* DESCRIPTIVE NAME:  MCI_STATUS MESSAGE HANDLER                            */
  6. /*                                                                          */
  7. /* COPYRIGHT:  (c) IBM Corp. 1991 - 1993                                    */
  8. /*                                                                          */
  9. /* FUNCTION:  This file contains routines to process the MCI_STATUS message.*/
  10. /*            Returns information on the status of this device instance.    */
  11. /*            See the programming reference for a complete list of status   */
  12. /*            items.                                                        */
  13. /*                                                                          */
  14. /* ENTRY POINTS:                                                            */
  15. /*       MCIStatus - Process the mci_status message and return status       */
  16. /*       MCIStatusErr - Process the mci_status message for errors           */
  17. /****************************************************************************/
  18. #define INCL_BASE
  19. #define INCL_DOSSEMAPHORES
  20.  
  21.  
  22. #define INCL_MCIOS2                  // use the OS/2 like MMPM/2 headers
  23.  
  24. #include <os2.h>                     // OS2 defines.
  25. #include <string.h>                  // string prototypes
  26. #include <stdlib.h>                  // standard C functions
  27. #include <os2me.h>                   // MME includes files.
  28. #include "mcdtemp.h"                 // MCD Function Prototypes and typedefs
  29.  
  30. /****************************************************************************/
  31. /*                                                                          */
  32. /* SUBROUTINE NAME:  MCIStatus                                              */
  33. /*                                                                          */
  34. /* DESCRIPTIVE NAME:  MCI_STATUS message processor                          */
  35. /*                                                                          */
  36. /* FUNCTION:  Process the MCI_STATUS message.                               */
  37. /*                                                                          */
  38. /* PARAMETERS:                                                              */
  39. /*      FUNCTION_PARM_BLOCK  *pFuncBlock -- Pointer to function parameter   */
  40. /*                                          block.                          */
  41. /* EXIT CODES:                                                              */
  42. /*      MCIERR_SUCCESS    -- Action completed without error.                */
  43. /*            .                                                             */
  44. /*            .                                                             */
  45. /*            .                                                             */
  46. /*            .                                                             */
  47. /*                                                                          */
  48. /****************************************************************************/
  49. RC MCIStatus (FUNCTION_PARM_BLOCK *pFuncBlock)
  50. {
  51.   ULONG                ulrc = MCIERR_SUCCESS;    // Propogated Error Code
  52.   ULONG                ulParam1;                 // Message flags
  53.   PMCI_STATUS_PARMS    pStatusParms;             // Pointer to status structure
  54.   PINSTANCE            pInstance;                // Pointer to instance
  55.   MMTIME               mmTime;                   // Current time in MMTIME format
  56.  
  57.   /*****************************************************/
  58.   /* dereference the values from pFuncBlock            */
  59.   /*****************************************************/
  60.   ulParam1       = pFuncBlock->ulParam1;
  61.   pInstance      = pFuncBlock->pInstance;
  62.   pStatusParms   = (PMCI_STATUS_PARMS)pFuncBlock->pParam2;
  63.  
  64.  
  65.   /**********************************************************/
  66.   /* Lock access to this instance until this command is done*/
  67.   /**********************************************************/
  68.   DosRequestMutexSem (pInstance->hmtxAccessSem, -2);  // wait for semaphore
  69.   switch (pStatusParms->ulItem)
  70.     {
  71.  
  72.     case MCI_STATUS_TIME_FORMAT:
  73.      ULONG_HIWD(ulrc) = MCI_TIME_FORMAT_RETURN;
  74.      pStatusParms->ulReturn = pInstance->ulTimeFormat;
  75.      break;
  76.  
  77.     case MCI_STATUS_SPEED_FORMAT:
  78.      ULONG_HIWD(ulrc) = MCI_SPEED_FORMAT_RETURN;
  79.      pStatusParms->ulReturn = pInstance->ulSpeedFormat;
  80.      break;
  81.  
  82.     case MCI_STATUS_MODE:
  83.      ULONG_HIWD(ulrc) = MCI_MODE_RETURN;
  84.      if (pInstance->Active == TRUE)
  85.         pStatusParms->ulReturn = pInstance->ulMode;
  86.      else
  87.         pStatusParms->ulReturn = MCI_MODE_NOT_READY;
  88.      break;
  89.  
  90.     case MCI_STATUS_VOLUME:
  91.      ULONG_HIWD(ulrc) = MCI_INTEGER_RETURNED;
  92.      pStatusParms->ulReturn = pInstance->ulVolume;
  93.      break;
  94.  
  95.     case MCI_STATUS_LENGTH:
  96.      ULONG_HIWD(ulrc) = MCI_INTEGER_RETURNED;
  97.      mmTime = pInstance->ulEndPosition - pInstance->ulStartPosition;
  98.      pStatusParms->ulReturn = ConvertTime(mmTime, MCI_FORMAT_MMTIME, pInstance->ulTimeFormat);
  99.      break;
  100.  
  101.     case MCI_STATUS_READY:
  102.      ULONG_HIWD(ulrc) = MCI_TRUE_FALSE_RETURN;
  103.      if (pInstance->Active == TRUE)
  104.         {
  105.         if (pInstance->ulMode == MCI_MODE_NOT_READY)
  106.            pStatusParms->ulReturn = MCI_FALSE;
  107.         else
  108.            pStatusParms->ulReturn = MCI_TRUE;
  109.         }
  110.      else
  111.         pStatusParms->ulReturn = MCI_FALSE;
  112.      break;
  113.  
  114.     case MCI_STATUS_POSITION:
  115.      ULONG_HIWD(ulrc) = MCI_INTEGER_RETURNED;
  116.      pStatusParms->ulReturn = pInstance->ulCurrentPosition;       // need to convert from MMTIME
  117.      pStatusParms->ulReturn =
  118.          ConvertTime(pInstance->ulCurrentPosition, MCI_FORMAT_MMTIME, pInstance->ulTimeFormat);
  119.      break;
  120.  
  121.     default:
  122.       ulrc = MCIERR_UNSUPPORTED_FLAG;
  123.       break;
  124.  
  125.  
  126.     }   /* Switch */
  127.  
  128.  
  129.   DosReleaseMutexSem (pInstance->hmtxAccessSem);      // release semaphore
  130.  
  131.   /***************************************************************/
  132.   /* Send back a notification if the notify flag was on          */
  133.   /***************************************************************/
  134.   if ((ulParam1 & MCI_NOTIFY) & (!ulrc))
  135.      mdmDriverNotify (pInstance->usDeviceID,
  136.                       pStatusParms->hwndCallback,
  137.                       MM_MCINOTIFY,
  138.                       pFuncBlock->usUserParm,
  139.                       MAKEULONG (MCI_STATUS, MCI_NOTIFY_SUCCESSFUL));
  140.  
  141.  
  142.   return (ulrc);
  143.  
  144. }      /* end of MCIStatus */
  145.  
  146.  
  147. /****************************************************************************/
  148. /*                                                                          */
  149. /* SUBROUTINE NAME:  MCIStatusErr                                           */
  150. /*                                                                          */
  151. /* DESCRIPTIVE NAME:  MCI_STATUS message processor for errors               */
  152. /*                                                                          */
  153. /* FUNCTION:  Process the MCI_STATUS message for errors                     */
  154. /*                                                                          */
  155. /* PARAMETERS:                                                              */
  156. /*      FUNCTION_PARM_BLOCK  *pFuncBlock -- Pointer to function parameter   */
  157. /*                                          block.                          */
  158. /* EXIT CODES:                                                              */
  159. /*      MCIERR_SUCCESS    -- Action completed without error.                */
  160. /*            .                                                             */
  161. /*            .                                                             */
  162. /*            .                                                             */
  163. /*            .                                                             */
  164. /*                                                                          */
  165. /****************************************************************************/
  166. RC MCIStatusErr (FUNCTION_PARM_BLOCK *pFuncBlock)
  167. {
  168.   ULONG                ulrc = MCIERR_SUCCESS;    // Propogated Error Code
  169.   ULONG                ulParam1;                 // Message flags
  170.   PMCI_STATUS_PARMS    pStatusParms;             // Pointer to status structure
  171.   PINSTANCE            pInstance;                // Pointer to instance
  172.  
  173.   /*****************************************************/
  174.   /* dereference the values from pFuncBlock            */
  175.   /*****************************************************/
  176.   ulParam1       = pFuncBlock->ulParam1;
  177.   pInstance      = pFuncBlock->pInstance;
  178.   pStatusParms   = (PMCI_STATUS_PARMS)pFuncBlock->pParam2;
  179.  
  180.  
  181.   return (ulrc);
  182.  
  183. }      /* end of MCIStatusErr */
  184.  
  185.