static int _testCMPIArgs() { CMPIStatus rc = { CMPI_RC_OK, NULL }; CMPIArgs *args = NULL; CMPIArgs *clonedArgs = NULL; CMPIUint32 count = 0; CMPIType type = CMPI_uint32; char *arg1 = "arg1"; char *arg2 = "arg2"; CMPIValue value; CMPIData data; CMPIData clonedData; CMPIBoolean cloneSuccessful = 0; CMPIBoolean getArgCountSuccessful = 0; args = CMNewArgs(_broker, &rc); value.uint32 = 10; rc = CMAddArg(args, arg1, &value, type); count = CMGetArgCount(args, &rc); if (count == 1) { getArgCountSuccessful = 1; } value.uint32 = 20; rc = CMAddArg(args, arg2, &value, type); count = CMGetArgCount(args, &rc); if (count == 2) { getArgCountSuccessful = 1; } data = CMGetArg(args, arg2, &rc); rc = CMAddArg(args, arg1, &value, type); clonedArgs = args->ft->clone(args, &rc); clonedData = CMGetArg(clonedArgs, arg2, &rc); rc = clonedArgs->ft->release(clonedArgs); if (data.value.uint32 == clonedData.value.uint32) { cloneSuccessful = 1; } rc = args->ft->release(args); return 0; }
CMPIStatus deliverInd(const CMPIObjectPath * ref, const CMPIArgs * in, CMPIInstance * ind) { _SFCB_ENTER(TRACE_INDPROVIDER, "deliverInd"); CMPIInstance *hci, *sub; CMPIStatus st = { CMPI_RC_OK, NULL }; CMPIString *dest; char strId[64]; ExpSegments xs; UtilStringBuffer *sb; static int id = 1; char *resp; char *msg; if ((hci = internalProviderGetInstance(ref, &st)) == NULL) { setStatus(&st, CMPI_RC_ERR_NOT_FOUND, NULL); _SFCB_RETURN(st); } dest = CMGetProperty(hci, "destination", NULL).value.string; _SFCB_TRACE(1, ("--- destination: %s\n", (char *) dest->hdl)); sub = CMGetArg(in, "subscription", NULL).value.inst; sprintf(strId, "%d", id++); xs = exportIndicationReq(ind, strId); sb = segments2stringBuffer(xs.segments); if (exportIndication ((char *) dest->hdl, (char *) sb->ft->getCharPtr(sb), &resp, &msg)) { setStatus(&st, CMPI_RC_ERR_FAILED, NULL); } RespSegment rs = xs.segments[5]; UtilStringBuffer *usb = (UtilStringBuffer *) rs.txt; CMRelease(usb); CMRelease(sb); if (resp) free(resp); if (msg) free(msg); _SFCB_RETURN(st); }
static CMPIStatus ClassProviderInvokeMethod(CMPIMethodMI * mi, const CMPIContext *ctx, const CMPIResult *rslt, const CMPIObjectPath * ref, const char *methodName, const CMPIArgs * in, CMPIArgs * out) { CMPIStatus st = { CMPI_RC_OK, NULL }; CMPIArray *ar; int rc; ClassRegister *cReg; _SFCB_ENTER(TRACE_PROVIDERS, "ClassProviderInvokeMethod"); cReg = getNsReg(ref, &rc); if (cReg == NULL) { CMPIStatus st = { CMPI_RC_ERR_INVALID_NAMESPACE, NULL }; _SFCB_RETURN(st); } if (strcasecmp(methodName, "getchildren") == 0) { CMPIData cn = CMGetArg(in, "class", NULL); _SFCB_TRACE(1, ("--- getchildren %s", (char *) cn.value.string->hdl)); cReg->ft->wLock(cReg); if (cn.type == CMPI_string && cn.value.string && cn.value.string->hdl) { char *child; int l = 0, i = 0; UtilList *ul = getChildren(cReg, (char *) cn.value.string->hdl); if (ul) l = ul->ft->size(ul); ar = CMNewArray(_broker, l, CMPI_string, NULL); if (ul) for (child = (char *) ul->ft->getFirst(ul); child; child = (char *) ul->ft->getNext(ul)) { CMSetArrayElementAt(ar, i++, child, CMPI_chars); } st = CMAddArg(out, "children", &ar, CMPI_stringA); } else { } cReg->ft->wUnLock(cReg); } else if (strcasecmp(methodName, "getallchildren") == 0) { int ignprov = 0; CMPIStatus st; CMPIData cn = CMGetArg(in, "class", &st); cReg->ft->wLock(cReg); if (st.rc != CMPI_RC_OK) { cn = CMGetArg(in, "classignoreprov", NULL); ignprov = 1; } _SFCB_TRACE(1, ("--- getallchildren %s", (char *) cn.value.string->hdl)); if (cn.type == CMPI_string && cn.value.string && cn.value.string->hdl) { int n = 0, i = 0; loopOnChildCount(cReg, (char *) cn.value.string->hdl, &n, ignprov); _SFCB_TRACE(1, ("--- count %d", n)); ar = CMNewArray(_broker, n, CMPI_string, NULL); if (n) { _SFCB_TRACE(1, ("--- loop %s", (char *) cn.value.string->hdl)); loopOnChildChars(cReg, (char *) cn.value.string->hdl, ar, &i, ignprov); } st = CMAddArg(out, "children", &ar, CMPI_stringA); } else { } cReg->ft->wUnLock(cReg); } else if (strcasecmp(methodName, "getassocs") == 0) { ar = CMNewArray(_broker, cReg->topAssocs, CMPI_string, NULL); ClassBase *cb = (ClassBase *) (cReg + 1); UtilHashTable *ct = cb->ht; HashTableIterator *i; char *cn; ClassRecord *crec; int n; cReg->ft->wLock(cReg); for (n = 0, i = ct->ft->getFirst(ct, (void **) &cn, (void **) &crec); i; i = ct->ft->getNext(ct, i, (void **) &cn, (void **) &crec)) { if (crec->flags & CREC_isAssociation && crec->parent == NULL) { /* * add top-level association class */ CMSetArrayElementAt(ar, n++, cn, CMPI_chars); } } CMAddArg(out, "assocs", &ar, CMPI_stringA); cReg->ft->wUnLock(cReg); } else if (strcasecmp(methodName, "ischild") == 0) { char *parent = (char *) CMGetClassName(ref, NULL)->hdl; char *chldn = (char *) CMGetArg(in, "child", NULL).value.string->hdl; st.rc = traverseChildren(cReg, parent, chldn); } else if (strcasecmp(methodName, "_startup") == 0) { /* let providerMgr know that we're odne init'ing */ semRelease(sfcbSem,INIT_CLASS_PROV_ID); st.rc = CMPI_RC_OK; } else { mlogf(M_ERROR, M_SHOW, "--- ClassProvider: Invalid invokeMethod request %s\n", methodName); st.rc = CMPI_RC_ERR_METHOD_NOT_FOUND; } _SFCB_RETURN(st); }
CMPIStatus IndCIMXMLHandlerInvokeMethod(CMPIMethodMI * mi, const CMPIContext *ctx, const CMPIResult *rslt, const CMPIObjectPath * ref, const char *methodName, const CMPIArgs * in, CMPIArgs * out) { _SFCB_ENTER(TRACE_INDPROVIDER, "IndCIMXMLHandlerInvokeMethod"); CMPIStatus st = { CMPI_RC_OK, NULL }; CMPIStatus circ = { CMPI_RC_OK, NULL }; struct timeval tv; struct timezone tz; static unsigned int indID=1; if (interOpNameSpace(ref, &st) == 0) _SFCB_RETURN(st); if (strcasecmp(methodName, "_deliver") == 0) { // On the first indication, check if reliable indications are enabled. if (RIEnabled == -1) { CMPIObjectPath *op=CMNewObjectPath(_broker,"root/interop","CIM_IndicationService",NULL); CMPIEnumeration *isenm = _broker->bft->enumerateInstances(_broker, ctx, op, NULL, NULL); CMPIData isinst=CMGetNext(isenm,NULL); CMPIData mc=CMGetProperty(isinst.value.inst,"DeliveryRetryAttempts",NULL); RIEnabled=mc.value.uint16; } CMPIInstance *indo=CMGetArg(in,"indication",NULL).value.inst; CMPIInstance *ind=CMClone(indo,NULL); CMPIContext *ctxLocal=NULL; CMPIObjectPath *iop=NULL,*subop=NULL; CMPIInstance *sub=NULL; if (RIEnabled) { ctxLocal = prepareUpcall((CMPIContext *) ctx); // Set the indication sequence values iop=CMGetObjectPath(ind,NULL); CMAddKey(iop,"SFCB_IndicationID",&indID,CMPI_uint32); CMSetProperty(ind,"SFCB_IndicationID",&indID,CMPI_uint32); // Prevent this property from showing up in the indication filterFlagProperty(ind, "SFCB_IndicationID"); sub=CMGetArg(in,"subscription",NULL).value.inst; CMPIData handler=CMGetProperty(sub, "Handler", &st); CMPIObjectPath *hop=handler.value.ref; CMPIInstance *hdlr=CBGetInstance(_broker, ctxLocal, hop, NULL, &st); // Build the complete sequence context // Get the stub from the handler CMPIString *context = CMGetProperty(hdlr, "SequenceContext", &st).value.string; // and add the sfcb start time char *cstr=malloc( (strlen(context->ft->getCharPtr(context,NULL)) + strlen(sfcBrokerStart) + 1) * sizeof(char)); sprintf(cstr,"%s%s",context->ft->getCharPtr(context,NULL),sfcBrokerStart); context = sfcb_native_new_CMPIString(cstr, NULL, 0); // and put it in the indication CMSetProperty(ind, "SequenceContext", &context, CMPI_string); free(cstr); CMRelease(context); // Get the proper sequence number CMPIValue lastseq = CMGetProperty(hdlr, "LastSequenceNumber", &st).value; lastseq.sint64++; // Handle wrapping of the signed int if (lastseq.sint64 < 0) lastseq.sint64=0; // Update the last used number in the handler CMSetProperty(hdlr, "LastSequenceNumber", &lastseq.sint64, CMPI_sint64); CBModifyInstance(_broker, ctxLocal, hop, hdlr, NULL); // And the indication CMSetProperty(ind, "SequenceNumber", &lastseq, CMPI_sint64); } // Now send the indication st = deliverInd(ref, in, ind); if (st.rc != 0) { if (RIEnabled){ _SFCB_TRACE(1,("--- Indication delivery failed, adding to retry queue")); // Indication delivery failed, send to retry queue // build an element RTElement *element; element = (RTElement *) malloc(sizeof(*element)); element->ref=ref->ft->clone(ref,NULL); // Get the OP of the subscription and indication subop=CMGetObjectPath(sub,NULL); element->sub=subop->ft->clone(subop,NULL); element->ind=iop->ft->clone(iop,NULL); // Store other attrs element->instanceID=indID; element->count=0; gettimeofday(&tv, &tz); element->lasttry=tv.tv_sec; // Push the indication to the repo CBCreateInstance(_broker, ctxLocal, iop, ind, &circ); if (circ.rc != 0) { mlogf(M_ERROR,M_SHOW,"Pushing indication instance to repository failed, rc:%d\n",circ.rc); } indID++; // Add it to the retry queue enqRetry(element,ctx,1); // And launch the thread if it isn't already running pthread_attr_init(&tattr); pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED); if (retryRunning == 0) { retryRunning = 1; _SFCB_TRACE(1,("--- Starting retryExport thread")); CMPIContext *pctx = native_clone_CMPIContext(ctx); pthread_create(&t, &tattr, &retryExport, (void *) pctx); } CMRelease(ctxLocal); } } CMRelease(ind); } else { printf("--- ClassProvider: Invalid request %s\n", methodName); st.rc = CMPI_RC_ERR_METHOD_NOT_FOUND; } _SFCB_RETURN(st); }
CMPIStatus TestMethodProviderInvokeMethod ( CMPIMethodMI * mi, const CMPIContext * ctx, const CMPIResult * rslt, const CMPIObjectPath * ref, const char *methodName, const CMPIArgs * in, CMPIArgs * out) { CMPIStatus rc = { CMPI_RC_OK, NULL }; CMPIString *className; CMPIData data; char result[80] = "Hello,"; const char *strCat; const char * name; char *argName = "Message"; CMPIString * str1; CMPIString * str2; CMPIValue val1, val2; /* get the class name from object-path */ className = CMGetClassName(ref, &rc); /* get a pointer to a C char* representation of this String. */ name = CMGetCharsPtr(className, &rc); if(!strcmp(name, _ClassName)) { if(!strcmp ("SayHello", methodName)) { /* gets the number of arguments contained in "in" Args. */ if(CMGetArgCount(in, &rc) > 0) { /* gets a Name argument value */ data = CMGetArg(in, "Name", &rc); /*check for data type and not null value of argument value recieved */ if(data.type == CMPI_string && !(CMIsNullValue(data))) { strCat = CMGetCharsPtr(data.value.string, &rc); strcat(result, strCat); // strcat(result, "!"); /* create the new string to return to client */ str1 = CMNewString(_broker, result, &rc); val1.string = str1; } } else { str1 = CMNewString(_broker, result, &rc); val1.string = str1; } /* create string to add to an array */ str2 = CMNewString(_broker,"Have a good day", &rc); val2.string = str2; /* Adds a value of str2 string to out array argument */ rc = CMAddArg(out, argName, &val2, CMPI_string); } else if (!strcmp("CheckArrayNoType", methodName)) { data = CMGetArg(in, "IntArray", &rc); CMPIType atype=data.value.array->ft->getSimpleType(data.value.array,&rc); sprintf(result,"Datatype is %s",paramType(atype)); str1 = CMNewString(_broker, result, &rc); val1.string = str1; } } CMReturnData (rslt, (CMPIValue *) &val1, CMPI_string); CMReturnDone (rslt); return rc; }
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 CMPIStatus enumInstances(CMPIInstanceMI * mi, const CMPIContext *ctx, void *rslt, const CMPIObjectPath * ref, const char **properties, void (*retFnc) (void *, CMPIInstance *), int ignprov) { CMPIStatus st = { CMPI_RC_OK, NULL }; CMPIStatus sti = { CMPI_RC_OK, NULL }; BlobIndex *bi; CMPIString *cn = CMGetClassName(ref, NULL); CMPIString *ns = CMGetNameSpace(ref, NULL); const char *nss = ns->ft->getCharPtr(ns, NULL); const char *cns = cn->ft->getCharPtr(cn, NULL); const char *bnss = repositoryNs(nss); int len, i, ac = 0; CMPIInstance *ci; CMPIArgs *in, *out; CMPIObjectPath *op; CMPIArray *ar; CMPIData rv; const char **keyList; _SFCB_ENTER(TRACE_INTERNALPROVIDER, "enumInstances"); _SFCB_TRACE(1, ("--- %s %s", nss, cns)); in = CMNewArgs(Broker, NULL); out = CMNewArgs(Broker, NULL); if (ignprov) CMAddArg(in, "classignoreprov", cns, CMPI_chars); else CMAddArg(in, "class", cns, CMPI_chars); op = CMNewObjectPath(Broker, bnss, "$ClassProvider$", &sti); _SFCB_TRACE(1, ("--- getallchildren")); rv = CBInvokeMethod(Broker, ctx, op, "getallchildren", in, out, &sti); _SFCB_TRACE(1, ("--- getallchildren rc: %d", sti.rc)); ar = CMGetArg(out, "children", NULL).value.array; if (ar) ac = CMGetArrayCount(ar, NULL); _SFCB_TRACE(1, ("--- getallchildren ar: %p count: %d", ar, ac)); for (i = 0; cns; i++) { _SFCB_TRACE(1, ("--- looking for %s", cns)); if ((bi = _getIndex(bnss, cns)) != NULL) { for (ci = ipGetFirst(bi, &len, NULL, 0); ci; ci = ipGetNext(bi, &len, NULL, 0)) { if (properties) { keyList = getKeyList(ci->ft->getObjectPath(ci, NULL)); ci->ft->setPropertyFilter(ci, properties, keyList); if (keyList) { free(keyList); } } _SFCB_TRACE(1, ("--- returning instance %p", ci)); retFnc(rslt, ci); } } freeBlobIndex(&bi, 1); if (i < ac) cns = (char *) CMGetArrayElementAt(ar, i, NULL).value.string->hdl; else cns = NULL; } _SFCB_RETURN(st); }
CMPIStatus InternalProviderEnumInstanceNames(CMPIInstanceMI * mi, const CMPIContext *ctx, const CMPIResult *rslt, const CMPIObjectPath * ref) { CMPIStatus st = { CMPI_RC_OK, NULL }; CMPIStatus sti = { CMPI_RC_OK, NULL }; BlobIndex *bi; CMPIString *cn = CMGetClassName(ref, NULL); CMPIString *ns = CMGetNameSpace(ref, NULL); CMPIObjectPath *cop; const char *nss = ns->ft->getCharPtr(ns, NULL); const char *cns = cn->ft->getCharPtr(cn, NULL); const char *bnss = repositoryNs(nss); size_t ekl; int i, ac = 0; char copKey[8192] = ""; char *kp; CMPIArgs *in, *out; CMPIObjectPath *op; CMPIArray *ar; CMPIData rv; _SFCB_ENTER(TRACE_INTERNALPROVIDER, "InternalProviderEnumInstanceNames"); _SFCB_TRACE(1, ("%s %s", nss, cns)); in = CMNewArgs(Broker, NULL); out = CMNewArgs(Broker, NULL); CMAddArg(in, "class", cns, CMPI_chars); op = CMNewObjectPath(Broker, bnss, "$ClassProvider$", &sti); rv = CBInvokeMethod(Broker, ctx, op, "getallchildren", in, out, &sti); ar = CMGetArg(out, "children", NULL).value.array; if (ar) ac = CMGetArrayCount(ar, NULL); for (i = 0; cns; i++) { if ((bi = _getIndex(bnss, cns)) != NULL) { if (ipGetFirst(bi, NULL, &kp, &ekl)) { while (1) { strcpy(copKey, nss); strcat(copKey, ":"); strcat(copKey, cns); strcat(copKey, "."); strncat(copKey, kp, ekl); cop = getObjectPath(copKey, NULL); if (cop) CMReturnObjectPath(rslt, cop); else { CMPIStatus st = { CMPI_RC_ERR_FAILED, NULL }; return st; } if (bi->next < bi->dSize && ipGetNext(bi, NULL, &kp, &ekl)) { continue; } break; } } freeBlobIndex(&bi, 1); } if (i < ac) cns = (char *) CMGetArrayElementAt(ar, i, NULL).value.string->hdl; else cns = NULL; } _SFCB_RETURN(st); }
/* * invokeMethod */ static CMPIStatus invokeMethod( CMPIMethodMI* self, const CMPIContext* ctx, const CMPIResult* rslt, const CMPIObjectPath* objName, const char* method, const CMPIArgs* in, CMPIArgs* out) { Target_Type _ctx; Target_Type _objName; CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; _SBLIM_TRACE(1,("invokeMethod() called, ctx %p, rslt %p, objName %p, method %s, in %p, out %p", ctx, rslt, objName, method, in, out)); TARGET_THREAD_BEGIN_BLOCK; _ctx = SWIG_NewPointerObj((void*) ctx, SWIGTYPE_p__CMPIContext, 0); _objName = SWIG_NewPointerObj((void*) objName, SWIGTYPE_p__CMPIObjectPath, 0); /* Ruby style method invocation */ #if defined(SWIGRUBY) /* de-camelize method name, might need 2time length */ char *methodname = alloca(strlen(method) * 2 + 1); decamelize(method, methodname); /* access method arguments information via <decamelized>_args */ int argsnamesize = strlen(methodname) + 5 + 1; char *argsname = alloca(argsnamesize); /* "<name>_args" */ snprintf(argsname, argsnamesize, "%s_args", methodname); /* get the args array, gives names of input and output arguments */ VALUE args = rb_funcall(((ProviderMIHandle*)self->hdl)->implementation, rb_intern(argsname), 0); if (check_ruby_type(args, T_ARRAY, "invoke: <method>_args must be Array", &status, (ProviderMIHandle*)self->hdl ) < 0) return status; VALUE argsin = rb_ary_entry(args, 0); /* array of input arg names */ if (check_ruby_type(argsin, T_ARRAY, "invoke: Input arguments must be Array", &status, (ProviderMIHandle*)self->hdl ) < 0) return status; int number_of_arguments = RARRAY_LEN(argsin) / 2; _SBLIM_TRACE(1,("%s -> %d input args", argsname, number_of_arguments)); /* 3 args will be added by TargetCall, 2 args are added here, others are input args to function */ VALUE *input = alloca((3 + 2 + number_of_arguments) * sizeof(VALUE)); input[3] = _ctx; input[4] = _objName; /* loop over input arg names and types and get CMPIData via CMGetArg() */ int i; for (i = 0; i < number_of_arguments; ++i) { const char *argname; CMPIData data; argname = target_charptr(rb_ary_entry(argsin, i*2)); data = CMGetArg(in, argname, &status); if (status.rc != CMPI_RC_OK) { if ((data.state & CMPI_nullValue) ||(data.state & CMPI_notFound)) { input[5+i] = Target_Null; continue; } _SBLIM_TRACE(1,("Failed (rc %d) to get input arg %d:%s for %s", status.rc, i>>1, argname, method)); return status; } input[5+i] = data_value(&data); } /* actual provider call, passes output args and return value via 'result' */ VALUE result = TargetCall((ProviderMIHandle*)self->hdl, &status, methodname, -(2+number_of_arguments), input); /* argsout is array of [<return_type>, <output_arg_name>, <output_arg_type>, ... */ VALUE argsout = rb_ary_entry(args, 1); CMPIValue value; CMPIType expected_type; CMPIType actual_type; if (check_ruby_type(argsout, T_ARRAY, "invoke: Output arguments must be Array", &status, (ProviderMIHandle*)self->hdl) < 0) return status; number_of_arguments = (RARRAY_LEN(argsout) - 1); if (number_of_arguments > 0) { /* if output args are defined, result must be an array * result[0] is the return value * result[1..n] are the output args in argsout order */ if (check_ruby_type(result, T_ARRAY, "invoke: function with output arguments must return Array", &status, (ProviderMIHandle*)self->hdl) < 0) return status; /* loop over output arg names and types and set CMPIData via CMSetArg() */ for (i = 0; i < number_of_arguments; i += 2) { const char *argname; argname = target_charptr(rb_ary_entry(argsout, i+1)); expected_type = FIX2ULONG(rb_ary_entry(argsout, i+2)); actual_type = target_to_value(rb_ary_entry(result, (i >> 1) + 1), &value, expected_type); status = CMAddArg(out, argname, &value, actual_type); if (status.rc != CMPI_RC_OK) { _SBLIM_TRACE(1,("Failed (rc %d) to set output arg %d:%s for %s; expected type %x, actual type %x", status.rc, i>>1, argname, method, expected_type, actual_type)); return status; } } /* result[0] is the return value */ result = rb_ary_entry(result, 0); }
int main() { CMCIClient * cc; CMPIObjectPath * objectpath; CMPIStatus status; CMPIArgs * args; char *cim_host, *cim_host_passwd, *cim_host_userid; CMPIData retval; CMPIValue arg; /* Setup a connection to the CIMOM */ cim_host = getenv("CIM_HOST"); if (cim_host == NULL) cim_host = "localhost"; cim_host_userid = getenv("CIM_HOST_USERID"); if (cim_host_userid == NULL) cim_host_userid = "root"; cim_host_passwd = getenv("CIM_HOST_PASSWD"); if (cim_host_passwd == NULL) cim_host_passwd = "password"; cc = cmciConnect(cim_host, NULL, "5988", cim_host_userid, cim_host_passwd, NULL); printf("\n----------------------------------------------------------\n"); printf("Testing invokeMethod() ...\n"); objectpath = newCMPIObjectPath("root/cimv2", "TST_MethodProperties", NULL); CMAddKey(objectpath, "CreationClassName", "TST_MethodProperties", CMPI_chars); CMAddKey(objectpath, "Id", "Instance #1", CMPI_chars); /*---------------------------------------------------------------------*/ printf("+++T1:passing IN int16_t argument\n"); args = newCMPIArgs(NULL); arg.sint16 = 65535; args->ft->addArg(args, "Property_int16", &arg, CMPI_sint16); retval = cc->ft->invokeMethod( cc, objectpath, "Method_sint16_in", args, NULL, &status); /* Print the results */ printf( "invokeMethod() rc=%d, msg=%s\n", status.rc, (status.msg)? (char *)status.msg->hdl : NULL); if (args) CMRelease(args); if (status.msg) CMRelease(status.msg); if (!status.rc) { char *cv = value2Chars(retval.type,&(retval.value)); printf("result(s):\n\treturn value:%s\n", cv); if (cv != NULL) free(cv); } else goto done; /*---------------------------------------------------------------------*/ printf("+++T2:returning int16_t value\n"); retval = cc->ft->invokeMethod( cc, objectpath, "Method_sint16", NULL, NULL, &status); /* Print the results */ printf( "invokeMethod() rc=%d, msg=%s\n", status.rc, (status.msg)? (char *)status.msg->hdl : NULL); if (!status.rc) { char *cv = value2Chars(retval.type,&(retval.value)); printf("result(s):\n\treturn value:%s\n", cv); if (cv != NULL) free(cv); } if (status.msg) CMRelease(status.msg); /*---------------------------------------------------------------------*/ printf("+++ T3:passing OUT int16_t value\n"); args = newCMPIArgs(NULL); retval = cc->ft->invokeMethod( cc, objectpath, "Method_sint16_out", NULL, args, &status); /* Print the results */ printf( "invokeMethod() rc=%d, msg=%s\n", status.rc, (status.msg)? (char *)status.msg->hdl : NULL); if (args) { char *cv; CMPIData data = CMGetArg(args, "Arg_int16", NULL); if (!CMIsNullValue(data)) { cv = value2Chars(data.type,&(data.value)); printf("\n result(s): OUT Parm:Arg_int16 type: %d value:%s\n", data.type, cv); if (cv != NULL) free(cv); CMRelease(args); } } if (status.msg) CMRelease(status.msg); if (!status.rc) { char *cv = value2Chars(retval.type,&(retval.value)); printf("result(s):\n\treturn value:%s\n", cv); if (cv != NULL) free(cv); } else goto done; /*---------------------------------------------------------------------*/ done: if (objectpath) CMRelease(objectpath); if (cc) CMRelease(cc); return 0; }
CMPIStatus TestMethodProviderInvokeMethod(CMPIMethodMI * mi, const CMPIContext *ctx, const CMPIResult *rslt, const CMPIObjectPath * ref, const char *methodName, const CMPIArgs * in, CMPIArgs * out) { CMPIStatus rc = { CMPI_RC_OK, NULL }; CMPIString *className; CMPIData data; char result[80] = "Hello,"; const char *strCat; const char *name; char *argName = "Message"; CMPIString *str1; CMPIString *str2; CMPIValue val1, val2; /* * get the class name from object-path */ className = CMGetClassName(ref, &rc); /* * get a pointer to a C char* representation of this String. */ name = CMGetCharsPtr(className, &rc); if (!strcmp(name, _ClassName)) { if (!strcmp("SayHello", methodName)) { /* * gets the number of arguments contained in "in" Args. */ if (CMGetArgCount(in, &rc) > 0) { /* * gets a Name argument value */ data = CMGetArg(in, "Name", &rc); /* * check for data type and not null value of argument value * recieved */ if (data.type == CMPI_string && !(CMIsNullValue(data))) { strCat = CMGetCharsPtr(data.value.string, &rc); strcat(result, strCat); // strcat(result, "!"); /* * create the new string to return to client */ str1 = CMNewString(_broker, result, &rc); val1.string = str1; } } else { str1 = CMNewString(_broker, result, &rc); val1.string = str1; } /* * create string to add to an array */ str2 = CMNewString(_broker, "Have a good day", &rc); val2.string = str2; /* * Adds a value of str2 string to out array argument */ rc = CMAddArg(out, argName, &val2, CMPI_string); /* * For: 3048960 method array types not filled in Test provider. */ } else if (!strcmp("CheckArrayNoType", methodName)) { data = CMGetArg(in, "IntArray", &rc); CMPIType atype=data.value.array->ft->getSimpleType(data.value.array,&rc); sprintf(result,"Datatype is %s",paramType(atype)); str1 = CMNewString(_broker, result, &rc); val1.string = str1; /* * This method simulates various provider problems for testing. */ } else if (!strcmp("Misbehave", methodName)) { data = CMGetArg(in, "Action", &rc); const char *strval = NULL; if (data.type == CMPI_string && !(CMIsNullValue(data))) { strval = CMGetCharsPtr(data.value.string, &rc); sprintf(result, "data type is %s, value = %s", paramType(data.type), strval); if (!strcmp(strval,"hang")) { while(sleep(60)); /* to test req handler timeout, etc. */ } else if (!strcmp(strval,"abort")) { abort(); } else if (!strcmp(strval,"fpe")) { #pragma GCC diagnostic ignored "-Wdiv-by-zero" fprintf(stderr,"ouch! %d\n",1/0); #pragma GCC diagnostic warning "-Wdiv-by-zero" } else if (!strcmp(strval,"segfault")) { void (*crashme)(void) = NULL; crashme(); } /* * These tend to behave as if the condition were raised internally */ else if (!strcmp(strval,"sigabrt")) { kill(getpid(), SIGABRT); while(sleep(3)); /* slight pause to ensure we catch signal */ } else if (!strcmp(strval,"sigfpe")) { kill(getpid(), SIGFPE); while(sleep(3)); } else if (!strcmp(strval,"sigsegv")) { kill(getpid(), SIGSEGV); while(sleep(3)); } else if (!strcmp(strval,"sigusr1")) { kill(getpid(), SIGUSR1); /* as if we received a signal from stopBroker() */ while(sleep(3)); } else if (!strcmp(strval,"sigkill")) { kill(getpid(), SIGKILL); /* this is currently not handled by providerDrv*/ while(sleep(3)); } else { sprintf(result, "Action not recognized: %s", strval); fprintf(stderr, "+++ cmpiTestMethodProvider: Action not recognized \"%s\"\n", strval); } /* * create the new string to return to client */ str1 = CMNewString(_broker, result, &rc); val1.string = str1; } } else { sprintf(result, "Unknown method name: %s", methodName); fprintf(stderr, "+++ cmpiTestMethodProvider: Unknown method name \"%s\"\n", methodName); str1 = CMNewString(_broker, result, &rc); val1.string = str1; } } CMReturnData(rslt, (CMPIValue *) & val1, CMPI_string); CMReturnDone(rslt); return rc; }
static int _testSimpleTypes() { CMPIArgs *args_ptr = NULL; CMPIStatus rc = { CMPI_RC_OK, NULL }; CMPIStatus rc1 = { CMPI_RC_OK, NULL }; int i, flag, size; CMPIValue value; CMPIValue value1; CMPIData data; CMPIData dataInst; CMPIData retDataInst; CMPIString *retNamespace = NULL; CMPIString *retClassname = NULL; CMPIObjectPath *objPath = make_ObjectPath(_broker, _Namespace, _ClassName); const char *str1; const char *str2; struct array_types { CMPIType element_type; char *typeName; char *args_name; } types_arr[] = { { CMPI_instance, "CMPI_instance", "CMPI_instance"}, { CMPI_ref, "CMPI_ref", "CMPI_ref"}}; size = 2; flag = 1; for (i = 0; i < size; i++) { args_ptr = CMNewArgs(_broker, &rc); switch (types_arr[i].element_type) { case CMPI_ref: value.ref = CMNewObjectPath(_broker, "root/cimv2", "Sample_Instance", &rc); break; case CMPI_instance: value.inst = make_Instance(objPath); value1.uint32 = 20; rc = CMSetProperty(value.inst, "Property1", &value1, CMPI_uint32); break; } rc = CMAddArg(args_ptr, types_arr[i].args_name, (CMPIValue *) & value, types_arr[i].element_type); data = CMGetArg(args_ptr, types_arr[i].args_name, &rc); switch (types_arr[i].element_type) { case CMPI_ref: retNamespace = CMGetNameSpace(data.value.ref, &rc); retClassname = CMGetClassName(data.value.ref, &rc1); if ((rc.rc == CMPI_RC_OK) && (rc1.rc == CMPI_RC_OK)) { str1 = CMGetCharsPtr(retNamespace, &rc); str2 = CMGetCharsPtr(retClassname, &rc1); if ((rc.rc == CMPI_RC_OK) && (rc1.rc == CMPI_RC_OK)) { if ((strcmp(str1, "root/cimv2")) || (strcmp(str2, "Sample_Instance"))) { flag = 0; } } else { flag = 0; } } else { flag = 0; } rc = CMRelease(value.ref); break; case CMPI_instance: retDataInst = CMGetProperty(data.value.inst, "Property1", &rc); dataInst = CMGetProperty(value.inst, "Property1", &rc); if (retDataInst.value.uint32 != dataInst.value.uint32) { flag = 0; } rc = CMRelease(value.inst); break; } if (data.type == types_arr[i].element_type && flag) { } rc = CMRelease(args_ptr); } return flag; }
static int _testArrayTypes() { struct array_types { CMPIType element_type; CMPIType typeA; char *typeName; char *typeAName; char *args_name; } types_arr[] = { { CMPI_uint32, CMPI_uint32A, "CMPI_uint32", "CMPI_uint32A", "CMPI_uint32_array"}, { CMPI_uint16, CMPI_uint16A, "CMPI_uint16", "CMPI_uint16A", "CMPI_uint16_array"}, { CMPI_uint8, CMPI_uint8A, "CMPI_uint8", "CMPI_uint8A", "CMPI_uint8_array"}, { CMPI_uint64, CMPI_uint64A, "CMPI_uint64", "CMPI_uint64A", "CMPI_uint64_array"}, { CMPI_sint32, CMPI_sint32A, "CMPI_sint32", "CMPI_sint32A", "CMPI_sint32_array"}, { CMPI_sint16, CMPI_sint16A, "CMPI_sint16", "CMPI_sint16A", "CMPI_sint16_array"}, { CMPI_sint8, CMPI_sint8A, "CMPI_sint8", "CMPI_sint8A", "CMPI_sint8_array"}, { CMPI_sint64, CMPI_sint64A, "CMPI_sint64", "CMPI_sint64A", "CMPI_sint64_array"}, { CMPI_real32, CMPI_real32A, "CMPI_real32", "CMPI_real32A", "CMPI_real32_array"}, { CMPI_real64, CMPI_real64A, "CMPI_real64", "CMPI_real64A", "CMPI_real64_array"}, { CMPI_char16, CMPI_char16A, "CMPI_char16", "CMPI_char16A", "CMPI_char16_array"}, { CMPI_boolean, CMPI_booleanA, "CMPI_boolean", "CMPI_booleanA", "CMPI_boolean_array"}, { CMPI_string, CMPI_stringA, "CMPI_string", "CMPI_stringA", "CMPI_string_array"}, { CMPI_dateTime, CMPI_dateTimeA, "CMPI_dateTime", "CMPI_dateTimeA", "CMPI_dateTime_array"}, { CMPI_ref, CMPI_refA, "CMPI_ref", "CMPI_refA", "CMPI_ref_array"}, { CMPI_instance, CMPI_instanceA, "CMPI_instance", "CMPI_instanceA", "CMPI_instance_array"}, { CMPI_null, CMPI_ARRAY, "Invalid", "InvalidArray", "Invalid_array"}}; int i, flag, size; CMPIStatus rc = { CMPI_RC_OK, NULL }; CMPIStatus rc1 = { CMPI_RC_OK, NULL }; CMPIArray *arr = NULL; CMPIString *retNamespace = NULL; CMPIString *retClassname = NULL; CMPIValue value, value1; CMPIData data; CMPIData arr_data; CMPIData dataInst; CMPIData retDataInst; CMPIArgs *args_ptr = NULL; CMPIObjectPath *objPath = make_ObjectPath(_broker, _Namespace, _ClassName); CMPIUint64 datetime1, datetime2; const char *str1; const char *str2; size = 17; for (i = 0; i < size; i++) { args_ptr = CMNewArgs(_broker, &rc); switch (types_arr[i].element_type) { case CMPI_uint32: value.uint32 = 56; break; case CMPI_uint16: value.uint16 = 32; break; case CMPI_uint8: value.uint8 = 56; break; case CMPI_uint64: value.uint64 = 32; break; case CMPI_sint32: value.sint32 = -56; break; case CMPI_sint16: value.sint16 = -32; break; case CMPI_sint8: value.sint8 = -56; break; case CMPI_sint64: value.sint64 = -32; break; case CMPI_real32: value.real32 = (CMPIReal32) -32.78; break; case CMPI_real64: value.real64 = -899.32; break; case CMPI_char16: value.char16 = 'k'; break; case CMPI_string: value.string = CMNewString(_broker, "string", &rc); break; case CMPI_boolean: value.boolean = 1; break; case CMPI_dateTime: value.dateTime = CMNewDateTime(_broker, &rc); break; case CMPI_ref: value.ref = CMNewObjectPath(_broker, "root/cimv2", "Sample_Instance", &rc); break; case CMPI_null: value.args = NULL; break; case CMPI_instance: value.inst = make_Instance(objPath); value1.uint32 = 20; rc = CMSetProperty(value.inst, "Property1", &value1, CMPI_uint32); break; } arr = NULL; rc = CMAddArg(args_ptr, "EmptyArray", (CMPIValue *) & arr, types_arr[i].typeA); arr = CMNewArray(_broker, 1, types_arr[i].element_type, &rc); rc = CMSetArrayElementAt(arr, 0, &value, types_arr[i].element_type); rc = CMAddArg(args_ptr, types_arr[i].args_name, (CMPIValue *) & arr, types_arr[i].typeA); flag = 1; if ((types_arr[i].element_type) != CMPI_null) { data = CMGetArg(args_ptr, types_arr[i].args_name, &rc); arr_data = CMGetArrayElementAt(data.value.array, 0, &rc); switch (types_arr[i].element_type) { case CMPI_uint32: if (arr_data.value.uint32 != value.uint32) { flag = 0; } break; case CMPI_uint16: if (arr_data.value.uint16 != value.uint16) { flag = 0; } break; case CMPI_uint8: if (arr_data.value.uint8 != value.uint8) { flag = 0; } break; case CMPI_uint64: if (arr_data.value.uint64 != value.uint64) { flag = 0; } break; case CMPI_sint32: if (arr_data.value.sint32 != value.sint32) { flag = 0; } break; case CMPI_sint16: if (arr_data.value.sint16 != value.sint16) { flag = 0; } break; case CMPI_sint8: if (arr_data.value.sint8 != value.sint8) { flag = 0; } break; case CMPI_sint64: if (arr_data.value.sint64 != value.sint64) { flag = 0; } break; case CMPI_real32: if (arr_data.value.real32 != value.real32) { flag = 0; } break; case CMPI_real64: if (arr_data.value.real64 != value.real64) { flag = 0; } break; case CMPI_char16: if (arr_data.value.char16 != value.char16) { flag = 0; } break; case CMPI_string: str1 = CMGetCharsPtr(arr_data.value.string, &rc); str2 = CMGetCharsPtr(value.string, &rc1); if ((rc.rc != CMPI_RC_OK) || (rc1.rc != CMPI_RC_OK) || strcmp(str1, str2)) { flag = 0; } break; case CMPI_boolean: if (arr_data.value.boolean != value.boolean) { flag = 0; } break; case CMPI_dateTime: datetime1 = CMGetBinaryFormat(arr_data.value.dateTime, &rc); datetime2 = CMGetBinaryFormat(value.dateTime, &rc1); if ((rc.rc != CMPI_RC_OK) || (rc1.rc != CMPI_RC_OK) || (datetime1 != datetime2)) { flag = 0; } rc = CMRelease(value.dateTime); break; case CMPI_ref: retNamespace = CMGetNameSpace(arr_data.value.ref, &rc); retClassname = CMGetClassName(arr_data.value.ref, &rc1); if ((rc.rc == CMPI_RC_OK) && (rc1.rc == CMPI_RC_OK)) { str1 = CMGetCharsPtr(retNamespace, &rc); str2 = CMGetCharsPtr(retClassname, &rc1); if ((rc.rc == CMPI_RC_OK) && (rc1.rc == CMPI_RC_OK)) { if ((strcmp(str1, "root/cimv2")) || (strcmp(str2, "TestCMPI_Instance"))) { flag = 0; } } else { flag = 0; } } else { flag = 0; } rc = CMRelease(value.ref); break; case CMPI_instance: retDataInst = CMGetProperty(arr_data.value.inst, "Property1", &rc); dataInst = CMGetProperty(value.inst, "Property1", &rc); if (retDataInst.value.uint32 != dataInst.value.uint32) { flag = 0; } rc = CMRelease(value.inst); break; } if (data.type == types_arr[i].typeA && flag) { } } rc = CMRelease(arr); rc = CMRelease(args_ptr); } return flag; }
static CMPIStatus ClassProviderInvokeMethod(CMPIMethodMI * mi, const CMPIContext * ctx, const CMPIResult * rslt, const CMPIObjectPath * ref, const char *methodName, const CMPIArgs * in, CMPIArgs * out) { CMPIStatus st = { CMPI_RC_OK, NULL }; CMPIArray *ar; int rc; ClassRegister *cReg; _SFCB_ENTER(TRACE_PROVIDERS, "ClassProviderInvokeMethod"); cReg=getNsReg(ref, &rc); if (cReg==NULL) { CMPIStatus st = { CMPI_RC_ERR_INVALID_NAMESPACE, NULL }; _SFCB_RETURN(st); } if (strcasecmp(methodName, "getchildren") == 0) { CMPIData cn = CMGetArg(in, "class", NULL); _SFCB_TRACE(1,("--- getchildren %s",(char*)cn.value.string->hdl)); cReg->ft->wLock(cReg); if (cn.type == CMPI_string && cn.value.string && cn.value.string->hdl) { char *child; int l=0, i=0; UtilList *ul = getChildren(cReg, (char *) cn.value.string->hdl); if (ul) l = ul->ft->size(ul); ar = CMNewArray(_broker, l, CMPI_string, NULL); if (ul) for (child = (char *) ul->ft->getFirst(ul); child; child = (char *) ul->ft->getNext(ul)) { CMSetArrayElementAt(ar, i++, child, CMPI_chars); } st = CMAddArg(out, "children", &ar, CMPI_stringA); } else { } cReg->ft->wUnLock(cReg); } else if (strcasecmp(methodName, "getallchildren") == 0) { int ignprov=0; CMPIStatus st; CMPIData cn = CMGetArg(in, "class", &st); cReg->ft->wLock(cReg); if (st.rc!=CMPI_RC_OK) { cn = CMGetArg(in, "classignoreprov", NULL); ignprov=1; } _SFCB_TRACE(1,("--- getallchildren %s",(char*)cn.value.string->hdl)); if (cn.type == CMPI_string && cn.value.string && cn.value.string->hdl) { int n=0,i=0; loopOnChildCount(cReg,(char *)cn.value.string->hdl,&n,ignprov); _SFCB_TRACE(1,("--- count %d",n)); ar = CMNewArray(_broker, n, CMPI_string, NULL); if (n) { _SFCB_TRACE(1,("--- loop %s",(char*)cn.value.string->hdl)); loopOnChildChars(cReg, (char *)cn.value.string->hdl,ar,&i,ignprov); } st = CMAddArg(out, "children", &ar, CMPI_stringA); } else { } cReg->ft->wUnLock(cReg); } else if (strcasecmp(methodName, "getassocs") == 0) { ar = CMNewArray(_broker, cReg->topAssocs, CMPI_string, NULL); ClassBase *cb = (ClassBase *) (cReg + 1); UtilHashTable *ct = cb->ht; HashTableIterator *i; char *cn; ClassRecord *crec; int n; cReg->ft->wLock(cReg); for (n = 0, i = ct->ft->getFirst(ct, (void **) &cn, (void **) &crec); i; i = ct->ft->getNext(ct, i, (void **) &cn, (void **) &crec)) { if(crec->flags & CREC_isAssociation && crec->parent == NULL) { /* add top-level association class */ CMSetArrayElementAt(ar, n++, cn, CMPI_chars); } } CMAddArg(out, "assocs", &ar, CMPI_stringA); cReg->ft->wUnLock(cReg); } else if (strcasecmp(methodName, "ischild") == 0) { char *parent=(char*)CMGetClassName(ref,NULL)->hdl; char *chldn=(char*)CMGetArg(in, "child", NULL).value.string->hdl; st.rc = traverseChildren(cReg, parent, chldn); } else if (strcasecmp(methodName, "_startup") == 0) { /* check to see if cacheLimit was specified in providerRegister */ CMPIStatus parm_st = { CMPI_RC_OK, NULL }; CMPIData parmdata = CMGetContextEntry(ctx, "sfcbProviderParameters", &parm_st); if (parm_st.rc == CMPI_RC_OK ) { const char* parms = CMGetCharPtr(parmdata.value.string); /* cacheLimit is currently the only param, so just take whatever is after the '=' */ const char* val = strchr(parms,'='); /* conversion to uint may cause wrapping; won't catch negatives */ cacheLimit = ((val != NULL) && (cacheLimit = atoi(val+sizeof(char)))>0) ? cacheLimit : 10; } st.rc=CMPI_RC_OK; } else { mlogf(M_ERROR,M_SHOW,"--- ClassProvider: Invalid invokeMethod request %s\n", methodName); st.rc = CMPI_RC_ERR_METHOD_NOT_FOUND; } _SFCB_RETURN(st); }