1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate * CDDL HEADER START
3*0Sstevel@tonic-gate *
4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
7*0Sstevel@tonic-gate * with the License.
8*0Sstevel@tonic-gate *
9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate * and limitations under the License.
13*0Sstevel@tonic-gate *
14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate *
20*0Sstevel@tonic-gate * CDDL HEADER END
21*0Sstevel@tonic-gate */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
24*0Sstevel@tonic-gate * Use is subject to license terms.
25*0Sstevel@tonic-gate */
26*0Sstevel@tonic-gate
27*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
28*0Sstevel@tonic-gate
29*0Sstevel@tonic-gate #include <pthread.h>
30*0Sstevel@tonic-gate
31*0Sstevel@tonic-gate #include "master.h"
32*0Sstevel@tonic-gate #include "util.h"
33*0Sstevel@tonic-gate #include "providerNames.h"
34*0Sstevel@tonic-gate #include "messageStrings.h"
35*0Sstevel@tonic-gate
36*0Sstevel@tonic-gate /* local function declarations */
37*0Sstevel@tonic-gate static int FindClassEntry(char *className);
38*0Sstevel@tonic-gate static int FindAssocClassEntry(char *className);
39*0Sstevel@tonic-gate
40*0Sstevel@tonic-gate
41*0Sstevel@tonic-gate /*
42*0Sstevel@tonic-gate * Encodes the CIM schema and provider version
43*0Sstevel@tonic-gate * into an unsigned long, use
44*0Sstevel@tonic-gate * getProviderVersion & getCimVersion to decode
45*0Sstevel@tonic-gate */
46*0Sstevel@tonic-gate
47*0Sstevel@tonic-gate unsigned long
cp_getVersion()48*0Sstevel@tonic-gate cp_getVersion()
49*0Sstevel@tonic-gate {
50*0Sstevel@tonic-gate return (MAKEVERSION(1.0, 2.3));
51*0Sstevel@tonic-gate }
52*0Sstevel@tonic-gate
53*0Sstevel@tonic-gate
54*0Sstevel@tonic-gate /*
55*0Sstevel@tonic-gate * The function will take CCIMObjectPath
56*0Sstevel@tonic-gate * and search the classNameTable[]
57*0Sstevel@tonic-gate * for a className match, and then
58*0Sstevel@tonic-gate * call the corresponding cp_enumInstance
59*0Sstevel@tonic-gate * for that provider
60*0Sstevel@tonic-gate */
61*0Sstevel@tonic-gate
62*0Sstevel@tonic-gate CCIMInstanceList*
cp_enumInstances(CCIMObjectPath * pOP)63*0Sstevel@tonic-gate cp_enumInstances(CCIMObjectPath* pOP)
64*0Sstevel@tonic-gate {
65*0Sstevel@tonic-gate CCIMInstanceList *instList = NULL;
66*0Sstevel@tonic-gate int index = 0;
67*0Sstevel@tonic-gate int error;
68*0Sstevel@tonic-gate
69*0Sstevel@tonic-gate /* Check if ObjectPath is NULL before continuing */
70*0Sstevel@tonic-gate if (pOP == NULL) {
71*0Sstevel@tonic-gate /* Set error exception with localized message */
72*0Sstevel@tonic-gate util_handleError(ENUM_INSTANCES, CIM_ERR_INVALID_PARAMETER,
73*0Sstevel@tonic-gate NULL, NULL, &error);
74*0Sstevel@tonic-gate return (NULL);
75*0Sstevel@tonic-gate }
76*0Sstevel@tonic-gate
77*0Sstevel@tonic-gate /* Object path is NOT NULL, so find the entry in the table */
78*0Sstevel@tonic-gate index = FindClassEntry(pOP->mName);
79*0Sstevel@tonic-gate
80*0Sstevel@tonic-gate /* check for error (-1) */
81*0Sstevel@tonic-gate if (index < 0) {
82*0Sstevel@tonic-gate util_handleError(ENUM_INSTANCES, CIM_ERR_INVALID_CLASS,
83*0Sstevel@tonic-gate NULL, NULL, &error);
84*0Sstevel@tonic-gate return (NULL);
85*0Sstevel@tonic-gate }
86*0Sstevel@tonic-gate
87*0Sstevel@tonic-gate /* OK, Find enumInstance */
88*0Sstevel@tonic-gate instList = (*enumInstanceTable[index])(pOP);
89*0Sstevel@tonic-gate return ((CCIMInstanceList*)instList);
90*0Sstevel@tonic-gate
91*0Sstevel@tonic-gate } /* cp_enumInstances */
92*0Sstevel@tonic-gate
93*0Sstevel@tonic-gate /* creates an instance */
94*0Sstevel@tonic-gate
95*0Sstevel@tonic-gate /*
96*0Sstevel@tonic-gate * The function will take CCIMObjectPath & CCIMInstance
97*0Sstevel@tonic-gate * and search the classNameTable[]
98*0Sstevel@tonic-gate * for a className match, and then
99*0Sstevel@tonic-gate * call the corresponding cp_createInstance
100*0Sstevel@tonic-gate * for that provider
101*0Sstevel@tonic-gate */
102*0Sstevel@tonic-gate
103*0Sstevel@tonic-gate CCIMObjectPath*
cp_createInstance(CCIMObjectPath * pOP,CCIMInstance * pInst)104*0Sstevel@tonic-gate cp_createInstance(CCIMObjectPath* pOP, CCIMInstance* pInst)
105*0Sstevel@tonic-gate {
106*0Sstevel@tonic-gate CCIMObjectPath *objPath = NULL;
107*0Sstevel@tonic-gate int index = 0;
108*0Sstevel@tonic-gate int error;
109*0Sstevel@tonic-gate
110*0Sstevel@tonic-gate /* check if NULL before finding the Instance to create */
111*0Sstevel@tonic-gate if (pInst == NULL) {
112*0Sstevel@tonic-gate util_handleError(CREATE_INSTANCE,
113*0Sstevel@tonic-gate CIM_ERR_INVALID_PARAMETER, NULL, NULL, &error);
114*0Sstevel@tonic-gate return (NULL);
115*0Sstevel@tonic-gate }
116*0Sstevel@tonic-gate
117*0Sstevel@tonic-gate /* find entry in the table */
118*0Sstevel@tonic-gate index = FindClassEntry(pInst->mClassName);
119*0Sstevel@tonic-gate
120*0Sstevel@tonic-gate /* check for error (-1) */
121*0Sstevel@tonic-gate if (index < 0) {
122*0Sstevel@tonic-gate util_handleError(CREATE_INSTANCE,
123*0Sstevel@tonic-gate CIM_ERR_INVALID_CLASS, NULL, NULL, &error);
124*0Sstevel@tonic-gate return (NULL);
125*0Sstevel@tonic-gate }
126*0Sstevel@tonic-gate
127*0Sstevel@tonic-gate objPath = (*createInstanceTable[index])(pOP, pInst);
128*0Sstevel@tonic-gate
129*0Sstevel@tonic-gate return ((CCIMObjectPath*) objPath);
130*0Sstevel@tonic-gate
131*0Sstevel@tonic-gate } /* cp_createInstances */
132*0Sstevel@tonic-gate
133*0Sstevel@tonic-gate
134*0Sstevel@tonic-gate /*
135*0Sstevel@tonic-gate * returns an array of CCIMObjectPaths for the class
136*0Sstevel@tonic-gate * params:
137*0Sstevel@tonic-gate * char* - the classname to enum
138*0Sstevel@tonic-gate */
139*0Sstevel@tonic-gate
140*0Sstevel@tonic-gate CCIMObjectPathList*
cp_enumInstanceNames(CCIMObjectPath * pOP)141*0Sstevel@tonic-gate cp_enumInstanceNames(CCIMObjectPath* pOP)
142*0Sstevel@tonic-gate {
143*0Sstevel@tonic-gate CCIMObjectPathList *objList = NULL;
144*0Sstevel@tonic-gate CCIMInstanceList *instList = NULL;
145*0Sstevel@tonic-gate int error = 0;
146*0Sstevel@tonic-gate
147*0Sstevel@tonic-gate /*
148*0Sstevel@tonic-gate * create an instance list which contains all of the
149*0Sstevel@tonic-gate * instances this provider will produce First check
150*0Sstevel@tonic-gate * for valid ObjectPath
151*0Sstevel@tonic-gate */
152*0Sstevel@tonic-gate if (pOP == NULL) {
153*0Sstevel@tonic-gate util_handleError(ENUM_INSTANCENAMES,
154*0Sstevel@tonic-gate CIM_ERR_INVALID_PARAMETER, NULL, NULL, &error);
155*0Sstevel@tonic-gate return (NULL);
156*0Sstevel@tonic-gate }
157*0Sstevel@tonic-gate
158*0Sstevel@tonic-gate instList = cp_enumInstances(pOP);
159*0Sstevel@tonic-gate
160*0Sstevel@tonic-gate if (instList == NULL) {
161*0Sstevel@tonic-gate return ((CCIMObjectPathList *)NULL);
162*0Sstevel@tonic-gate }
163*0Sstevel@tonic-gate
164*0Sstevel@tonic-gate objList = cim_createObjectPathList(instList);
165*0Sstevel@tonic-gate
166*0Sstevel@tonic-gate /*
167*0Sstevel@tonic-gate * we no longer need the instList so free
168*0Sstevel@tonic-gate * the memory allocated for it
169*0Sstevel@tonic-gate */
170*0Sstevel@tonic-gate
171*0Sstevel@tonic-gate cim_freeInstanceList(instList);
172*0Sstevel@tonic-gate return (objList);
173*0Sstevel@tonic-gate }
174*0Sstevel@tonic-gate
175*0Sstevel@tonic-gate /* get an instance */
176*0Sstevel@tonic-gate
177*0Sstevel@tonic-gate CCIMInstance*
cp_getInstance(CCIMObjectPath * pOP)178*0Sstevel@tonic-gate cp_getInstance(CCIMObjectPath* pOP)
179*0Sstevel@tonic-gate {
180*0Sstevel@tonic-gate CCIMInstance* inst = NULL;
181*0Sstevel@tonic-gate int index = 0;
182*0Sstevel@tonic-gate int error;
183*0Sstevel@tonic-gate
184*0Sstevel@tonic-gate /* Check if ObjectPath is NULL before continuing */
185*0Sstevel@tonic-gate if (pOP == NULL) {
186*0Sstevel@tonic-gate util_handleError(GET_INSTANCE, CIM_ERR_INVALID_PARAMETER,
187*0Sstevel@tonic-gate NULL, NULL, &error);
188*0Sstevel@tonic-gate return (NULL);
189*0Sstevel@tonic-gate }
190*0Sstevel@tonic-gate
191*0Sstevel@tonic-gate /* Object path is NOT NULL, so find the entry in the table */
192*0Sstevel@tonic-gate index = FindClassEntry(pOP->mName);
193*0Sstevel@tonic-gate
194*0Sstevel@tonic-gate /* check for error (-1) */
195*0Sstevel@tonic-gate if (index < 0) {
196*0Sstevel@tonic-gate util_handleError(GET_INSTANCE, CIM_ERR_INVALID_CLASS, NULL,
197*0Sstevel@tonic-gate NULL, &error);
198*0Sstevel@tonic-gate return (NULL);
199*0Sstevel@tonic-gate }
200*0Sstevel@tonic-gate
201*0Sstevel@tonic-gate inst = (*getInstanceTable[index])(pOP);
202*0Sstevel@tonic-gate return ((CCIMInstance *)inst);
203*0Sstevel@tonic-gate }
204*0Sstevel@tonic-gate
205*0Sstevel@tonic-gate /*
206*0Sstevel@tonic-gate * returns the specified property,
207*0Sstevel@tonic-gate * should return NULL if not found
208*0Sstevel@tonic-gate *
209*0Sstevel@tonic-gate * params:
210*0Sstevel@tonic-gate * CCIMObjectPath* - ObjectPath to get the property from
211*0Sstevel@tonic-gate * char* - The property name to get
212*0Sstevel@tonic-gate *
213*0Sstevel@tonic-gate */
214*0Sstevel@tonic-gate
215*0Sstevel@tonic-gate CCIMProperty*
cp_getProperty(CCIMObjectPath * pOP,char * pPropName)216*0Sstevel@tonic-gate cp_getProperty(CCIMObjectPath *pOP, char *pPropName)
217*0Sstevel@tonic-gate {
218*0Sstevel@tonic-gate CCIMProperty* prop = NULL;
219*0Sstevel@tonic-gate CCIMInstance* inst = NULL;
220*0Sstevel@tonic-gate int error;
221*0Sstevel@tonic-gate
222*0Sstevel@tonic-gate /* See if ObjectPath is OK */
223*0Sstevel@tonic-gate if (pOP == NULL) {
224*0Sstevel@tonic-gate util_handleError(GET_PROPERTY, CIM_ERR_INVALID_PARAMETER,
225*0Sstevel@tonic-gate NULL, NULL, &error);
226*0Sstevel@tonic-gate return (NULL);
227*0Sstevel@tonic-gate }
228*0Sstevel@tonic-gate
229*0Sstevel@tonic-gate /* Make sure property name isn't NULL */
230*0Sstevel@tonic-gate if (pPropName == NULL) {
231*0Sstevel@tonic-gate util_handleError(GET_PROPERTY, CIM_ERR_INVALID_CLASS,
232*0Sstevel@tonic-gate NULL, NULL, &error);
233*0Sstevel@tonic-gate return (NULL);
234*0Sstevel@tonic-gate }
235*0Sstevel@tonic-gate
236*0Sstevel@tonic-gate /* see if we have any instances which match the obj path */
237*0Sstevel@tonic-gate inst = cp_getInstance(pOP);
238*0Sstevel@tonic-gate
239*0Sstevel@tonic-gate /* check for valid instance */
240*0Sstevel@tonic-gate if (inst == NULL) {
241*0Sstevel@tonic-gate util_handleError(GET_PROPERTY, CIM_ERR_FAILED,
242*0Sstevel@tonic-gate NULL, NULL, &error);
243*0Sstevel@tonic-gate return (NULL);
244*0Sstevel@tonic-gate }
245*0Sstevel@tonic-gate
246*0Sstevel@tonic-gate /* see if it has the specified property */
247*0Sstevel@tonic-gate prop = cim_getProperty(inst, pPropName);
248*0Sstevel@tonic-gate
249*0Sstevel@tonic-gate /* free memory allocated for the instance */
250*0Sstevel@tonic-gate cim_freeInstance(inst);
251*0Sstevel@tonic-gate
252*0Sstevel@tonic-gate /* return the property */
253*0Sstevel@tonic-gate return ((CCIMProperty *)prop);
254*0Sstevel@tonic-gate }
255*0Sstevel@tonic-gate
256*0Sstevel@tonic-gate /*
257*0Sstevel@tonic-gate * Sets the property in the passed in
258*0Sstevel@tonic-gate * instance to the new values of the
259*0Sstevel@tonic-gate * passed in property
260*0Sstevel@tonic-gate *
261*0Sstevel@tonic-gate * params:
262*0Sstevel@tonic-gate * CCIMObjectPath* - the Object Path in which the property should be changed
263*0Sstevel@tonic-gate * CCIMProperty* - a property structure which contains the new values
264*0Sstevel@tonic-gate *
265*0Sstevel@tonic-gate * return:
266*0Sstevel@tonic-gate * cim_true if property was updated otherwise cim_false
267*0Sstevel@tonic-gate *
268*0Sstevel@tonic-gate *
269*0Sstevel@tonic-gate * The function will take CCIMObjectPath & CCIMProperty
270*0Sstevel@tonic-gate * and search the classNameTable[]
271*0Sstevel@tonic-gate * for a className match, and then
272*0Sstevel@tonic-gate * call the corresponding setProperty
273*0Sstevel@tonic-gate * for that provider
274*0Sstevel@tonic-gate */
275*0Sstevel@tonic-gate
276*0Sstevel@tonic-gate CIMBool
cp_setProperty(CCIMObjectPath * pObjPath,CCIMProperty * pProp)277*0Sstevel@tonic-gate cp_setProperty(CCIMObjectPath* pObjPath, CCIMProperty* pProp)
278*0Sstevel@tonic-gate {
279*0Sstevel@tonic-gate CIMBool retVal;
280*0Sstevel@tonic-gate int index = 0;
281*0Sstevel@tonic-gate int error;
282*0Sstevel@tonic-gate
283*0Sstevel@tonic-gate if (pObjPath == NULL) {
284*0Sstevel@tonic-gate util_handleError(SET_PROPERTY, CIM_ERR_INVALID_PARAMETER,
285*0Sstevel@tonic-gate NULL, NULL, &error);
286*0Sstevel@tonic-gate return (NULL);
287*0Sstevel@tonic-gate }
288*0Sstevel@tonic-gate
289*0Sstevel@tonic-gate index = FindClassEntry(pObjPath->mName);
290*0Sstevel@tonic-gate
291*0Sstevel@tonic-gate /* check for error (-1) */
292*0Sstevel@tonic-gate if (index < 0) {
293*0Sstevel@tonic-gate util_handleError(SET_PROPERTY, CIM_ERR_INVALID_CLASS,
294*0Sstevel@tonic-gate NULL, NULL, &error);
295*0Sstevel@tonic-gate return (NULL);
296*0Sstevel@tonic-gate }
297*0Sstevel@tonic-gate
298*0Sstevel@tonic-gate retVal = (*setPropertyTable[index])(pObjPath, pProp);
299*0Sstevel@tonic-gate return ((CIMBool)retVal);
300*0Sstevel@tonic-gate }
301*0Sstevel@tonic-gate
302*0Sstevel@tonic-gate
303*0Sstevel@tonic-gate /* sets an instance */
304*0Sstevel@tonic-gate
305*0Sstevel@tonic-gate /*
306*0Sstevel@tonic-gate * The function will take CCIMObjectPath & CCIMInstance
307*0Sstevel@tonic-gate * and search the classNameTable[]
308*0Sstevel@tonic-gate * for a className match, and then
309*0Sstevel@tonic-gate * call the corresponding cp_setInstance
310*0Sstevel@tonic-gate * for that provider
311*0Sstevel@tonic-gate */
312*0Sstevel@tonic-gate
313*0Sstevel@tonic-gate CIMBool
cp_setInstance(CCIMObjectPath * pOP,CCIMInstance * pInst)314*0Sstevel@tonic-gate cp_setInstance(CCIMObjectPath* pOP, CCIMInstance* pInst)
315*0Sstevel@tonic-gate {
316*0Sstevel@tonic-gate CIMBool retVal;
317*0Sstevel@tonic-gate int index = 0;
318*0Sstevel@tonic-gate int error;
319*0Sstevel@tonic-gate
320*0Sstevel@tonic-gate if (pOP == NULL) {
321*0Sstevel@tonic-gate util_handleError(SET_INSTANCE, CIM_ERR_INVALID_PARAMETER,
322*0Sstevel@tonic-gate NULL, NULL, &error);
323*0Sstevel@tonic-gate return (NULL);
324*0Sstevel@tonic-gate }
325*0Sstevel@tonic-gate
326*0Sstevel@tonic-gate if (pInst == NULL) {
327*0Sstevel@tonic-gate util_handleError(SET_INSTANCE, CIM_ERR_INVALID_CLASS,
328*0Sstevel@tonic-gate NULL, NULL, &error);
329*0Sstevel@tonic-gate return (NULL);
330*0Sstevel@tonic-gate }
331*0Sstevel@tonic-gate
332*0Sstevel@tonic-gate /* get the index into the table */
333*0Sstevel@tonic-gate index = FindClassEntry(pInst->mClassName);
334*0Sstevel@tonic-gate
335*0Sstevel@tonic-gate /* check for error (-1) */
336*0Sstevel@tonic-gate if (index < 0) {
337*0Sstevel@tonic-gate util_handleError(SET_INSTANCE, CIM_ERR_INVALID_CLASS,
338*0Sstevel@tonic-gate NULL, NULL, &error);
339*0Sstevel@tonic-gate return (NULL);
340*0Sstevel@tonic-gate }
341*0Sstevel@tonic-gate
342*0Sstevel@tonic-gate retVal = (*setInstanceTable[index])(pOP, pInst);
343*0Sstevel@tonic-gate return ((CIMBool)retVal);
344*0Sstevel@tonic-gate }
345*0Sstevel@tonic-gate
346*0Sstevel@tonic-gate
347*0Sstevel@tonic-gate /*
348*0Sstevel@tonic-gate * deletes an instance
349*0Sstevel@tonic-gate *
350*0Sstevel@tonic-gate * The function will take CCIMObjectPath
351*0Sstevel@tonic-gate * and search the classNameTable[]
352*0Sstevel@tonic-gate * for a className match, and then
353*0Sstevel@tonic-gate * call the corresponding cp_deleteInstance
354*0Sstevel@tonic-gate * for that provider
355*0Sstevel@tonic-gate */
356*0Sstevel@tonic-gate
357*0Sstevel@tonic-gate CIMBool
cp_deleteInstance(CCIMObjectPath * pOP)358*0Sstevel@tonic-gate cp_deleteInstance(CCIMObjectPath* pOP)
359*0Sstevel@tonic-gate {
360*0Sstevel@tonic-gate CIMBool retVal;
361*0Sstevel@tonic-gate int index = 0;
362*0Sstevel@tonic-gate int error;
363*0Sstevel@tonic-gate
364*0Sstevel@tonic-gate /* Verify ObjectPath is NOT NULL */
365*0Sstevel@tonic-gate if (pOP == NULL) {
366*0Sstevel@tonic-gate util_handleError(DELETE_INSTANCE, CIM_ERR_INVALID_PARAMETER,
367*0Sstevel@tonic-gate NULL, NULL, &error);
368*0Sstevel@tonic-gate return (NULL);
369*0Sstevel@tonic-gate }
370*0Sstevel@tonic-gate
371*0Sstevel@tonic-gate /* find Entry in table */
372*0Sstevel@tonic-gate index = FindClassEntry(pOP->mName);
373*0Sstevel@tonic-gate
374*0Sstevel@tonic-gate /* check for error (-1) */
375*0Sstevel@tonic-gate if (index < 0) {
376*0Sstevel@tonic-gate util_handleError(DELETE_INSTANCE, CIM_ERR_INVALID_CLASS,
377*0Sstevel@tonic-gate NULL, NULL, &error);
378*0Sstevel@tonic-gate return (NULL);
379*0Sstevel@tonic-gate }
380*0Sstevel@tonic-gate
381*0Sstevel@tonic-gate retVal = (*deleteInstanceTable[index])(pOP);
382*0Sstevel@tonic-gate return ((CIMBool)retVal);
383*0Sstevel@tonic-gate }
384*0Sstevel@tonic-gate
385*0Sstevel@tonic-gate /*
386*0Sstevel@tonic-gate * Invokes the method and returns the results
387*0Sstevel@tonic-gate * The caller is responsible for freeing the
388*0Sstevel@tonic-gate * memory allocated for the returned object
389*0Sstevel@tonic-gate *
390*0Sstevel@tonic-gate * params:
391*0Sstevel@tonic-gate * CCIMObjectPath* - An object path of the instance
392*0Sstevel@tonic-gate * to invoke the function on
393*0Sstevel@tonic-gate * char* - name of the method to invoke
394*0Sstevel@tonic-gate * CCIMPropertyList* - input parameters to the function
395*0Sstevel@tonic-gate * CCIMPropertyList* - input/output parameters to the function
396*0Sstevel@tonic-gate *
397*0Sstevel@tonic-gate * returns:
398*0Sstevel@tonic-gate * NULL if it failed otherwise a CCIMProperty*
399*0Sstevel@tonic-gate * which represents the return value of the function
400*0Sstevel@tonic-gate */
401*0Sstevel@tonic-gate
402*0Sstevel@tonic-gate CCIMProperty*
cp_invokeMethod(CCIMObjectPath * pOP,cimchar * pName,CCIMPropertyList * pInParams,CCIMPropertyList * pInOutParams)403*0Sstevel@tonic-gate cp_invokeMethod(CCIMObjectPath* pOP, cimchar* pName,
404*0Sstevel@tonic-gate CCIMPropertyList* pInParams, CCIMPropertyList* pInOutParams)
405*0Sstevel@tonic-gate {
406*0Sstevel@tonic-gate CCIMProperty *prop;
407*0Sstevel@tonic-gate int index = 0;
408*0Sstevel@tonic-gate int error;
409*0Sstevel@tonic-gate
410*0Sstevel@tonic-gate /* First check for valid ObjectPath */
411*0Sstevel@tonic-gate if (pOP == NULL) {
412*0Sstevel@tonic-gate util_handleError(INVOKE_METHOD, CIM_ERR_INVALID_PARAMETER,
413*0Sstevel@tonic-gate NULL, NULL, &error);
414*0Sstevel@tonic-gate return (NULL);
415*0Sstevel@tonic-gate }
416*0Sstevel@tonic-gate
417*0Sstevel@tonic-gate /* find entry in the table */
418*0Sstevel@tonic-gate index = FindClassEntry(pOP->mName);
419*0Sstevel@tonic-gate
420*0Sstevel@tonic-gate /* check for error (-1) */
421*0Sstevel@tonic-gate if (index < 0) {
422*0Sstevel@tonic-gate util_handleError(INVOKE_METHOD, CIM_ERR_INVALID_CLASS,
423*0Sstevel@tonic-gate NULL, NULL, &error);
424*0Sstevel@tonic-gate return (NULL);
425*0Sstevel@tonic-gate }
426*0Sstevel@tonic-gate
427*0Sstevel@tonic-gate prop = (*cpInvokeMethodTable[index])
428*0Sstevel@tonic-gate (pOP, pName, pInParams, pInOutParams);
429*0Sstevel@tonic-gate
430*0Sstevel@tonic-gate return ((CCIMProperty*)prop);
431*0Sstevel@tonic-gate }
432*0Sstevel@tonic-gate
433*0Sstevel@tonic-gate /*
434*0Sstevel@tonic-gate * cp_execQuery
435*0Sstevel@tonic-gate */
436*0Sstevel@tonic-gate
437*0Sstevel@tonic-gate CCIMInstanceList*
cp_execQuery(CCIMObjectPath * pOP,char * selectList,char * nonJoinExp,char * queryExp,char * queryType)438*0Sstevel@tonic-gate cp_execQuery(CCIMObjectPath *pOP, char *selectList,
439*0Sstevel@tonic-gate char *nonJoinExp, char *queryExp, char *queryType)
440*0Sstevel@tonic-gate {
441*0Sstevel@tonic-gate CCIMInstanceList *instList = NULL;
442*0Sstevel@tonic-gate int index = 0;
443*0Sstevel@tonic-gate int error = 0;
444*0Sstevel@tonic-gate
445*0Sstevel@tonic-gate
446*0Sstevel@tonic-gate /* First check for valid ObjectPath */
447*0Sstevel@tonic-gate if (pOP == NULL) {
448*0Sstevel@tonic-gate util_handleError(EXEC_QUERY, CIM_ERR_INVALID_PARAMETER, NULL, NULL,
449*0Sstevel@tonic-gate &error);
450*0Sstevel@tonic-gate return ((CCIMInstanceList *)NULL);
451*0Sstevel@tonic-gate }
452*0Sstevel@tonic-gate
453*0Sstevel@tonic-gate /* find entry in the table */
454*0Sstevel@tonic-gate index = FindClassEntry(pOP->mName);
455*0Sstevel@tonic-gate
456*0Sstevel@tonic-gate /* check for error (-1) */
457*0Sstevel@tonic-gate if (index < 0) {
458*0Sstevel@tonic-gate /* Set error exception with localized message */
459*0Sstevel@tonic-gate util_handleError(EXEC_QUERY, CIM_ERR_INVALID_CLASS, NULL,
460*0Sstevel@tonic-gate NULL, &error);
461*0Sstevel@tonic-gate return ((CCIMInstanceList *)NULL);
462*0Sstevel@tonic-gate }
463*0Sstevel@tonic-gate instList = (*execQueryTable[index])(pOP, selectList, nonJoinExp,
464*0Sstevel@tonic-gate queryExp, queryType);
465*0Sstevel@tonic-gate
466*0Sstevel@tonic-gate return (instList);
467*0Sstevel@tonic-gate }
468*0Sstevel@tonic-gate
469*0Sstevel@tonic-gate /*
470*0Sstevel@tonic-gate * cp_associators
471*0Sstevel@tonic-gate */
472*0Sstevel@tonic-gate
473*0Sstevel@tonic-gate CCIMInstanceList*
cp_associators(CCIMObjectPath * pAssocName,CCIMObjectPath * pObjectName,char * pResultClass,char * pRole,char * pResultRole)474*0Sstevel@tonic-gate cp_associators(CCIMObjectPath *pAssocName, CCIMObjectPath *pObjectName,
475*0Sstevel@tonic-gate char *pResultClass, char *pRole, char *pResultRole)
476*0Sstevel@tonic-gate {
477*0Sstevel@tonic-gate CCIMInstanceList *instList;
478*0Sstevel@tonic-gate int index = 0;
479*0Sstevel@tonic-gate int error = 0;
480*0Sstevel@tonic-gate
481*0Sstevel@tonic-gate /* First check for valid ObjectPath */
482*0Sstevel@tonic-gate if (pAssocName == NULL) {
483*0Sstevel@tonic-gate /* Set error exception with localized message */
484*0Sstevel@tonic-gate util_handleError(ASSOCIATORS, CIM_ERR_INVALID_PARAMETER, NULL,
485*0Sstevel@tonic-gate NULL, &error);
486*0Sstevel@tonic-gate return ((CCIMInstanceList *)NULL);
487*0Sstevel@tonic-gate }
488*0Sstevel@tonic-gate
489*0Sstevel@tonic-gate /* find entry in the table */
490*0Sstevel@tonic-gate index = FindAssocClassEntry(pAssocName->mName);
491*0Sstevel@tonic-gate
492*0Sstevel@tonic-gate /* check for error (-1) */
493*0Sstevel@tonic-gate if (index < 0) {
494*0Sstevel@tonic-gate /* Set error exception with localized message */
495*0Sstevel@tonic-gate util_handleError(ASSOCIATORS, CIM_ERR_INVALID_CLASS, NULL,
496*0Sstevel@tonic-gate NULL, &error);
497*0Sstevel@tonic-gate return ((CCIMInstanceList *)NULL);
498*0Sstevel@tonic-gate }
499*0Sstevel@tonic-gate
500*0Sstevel@tonic-gate /*
501*0Sstevel@tonic-gate * Call the appropriate associator function. Let the specific function
502*0Sstevel@tonic-gate * in the c provider handle the checking for correctness of the
503*0Sstevel@tonic-gate * other parameters.
504*0Sstevel@tonic-gate */
505*0Sstevel@tonic-gate
506*0Sstevel@tonic-gate instList = (*associatorsTable[index])(pAssocName, pObjectName,
507*0Sstevel@tonic-gate pResultClass, pRole, pResultRole);
508*0Sstevel@tonic-gate return ((CCIMInstanceList *)instList);
509*0Sstevel@tonic-gate }
510*0Sstevel@tonic-gate
511*0Sstevel@tonic-gate /*
512*0Sstevel@tonic-gate * cp_associatorNames
513*0Sstevel@tonic-gate */
514*0Sstevel@tonic-gate
515*0Sstevel@tonic-gate CCIMObjectPathList*
cp_associatorNames(CCIMObjectPath * pAssocName,CCIMObjectPath * pObjectName,char * pResultClass,char * pRole,char * pResultRole)516*0Sstevel@tonic-gate cp_associatorNames(CCIMObjectPath *pAssocName, CCIMObjectPath *pObjectName,
517*0Sstevel@tonic-gate char *pResultClass, char *pRole, char *pResultRole)
518*0Sstevel@tonic-gate {
519*0Sstevel@tonic-gate CCIMObjectPathList *objList;
520*0Sstevel@tonic-gate int index = 0;
521*0Sstevel@tonic-gate int error = 0;
522*0Sstevel@tonic-gate
523*0Sstevel@tonic-gate /* First check for valid ObjectPath */
524*0Sstevel@tonic-gate if (pAssocName == NULL) {
525*0Sstevel@tonic-gate /* Set error exception with localized message */
526*0Sstevel@tonic-gate util_handleError(ASSOCIATORS, CIM_ERR_INVALID_PARAMETER, NULL,
527*0Sstevel@tonic-gate NULL, &error);
528*0Sstevel@tonic-gate return ((CCIMObjectPathList *)NULL);
529*0Sstevel@tonic-gate }
530*0Sstevel@tonic-gate
531*0Sstevel@tonic-gate /* find entry in the table */
532*0Sstevel@tonic-gate index = FindAssocClassEntry(pAssocName->mName);
533*0Sstevel@tonic-gate
534*0Sstevel@tonic-gate /* check for error (-1) */
535*0Sstevel@tonic-gate if (index < 0) {
536*0Sstevel@tonic-gate /* Set error exception with localized message */
537*0Sstevel@tonic-gate util_handleError(ASSOCIATORS, CIM_ERR_INVALID_CLASS, NULL,
538*0Sstevel@tonic-gate NULL, &error);
539*0Sstevel@tonic-gate return ((CCIMObjectPathList *)NULL);
540*0Sstevel@tonic-gate }
541*0Sstevel@tonic-gate
542*0Sstevel@tonic-gate /*
543*0Sstevel@tonic-gate * Call the appropriate associatorName function. Let the specific
544*0Sstevel@tonic-gate * function in the c provider handle the checking for correctness of
545*0Sstevel@tonic-gate * the other parameters.
546*0Sstevel@tonic-gate */
547*0Sstevel@tonic-gate
548*0Sstevel@tonic-gate objList = (*associatorNamesTable[index])(pAssocName, pObjectName,
549*0Sstevel@tonic-gate pResultClass, pRole, pResultRole);
550*0Sstevel@tonic-gate return ((CCIMObjectPathList *)objList);
551*0Sstevel@tonic-gate }
552*0Sstevel@tonic-gate
553*0Sstevel@tonic-gate /*
554*0Sstevel@tonic-gate * cp_references
555*0Sstevel@tonic-gate */
556*0Sstevel@tonic-gate
557*0Sstevel@tonic-gate CCIMInstanceList*
cp_references(CCIMObjectPath * pAssocName,CCIMObjectPath * pObjectName,char * pRole)558*0Sstevel@tonic-gate cp_references(CCIMObjectPath *pAssocName, CCIMObjectPath *pObjectName,
559*0Sstevel@tonic-gate char *pRole)
560*0Sstevel@tonic-gate {
561*0Sstevel@tonic-gate CCIMInstanceList *instList;
562*0Sstevel@tonic-gate int index = 0;
563*0Sstevel@tonic-gate int error = 0;
564*0Sstevel@tonic-gate
565*0Sstevel@tonic-gate /* First check for valid ObjectPath */
566*0Sstevel@tonic-gate if (pAssocName == NULL) {
567*0Sstevel@tonic-gate /* Set error exception with localized message */
568*0Sstevel@tonic-gate util_handleError(REFERENCES, CIM_ERR_INVALID_PARAMETER, NULL,
569*0Sstevel@tonic-gate NULL, &error);
570*0Sstevel@tonic-gate return ((CCIMInstanceList *)NULL);
571*0Sstevel@tonic-gate }
572*0Sstevel@tonic-gate
573*0Sstevel@tonic-gate /* find entry in the table */
574*0Sstevel@tonic-gate index = FindAssocClassEntry(pAssocName->mName);
575*0Sstevel@tonic-gate
576*0Sstevel@tonic-gate /* check for error (-1) */
577*0Sstevel@tonic-gate if (index < 0) {
578*0Sstevel@tonic-gate /* Set error exception with localized message */
579*0Sstevel@tonic-gate util_handleError(REFERENCES, CIM_ERR_INVALID_CLASS, NULL,
580*0Sstevel@tonic-gate NULL, &error);
581*0Sstevel@tonic-gate return ((CCIMInstanceList *)NULL);
582*0Sstevel@tonic-gate }
583*0Sstevel@tonic-gate
584*0Sstevel@tonic-gate /*
585*0Sstevel@tonic-gate * Call the appropriate references function. Let the specific function
586*0Sstevel@tonic-gate * in the c provider handle the checking for correctness of the
587*0Sstevel@tonic-gate * other parameters.
588*0Sstevel@tonic-gate */
589*0Sstevel@tonic-gate
590*0Sstevel@tonic-gate instList = (*referencesTable[index])(pAssocName, pObjectName, pRole);
591*0Sstevel@tonic-gate return ((CCIMInstanceList *)instList);
592*0Sstevel@tonic-gate }
593*0Sstevel@tonic-gate
594*0Sstevel@tonic-gate /*
595*0Sstevel@tonic-gate * InParam: Class Name
596*0Sstevel@tonic-gate * Returns: Index into Name Table
597*0Sstevel@tonic-gate * If it hit libWBEMdisk, then we
598*0Sstevel@tonic-gate * have hit bottom, return err (-1)
599*0Sstevel@tonic-gate */
600*0Sstevel@tonic-gate
601*0Sstevel@tonic-gate static int
FindClassEntry(char * className)602*0Sstevel@tonic-gate FindClassEntry(char *className)
603*0Sstevel@tonic-gate {
604*0Sstevel@tonic-gate int i = 0;
605*0Sstevel@tonic-gate
606*0Sstevel@tonic-gate while (strcasecmp(className, classNameTable[i])) {
607*0Sstevel@tonic-gate if (!strcasecmp(classNameTable[i], "libWBEMdisk")) {
608*0Sstevel@tonic-gate i = -1;
609*0Sstevel@tonic-gate break;
610*0Sstevel@tonic-gate }
611*0Sstevel@tonic-gate i++;
612*0Sstevel@tonic-gate }
613*0Sstevel@tonic-gate
614*0Sstevel@tonic-gate return (i);
615*0Sstevel@tonic-gate }
616*0Sstevel@tonic-gate /*
617*0Sstevel@tonic-gate * InParam: Class Name
618*0Sstevel@tonic-gate * Returns: Index into Name Table
619*0Sstevel@tonic-gate * If it hit libWBEMdisk, then we
620*0Sstevel@tonic-gate * have hit bottom, return err (-1)
621*0Sstevel@tonic-gate */
622*0Sstevel@tonic-gate
623*0Sstevel@tonic-gate static int
FindAssocClassEntry(char * className)624*0Sstevel@tonic-gate FindAssocClassEntry(char *className)
625*0Sstevel@tonic-gate {
626*0Sstevel@tonic-gate int i = 0;
627*0Sstevel@tonic-gate
628*0Sstevel@tonic-gate while (strcasecmp(className, assocclassNameTable[i])) {
629*0Sstevel@tonic-gate if (!strcasecmp(assocclassNameTable[i], "libWBEMdisk")) {
630*0Sstevel@tonic-gate i = -1;
631*0Sstevel@tonic-gate break;
632*0Sstevel@tonic-gate }
633*0Sstevel@tonic-gate i++;
634*0Sstevel@tonic-gate }
635*0Sstevel@tonic-gate
636*0Sstevel@tonic-gate return (i);
637*0Sstevel@tonic-gate }
638*0Sstevel@tonic-gate
639*0Sstevel@tonic-gate /*
640*0Sstevel@tonic-gate * cp_referenceNames
641*0Sstevel@tonic-gate */
642*0Sstevel@tonic-gate
643*0Sstevel@tonic-gate CCIMObjectPathList*
cp_referenceNames(CCIMObjectPath * pAssocName,CCIMObjectPath * pObjectName,char * pRole)644*0Sstevel@tonic-gate cp_referenceNames(CCIMObjectPath *pAssocName, CCIMObjectPath *pObjectName,
645*0Sstevel@tonic-gate char *pRole)
646*0Sstevel@tonic-gate {
647*0Sstevel@tonic-gate CCIMObjectPathList *objList;
648*0Sstevel@tonic-gate int index = 0;
649*0Sstevel@tonic-gate int error = 0;
650*0Sstevel@tonic-gate
651*0Sstevel@tonic-gate /* First check for valid ObjectPath */
652*0Sstevel@tonic-gate if (pAssocName == NULL) {
653*0Sstevel@tonic-gate /* Set error exception with localized message */
654*0Sstevel@tonic-gate util_handleError(REFERENCE_NAMES, CIM_ERR_INVALID_PARAMETER,
655*0Sstevel@tonic-gate NULL, NULL, &error);
656*0Sstevel@tonic-gate return ((CCIMObjectPathList *)NULL);
657*0Sstevel@tonic-gate }
658*0Sstevel@tonic-gate
659*0Sstevel@tonic-gate /* find entry in the table */
660*0Sstevel@tonic-gate index = FindAssocClassEntry(pAssocName->mName);
661*0Sstevel@tonic-gate
662*0Sstevel@tonic-gate /* check for error (-1) */
663*0Sstevel@tonic-gate if (index < 0) {
664*0Sstevel@tonic-gate /* Set error exception with localized message */
665*0Sstevel@tonic-gate util_handleError(REFERENCE_NAMES, CIM_ERR_INVALID_CLASS,
666*0Sstevel@tonic-gate NULL, NULL, &error);
667*0Sstevel@tonic-gate return ((CCIMObjectPathList *)NULL);
668*0Sstevel@tonic-gate }
669*0Sstevel@tonic-gate
670*0Sstevel@tonic-gate /*
671*0Sstevel@tonic-gate * Call the appropriate referenceName function. Let the specific
672*0Sstevel@tonic-gate * function in the c provider handle the checking for correctness of
673*0Sstevel@tonic-gate * the other parameters.
674*0Sstevel@tonic-gate */
675*0Sstevel@tonic-gate
676*0Sstevel@tonic-gate objList = (*referenceNamesTable[index])(pAssocName, pObjectName, pRole);
677*0Sstevel@tonic-gate return ((CCIMObjectPathList *)objList);
678*0Sstevel@tonic-gate }
679*0Sstevel@tonic-gate
680*0Sstevel@tonic-gate CIMBool
cp_isAssociatorProvider(CCIMObjectPath * pOp)681*0Sstevel@tonic-gate cp_isAssociatorProvider(CCIMObjectPath *pOp)
682*0Sstevel@tonic-gate {
683*0Sstevel@tonic-gate
684*0Sstevel@tonic-gate int index = 0;
685*0Sstevel@tonic-gate int error = 0;
686*0Sstevel@tonic-gate
687*0Sstevel@tonic-gate /*
688*0Sstevel@tonic-gate * If the object path coming in matches any in the associator table,
689*0Sstevel@tonic-gate * return true, otherwise, return false.
690*0Sstevel@tonic-gate */
691*0Sstevel@tonic-gate
692*0Sstevel@tonic-gate /* First check for valid ObjectPath */
693*0Sstevel@tonic-gate if (pOp == NULL) {
694*0Sstevel@tonic-gate /* Set error exception with localized message */
695*0Sstevel@tonic-gate util_handleError(REFERENCE_NAMES, CIM_ERR_INVALID_PARAMETER,
696*0Sstevel@tonic-gate NULL, NULL, &error);
697*0Sstevel@tonic-gate return (cim_false);
698*0Sstevel@tonic-gate }
699*0Sstevel@tonic-gate
700*0Sstevel@tonic-gate /* find entry in the table */
701*0Sstevel@tonic-gate index = FindAssocClassEntry(pOp->mName);
702*0Sstevel@tonic-gate
703*0Sstevel@tonic-gate if (index < 0) {
704*0Sstevel@tonic-gate return (cim_false);
705*0Sstevel@tonic-gate }
706*0Sstevel@tonic-gate return (cim_true);
707*0Sstevel@tonic-gate }
708