home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional Developers Kit 1992 November / Disc01 / Disc01.mdf / mmpm2tk / mmpmtlk2 / fssht / shmisc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-05-06  |  8.2 KB  |  163 lines

  1. /*static char *SCCSID = "@(#)shmisc.c    13.2 92/05/01";*/
  2. /****************************************************************************/
  3. /*                                                                          */
  4. /*                    Copyright (c) IBM Corporation 1992                    */
  5. /*                           All Rights Reserved                            */
  6. /*                                                                          */
  7. /* SOURCE FILE NAME: SHMISC.C                                               */
  8. /*                                                                          */
  9. /* DESCRIPTIVE NAME:  Stream Handler Misc. routines                         */
  10. /*                                                                          */
  11. /* FUNCTION: This file contains the supporting routines for the stream      */
  12. /*           handlers.                                                      */
  13. /*                                                                          */
  14. /* ENTRY POINTS: ShFindSib                                                  */
  15. /*               ShFindEspcb                                                */
  16. /*************************** END OF SPECIFICATIONS **************************/
  17. #define  INCL_NOPMAPI                  /* no PM include files required */
  18. #define  INCL_DOSSEMAPHORES
  19. #define  INCL_DOSERRORS
  20. #define  INCL_DOSPROCESS
  21. #include <os2.h>
  22. #include <os2me.h>
  23. #include <hhpheap.h>
  24. #include <shi.h>
  25.  
  26. /************************** START OF SPECIFICATIONS *************************/
  27. /*                                                                          */
  28. /* SUBROUTINE NAME: ShFindSib                                               */
  29. /*                                                                          */
  30. /* DESCRIPTIVE NAME: Stream Handler Find Stream Instance Block              */
  31. /*                                                                          */
  32. /* FUNCTION: Finds the SIB associated with the stream handle, and handler   */
  33. /*           ID passed.                                                     */
  34. /* NOTES:                                                                   */
  35. /*                                                                          */
  36. /* ENTRY POINT: ShFindSib                                                   */
  37. /*   LINKAGE:   CALL NEAR (0:32)                                            */
  38. /*                                                                          */
  39. /* INPUT:                                                                   */
  40. /*                                                                          */
  41. /* EXIT-NORMAL:                                                             */
  42. /*                                                                          */
  43. /* EXIT-ERROR:                                                              */
  44. /*                                                                          */
  45. /* SIDE EFFECTS:                                                            */
  46. /*                                                                          */
  47. /* INTERNAL REFERENCES:                                                     */
  48. /*        ROUTINES:                                                         */
  49. /*                                                                          */
  50. /* EXTERNAL REFERENCES:                                                     */
  51. /*        ROUTINES:                                                         */
  52. /*        DATA STRUCTURES:                                                  */
  53. /*                                                                          */
  54. /*************************** END OF SPECIFICATIONS **************************/
  55.  
  56. RC ShFindSib(psib, hstream, hid)
  57. PSIB *psib;                               // Output - pointer to SIB
  58. HSTREAM hstream;                          // Input - stream handle
  59. HID hid;                                  // Handler ID to identify
  60.                                           //  source or target
  61.  
  62. { /* Start of ShFindSib */
  63.  
  64. RC rc = NO_ERROR;                       // local return code
  65. PSIB psibtemp;                          // Stream instance block
  66.  
  67.   /*
  68.    * Find our Stream Instance Block by searching the SIB list.  It is
  69.    *  under semaphore control, so get it first.
  70.    */
  71.   rc = DosRequestMutexSem(hmtxGlobalData, SEM_INDEFINITE_WAIT);
  72.   if (!rc)
  73.     { /* Search SIB list */
  74.       psibtemp = pSIB_list_head;
  75.       while ((psibtemp) &&
  76.              !((psibtemp->hStream == hstream) && (psibtemp->HandlerID == hid)))
  77.         {
  78.           psibtemp = psibtemp->pnxtSIB;
  79.         }
  80.       if (psibtemp)
  81.         {
  82.           *psib = psibtemp;
  83.         }
  84.       else
  85.         {
  86.           rc = ERROR_INVALID_STREAM;
  87.         }
  88.  
  89.       DosReleaseMutexSem(hmtxGlobalData);
  90.  
  91.     } /* Search SIB list */
  92.  
  93.   return(rc);
  94.  
  95. } /* End of ShFindSib */
  96.  
  97. /************************** START OF SPECIFICATIONS *************************/
  98. /*                                                                          */
  99. /* SUBROUTINE NAME: ShFindEspcb                                             */
  100. /*                                                                          */
  101. /* DESCRIPTIVE NAME: Stream Handler Find Extended Stream Protocol Control   */
  102. /*                   Block                                                  */
  103. /*                                                                          */
  104. /* FUNCTION: Finds the ESPCB described by the spcbkey passed.               */
  105. /*                                                                          */
  106. /* NOTES: The hmtxGlobalData semaphore must be obtained before calling      */
  107. /*        this routine.                                                     */
  108. /*                                                                          */
  109. /* ENTRY POINT: ShFindEspcb                                                 */
  110. /*   LINKAGE:   CALL NEAR (0:32)                                            */
  111. /*                                                                          */
  112. /* INPUT:                                                                   */
  113. /*                                                                          */
  114. /* EXIT-NORMAL:                                                             */
  115. /*                                                                          */
  116. /* EXIT-ERROR:                                                              */
  117. /*                                                                          */
  118. /* SIDE EFFECTS:                                                            */
  119. /*                                                                          */
  120. /* INTERNAL REFERENCES:                                                     */
  121. /*        ROUTINES:                                                         */
  122. /*                                                                          */
  123. /* EXTERNAL REFERENCES:                                                     */
  124. /*        ROUTINES:                                                         */
  125. /*        DATA STRUCTURES:                                                  */
  126. /*                                                                          */
  127. /*************************** END OF SPECIFICATIONS **************************/
  128.  
  129. PESPCB ShFindEspcb(spcbkey)
  130. SPCBKEY spcbkey;                          // Input - key of espcb to find
  131.  
  132. { /* Start of ShFindEspcb */
  133.  
  134. int notfound = TRUE;
  135. PESPCB pTempEspcb;
  136.  
  137.   /*
  138.    * Find our Extended SPCB by searching the ESPCB list.
  139.    */
  140.  
  141.     { /* Search ESPCB list */
  142.  
  143.       pTempEspcb = pESPCB_ListHead;
  144.       while (pTempEspcb && notfound)
  145.         { /* Loop thru espcbs */
  146.           if ((spcbkey.ulDataType == pTempEspcb->spcb.spcbkey.ulDataType) &&
  147.               (spcbkey.ulDataSubType == pTempEspcb->spcb.spcbkey.ulDataSubType) &&
  148.               (spcbkey.ulIntKey == pTempEspcb->spcb.spcbkey.ulIntKey))
  149.             {
  150.               notfound = FALSE;
  151.             }
  152.           else
  153.             {
  154.               pTempEspcb = pTempEspcb->pnxtESPCB;
  155.             }
  156.         } /* Loop thru espcbs */
  157.  
  158.     } /* Search ESPCB list */
  159.  
  160.   return(pTempEspcb);
  161.  
  162. } /* End of ShFindEspcb */
  163.