(file) Return to ProtocolHandlerCache.h CVS log (file) (dir) Up to [OMI] / omi / miapi

 1 krisbash 1.1 /*============================================================================
 2               * Copyright (C) Microsoft Corporation, All rights reserved. 
 3               *============================================================================
 4               */
 5              #ifndef _miapi_protocolHandlerCache_h_
 6              #define _miapi_protocolHandlerCache_h_
 7              #include <MI.h>
 8              #include <pal/lock.h>
 9              #include <pal/strings.h>
10              #include <pal/shlib.h>
11              
12              typedef MI_Result (MI_MAIN_CALL *ProtocolHandlerInitializeV1)(
13                             MI_Uint32 flags, 
14                  _In_opt_z_ const MI_Char * applicationID,
15                  _Outptr_opt_result_maybenull_ MI_Instance **extendedError,
16                  _Out_      MI_Application *application);
17              
18              /* ProtocolHandlerCacheItem
19               * This object represents a specific protocol handler
20               */
21              typedef struct _ProtocolHandlerCacheItem
22 krisbash 1.1 {
23                  MI_Boolean dllInitialized;
24                  MI_Char name[30];  /* Protocol handler name string */
25                  char dllPath[PAL_MAX_PATH_SIZE]; /* Path to DLL */
26                  char dllEntryPoint[30]; /* Entry point name in the DLL to call */
27                  MI_Uint32 majorVersion;
28                  MI_Uint32 minorVersion;
29                  ProtocolHandlerInitializeV1 dllFunctionPointer; /* Statically loaded hander entry point */
30                  Shlib *dllHandle; /* Handle from LoadLibrary */
31                  MI_Application application; /* application returned when initialized */
32                  volatile ptrdiff_t outstandingProtocolHandlerCalls; /* If we are currently calling into a protocol handler within a thread we bump this and decrement straight after */
33                  struct _ProtocolHandlerCacheItem *nextItem; /* Next item in list */
34              } ProtocolHandlerCacheItem;
35              
36              typedef struct _ProtocolHandlerCache
37              {
38                  /* fast read/write lock, optimized for many reads/few writes */
39                  ReadWriteLock lock;
40              
41                  /* Array of transports */
42                  ProtocolHandlerCacheItem *cacheList;
43 krisbash 1.1 
44                  ProtocolHandlerCacheItem *defaultLocalItem;
45                  ProtocolHandlerCacheItem *defaultRemoteItem;
46              
47                  const MI_Char *applicationID;
48              } ProtocolHandlerCache;
49              
50              /* PUBLIC: ProtocolHandlerCache_Initialize
51               * Initializes the cache.  Cache needs to be deinitialized when finished with.
52               *
53               * cache - Pointer to a ProtocolHandlerCache to be initialized
54               *
55               * Returns:
56               *      ERROR_OUTOFMEMORY
57               *      ERROR_SUCCESS
58               */
59              MI_EXTERN_C MI_Result ProtocolHandlerCache_Initialize(_In_opt_z_ const MI_Char *applicationId, _Out_ ProtocolHandlerCache *Self);
60              
61              /* PUBLIC: ProtocolHandlerCache_DeInitialize
62               * Shuts down the cache, unloading all cache entries in the process.
63               *
64 krisbash 1.1  * cache - Pointer to a ProtocolHandlerCache to be deinitialized
65               *
66               * Returns:
67               *      ERROR_SUCCESS
68               */
69              MI_EXTERN_C MI_Result ProtocolHandlerCache_DeInitialize(_Inout_ ProtocolHandlerCache *cache);
70              
71              /* PUBLIC: ProtocolHandlerCache_GetProtocolHandler
72               */
73              _Success_(return == MI_RESULT_OK)
74              MI_EXTERN_C MI_Result ProtocolHandlerCache_GetProtocolHandler(_Inout_ ProtocolHandlerCache *cache, _In_z_ const MI_Char *name, _Outptr_ ProtocolHandlerCacheItem **cacheItem);
75              
76              MI_Result ProtocolHandlerCache_IncrementApiCount(_Inout_ ProtocolHandlerCacheItem *cacheItem);
77              MI_Result ProtocolHandlerCache_DecrementApiCount(_Inout_ ProtocolHandlerCacheItem *cacheItem);
78              
79              
80              _Success_(return == MI_RESULT_OK)
81              MI_EXTERN_C MI_Result ProtocolHandlerCache_InsertProtocolEntries(_Inout_ ProtocolHandlerCache *cache,
82                          _In_z_ const char *protocolHandlerName,
83                          _In_z_ const char *protocolHandlerDLL,
84                          _In_z_ const char *protocolHandlerDllEntryPoint,
85 krisbash 1.1             MI_Uint32 protocolHandlerMajorVersion,
86                          MI_Uint32 protocolHandlerMinorVersion,
87                          _Outptr_ ProtocolHandlerCacheItem **cacheItem);
88              
89              
90              #endif /* _miapi_protocolHandlerCache_h_ */
91              

ViewCVS 0.9.2