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