2
* $Id: instance.c,v 1.40 2008/04/15 22:06:00 buccella Exp $
2
* $Id: instance.c,v 1.45 2008/11/21 20:23:51 mchasal Exp $
4
4
* © Copyright IBM Corp. 2005, 2007
60
60
extern const char *ClObjectGetClString(ClObjectHdr * hdr, ClString * id);
61
61
extern int sfcb_comp_CMPIValue(CMPIValue *val1, CMPIValue *val2, CMPIType type);
62
extern long addClString(ClObjectHdr * hdr, const char *str);
63
64
extern CMPIBroker *Broker;
278
279
CMReturn(CMPI_RC_OK);
282
static CMPIStatus __ift_setObjectPath(CMPIInstance * inst,
283
const CMPIObjectPath * cop)
285
CMPIStatus tmp1, tmp2, tmp3;
289
CMPIStatus rc = { CMPI_RC_OK, NULL };
291
/* get information out of objectpath */
293
j = CMGetKeyCount(cop, &tmp1);
294
str = CMGetClassName(cop, &tmp2);
295
cn = CMGetCharsPtr(str, NULL);
296
str = CMGetNameSpace(cop, &tmp3);
297
ns = CMGetCharsPtr(str, NULL);
300
/* there SHOULD be an op passed in, otherwise this call is useless.... */
303
//SFCB_ASM("int $3");
304
ns = "*NoNameSpace*";
305
cn = "*NoClassName*";
306
tmp1.rc=tmp2.rc=tmp3.rc=CMPI_RC_OK;
309
if (tmp1.rc != CMPI_RC_OK || tmp2.rc != CMPI_RC_OK || tmp3.rc != CMPI_RC_OK) {
310
rc.rc = CMPI_RC_ERR_FAILED;
315
/* set cn and ns in inst */
316
ClInstance* instance = (ClInstance*)inst->hdl;
317
if (ns) instance->nameSpace.id = addClString(&instance->hdr, ns);
318
if (cn) instance->className.id = addClString(&instance->hdr, cn);
320
/* loop over keys, set them in the inst */
321
while (j-- && (tmp1.rc == CMPI_RC_OK)) {
323
CMPIData tmp = CMGetKeyAt(cop, j, &keyName, &tmp1);
324
__ift_setProperty(inst, CMGetCharsPtr(keyName, NULL),
325
&tmp.value, tmp.type);
282
334
static CMPIObjectPath *__ift_getObjectPath(const CMPIInstance * instance,
316
367
unsigned int e, m;
318
369
if (mtx == NULL) {
319
mtx = malloc(sizeof(CMPI_MUTEX_TYPE));
371
mtx = memAlloc(MEM_TRACKED, sizeof(CMPI_MUTEX_TYPE), &dummy);
320
372
*mtx = Broker->xft->newMutex(0);
322
374
Broker->xft->lockMutex(*mtx);
342
394
for (e = 0; e < m; e++) {
343
395
CMPIString *n = kl->ft->getElementAt(kl, e, NULL).value.string;
345
396
d = __ift_getProperty(instance, CMGetCharPtr(n), &tmp);
346
397
if (tmp.rc == CMPI_RC_OK) {
347
398
CMAddKey(cop, CMGetCharPtr(n), &d.value, d.type);
384
435
for (j = 0, m = __ift_getPropertyCount(instance, &st); j < m; j++) {
385
436
data = __ift_internal_getPropertyAt(instance, j, &name, &st, 1);
386
437
if(__contained_list((char**)propertyList, name) || __contained_list((char**)keys, name)) {
387
newInstance->ft->setProperty(newInstance, name, &data.value, data.type);
438
if ( (data.state & ~CMPI_keyValue) != 0) {
439
newInstance->ft->setProperty(
440
newInstance, name, NULL, data.type);
442
newInstance->ft->setProperty(
443
newInstance, name, &data.value, data.type);
662
720
instance.instance.hdl = ClInstanceNew(ns, cn);
722
#ifdef HAVE_DEFAULT_PROPERTIES
724
instFillDefaultProperties(&instance,ns,cn);
664
728
while (j-- && (tmp1.rc == CMPI_RC_OK)) {
665
729
CMPIString *keyName;
666
730
CMPIData tmp = CMGetKeyAt(cop, j, &keyName, &tmp1);
673
737
tInst=memAddEncObj(mode, &instance, sizeof(instance),&state);
674
738
tInst->mem_state=state;
675
739
tInst->refCount=0;
677
#ifdef HAVE_DEFAULT_PROPERTIES
679
instFillDefaultProperties(tInst,ns,cn);
683
741
return (CMPIInstance*)tInst;