home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional Developers Kit 1992 November / Disc01 / Disc01.mdf / runnable / mmos2 / mmtoolkt / samples / fssht / shgprot.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-05-06  |  4.3 KB  |  87 lines

  1. /*static char *SCCSID = "@(#)shgprot.c    13.2 92/05/01";*/
  2. /****************************************************************************/
  3. /*                                                                          */
  4. /*                    Copyright (c) IBM Corporation 1992                    */
  5. /*                           All Rights Reserved                            */
  6. /*                                                                          */
  7. /* SOURCE FILE NAME: SHGPROT.C                                              */
  8. /*                                                                          */
  9. /* DESCRIPTIVE NAME:  Stream Handler Get Protocol routine                   */
  10. /*                                                                          */
  11. /* FUNCTION: Get the protocols installed for this stream handler.           */
  12. /*                                                                          */
  13. /* ENTRY POINTS: ShcGetProtocol                                             */
  14. /*                                                                          */
  15. /*************************** END OF SPECIFICATIONS **************************/
  16. #define  INCL_NOPMAPI                  /* no PM include files required */
  17. #define  INCL_DOSSEMAPHORES
  18. #define  INCL_DOSPROCESS
  19. #include <os2.h>
  20. #include <os2me.h>
  21. #include <hhpheap.h>
  22. #include <shi.h>
  23.  
  24. /************************** START OF SPECIFICATIONS *************************/
  25. /*                                                                          */
  26. /* SUBROUTINE NAME: ShcGetProtocol                                          */
  27. /*                                                                          */
  28. /* DESCRIPTIVE NAME: Stream Handler Command Get Protocol                    */
  29. /*                                                                          */
  30. /* FUNCTION: This returns a SPCB indicated by the key passed in.            */
  31. /*                                                                          */
  32. /* NOTES:                                                                   */
  33. /*                                                                          */
  34. /* ENTRY POINT: ShcGetProtocol                                              */
  35. /*   LINKAGE:   CALL NEAR (0:32)                                            */
  36. /*                                                                          */
  37. /* INPUT:                                                                   */
  38. /*                                                                          */
  39. /* EXIT-NORMAL:                                                             */
  40. /*                                                                          */
  41. /* EXIT-ERROR:                                                              */
  42. /*                                                                          */
  43. /* SIDE EFFECTS:                                                            */
  44. /*                                                                          */
  45. /* INTERNAL REFERENCES:                                                     */
  46. /*        ROUTINES:                                                         */
  47. /*                                                                          */
  48. /* EXTERNAL REFERENCES:                                                     */
  49. /*        ROUTINES:                                                         */
  50. /*        DATA STRUCTURES:                                                  */
  51. /*                                                                          */
  52. /*************************** END OF SPECIFICATIONS **************************/
  53.  
  54. RC ShcGetProtocol(pgpparm)
  55. PPARM_GPROT pgpparm;
  56.  
  57. { /* Start of ShcGetProtocol */
  58.  
  59. RC rc = NO_ERROR;                       // local return code
  60. PESPCB pTempEspcb;
  61.  
  62.   //
  63.   // the ESPCB list is under semphore control
  64.   //
  65.   if (!(rc = DosRequestMutexSem(hmtxGlobalData, SEM_INDEFINITE_WAIT)))
  66.     { /* obtained semaphore */
  67.       /*
  68.        * Locate the spcb and return it
  69.        */
  70.       pTempEspcb = ShFindEspcb(pgpparm->spcbkey);
  71.       if (pTempEspcb)
  72.         {
  73.           *pgpparm->pspcb = pTempEspcb->spcb;
  74.         }
  75.       else
  76.         {
  77.           rc = ERROR_INVALID_SPCBKEY;
  78.         }
  79.  
  80.       DosReleaseMutexSem(hmtxGlobalData);
  81.  
  82.     } /* obtained semaphore */
  83.  
  84.   return(rc);
  85.  
  86. } /* End of ShcGetProtocol */
  87.