1 karl 1.19 //%2006////////////////////////////////////////////////////////////////////////
|
2 schuur 1.1 //
|
3 karl 1.11 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 schuur 1.1 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.11 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.12 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.19 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 schuur 1.1 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
15 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
18 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
|
20 karl 1.11 //
|
21 schuur 1.1 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
22 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
24 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 // Author: Adrian Schuur, schuur@de.ibm.com
33 //
34 // Modified By:
35 //
36 //%/////////////////////////////////////////////////////////////////////////////
37
|
38 r.kieninger 1.18 #include <Pegasus/Common/CIMNameUnchecked.h>
|
39 schuur 1.5 #include "CMPI_Version.h"
|
40 schuur 1.2
|
41 schuur 1.1 #include "CMPI_ContextArgs.h"
42 #include "CMPI_Ftabs.h"
43 #include "CMPI_Value.h"
44 #include "CMPI_String.h"
45
|
46 schuur 1.6 #include <string.h>
47
|
48 schuur 1.1 PEGASUS_USING_STD;
49 PEGASUS_NAMESPACE_BEGIN
50
51 // CMPIArgs section
52
|
53 schuur 1.10 extern "C" {
54
55 static CMPIStatus argsRelease(CMPIArgs* eArg) {
56 Array<CIMParamValue>* arg=(Array<CIMParamValue>*)eArg->hdl;
57 if (arg) {
58 delete arg;
59 (reinterpret_cast<CMPI_Object*>(eArg))->unlinkAndDelete();
60 }
61 CMReturn(CMPI_RC_OK);
|
62 schuur 1.8 }
|
63 schuur 1.1
|
64 schuur 1.10 static CMPIStatus argsReleaseNop(CMPIArgs* eArg) {
65 CMReturn(CMPI_RC_OK);
66 }
|
67 schuur 1.1
|
68 konrad.r 1.13 static CMPIArgs* argsClone(const CMPIArgs* eArg, CMPIStatus* rc) {
|
69 schuur 1.10 Array<CIMParamValue>* arg=(Array<CIMParamValue>*)eArg->hdl;
70 Array<CIMParamValue>* cArg=new Array<CIMParamValue>();
71 for (long i=0,s=arg->size(); i<s; i++) {
72 const CIMParamValue &v=(*arg)[i];
73 cArg->append(v.clone());
74 }
75 CMPI_Object* obj=new CMPI_Object(cArg);
76 obj->unlink();
|
77 mreddy 1.20 CMPIArgs* neArg=reinterpret_cast<CMPIArgs*>(obj);
|
78 schuur 1.10 if (rc) CMSetStatus(rc,CMPI_RC_OK);
79 return neArg;
80 }
|
81 schuur 1.1
|
82 schuur 1.10 static long locateArg(const Array<CIMParamValue> &a, const CIMName &eName) {
83 for (long i=0,s=a.size(); i<s; i++) {
84 const String &n=a[i].getParameterName();
85 if (String::equalNoCase(n,eName.getString())) return i;
86 }
87 return -1;
|
88 schuur 1.1 }
89
|
90 konrad.r 1.16 static CMPIStatus argsAddArg(const CMPIArgs* eArg, const char *name, const CMPIValue* data, CMPIType type) {
|
91 schuur 1.10 Array<CIMParamValue>* arg=(Array<CIMParamValue>*)eArg->hdl;
92 CMPIrc rc;
93 CIMValue v=value2CIMValue(data,type,&rc);
94 CIMName sName(name);
95
96 long i=locateArg(*arg,sName);
97 if (i>=0) arg->remove(i);
|
98 schuur 1.1
|
99 schuur 1.10 arg->append(CIMParamValue(sName.getString(),v));
100 CMReturn(CMPI_RC_OK);
101 }
|
102 schuur 1.1
|
103 konrad.r 1.13 static CMPIData argsGetArgAt(const CMPIArgs* eArg, CMPICount pos,
104 CMPIString** name,
105 CMPIStatus* rc) {
106
|
107 schuur 1.10 Array<CIMParamValue>* arg=(Array<CIMParamValue>*)eArg->hdl;
108 CMPIData data={0,CMPI_nullValue | CMPI_notFound,{0}};
109
110 if (pos>arg->size()) {
111 if (rc) CMSetStatus(rc,CMPI_RC_ERR_NOT_FOUND);
112 return data;
113 }
|
114 schuur 1.1
|
115 schuur 1.10 CIMValue v=(*arg)[pos].getValue();
116 CIMType pType=v.getType();
117 CMPIType t=type2CMPIType(pType,v.isArray());
118
119 value2CMPIData(v,t,&data);
120
121 if (name) {
122 String n=(*arg)[pos].getParameterName();
123 *name=(CMPIString*)string2CMPIString(n);
124 }
|
125 schuur 1.1
|
126 schuur 1.10 if (rc) CMSetStatus(rc,CMPI_RC_OK);
|
127 schuur 1.1 return data;
128 }
129
|
130 konrad.r 1.13 static CMPIData argsGetArg(const CMPIArgs* eArg, const char *name, CMPIStatus* rc) {
|
131 schuur 1.10 Array<CIMParamValue>* arg=(Array<CIMParamValue>*)eArg->hdl;
|
132 r.kieninger 1.18 CIMNameUnchecked eName(name);
|
133 schuur 1.1
|
134 schuur 1.10 long i=locateArg(*arg,eName);
135 if (i>=0) return argsGetArgAt(eArg,i,NULL,rc);
|
136 schuur 1.1
|
137 schuur 1.10 CMPIData data={0,CMPI_nullValue | CMPI_notFound,{0}};
138 if (rc) CMSetStatus(rc,CMPI_RC_ERR_NOT_FOUND);
139 return data;
|
140 schuur 1.1 }
141
|
142 konrad.r 1.13 static CMPICount argsGetArgCount(const CMPIArgs* eArg, CMPIStatus* rc) {
|
143 schuur 1.10 Array<CIMParamValue>* arg=(Array<CIMParamValue>*)eArg->hdl;
144 if (rc) CMSetStatus(rc,CMPI_RC_OK);
145 return arg->size();
146 }
|
147 schuur 1.1
148 }
149
150 static CMPIArgsFT args_FT={
151 CMPICurrentVersion,
152 argsRelease,
153 argsClone,
154 argsAddArg,
155 argsGetArg,
156 argsGetArgAt,
157 argsGetArgCount,
158 };
159
160 CMPIArgsFT *CMPI_Args_Ftab=&args_FT;
161
162 static CMPIArgsFT argsOnStack_FT={
163 CMPICurrentVersion,
164 argsReleaseNop,
165 argsClone,
166 argsAddArg,
167 argsGetArg,
168 schuur 1.1 argsGetArgAt,
169 argsGetArgCount,
170 };
171
172 CMPIArgsFT *CMPI_ArgsOnStack_Ftab=&argsOnStack_FT;
173
174
175
176 // CMPIContext Session
177
|
178 schuur 1.10 extern "C" {
179
|
180 schuur 1.1 static CMPIStatus contextReleaseNop(CMPIContext* eCtx) {
181 CMReturn(CMPI_RC_OK);
182 }
183
|
184 konrad.r 1.13 static CMPIData contextGetEntry(const CMPIContext* eCtx, const char *name, CMPIStatus* rc) {
|
185 mreddy 1.20 return argsGetArg(reinterpret_cast<const CMPIArgs*>(eCtx),name,rc);
|
186 schuur 1.10 }
|
187 schuur 1.1
|
188 konrad.r 1.13 CMPIData contextGetEntryAt(const CMPIContext* eCtx, CMPICount pos,
|
189 schuur 1.10 CMPIString** name, CMPIStatus* rc) {
|
190 mreddy 1.20 return argsGetArgAt(reinterpret_cast<const CMPIArgs*>(eCtx),pos,name,rc);
|
191 schuur 1.10 }
192
|
193 konrad.r 1.13 static CMPICount contextGetEntryCount(const CMPIContext* eCtx, CMPIStatus* rc) {
|
194 mreddy 1.20 return argsGetArgCount(reinterpret_cast<const CMPIArgs*>(eCtx),rc);
|
195 schuur 1.10 }
196
|
197 konrad.r 1.13 static CMPIStatus contextAddEntry(const CMPIContext* eCtx, const char *name,
|
198 konrad.r 1.16 const CMPIValue* data, CMPIType type) {
|
199 schuur 1.10 if (strcmp(name,SnmpTrapOidContainer::NAME.getCString())==0) {
200 OperationContext *ctx=((CMPI_Context*)eCtx)->ctx;
201 if (type==CMPI_chars) {
202 ctx->insert(SnmpTrapOidContainer((char*)data));
203 CMReturn(CMPI_RC_OK);
204 }
205 else if (type==CMPI_string) {
206 ctx->insert(SnmpTrapOidContainer((char*)data->string->hdl));
207 CMReturn(CMPI_RC_OK);
208 }
|
209 schuur 1.4 }
|
210 mreddy 1.20 return argsAddArg(reinterpret_cast<const CMPIArgs*>(eCtx),name,data,type);
|
211 schuur 1.4 }
|
212 schuur 1.10
|
213 schuur 1.1 }
214
215 static CMPIContextFT context_FT={
216 CMPICurrentVersion,
217 contextReleaseNop,
218 NULL,
219 contextGetEntry,
220 contextGetEntryAt,
221 contextGetEntryCount,
222 contextAddEntry,
223 };
224
225 CMPIContextFT *CMPI_Context_Ftab=&context_FT;
226
227 static CMPIContextFT contextOnStack_FT={
228 CMPICurrentVersion,
229 contextReleaseNop,
230 NULL,
231 contextGetEntry,
232 contextGetEntryAt,
233 contextGetEntryCount,
234 schuur 1.1 contextAddEntry,
235 };
236
237 CMPIContextFT *CMPI_ContextOnStack_Ftab=&contextOnStack_FT;
238
239
240 CMPI_Context::CMPI_Context(const OperationContext& ct) {
241 ctx=(OperationContext*)&ct;
242 thr=NULL;
243 hdl=(void*)new Array<CIMParamValue>();
244 ft=CMPI_Context_Ftab;
245 }
|
246 konrad.r 1.17 CMPI_Context::~CMPI_Context() {
247 delete (Array<CIMParamValue>*)hdl;
248 delete ctx;
249 }
|
250 schuur 1.1 CMPI_ContextOnStack::CMPI_ContextOnStack(const OperationContext& ct) {
251 ctx=(OperationContext*)&ct;
252 hdl=(void*)new Array<CIMParamValue>();
253 ft=CMPI_ContextOnStack_Ftab;
254 }
255
256 CMPI_ContextOnStack::~CMPI_ContextOnStack() {
257 delete (Array<CIMParamValue>*)hdl;
258 }
259
260 CMPI_ArgsOnStack::CMPI_ArgsOnStack(const Array<CIMParamValue>& args) {
261 hdl=(void*)&args;
262 ft=CMPI_ArgsOnStack_Ftab;
263 }
264
265 PEGASUS_NAMESPACE_END
266
267
268
269
270
271 schuur 1.1
272
|