示例#1
0
CMPIData KFindProperty(
    const CMPIInstance* ci, 
    const char* name,
    CMPIStatus* status)
{
    CMPICount count;
    CMPICount i;
    CMPIData cd;

    count = CMGetPropertyCount(ci, NULL);

    for (i = 0; i < count; i++)
    {
        CMPIString* pn = NULL;
        CMPIStatus st;

        cd = CMGetPropertyAt(ci, i, &pn, &st);

        if (!KOkay(st) || !pn)
        {
            memset(&cd, 0, sizeof(cd));

            if (status)
                CMSetStatus(status, CMPI_RC_ERR_FAILED);

            return cd;
        }

        if (strcasecmp(KChars(pn), name) == 0)
        {
            if (status)
                CMSetStatus(status, CMPI_RC_OK);

            return cd;
        }
    }

    /* Not found! */

    memset(&cd, 0, sizeof(cd));

    if (status)
        CMSetStatus(status, CMPI_RC_ERR_NOT_FOUND);

    return cd;
}
示例#2
0
void print(const CMPIInstance* inst)
{
    printf("CMPIInstance\n");
    printf("{\n");

    for (size_t i = 0, n = CMGetPropertyCount(inst, NULL); i < n; i++)
    {
        CMPIString* name;
        CMPIData data = CMGetPropertyAt(inst, i, &name, NULL);

        if (data.type == 0)
        {
            // FIXME: for some reason the data type is zero here. Embedded
            // object types are not converted correctly here.
            continue;
        }

        printf("    %s(%s): ", CMGetCharPtr(name), type_name_of(data.type));
        print(data);
        putchar('\n');
    }

    printf("}\n");
}
示例#3
0
static CMPI_THREAD_RETURN CMPI_THREAD_CDECL
thread (void *args)
{
  CMPIString *str = NULL;
  CMPIStatus rc = { CMPI_RC_OK, NULL };
  CMPIStatus rc_Eval = { CMPI_RC_OK, NULL };
  CMPIStatus rc_Clone = { CMPI_RC_OK, NULL };
  CMPIStatus rc_Inst = { CMPI_RC_OK, NULL };
  CMPIStatus rc_Pred = { CMPI_RC_OK, NULL };
  CMPIStatus rc_Array = { CMPI_RC_OK, NULL };
  CMPIStatus rc_CMGetPropertyAt = { CMPI_RC_OK, NULL };

  CMPIString *type = NULL;
  CMPISelectExp *clone = NULL;
  CMPIBoolean evalRes;
  CMPIInstance *inst = NULL;
  CMPIObjectPath *objPath = NULL;
  CMPIString *name = NULL;
  CMPIData prop_data = { 0, CMPI_null, {0} };
  CMPIData data = { 0, CMPI_null, {0} };
  CMPIArray *projection = NULL;
  /* General purpose counters */
  unsigned int idx;
  CMPICount cnt;
  /* Select Condition and sub conditions */
  CMPISelectCond *cond = NULL;
  int sub_type;
  CMPISubCond *subcnd = NULL;
  /* Predicate operations */
  CMPICount pred_cnt;
  unsigned int pred_idx;
  CMPIPredicate *pred = NULL;
  CMPIType pred_type;
  CMPIPredOp pred_op;
  CMPIString *left_side = NULL;
  CMPIString *right_side = NULL;
  /* Thread specific data, passed in via arguments. This could also
     be passed via thread specific data.. */
  void **arguments = (void **) args;
  CMPIContext *ctx;
  CMPISelectExp *se;
  char *ns;
  CMPIBroker *broker;

 // Copy over the CMPISelectExp, CMPIContext, CMPIBroker and the ns from the argument. 
  se = (CMPISelectExp *)arguments[0];
  ctx = (CMPIContext *)arguments[1];
  broker = (CMPIBroker *)arguments[2];
  ns = (char *)arguments[3];

  free(arguments);

  _thread_active = 1;
  // Get the CMPIContext and attach it to this thread.
  rc = CBAttachThread (broker, ctx);

  // Wait until we get the green signal.
  while (_thread_runs == 0)
    {
	broker->xft->threadSleep(1000);
    }

  //PROV_LOG_OPEN (_IndClassName, _ProviderLocation);
  PROV_LOG ("--- CBAttachThread callled.");
  PROV_LOG ("---- %s [%s]", strCMPIStatus (rc), (rc.msg == 0) ? "" : CMGetCharPtr(rc.msg));

  PROV_LOG ("--- %s CMPI thread(void *) running",_IndClassName);


  PROV_LOG ("-- #1 Clone");
  clone = CMClone (se, &rc_Clone);
  PROV_LOG ("---- %s [%s]", strCMPIStatus (rc_Clone), (rc_Clone.msg == 0) ? "" : CMGetCharPtr(rc_Clone.msg));
  if (clone)
    CMRelease (clone);

  /*
     This functionality is not used in indication providers, but instead in
     ExecQuery provider API (instance providers). But for the sake
     of completness this functionality is also used here. */

  PROV_LOG ("-- #1.1 CMNewSelectExp");
  str = CMGetSelExpString (se, &rc);
  clone =
    //CMPI_CQL_NewSelectExp (broker, CMGetCharPtr (str), "CIMxCQL",
    CMNewSelectExp (broker, CMGetCharPtr (str), "CIM:CQL",
                    &projection, &rc_Clone);

  PROV_LOG ("---- %s [%s]", strCMPIStatus (rc_Clone), (rc_Clone.msg == 0) ? "" : CMGetCharPtr(rc_Clone.msg));
  if (clone)
    {
      if (projection)
        {
          PROV_LOG ("--- #1.2 Projection list is: ");
          cnt = CMGetArrayCount (projection, &rc_Array);
          PROV_LOG ("---- %s, [%s]", strCMPIStatus (rc_Array),(rc_Array.msg == 0) ? "" : CMGetCharPtr(rc_Array.msg));
          PROV_LOG ("--- #1.3 CMGetArrayCount, %d", cnt);
          for (idx = 0; idx < cnt; idx++)
            {
              PROV_LOG ("--- #1.4 CMGetArrayElementAt");
              data = CMGetArrayElementAt (projection, idx, &rc_Array);
              PROV_LOG ("---- %s [%s]", strCMPIStatus (rc_Array), (rc_Array.msg == 0) ? "" : CMGetCharPtr(rc_Array.msg));
              PROV_LOG ("---- type is : %d", data.type);
              if (data.type == CMPI_chars)
                {
                  PROV_LOG ("---- %s (chars)", data.value.chars);
                }
              if (data.type == CMPI_string)
                {
                  PROV_LOG ("---- %s (string)",
                            CMGetCharPtr (data.value.string));
                }
            }
        }
      else
        {
          PROV_LOG
            ("--- #1.2 No projection list, meaning it is SELECT * .... ");
        }
    }
  // This is how an indication provider would work.
  //  Create an objectpath + instance and use CMEvaluateSelExp
  //  OR
  //  use CMEvaluateSelExpUsingAccessor and pass in the function that would
  // provide the properties values.

  PROV_LOG ("-- #2 MakeObjectPath");
  // Create instance

  objPath = make_ObjectPath (broker, _Namespace, _IndClassName);
  type = CDGetType (broker, objPath, &rc_Inst);
  PROV_LOG ("---- %s (%s) [%s]", CMGetCharPtr (type), strCMPIStatus (rc_Inst),(rc_Inst.msg == 0) ? "" : CMGetCharPtr(rc_Inst.msg));
  CMRelease (type);

  PROV_LOG ("-- #3 Instance");
  inst = CMNewInstance (broker, objPath, &rc_Inst);
  PROV_LOG ("---- %s [%s]", strCMPIStatus (rc_Inst), (rc_Inst.msg == 0) ? "" : CMGetCharPtr(rc_Inst.msg));

  if (rc_Inst.rc == CMPI_RC_ERR_NOT_FOUND)
    {
      PROV_LOG (" --- Class %s is not found in the %s namespace!",
                _IndClassName, _Namespace);
      PROV_LOG (" --- Aborting!!! ");
      goto exit;
    }

  type = CDGetType (broker, inst, &rc_Inst);
  if (type)
    {
      PROV_LOG ("---- %s (%s) [%s]", CMGetCharPtr (type), strCMPIStatus (rc_Inst),(rc_Inst.msg == 0) ? "" : CMGetCharPtr(rc_Inst.msg));
      CMRelease (type);
    }

  PROV_LOG ("- CMGetPropertyCount: %d", CMGetPropertyCount (inst, &rc));
  // Set each property.
  for (idx = 0; idx < CMGetPropertyCount (inst, &rc); idx++)
    {
      prop_data = CMGetPropertyAt (inst, idx, &name, &rc_CMGetPropertyAt);
      // Really dumb way of doing it. Just set each property with its own property name.
      if (prop_data.type == CMPI_string)
        {
          CMSetProperty (inst, CMGetCharPtr (name), CMGetCharPtr (name),
                         CMPI_chars);
        }
      prop_data = CMGetPropertyAt (inst, idx, &name, &rc_CMGetPropertyAt);

      PROV_LOG ("-- %d: %s(%s: %s: %s) [%s]", idx,
                CMGetCharPtr (name),
                strCMPIType (prop_data.type),
                strCMPIValueState (prop_data.state),
                strCMPIValue (prop_data.value),
                strCMPIStatus (rc_CMGetPropertyAt));

    }

  PROV_LOG ("-- #4 Evaluate using instance");
  evalRes = CMEvaluateSelExp (se, inst, &rc_Eval);
  PROV_LOG ("---- %s [%s]", strCMPIStatus (rc_Eval), (rc_Eval.msg == 0) ? "" : CMGetCharPtr(rc_Eval.msg));
  if (evalRes == CMPI_true)
    {
      PROV_LOG ("--- True, sending indication");
      rc_Eval = CBDeliverIndication (broker, ctx, _Namespace, inst);
      PROV_LOG ("---- %s [%s]", strCMPIStatus (rc_Eval), (rc_Eval.msg == 0) ? "" : CMGetCharPtr(rc_Eval.msg));
    }
  else
    {
      PROV_LOG ("--- False");
    }

  PROV_LOG ("-- #4.1 Evalute using accessor");
  evalRes =
    CMEvaluateSelExpUsingAccessor (se, instance_accessor, broker, &rc_Eval);
  PROV_LOG ("---- %s [%s]", strCMPIStatus (rc_Eval), (rc_Eval.msg == 0) ? "" : CMGetCharPtr(rc_Eval.msg));
  if (evalRes == CMPI_true)
    {
      PROV_LOG ("--- True, but not sending indication");
    }
  else
    {
      PROV_LOG ("--- False");
    }

  PROV_LOG ("-- #5 CMGetSelExpString");
  str = CMGetSelExpString (se, &rc);
  type = CDGetType (broker, str, &rc_Inst);
  if (type != NULL)
    {
      PROV_LOG ("---- %s (%s) [%s]", CMGetCharPtr (type), strCMPIStatus (rc_Inst), (rc_Inst.msg == 0) ? "" : CMGetCharPtr(rc_Inst.msg));
      CMRelease (type);
    }

  PROV_LOG ("---- %s [%s]", strCMPIStatus (rc), (rc.msg == 0) ? "" : CMGetCharPtr(rc.msg));
  PROV_LOG ("-- #5.1 Query is [%s]", CMGetCharPtr (str));
  PROV_LOG ("-- #5.2 Query is [%s]", ns);


  PROV_LOG ("-- #6 Continue evaluating using GetDOC");
  {
    cond = CMGetDoc (se, &rc);
    PROV_LOG ("---- %s [%s]", strCMPIStatus (rc), (rc.msg == 0) ? "" : CMGetCharPtr(rc.msg));
    if (cond != NULL)
      {

        PROV_LOG ("--- #6.1 CMGetSubCondCountAndType ");
        cnt = CMGetSubCondCountAndType (cond, &sub_type, &rc);
        PROV_LOG ("---- %s %s", strCMPIStatus (rc), (rc.msg == 0) ? "" : CMGetCharPtr(rc.msg));


        PROV_LOG ("---- Number of disjunctives: %d, Type: %X", cnt, sub_type);

        /* Parsing the disjunctives */
        for (idx = 0; idx < cnt; idx++)
          {
            PROV_LOG ("--- #6.2 CMGetSubCondAt @ %d ", idx);
            subcnd = CMGetSubCondAt (cond, idx, &rc);
            PROV_LOG ("---- %s [%s]", strCMPIStatus (rc),(rc.msg == 0) ? "" : CMGetCharPtr(rc.msg));

            PROV_LOG ("--- #6.3 CMGetPredicateCount");
            pred_cnt = CMGetPredicateCount (subcnd, &rc);
            PROV_LOG ("---- %s [%s]", strCMPIStatus (rc), (rc.msg == 0) ? "" : CMGetCharPtr(rc.msg));
            PROV_LOG ("---- Number of predicates in the conjuctives: %d",
                      pred_cnt);

            /* Parsing throught conjuctives */
            for (pred_idx = 0; pred_idx < pred_cnt; pred_idx++)
              {
                PROV_LOG ("--- #6.4 CMGetPredicateAt, %d", pred_idx);
                pred = CMGetPredicateAt (subcnd, pred_idx, &rc);

                PROV_LOG ("---- %s [%s]", strCMPIStatus (rc),(rc.msg == 0) ? "" : CMGetCharPtr(rc.msg));
                PROV_LOG ("--- #6.4 CMGetPredicateData");
                rc = CMGetPredicateData (pred,
                                         &pred_type,
                                         &pred_op, &left_side, &right_side);
                PROV_LOG ("---- %s [%s]", strCMPIStatus (rc),(rc.msg == 0) ? "" : CMGetCharPtr(rc.msg));

                PROV_LOG ("----- Type: %s , CMPIPredOp: %s, LS: %s, RS: %s",
                          strCMPIType (pred_type), strCMPIPredOp (pred_op),
                          CMGetCharPtr (left_side),
                          CMGetCharPtr (right_side));

                PROV_LOG ("--- #6.5 Evaluate using predicate");
#ifdef CMPI_VER_100
// The CMEvaluatePredicate is gone in the CMPI 1.0 standard.
                evalRes =
                  CMEvaluatePredicateUsingAccessor (pred, instance_accessor,
                                                    NULL, &rc_Pred);
#else
                // One can also evaluate this specific predicate
                evalRes =
                  CMEvaluatePredicate (pred, "PredicateEvaluation",
                                       CMPI_chars, &rc_Pred);
#endif
                PROV_LOG ("---- %s [%s]", strCMPIStatus (rc_Pred), (rc_Pred.msg == 0) ? "" : CMGetCharPtr(rc_Pred.msg));

                if (evalRes == CMPI_true)
                  {
                    PROV_LOG ("--- True");
                  }
                else
                  {
                    PROV_LOG ("--- False");
                  }
              }

          }
      }
  }
  PROV_LOG ("-- #7 GetCOD");
  {
    cond = CMGetCod (se, &rc);
    PROV_LOG ("---- %s [%s]", strCMPIStatus (rc), (rc.msg == 0) ? "" : CMGetCharPtr(rc.msg));
    /* Currently this is not supported in Pegasus. */
    if (cond != NULL)
      {
      }
  }
exit:
  PROV_LOG ("--- CBDetachThread called");
  rc = CBDetachThread (broker, ctx);
  free (ns);
  PROV_LOG ("---- %s [%s]", strCMPIStatus (rc), (rc.msg == 0) ? "" : CMGetCharPtr(rc.msg));

  PROV_LOG ("--- %s CMPI thread(void *) exited", _IndClassName);

  _thread_active = 0;
  _thread_runs = 0;
  return (CMPI_THREAD_RETURN) 0;
}
CMPIStatus
getRefs(const CMPIContext *ctx, const CMPIResult *rslt,
        const CMPIObjectPath * cop,
        const char *assocClass,
        const char *resultClass,
        const char *role,
        const char *resultRole,
        const char **propertyList, int associatorFunction)
{
  UtilList       *refs = UtilFactory->newList(memAddUtilList, memUnlinkEncObj);
  char           *ns = (char *) CMGetNameSpace(cop, NULL)->hdl;
  CMPIStatus      st = { CMPI_RC_OK, NULL };

  _SFCB_ENTER(TRACE_INTERNALPROVIDER, "getRefs");

  if (assocClass != NULL) {
    CMPIObjectPath *path;
    if (assocForName(ns, assocClass, role, resultRole) == NULL) {
      /*
       * for an unknown class we just return nothing 
       */
      _SFCB_RETURN(st);
    }
    path = CMNewObjectPath(_broker, ns, assocClass, NULL);
    SafeInternalProviderAddEnumInstances(refs, NULL, ctx, path,
                                         propertyList, &st, 1);
  }

  else {
    CMPIData        rv;
    CMPIObjectPath *op =
        CMNewObjectPath(Broker, ns, "$ClassProvider$", &st);
    CMPIArgs       *in = CMNewArgs(Broker, NULL);
    CMPIArgs       *out = CMNewArgs(Broker, NULL);
    rv = CBInvokeMethod(Broker, ctx, op, "getassocs", in, out, &st);
    if (out) {
      int             i,
                      m;
      CMPIArray      *ar = CMGetArg(out, "assocs", &st).value.array;
      for (i = 0, m = CMGetArrayCount(ar, NULL); i < m; i++) {
        char           *name =
            CMGetArrayElementAt(ar, i, NULL).value.string->hdl;
        if (name) {
          CMPIObjectPath *cop = CMNewObjectPath(Broker, ns, name, NULL);
          if (cop) {
            SafeInternalProviderAddEnumInstances(refs, NULL, ctx, cop,
                                                 propertyList, &st, 1);
          }
        }
        _SFCB_TRACE(1, ("--- assoc %s", name));
      }
    }
  }

  if (role) {
    // filter out the associations not matching the role property
    CMPIInstance   *ci;
    UtilStringBuffer *pn = normalizeObjectPathStrBuf(cop);
    for (ci = refs->ft->getFirst(refs); ci; ci = refs->ft->getNext(refs)) {
      CMPIData        data = CMGetProperty(ci, role, NULL);
      if ((data.state & CMPI_notFound) ||
          data.type != CMPI_ref ||
          objectPathEquals(pn, data.value.ref, NULL, 0) == 0) {
        refs->ft->removeCurrent(refs);
      }
    }
    pn->ft->release(pn);
  }

  else {
    // filter out associations not referencing pathName
    CMPIInstance   *ci;
    int             matched,
                    i,
                    m;
    UtilStringBuffer *pn = normalizeObjectPathStrBuf(cop);
    for (ci = refs->ft->getFirst(refs); ci; ci = refs->ft->getNext(refs)) {
      for (matched = 0, i = 0, m = CMGetPropertyCount(ci, NULL); i < m;
           i++) {
        CMPIData        data = CMGetPropertyAt(ci, i, NULL, NULL);
        if (data.type == CMPI_ref
            && objectPathEquals(pn, data.value.ref, NULL, 0)) {
          matched = 1;
          break;
        }
      }
      if (matched == 0)
        refs->ft->removeCurrent(refs);
    }
    pn->ft->release(pn);
  }

  if (associatorFunction == REF) {
    CMPIInstance   *ci;
    for (ci = refs->ft->getFirst(refs); ci; ci = refs->ft->getNext(refs)) {
      CMReturnInstance(rslt, ci);
    }
    refs->ft->release(refs);
    _SFCB_RETURN(st);
  }

  else if (associatorFunction == REF_NAME) {
    CMPIInstance   *ci;
    for (ci = refs->ft->getFirst(refs); ci; ci = refs->ft->getNext(refs)) {
      CMPIObjectPath *ref = CMGetObjectPath(ci, NULL);
      CMReturnObjectPath(rslt, ref);
    }
    refs->ft->release(refs);
    _SFCB_RETURN(st);
  }

  else {
    // Use hashtable to avoid dup'd associators
    CMPIInstance   *ci;
    UtilHashTable  *assocs =
        UtilFactory->newHashTable(61, UtilHashTable_charKey);
    UtilStringBuffer *pn = normalizeObjectPathStrBuf(cop);
    for (ci = refs->ft->getFirst(refs); ci; ci = refs->ft->getNext(refs)) {
      // Q: for ASSOC_NAME we should not require the
      // object exist if we go by the book, should we?
      // The current approach retrieves the instances
      // via the CIMOM handle
      if (resultRole) {
        CMPIData        data = CMGetProperty(ci, resultRole, NULL);
        UtilStringBuffer *an = NULL;
        if ((data.state & CMPI_notFound) == 0 && data.type == CMPI_ref &&
            objectPathEquals(pn, data.value.ref, &an, 0) == 0) {
          if (resultClass == NULL
              || CMClassPathIsA(Broker, data.value.ref, resultClass,
                                NULL)) {
            CMPIInstance   *aci =
                CBGetInstance(Broker, ctx, data.value.ref, propertyList,
                              &st);
            assocs->ft->put(assocs, an->ft->getCharPtr(an), aci);
          }
        }
      }

      else {
        // must loop over the properties to find ref instances
        int             i,
                        m;
        for (i = 0, m = CMGetPropertyCount(ci, NULL); i < m; i++) {
          CMPIData        data = CMGetPropertyAt(ci, i, NULL, NULL);
          if (data.type == CMPI_ref) {
            CMPIObjectPath *ref = data.value.ref;
            CMPIString     *tns = CMGetNameSpace(ref, NULL);
            if (tns == NULL || tns->hdl == NULL)
              CMSetNameSpace(ref, ns);
            UtilStringBuffer *an = NULL;
            if (objectPathEquals(pn, ref, &an, 0) == 0) {

              if (resultClass == NULL
                  || CMClassPathIsA(Broker, ref, resultClass, NULL)) {
                CMPIInstance   *aci =
                    CBGetInstance(Broker, ctx, ref, propertyList, &st);
                if (aci)
                  assocs->ft->put(assocs, an->ft->getCharPtr(an), aci);
              }
            }
          }
        }
      }
    }

    {
      HashTableIterator *it;
      char           *an;
      CMPIInstance   *aci;
      for (it =
           assocs->ft->getFirst(assocs, (void **) &an, (void **) &aci); it;
           it =
           assocs->ft->getNext(assocs, it, (void **) &an,
                               (void **) &aci)) {
        if (associatorFunction == ASSOC)
          CMReturnInstance(rslt, aci);
        else {
          CMPIObjectPath *op = CMGetObjectPath(aci, NULL);
          CMReturnObjectPath(rslt, op);
        }
      }
    }

    refs->ft->release(refs);
    assocs->ft->release(assocs);
    pn->ft->release(pn);
    _SFCB_RETURN(st);

  }
}
static int
_testCMPIInstance()
{
  CMPIStatus      rc = { CMPI_RC_OK, NULL };

  CMPIInstance   *instance = NULL;
  CMPIInstance   *clonedInstance = NULL;
  CMPIObjectPath *objPath = NULL;
  CMPIObjectPath *newObjPath = NULL;
  CMPIObjectPath *returnedObjPath = NULL;

  CMPIData        returnedData1;
  CMPIData        returnedData2;
  CMPIData        clonedData1;

  CMPIString     *returnedName = NULL;
  unsigned int    count = 0;
  const char     *name1 = "firstPropertyName";
  CMPIValue       value1;
  const char     *name2 = "secondPropertyName";
  CMPIValue       value2;
  CMPIType        type = CMPI_uint64;
  CMPIBoolean     dataEqual = 0;
  CMPIBoolean     objectPathEqual = 0;
  CMPIBoolean     cloneSuccessful = 0;
  CMPIString     *beforeObjPath = NULL;
  CMPIString     *afterObjPath = NULL;
  const char     *beforeString = NULL;
  const char     *afterString = NULL;
  objPath = make_ObjectPath(_broker, _Namespace, _ClassName);
  instance = make_Instance(objPath);
  value1.uint32 = 10;
  rc = CMSetProperty(instance, name1, &value1, type);
  value2.uint32 = 20;
  rc = CMSetProperty(instance, name2, &value2, type);
  count = CMGetPropertyCount(instance, &rc);
  returnedData1 = CMGetProperty(instance, name1, &rc);
  if (returnedData1.value.uint32 == 10) {
    dataEqual = 1;
  }
  returnedData2 = CMGetPropertyAt(instance, 2, &returnedName, &rc);
  if (returnedData2.value.uint32 == 20) {
    dataEqual = 1;
  }
  newObjPath = make_ObjectPath(_broker, _Namespace, _ClassName);
  returnedObjPath = CMGetObjectPath(instance, &rc);
  beforeObjPath = CMObjectPathToString(returnedObjPath, &rc);
  beforeString = CMGetCharsPtr(beforeObjPath, &rc);
  rc = CMSetNameSpace(newObjPath, "newNamespace");
  rc = CMSetObjectPath(instance, newObjPath);
  returnedObjPath = CMGetObjectPath(instance, &rc);
  afterObjPath = CMObjectPathToString(returnedObjPath, &rc);
  afterString = CMGetCharsPtr(afterObjPath, &rc);
  afterString = CMGetCharsPtr(CMGetNameSpace(returnedObjPath, &rc), &rc);
  if (strcmp("newNamespace", afterString) == 0) {
    objectPathEqual = 1;
  }
  clonedInstance = instance->ft->clone(instance, &rc);
  clonedData1 = CMGetProperty(clonedInstance, name1, &rc);
  rc = clonedInstance->ft->release(clonedInstance);
  if (returnedData1.value.uint32 == clonedData1.value.uint32) {
    cloneSuccessful = 1;
  } else {
    cloneSuccessful = 0;
  }
  CMGetProperty(instance, "noProperty", &rc);
  if (rc.rc != CMPI_RC_ERR_NO_SUCH_PROPERTY) {
    return 1;
  }

  CMGetPropertyAt(instance, 100, &returnedName, &rc);
  if (rc.rc != CMPI_RC_ERR_NO_SUCH_PROPERTY) {
    return 1;
  }
  rc = instance->ft->release(instance);
  return 0;
}
示例#6
0
CMPIStatus KBase_FromInstance(KBase* self, const CMPIInstance* ci)
{
    CMPIObjectPath* cop;
    CMPIString* cn;
    CMPIString* ns;
    CMPIStatus st = KSTATUS_INIT;
    CMPICount count;
    CMPICount i;
    KValue* kv;

    if (!self || self->magic != KMAGIC)
        KReturn(ERR_FAILED);

    /* Get object path */

    if (!(cop = CMGetObjectPath(ci, &st)))
        return st;

    /* Set namespace */

    if (!(ns = CMGetNameSpace(cop, &st)))
        return st;

    self->ns = ns;

    /* Get classname */

    if (!(cn = CMGetClassName(cop, &st)))
        return st;

    /* For each property */

    count = CMGetPropertyCount(ci, &st); 

    if (!KOkay(st))
        return st;

    for (i = 0; i < count; i++)
    {
        CMPIData cd;
        CMPIString* pn = NULL;
        KTag tag;

        /* Get i-th property */

        cd = CMGetPropertyAt(ci, i, &pn, &st);

        if (!KOkay(st))
            return st;

        if (!pn)
            KReturn(ERR_FAILED);

        /* Find the given property */

        if ((kv = _find_property(self, KChars(pn), &tag)))
        {
            _set_value(kv, tag, &cd);
        }
    }

    KReturn(OK);
}