(file) Return to host.c CVS log (file) (dir) Up to [OMI] / omi / indication / indimgr

 1 krisbash 1.1 /*
 2              **==============================================================================
 3              **
 4              ** Open Management Infrastructure (OMI)
 5              **
 6              ** Copyright (c) Microsoft Corporation
 7              ** 
 8              ** Licensed under the Apache License, Version 2.0 (the "License"); you may not 
 9              ** use this file except in compliance with the License. You may obtain a copy 
10              ** of the License at 
11              **
12              **     http://www.apache.org/licenses/LICENSE-2.0 
13              **
14              ** THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15              ** KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 
16              ** WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 
17              ** MERCHANTABLITY OR NON-INFRINGEMENT. 
18              **
19              ** See the Apache 2 License for the specific language governing permissions 
20              ** and limitations under the License.
21              **
22 krisbash 1.1 **==============================================================================
23              */
24              
25              #include <disp/agentmgr.h>
26              #include <disp/disp.h>
27              #include "host.h"
28              
29              /* Get ProvReg object from Dispatcher */
30              static ProvReg* _DISP_GetProvReg(_In_ void* disp)
31              {
32                  DEBUG_ASSERT(disp);
33                  return &((Disp*)disp)->provreg;
34              }
35              
36              /*
37              * Handles request by Dispatcher, 
38              * i.e., relies on AgentMgr to send the request to provider
39              */
40              static void _DISP_HandleRequest(
41                  _In_ void* disp,
42                  _Inout_ InteractionOpenParams* interactionParams, 
43 krisbash 1.1     _In_ const ProvRegEntry* proventry)
44              {
45                  AgentMgr_OpenCallbackData data;
46                  
47                  DEBUG_ASSERT(disp);
48              
49                  data.self = &((Disp*)disp)->agentmgr;
50                  data.proventry = proventry;
51                  interactionParams->callbackData = &data;
52                  
53                  AgentMgr_OpenCallback(interactionParams);
54              }
55              
56              /* Initialize host object from disp object */
57              _Use_decl_annotations_
58              int IndicationHost_InitFromDisp(
59                  void* disp,
60                  IndicationHost* host)
61              {
62                  return IndicationHost_Init(disp, _DISP_GetProvReg, _DISP_HandleRequest, host);
63              }
64 krisbash 1.1 
65              /* Initialize host object from given context and functions */
66              _Use_decl_annotations_
67              int IndicationHost_Init(
68                  void* context,
69                  fnGetProvReg getprovreg,
70                  fnHandleRequest handlerequest,
71                  IndicationHost* host)
72              {
73                  DEBUG_ASSERT(host);
74                  host->context = context;
75                  host->getProvReg = getprovreg;
76                  host->handleRequest = handlerequest;
77                  return 0;
78              }
79              
80              /* Get ProvReg object from host */
81              ProvReg* IndicationHost_GetProvReg(_In_ IndicationHost* host)
82              {
83                  DEBUG_ASSERT(host);
84                  return host->getProvReg(host->context);
85 krisbash 1.1 }
86              
87              /* Ask host to handle request */
88              void IndicationHost_HandleRequest(
89                  _Inout_ InteractionOpenParams* interactionParams )
90              {
91                  IndicationHost_Data* data = (IndicationHost_Data*)interactionParams->callbackData;
92                  IndicationHost* host = data->host;
93                  const ProvRegEntry* proventry = data->proventry;
94                  
95                  DEBUG_ASSERT(host);
96                  host->handleRequest(host->context, interactionParams, proventry);
97              }
98              

ViewCVS 0.9.2