home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mmpm21tk.zip / TK / FSSHT / SHSTART.C < prev    next >
C/C++ Source or Header  |  1993-02-25  |  6KB  |  112 lines

  1. /****************************************************************************/
  2. /*                                                                          */
  3. /*                    Copyright (c) IBM Corporation 1992, 1993              */
  4. /*                           All Rights Reserved                            */
  5. /*                                                                          */
  6. /* SOURCE FILE NAME: SHSTART.C                                              */
  7. /*                                                                          */
  8. /* DESCRIPTIVE NAME:  Stream Handler Start stream routine                   */
  9. /*                                                                          */
  10. /* FUNCTION: This function starts a stream instance.                        */
  11. /*                                                                          */
  12. /* ENTRY POINTS: ShcStart                                                   */
  13. /*                                                                          */
  14. /*************************** END OF SPECIFICATIONS **************************/
  15. #define  INCL_NOPMAPI                  /* no PM include files required */
  16. #define  INCL_DOSSEMAPHORES
  17. #define  INCL_DOSPROCESS
  18. #include <os2.h>
  19. #include <os2me.h>
  20. #include <hhpheap.h>
  21. #include <shi.h>
  22.  
  23. /************************** START OF SPECIFICATIONS *************************/
  24. /*                                                                          */
  25. /* SUBROUTINE NAME: ShcStart                                                */
  26. /*                                                                          */
  27. /* DESCRIPTIVE NAME: Stream Handler Command Start stream routine            */
  28. /*                                                                          */
  29. /* FUNCTION: This routine kick starts the IO thread to start reading or     */
  30. /*   writing.  It may be called indirectly from SpiStartStream, or by the   */
  31. /*   stream manager buffer control code.  If we had to block because no     */
  32. /*   buffers were available, then the buffer control code will send a start.*/
  33. /*                                                                          */
  34. /* NOTES:                                                                   */
  35. /*                                                                          */
  36. /* ENTRY POINT: ShcStart                                                    */
  37. /*   LINKAGE:   CALL NEAR (0:32)                                            */
  38. /*                                                                          */
  39. /* INPUT: Pointer to shc start parameter block (PARM_START) containing:     */
  40. /*   ULONG   ulFunction  Handler command function SHC_START                 */
  41. /*   HID     hid         handler ID                                         */
  42. /*   HSTREAM hstream     handle of stream instance                          */
  43. /*   ULONG   ulFlags     Stop flags (see SSM.H)                             */
  44. /*                                                                          */
  45. /* EXIT-NORMAL: NO_ERROR (0)                                                */
  46. /*                                                                          */
  47. /* EXIT-ERROR:                                                              */
  48. /*   ERROR_DATA_ITEM_NOT_SPECIFIED                                          */
  49. /*   ERROR_INVALID_SEQUENCE                                                 */
  50. /*                                                                          */
  51. /* SIDE EFFECTS:                                                            */
  52. /*   The IO thread is unblocked.                                            */
  53. /*                                                                          */
  54. /* INTERNAL REFERENCES:                                                     */
  55. /*        ROUTINES: None                                                    */
  56. /*                                                                          */
  57. /* EXTERNAL REFERENCES:                                                     */
  58. /*   ROUTINES:                                                              */
  59. /*     ShFindSib                                                            */
  60. /*     DosResumeThread                                                      */
  61. /*     DosPostEventSem                                                      */
  62. /*                                                                          */
  63. /*   DATA STRUCTURES:                                                       */
  64. /*                                                                          */
  65. /*************************** END OF SPECIFICATIONS **************************/
  66.  
  67. RC ShcStart(pstparm)
  68. PPARM_START pstparm;
  69.  
  70. { /* Start of ShcStart */
  71.  
  72. RC rc = NO_ERROR;                       /* local return code */
  73. PSIB psib;                              /* Stream instance block */
  74. BOOL bPaused;                           /* Is stream paused? */
  75.  
  76.   /*
  77.    * Find our Stream Instance Block
  78.    */
  79.   if (!(rc = ShFindSib(&psib, pstparm->hstream, pstparm->hid)))
  80.     { /* We have SIB */
  81.       /* error if we don't have something to stream */
  82.       if (psib->ulStatus < SIB_RUNNING)
  83.         {
  84.           rc = ERROR_DATA_ITEM_NOT_SPECIFIED;
  85.         }
  86.       else
  87.         {
  88.           if (DEAD(psib))
  89.             {
  90.               rc = ERROR_INVALID_SEQUENCE;
  91.             }
  92.           else
  93.             { /* command sequence ok */
  94.  
  95.               bPaused = (psib->ulStatus == SIB_PAUSED);
  96.               psib->ulStatus = SIB_RUNNING;
  97.               if (psib->ThreadID)
  98.                 {
  99.                   DosPostEventSem(psib->hevStop);
  100.                   if (bPaused)
  101.                     {
  102.                       DosResumeThread(psib->ThreadID);
  103.                     }
  104.                 }
  105.             } /* command sequence ok */
  106.         }
  107.     } /* We have SIB */
  108.  
  109.   return(rc);
  110.  
  111. } /* End of ShcStart */
  112.