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

  1. /****************************************************************************/
  2. /*                                                                          */
  3. /*                    Copyright (c) IBM Corporation 1992, 1993              */
  4. /*                           All Rights Reserved                            */
  5. /*                                                                          */
  6. /* SOURCE FILE NAME: SHEPROT.C                                              */
  7. /*                                                                          */
  8. /* DESCRIPTIVE NAME:  Stream Handler Enumerate Protocols routine            */
  9. /*                                                                          */
  10. /* FUNCTION: Enumerate the protocols installed in this stream handler.      */
  11. /*                                                                          */
  12. /* ENTRY POINTS: ShcEnumerateProtocols                                      */
  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: ShcEnumerateProtocols                                   */
  26. /*                                                                          */
  27. /* DESCRIPTIVE NAME: Stream Handler Command Enumerate Protocols (spcbs)     */
  28. /*                                                                          */
  29. /* FUNCTION: This returns a list of the protocols supported by the stream   */
  30. /*           handler.                                                       */
  31. /*                                                                          */
  32. /* NOTES:                                                                   */
  33. /*                                                                          */
  34. /* ENTRY POINT: ShcEnumerateProtocols                                       */
  35. /*   LINKAGE:   CALL NEAR (0:32)                                            */
  36. /*                                                                          */
  37. /* INPUT: Pointer to shc enumerate protocol parameter block (PARM_ENUMPROT) */
  38. /*        containing:                                                       */
  39. /*   ULONG   ulFunction  Handler command function SHC_ENUMERATE_PROTOCOLS   */
  40. /*   HID     hid         handler ID                                         */
  41. /*   PVOID   paSPCBKeys  pointer to buffer to fill with SPCB keys           */
  42. /*   PULONG  pulNumSPCBKeys number of SPCB keys on output                   */
  43. /*                                                                          */
  44. /* EXIT-NORMAL: NO_ERROR (0)                                                */
  45. /*                                                                          */
  46. /* EXIT-ERROR:                                                              */
  47. /*   ERROR_INVALID_BUFFER_SIZE                                              */
  48. /*                                                                          */
  49. /* SIDE EFFECTS:                                                            */
  50. /*                                                                          */
  51. /* INTERNAL REFERENCES:                                                     */
  52. /*        ROUTINES: None                                                    */
  53. /*                                                                          */
  54. /* EXTERNAL REFERENCES:                                                     */
  55. /*   ROUTINES:                                                              */
  56. /*     None                                                                 */
  57. /*                                                                          */
  58. /*   DATA STRUCTURES:                                                       */
  59. /*     ESPCB                                                                */
  60. /*                                                                          */
  61. /*************************** END OF SPECIFICATIONS **************************/
  62.  
  63. RC ShcEnumerateProtocols(pepparm)
  64. PPARM_ENUMPROT pepparm;
  65.  
  66. { /* Start of ShcEnumerateProtocols */
  67.  
  68. RC rc = NO_ERROR;                       /* local return code */
  69. ULONG  ulNumEspcbs;                     /* loop control */
  70. PSPCBKEY aSpcbKeys;                     /* array of spcbkeys to return */
  71. PESPCB pTempEspcb;                      /* temp pointer to espcb */
  72.  
  73.  
  74.   ENTERCRITX(rc);
  75.  
  76.   /* Count the number of espcb's installed to */
  77.   /* check if application passed large enough buffer. */
  78.   /* If not return error and size needed. */
  79.  
  80.   pTempEspcb = pESPCB_ListHead;
  81.   ulNumEspcbs = 0;
  82.   while (pTempEspcb)
  83.     {
  84.       ulNumEspcbs++;
  85.       pTempEspcb = pTempEspcb->pnxtESPCB;
  86.     }
  87.  
  88.   /* check the buffer size passed */
  89.   if (*pepparm->pulNumSPCBKeys < ulNumEspcbs)
  90.     { /* Not enough space */
  91.       rc = ERROR_INVALID_BUFFER_SIZE;
  92.     } /* Not enough space */
  93.   else
  94.     { /* Get the spcb keys */
  95.  
  96.       /* Loop thru the espcb list and copy the spcbkey to the */
  97.       /* callers buffer. */
  98.  
  99.       aSpcbKeys = pepparm->paSPCBKeys;
  100.       ulNumEspcbs = 0;
  101.       pTempEspcb = pESPCB_ListHead;
  102.       while (pTempEspcb)
  103.         { /* Loop thru espcbs */
  104.  
  105.           aSpcbKeys[ulNumEspcbs].ulDataType    = pTempEspcb->spcb.spcbkey.ulDataType;
  106.           aSpcbKeys[ulNumEspcbs].ulDataSubType = pTempEspcb->spcb.spcbkey.ulDataSubType;
  107.           aSpcbKeys[ulNumEspcbs].ulIntKey      = pTempEspcb->spcb.spcbkey.ulIntKey;
  108.           ulNumEspcbs++;
  109.           pTempEspcb = pTempEspcb->pnxtESPCB;
  110.  
  111.         } /* Loop thru espcbs */
  112.  
  113.     } /* Get the spcb keys */
  114.  
  115.   /* Return the real number of spcb keys in all cases */
  116.   *pepparm->pulNumSPCBKeys = ulNumEspcbs;
  117.  
  118.   EXITCRIT;
  119.   return(rc);
  120.  
  121. } /* End of ShcEnumerateProtocols */
  122.