~ubuntu-branches/ubuntu/trusty/sblim-sfcb/trusty-proposed

« back to all changes in this revision

Viewing changes to instance.c

  • Committer: Bazaar Package Importer
  • Author(s): Thierry Carrez
  • Date: 2009-06-08 12:04:49 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090608120449-byfplk09rqz8rtg6
Tags: 1.3.3-0ubuntu1
* New upstream release.
* debian/rules: Removed rpath hacks, SFCB default build handles that now.
* Removed 1934753-remove-assignment.diff, now upstream.
* Refreshed patch cim-schema-location.diff

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
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 $
3
3
 *
4
4
 * © Copyright IBM Corp. 2005, 2007
5
5
 *
59
59
                                            CMPIStatus * rc);
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);
62
63
 
63
64
extern CMPIBroker *Broker;
64
65
 
278
279
   CMReturn(CMPI_RC_OK);
279
280
}
280
281
 
 
282
static CMPIStatus __ift_setObjectPath(CMPIInstance * inst,
 
283
                                      const CMPIObjectPath * cop)
 
284
{
 
285
   CMPIStatus tmp1, tmp2, tmp3;
 
286
   CMPIString *str;
 
287
   const char *ns, *cn;
 
288
   int j;
 
289
   CMPIStatus rc = { CMPI_RC_OK, NULL };
 
290
 
 
291
   /* get information out of objectpath */
 
292
   if (cop) {
 
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);
 
298
   }
 
299
 
 
300
   /* there SHOULD be an op passed in, otherwise this call is useless.... */
 
301
   else {
 
302
      j=0;
 
303
      //SFCB_ASM("int $3");
 
304
      ns = "*NoNameSpace*";
 
305
      cn = "*NoClassName*";
 
306
      tmp1.rc=tmp2.rc=tmp3.rc=CMPI_RC_OK;
 
307
   }
 
308
 
 
309
   if (tmp1.rc != CMPI_RC_OK || tmp2.rc != CMPI_RC_OK || tmp3.rc != CMPI_RC_OK) {
 
310
      rc.rc = CMPI_RC_ERR_FAILED;
 
311
      return rc;
 
312
   }
 
313
   else {
 
314
 
 
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);
 
319
 
 
320
      /* loop over keys, set them in the inst */
 
321
      while (j-- && (tmp1.rc == CMPI_RC_OK)) {
 
322
         CMPIString *keyName;
 
323
         CMPIData tmp = CMGetKeyAt(cop, j, &keyName, &tmp1);
 
324
         __ift_setProperty(inst, CMGetCharsPtr(keyName, NULL),
 
325
                           &tmp.value, tmp.type);
 
326
      }
 
327
      return tmp1;
 
328
   }
 
329
 
 
330
   return rc;
 
331
 
 
332
}
281
333
 
282
334
static CMPIObjectPath *__ift_getObjectPath(const CMPIInstance * instance,
283
335
                                           CMPIStatus * rc)
288
340
   CMPIStatus tmp;
289
341
   const char *cn = ClInstanceGetClassName((ClInstance *) instance->hdl);
290
342
   const char *ns = ClInstanceGetNameSpace((ClInstance *) instance->hdl);
291
 
   char *id;
292
343
 
293
344
   CMPIObjectPath *cop;
294
345
   cop = TrackedCMPIObjectPath(ns, cn, rc);
316
367
      unsigned int e, m;
317
368
 
318
369
      if (mtx == NULL) {
319
 
         mtx = malloc(sizeof(CMPI_MUTEX_TYPE));
 
370
         int dummy = 0;
 
371
         mtx = memAlloc(MEM_TRACKED, sizeof(CMPI_MUTEX_TYPE), &dummy);
320
372
         *mtx = Broker->xft->newMutex(0); 
321
373
      }
322
374
      Broker->xft->lockMutex(*mtx);
341
393
 
342
394
      for (e = 0; e < m; e++) {
343
395
         CMPIString *n = kl->ft->getElementAt(kl, e, NULL).value.string;
344
 
         id=CMGetCharPtr(n);
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);
 
441
               } else {
 
442
                  newInstance->ft->setProperty(
 
443
                     newInstance, name, &data.value, data.type);
 
444
               }
388
445
            }
389
446
        }
390
447
        
524
581
   __ift_getPropertyCount,
525
582
   __ift_setProperty,
526
583
   __ift_getObjectPath,
527
 
   __ift_setPropertyFilter
 
584
   __ift_setPropertyFilter,
 
585
   __ift_setObjectPath
528
586
};
529
587
 
530
588
static struct {
661
719
   else {
662
720
      instance.instance.hdl = ClInstanceNew(ns, cn);
663
721
 
 
722
#ifdef HAVE_DEFAULT_PROPERTIES
 
723
   if(!override) {
 
724
      instFillDefaultProperties(&instance,ns,cn);
 
725
   }
 
726
#endif
 
727
 
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;
676
 
   
677
 
#ifdef HAVE_DEFAULT_PROPERTIES
678
 
   if(!override) {
679
 
      instFillDefaultProperties(tInst,ns,cn);
680
 
   }
681
 
#endif
682
740
 
683
741
   return (CMPIInstance*)tInst;
684
742
}