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

  1. /*************************START OF SPECIFICATIONS *************************/
  2. /* SOURCE FILE NAME:  IOENTRY.C                                           */
  3. /*                                                                        */
  4. /* DESCRIPTIVE NAME: FileFormat IO Proc Main (Entry Point) Module         */
  5. /*                                                                        */
  6. /* COPYRIGHT:     IBM - International Business Machines                   */
  7. /*            Copyright (c) IBM Corporation  1991, 1992, 1993             */
  8. /*                        All Rights Reserved                             */
  9. /*                                                                        */
  10. /* STATUS: OS/2 Release 2.0                                               */
  11. /*                                                                        */
  12. /* FUNCTION: This source module contains the entry point for the IO Proc. */
  13. /*                                                                        */
  14. /* NOTES:                                                                 */
  15. /*    DEPENDENCIES: none                                                  */
  16. /*    RESTRICTIONS: Runs in 32 bit protect mode (OS/2 2.0)                */
  17. /*                                                                        */
  18. /* ENTRY POINTS:                                                          */
  19. /*      IOProc_Entry                                                      */
  20. /*      IOInvalidEntry                                                    */
  21. /*                                                                        */
  22. /************************** END OF SPECIFICATIONS *************************/
  23.  
  24. #include        <stdio.h>
  25. #include        <string.h>
  26. #include        <stdlib.h>
  27. #include        <memory.h>
  28.  
  29. #define         INCL_DOS                        /* #define  INCL_DOSPROCESS.*/
  30. #define         INCL_GPIBITMAPS
  31. #define         INCL_ERRORS
  32. #define         INCL_WIN
  33. #define         INCL_GPI
  34. #include        <os2.h>                         /* OS/2 headers.            */
  35. #include        <pmbitmap.h>
  36.  
  37. #define         INCL_OS2MM
  38. #define         INCL_MMIO_CODEC
  39. #define         INCL_MMIO_DOSIOPROC
  40. #include        <os2me.h>                       /* Multi-Media IO extensions.*/
  41. #include        <hhpheap.h>
  42. #include        <ioi.h>
  43.  
  44. /************************** START OF SPECIFICATIONS *************************/
  45. /*                                                                          */
  46. /* SUBROUTINE NAME: IOProc_Entry                                            */
  47. /*                                                                          */
  48. /* DESCRIPTIVE NAME: IO Proc entrypoint.                                    */
  49. /*                                                                          */
  50. /* FUNCTION: This function provides access to the functionality of this     */
  51. /*           IO Proc. This is the sole entrypoint.                          */
  52. /*                                                                          */
  53. /* NOTES: None                                                              */
  54. /*                                                                          */
  55. /* ENTRY POINT: IOProc_Entry                                                */
  56. /*   LINKAGE:   CALL FAR (00:32)                                            */
  57. /*                                                                          */
  58. /* INPUT:                                                                   */
  59. /*              PVOID   pmmioStr   - Pointer to MMIOINFO staus structure    */
  60. /*              WORD    wMessage   - MMIO Message request number            */
  61. /*              LONG    lParam1    - Primary message dependent parameter    */
  62. /*              LONG    lParam2    - Secondary message dependent parameter  */
  63. /*                                                                          */
  64. /* EXIT-NORMAL:                                                             */
  65. /*              MMIO_SUCCESS                                                */
  66. /*                                                                          */
  67. /* EXIT-ERROR:                                                              */
  68. /*              MMIOERR_UNSUPPORTED_MESSAGE                                 */
  69. /*              Message specific error                                      */
  70. /*                                                                          */
  71. /* SIDE EFFECTS:                                                            */
  72. /*                                                                          */
  73. /*************************** END OF SPECIFICATIONS **************************/
  74.  
  75. LONG APIENTRY IOProc_Entry ( PVOID pmmioStr,
  76.                              WORD wMessage,
  77.                              LONG lParam1,
  78.                              LONG lParam2  )
  79. {
  80.    LONG        lReserved = 0;
  81.    LONG        lRetCode;                         /* Return code.            */
  82.    PMMIOINFO   pmmioinfo;                        /* Local work structure.   */
  83.    PINSTANCE   pinstance;
  84.  
  85.    // Clear the error return before anything happens to insure valid results.
  86.  
  87.    if (pmmioStr) {
  88.       pmmioinfo = (PMMIOINFO) pmmioStr;
  89.       pmmioinfo->ulErrorRet = MMIO_SUCCESS;
  90.       }
  91.    else {
  92.       pmmioinfo = NULL;
  93.       }
  94.  
  95.    switch (wMessage) {
  96.       /*****************************************************/
  97.       /* Standard IO Proc Messages that must be supported. */
  98.       /*****************************************************/
  99.  
  100.       case MMIOM_OPEN :     /* Open file, setup for read. */
  101.          if ( ffiofnct.pfnIOProcOpen ) {
  102.             lRetCode = ffiofnct.pfnIOProcOpen(pmmioinfo,(PSZ)lParam1);
  103.          }
  104.          else {
  105.             lRetCode = ioInvalidEntry( pmmioinfo, &pinstance,
  106.                                        wMessage, lParam1, lParam2 );
  107.          }
  108.          break;
  109.  
  110.       case MMIOM_CLOSE :    /* Close and free buffers. */
  111.          if ( ffiofnct.pfnIOProcClose ) {
  112.             lRetCode = ffiofnct.pfnIOProcClose(pmmioinfo);
  113.          }
  114.          else {
  115.             lRetCode = ioInvalidEntry( pmmioinfo, &pinstance,
  116.                                        wMessage, lParam1, lParam2 );
  117.          }
  118.          break;
  119.  
  120.       case MMIOM_SAVE:
  121.          if ( ffiofnct.pfnIOProcSave ) {
  122.             lRetCode = ffiofnct.pfnIOProcSave(pmmioinfo,(PSZ)lParam1);
  123.          }
  124.          else {
  125.             lRetCode = ioInvalidEntry( pmmioinfo, &pinstance,
  126.                                        wMessage, lParam1, lParam2 );
  127.          }
  128.          break;
  129.  
  130.       case MMIOM_READ :     /* Read file. */
  131.          if ( ffiofnct.pfnIOProcRead ) {
  132.             lRetCode = ffiofnct.pfnIOProcRead(pmmioinfo,(PSZ)lParam1,lParam2);
  133.          }
  134.          else {
  135.             lRetCode = ioInvalidEntry( pmmioinfo, &pinstance,
  136.                                        wMessage, lParam1, lParam2 );
  137.          }
  138.          break;
  139.  
  140.       case MMIOM_WRITE:
  141.          if ( ffiofnct.pfnIOProcWrite ) {
  142.             lRetCode = ffiofnct.pfnIOProcWrite(pmmioinfo,(PSZ)lParam1,lParam2);
  143.          }
  144.          else {
  145.             lRetCode = ioInvalidEntry( pmmioinfo, &pinstance,
  146.                                        wMessage, lParam1, lParam2 );
  147.          }
  148.          break;
  149.  
  150.       case MMIOM_SEEK :     /* Resets file postition to indicate offset. */
  151.          if ( ffiofnct.pfnIOProcSeek ) {
  152.             lRetCode = ffiofnct.pfnIOProcSeek(pmmioinfo,lParam1,lParam2);
  153.          }
  154.          else {
  155.             lRetCode = ioInvalidEntry( pmmioinfo, &pinstance,
  156.                                        wMessage, lParam1, lParam2 );
  157.          }
  158.          break;
  159.  
  160.       case MMIOM_SEEKBYTIME:
  161.          if ( ffiofnct.pfnIOProcSeekByTime ) {
  162.             lRetCode = ffiofnct.pfnIOProcSeekByTime(pmmioinfo,(PSZ)lParam1, lParam2);
  163.          }
  164.          else {
  165.             lRetCode = ioInvalidEntry( pmmioinfo, &pinstance,
  166.                                        wMessage, lParam1, lParam2 );
  167.          }
  168.          break;
  169.  
  170.       case MMIOM_GETFORMATNAME :     /* Text describes File format. */
  171.          if ( ffiofnct.pfnIOProcGetFormatName ) {
  172.             lRetCode = ffiofnct.pfnIOProcGetFormatName((PSZ)lParam1,lParam2);
  173.          }
  174.          else {
  175.             lRetCode = ioInvalidEntry( pmmioinfo, &pinstance,
  176.                                        wMessage, lParam1, lParam2 );
  177.          }
  178.          break;
  179.  
  180.       case MMIOM_GETFORMATINFO :     /* Get file format information. */
  181.          if ( ffiofnct.pfnIOProcGetFormatInfo ) {
  182.             lRetCode = ffiofnct.pfnIOProcGetFormatInfo((PMMFORMATINFO)lParam1);
  183.          }
  184.          else {
  185.             lRetCode = ioInvalidEntry( pmmioinfo, &pinstance,
  186.                                        wMessage, lParam1, lParam2 );
  187.          }
  188.          break;
  189.  
  190.       case MMIOM_GETHEADER :     /* Get File or Track header */
  191.          if ( ffiofnct.pfnIOProcGetHeader ) {
  192.             lRetCode = ffiofnct.pfnIOProcGetHeader(pmmioinfo,(PVOID)lParam1,lParam2,lReserved);
  193.          }
  194.          else {
  195.             lRetCode = ioInvalidEntry( pmmioinfo, &pinstance,
  196.                                        wMessage, lParam1, lParam2 );
  197.          }
  198.          break;
  199.  
  200.       case MMIOM_IDENTIFYFILE :     /* Determine if this IO Proc can process this file  */
  201.          if ( ffiofnct.pfnIOProcIdentifyFile ) {
  202.             lRetCode = ffiofnct.pfnIOProcIdentifyFile(pmmioinfo,(PSZ)lParam1,(HMMIO)lParam2);
  203.          }
  204.          else {
  205.             lRetCode = ioInvalidEntry( pmmioinfo, &pinstance,
  206.                                        wMessage, lParam1, lParam2 );
  207.          }
  208.          break;
  209.  
  210.       case MMIOM_QUERYHEADERLENGTH :     /* Query length of file or track header */
  211.          if ( ffiofnct.pfnIOProcQueryHeaderLength )
  212.             lRetCode = ffiofnct.pfnIOProcQueryHeaderLength(pmmioinfo,lReserved);
  213.          else
  214.             lRetCode = ioInvalidEntry(pmmioinfo, &pinstance, wMessage, lParam1, lParam2);
  215.          break;
  216.  
  217.       case MMIOM_SET:     /* general query and set function */
  218.          if ( ffiofnct.pfnIOProcSet )
  219.             lRetCode = ffiofnct.pfnIOProcSet(pmmioinfo,lParam1,lParam2);
  220.          else
  221.             lRetCode = ioInvalidEntry(pmmioinfo, &pinstance, wMessage, lParam1, lParam2);
  222.          break;
  223.  
  224.       case MMIOM_BEGININSERT:
  225.          if ( ffiofnct.pfnIOProcBeginInsert )
  226.             lRetCode = ffiofnct.pfnIOProcBeginInsert(pmmioinfo,(PSZ)lParam1);
  227.          else
  228.             lRetCode = ioInvalidEntry(pmmioinfo, &pinstance, wMessage, lParam1, lParam2);
  229.          break;
  230.  
  231.       case MMIOM_ENDINSERT:
  232.          if ( ffiofnct.pfnIOProcEndInsert )
  233.             lRetCode = ffiofnct.pfnIOProcEndInsert(pmmioinfo,(PSZ)lParam1);
  234.          else
  235.             lRetCode = ioInvalidEntry(pmmioinfo, &pinstance, wMessage, lParam1, lParam2);
  236.          break;
  237.  
  238.       case MMIOM_SETHEADER :     /* Set File or Track header */
  239.          if ( ffiofnct.pfnIOProcSetHeader )
  240.             lRetCode = ffiofnct.pfnIOProcSetHeader(pmmioinfo,(PVOID)lParam1,lParam2,lReserved);
  241.          else
  242.             lRetCode = ioInvalidEntry(pmmioinfo, &pinstance, wMessage, lParam1, lParam2);
  243.          break;
  244.  
  245.       /*****************************************************/
  246.       /* SendMsg IO Proc Messages supported.               */
  247.       /*****************************************************/
  248.  
  249.       case MMIOM_MULTITRACKREAD:     /* Read multiple tracks by track  */
  250.          if ( ffiofnct.pfnIOProcMultiTrackRead )
  251.             lRetCode = ffiofnct.pfnIOProcMultiTrackRead(pmmioinfo,(PMMMULTITRACKREAD)lParam1);
  252.          else
  253.             lRetCode = ioInvalidEntry(pmmioinfo, &pinstance, wMessage, lParam1, lParam2);
  254.          break;
  255.  
  256.       case MMIOM_MULTITRACKWRITE:    /* Write multiple tracks by track */
  257.          if ( ffiofnct.pfnIOProcMultiTrackWrite )
  258.             lRetCode = ffiofnct.pfnIOProcMultiTrackWrite(pmmioinfo,(PMMMULTITRACKWRITE)lParam1);
  259.          else
  260.             lRetCode = ioInvalidEntry(pmmioinfo, &pinstance, wMessage, lParam1, lParam2);
  261.          break;
  262.  
  263.       case MMIOM_COMPRESS:  /* compress buffer */
  264.          if ( ffiofnct.pfnIOProcCompress )
  265.             lRetCode = ffiofnct.pfnIOProcCompress(pmmioinfo,(PSZ)lParam1);
  266.          else
  267.             lRetCode = ioInvalidEntry( pmmioinfo, &pinstance, wMessage, lParam1, lParam2);
  268.          break;
  269.  
  270.       case MMIOM_DECOMPRESS:  /* Decompress a buffer */
  271.          if ( ffiofnct.pfnIOProcDecompress )
  272.             lRetCode = ffiofnct.pfnIOProcDecompress(pmmioinfo,(PMMDECOMPRESS)lParam1);
  273.          else
  274.             lRetCode = ioInvalidEntry(pmmioinfo, &pinstance, wMessage, lParam1, lParam2);
  275.          break;
  276.  
  277.       case MMIOM_TEMPCHANGE:
  278.          if ( ffiofnct.pfnIOProcTempChange )
  279.             lRetCode = ffiofnct.pfnIOProcTempChange(pmmioinfo,(PSZ)lParam1);
  280.          else
  281.             lRetCode = ioInvalidEntry(pmmioinfo, &pinstance, wMessage, lParam1, lParam2);
  282.          break;
  283.  
  284.       case MMIOM_COPY:
  285.          if (ffiofnct.pfnIOProcCopy)
  286.             lRetCode = ffiofnct.pfnIOProcCopy(pmmioinfo,(PMMIO_EDIT_PARMS)lParam1);
  287.          else
  288.             lRetCode = ioInvalidEntry(pmmioinfo, &pinstance, wMessage, lParam1, lParam2);
  289.          break;
  290.  
  291.       case MMIOM_CUT:
  292.          if (ffiofnct.pfnIOProcCut)
  293.             lRetCode = ffiofnct.pfnIOProcCut(pmmioinfo,(PMMIO_EDIT_PARMS)lParam1);
  294.          else
  295.             lRetCode = ioInvalidEntry(pmmioinfo, &pinstance, wMessage, lParam1, lParam2);
  296.          break;
  297.  
  298.       case MMIOM_PASTE:
  299.          if (ffiofnct.pfnIOProcPaste)
  300.             lRetCode = ffiofnct.pfnIOProcPaste(pmmioinfo,(PMMIO_EDIT_PARMS)lParam1);
  301.          else
  302.             lRetCode = ioInvalidEntry(pmmioinfo, &pinstance, wMessage, lParam1, lParam2);
  303.          break;
  304.  
  305.       case MMIOM_CLEAR:
  306.          if (ffiofnct.pfnIOProcClear)
  307.             lRetCode = ffiofnct.pfnIOProcClear(pmmioinfo,(PMMIO_EDIT_PARMS)lParam1);
  308.          else
  309.             lRetCode = ioInvalidEntry( pmmioinfo, &pinstance, wMessage, lParam1, lParam2);
  310.          break;
  311.  
  312.       case MMIOM_UNDO:
  313.          if (ffiofnct.pfnIOProcUndo)
  314.             lRetCode = ffiofnct.pfnIOProcUndo(pmmioinfo,(PMMIO_EDIT_PARMS)lParam1);
  315.          else
  316.             lRetCode = ioInvalidEntry( pmmioinfo, &pinstance, wMessage, lParam1, lParam2);
  317.          break;
  318.  
  319.       case MMIOM_REDO:
  320.          if (ffiofnct.pfnIOProcRedo)
  321.             lRetCode = ffiofnct.pfnIOProcRedo(pmmioinfo,(PMMIO_EDIT_PARMS)lParam1);
  322.          else
  323.             lRetCode = ioInvalidEntry( pmmioinfo, &pinstance, wMessage, lParam1, lParam2);
  324.          break;
  325.  
  326.       case MMIOM_STATUS:
  327.          if (ffiofnct.pfnIOProcStatus)
  328.             lRetCode = ffiofnct.pfnIOProcStatus(pmmioinfo, lParam1, (PMMIO_STATUS_PARMS)lParam2);
  329.          else
  330.             lRetCode = ioInvalidEntry(pmmioinfo, &pinstance, wMessage, lParam1, lParam2);
  331.          break;
  332.  
  333.       case MMIOM_WINMSG:
  334.          if (ffiofnct.pfnIOProcWinMsg)
  335.             lRetCode = ffiofnct.pfnIOProcWinMsg(pmmioinfo, (PMMIO_WINMSG)lParam1);
  336.          else
  337.             lRetCode = ioInvalidEntry(pmmioinfo, &pinstance, wMessage, lParam1, lParam2);
  338.          break;
  339.  
  340.       default :
  341.  
  342.          lRetCode = ioInvalidEntry(pmmioinfo, &pinstance, wMessage, lParam1, lParam2);
  343.          break;
  344.  
  345.       } /* end switch */
  346.  
  347.    return lRetCode;
  348. }
  349.  
  350. /************************** START OF SPECIFICATIONS *************************/
  351. /*                                                                          */
  352. /* SUBROUTINE NAME: ioInvalidEntry                                          */
  353. /*                                                                          */
  354. /* DESCRIPTIVE NAME: IO Proc invalid entrypoint handler.                    */
  355. /*                                                                          */
  356. /* FUNCTION: If an IO Proc has a child IO Proc, then instead of             */
  357. /*           returning UNSUPPORTED_MESSAGE, send the message to             */
  358. /*           the child IO Proc to see if it can understand and              */
  359. /*           process the message.                                           */
  360. /*                                                                          */
  361. /* NOTES: None                                                              */
  362. /*                                                                          */
  363. /* ENTRY POINT: ioInvalidEntry                                              */
  364. /*   LINKAGE:   CALL FAR (00:32)                                            */
  365. /*                                                                          */
  366. /* INPUT:                                                                   */
  367. /*           PMMIOINFO pmmioinfo  - MMIOINFO instant structure.             */
  368. /*           PINSTANCE *pinstance - ptr to instance structure.              */
  369. /*                                                                          */
  370. /* EXIT-NORMAL:                                                             */
  371. /*              MMIO_SUCCESS                                                */
  372. /*                                                                          */
  373. /* EXIT-ERROR:                                                              */
  374. /*              MMIOERR_UNSUPPORTED_MESSAGE                                 */
  375. /*              Message specific error                                      */
  376. /*                                                                          */
  377. /* SIDE EFFECTS:                                                            */
  378. /*                                                                          */
  379. /*************************** END OF SPECIFICATIONS **************************/
  380. LONG ioInvalidEntry( PMMIOINFO pmmioinfo,
  381.                      PINSTANCE *ppinstance,
  382.                      WORD wMessage,
  383.                      LONG lParam1,
  384.                      LONG lParam2 )
  385. {
  386.    LONG        lRetCode;
  387.  
  388.    if ( lRetCode = ioGetPtrInstance( pmmioinfo, ppinstance ))
  389.       return( lRetCode );
  390.  
  391.    if ( (*ppinstance)->hmmioFileHandle ) {
  392.       return( mmioSendMessage( (*ppinstance)->hmmioFileHandle,
  393.                                wMessage,
  394.                                lParam1,
  395.                                lParam2 ));
  396.       }
  397.    else {
  398.       pmmioinfo->ulErrorRet = MMIOERR_UNSUPPORTED_MESSAGE;
  399.       return (MMIOERR_UNSUPPORTED_MESSAGE);
  400.       }
  401. }
  402.