int args2xml(CMPIArgs * args, UtilStringBuffer * sb) { int i, m; _SFCB_ENTER(TRACE_CIMXMLPROC, "args2xml"); if (args == NULL) _SFCB_RETURN(0); m = CMGetArgCount(args, NULL); if (m == 0) _SFCB_RETURN(0); for (i = 0; i < m; i++) { CMPIString *name; CMPIData data; data = CMGetArgAt(args, i, &name, NULL); DATA2XML(&data, args, name, NULL, "<PARAMVALUE NAME=\"", "</PARAMVALUE>\n", sb, NULL, 1, 1); if ((data.type & (CMPI_ENC | CMPI_ARRAY)) && data.value.inst) { // don't get confused using generic release data.value.inst->ft->release(data.value.inst); } CMRelease(name); } _SFCB_RETURN(0); }
CMPIStatus IndCIMXMLHandlerDeleteInstance(CMPIInstanceMI * mi, const CMPIContext *ctx, const CMPIResult *rslt, const CMPIObjectPath * cop) { CMPIStatus st = { CMPI_RC_OK, NULL }; CMPIArgs *in, *out = NULL; CMPIObjectPath *op; _SFCB_ENTER(TRACE_INDPROVIDER, "IndCIMXMLHandlerDeleteInstance"); if (interOpNameSpace(cop, &st) == 0) _SFCB_RETURN(st); internalProviderGetInstance(cop, &st); if (st.rc) _SFCB_RETURN(st); in = CMNewArgs(_broker, NULL); CMAddArg(in, "key", &cop, CMPI_ref); op = CMNewObjectPath(_broker, "root/interop", "cim_indicationsubscription", &st); CBInvokeMethod(_broker, ctx, op, "_removeHandler", in, out, &st); if (st.rc == CMPI_RC_OK) { st = InternalProviderDeleteInstance(NULL, ctx, rslt, cop); } _SFCB_RETURN(st); }
// transforms numerical values into their string counterpart // utilizing the Values and ValueMap qualifiers char * transformValue(char *cssf, CMPIObjectPath * op, char *propertyName) // cssf = cimSLPService Field in the struct { CMPIData qd; CMPIStatus status; char *valuestr; _SFCB_ENTER(TRACE_SLP, "transformValue"); qd = CMGetPropertyQualifier(op, propertyName, "ValueMap", &status); if (status.rc) { printf("getPropertyQualifier failed ... Status: %d\n", status.rc); _SFCB_RETURN(NULL); } if (CMIsArray(qd)) { CMPIArray *arr = qd.value.array; CMPIType eletyp = qd.type & ~CMPI_ARRAY; int j = 0; int n; n = CMGetArrayCount(arr, NULL); CMPIData ele; ele = CMGetArrayElementAt(arr, j, NULL); valuestr = value2Chars(eletyp, &ele.value); j++; while (strcmp(valuestr, cssf)) { free(valuestr); ele = CMGetArrayElementAt(arr, j, NULL); valuestr = value2Chars(eletyp, &ele.value); if (j == n) { free(valuestr); _SFCB_RETURN(cssf); // nothing found, probably "NULL" -> // return it } j++; } free(valuestr); free(cssf); if (j - 1 <= n) { qd = CMGetPropertyQualifier(op, propertyName, "Values", &status); arr = qd.value.array; eletyp = qd.type & ~CMPI_ARRAY; ele = CMGetArrayElementAt(arr, j - 1, NULL); cssf = value2Chars(eletyp, &ele.value); _SFCB_RETURN(cssf); } else { // printf("No Valuemap Entry for %s in %s. Exiting ...\n", cssf, // propertyName); _SFCB_RETURN(NULL); } } else { // printf("No qualifier found for %s. Exiting ...\n", propertyName); _SFCB_RETURN(NULL); } }
static CMPIConstClass * getResolvedClass(ClassRegister * cr, const char *clsName, ClassRecord * crec, ReadCtl * rctl) { _SFCB_ENTER(TRACE_PROVIDERS, "getResolvedClass"); _SFCB_TRACE(1, ("--- classname %s cReg %p", clsName, cr)); CMPIConstClass *cc = NULL, *cls; ReadCtl ctl = *rctl; ClassBase *cb = (ClassBase *) cr->hdl; if (crec == NULL) { crec = cb->ht->ft->get(cb->ht, clsName); if (crec == NULL) _SFCB_RETURN(NULL); } if (crec->cachedRCls == NULL) { cls = getClass(cr, clsName, &ctl); ClClass *ccl = (ClClass *) cls->hdl; if (ccl->hdr.type == HDR_Class) return cls; char *pn = (char *) cls->ft->getCharSuperClassName(cls); if (pn == NULL) { *rctl = ctl; return cls; } ClClass *mc = ClClassNew(clsName, pn); cc = NEW(CMPIConstClass); cc->ft = CMPIConstClassFT; cc->hdl = mc; // printf("#-# merging %s %s\n",clsName,pn); mergeParents(cr, mc, pn, cls, rctl); if (*rctl == tempRead) _SFCB_RETURN(cc); crec->cachedRCls = cc; cb->cachedRCount++; if (cb->cachedRCount >= cSize) pruneRCache(cr); /* should this be checking rSize? */ ENQ_TOP_LIST(crec, cb->firstRCached, cb->lastRCached, nextRCached, prevRCached); } else { // printf("-#- class %s in resolved cache // %p\n",clsName,crec->cachedRCls); if (crec != cb->firstRCached) { DEQ_FROM_LIST(crec, cb->firstRCached, cb->lastRCached, nextRCached, prevRCached); ENQ_TOP_LIST(crec, cb->firstRCached, cb->lastRCached, nextRCached, prevRCached); } } *rctl = cached; _SFCB_RETURN(crec->cachedRCls); }
CMPIStatus IndCIMXMLHandlerEnumInstanceNames(CMPIInstanceMI * mi, const CMPIContext * ctx, const CMPIResult * rslt, const CMPIObjectPath * ref) { CMPIStatus st; CMPIEnumeration *enm; CMPIContext *ctxLocal; _SFCB_ENTER(TRACE_INDPROVIDER, "IndCIMXMLHandlerEnumInstanceNames"); if (interOpNameSpace(ref,&st)!=1) _SFCB_RETURN(st); ctxLocal = prepareUpcall((CMPIContext *)ctx); #ifdef HAVE_OPTIMIZED_ENUMERATION CMPIString* cn; CMPIObjectPath* refLocal; cn = CMGetClassName(ref, &st); if (strcasecmp(CMGetCharPtr(cn), "cim_listenerdestination") == 0) { enm = _broker->bft->enumerateInstanceNames(_broker, ctxLocal, ref, &st); while(enm && enm->ft->hasNext(enm, &st)) { CMReturnObjectPath(rslt, (enm->ft->getNext(enm, &st)).value.ref); } refLocal = CMNewObjectPath(_broker,"root/interop","cim_listenerdestinationcimxml",&st); enm = _broker->bft->enumerateInstanceNames(_broker, ctxLocal, refLocal, &st); while(enm && enm->ft->hasNext(enm, &st)) { CMReturnObjectPath(rslt, (enm->ft->getNext(enm, &st)).value.ref); } refLocal = CMNewObjectPath(_broker,"root/interop","cim_indicationhandlercimxml",&st); enm = _broker->bft->enumerateInstanceNames(_broker, ctxLocal, refLocal, &st); while(enm && enm->ft->hasNext(enm, &st)) { CMReturnObjectPath(rslt, (enm->ft->getNext(enm, &st)).value.ref); } CMRelease(refLocal); } else { enm = _broker->bft->enumerateInstanceNames(_broker, ctxLocal, ref, &st); while(enm && enm->ft->hasNext(enm, &st)) { CMReturnObjectPath(rslt, (enm->ft->getNext(enm, &st)).value.ref); } } #else enm = _broker->bft->enumerateInstanceNames(_broker, ctxLocal, ref, &st); while(enm && enm->ft->hasNext(enm, &st)) { CMReturnObjectPath(rslt, (enm->ft->getNext(enm, &st)).value.ref); } #endif CMRelease(ctxLocal); if(enm) CMRelease(enm); _SFCB_RETURN(st); }
static CMPIConstClass * getClass(ClassRegister * cr, const char *clsName, enum readCtl *ctl) { ClassRecord *crec; int r; CMPIConstClass *cc; char *buf; _SFCB_ENTER(TRACE_PROVIDERS, "getClass"); _SFCB_TRACE(1, ("--- classname %s cReg %p", clsName, cr)); ClassBase *cb = (ClassBase *) cr->hdl; crec = cb->ht->ft->get(cb->ht, clsName); if (crec == NULL) { _SFCB_RETURN(NULL); } if (crec->cachedCCls == NULL) { r = gzseek(cr->f, crec->position, SEEK_SET); buf = (char *) malloc(crec->length); r = gzread(cr->f, buf, crec->length); cc = NEW(CMPIConstClass); cc->hdl = buf; cc->ft = CMPIConstClassFT; cc->ft->relocate(cc); if (*ctl == tempRead) _SFCB_RETURN(cc); // printf("-#- class %s Added %p\n",clsName,cc); crec->cachedCCls = cc; cb->cachedCCount++; if (cb->cachedCCount >= cSize) pruneCCache(cr); ENQ_TOP_LIST(crec, cb->firstCCached, cb->lastCCached, nextCCached, prevCCached); *ctl = cached; } else { // printf("-#- class %s in cache %p\n",clsName,crec->cachedCCls); if (crec != cb->firstCCached) { DEQ_FROM_LIST(crec, cb->firstCCached, cb->lastCCached, nextCCached, prevCCached); ENQ_TOP_LIST(crec, cb->firstCCached, cb->lastCCached, nextCCached, prevCCached); } } *ctl = cached; _SFCB_RETURN(crec->cachedCCls); }
static CMPIStatus ClassProviderDeleteClass(CMPIClassMI * mi, const CMPIContext *ctx, const CMPIResult *rslt, const CMPIObjectPath * cop) { ClassRegister *cReg; CMPIConstClass *cl; int rc; CMPIStatus st = { CMPI_RC_OK, NULL }; _SFCB_ENTER(TRACE_PROVIDERS, "ClassProviderDeleteClass"); cReg = getNsReg(cop, &rc); if (cReg == NULL) { CMPIStatus st = { CMPI_RC_ERR_INVALID_NAMESPACE, NULL }; _SFCB_RETURN(st); } char *cn = (char *) cop->ft->getClassName(cop, NULL)->hdl; cl = getClass(cReg, cn); if (cl == NULL) { st.rc = CMPI_RC_ERR_NOT_FOUND; _SFCB_RETURN(st); } UtilList *ul = getChildren(cReg, cn); if (ul && ul->ft->size(ul)) { // char *child; // for (child =(char*)ul->ft->getFirst(ul); child; // child=(char*)ul->ft->getNext(ul)) // printf("child: %s\n",child); st.rc = CMPI_RC_ERR_CLASS_HAS_CHILDREN; _SFCB_RETURN(st); } char *pn = (char *) cl->ft->getCharSuperClassName(cl); cReg->ft->wLock(cReg); if (pn) removeChild(cReg, pn, cn); removeClass(cReg, cn); cReg->ft->wUnLock(cReg); _SFCB_RETURN(st); }
CMPIStatus InternalProviderModifyInstance(CMPIInstanceMI * mi, const CMPIContext *ctx, const CMPIResult *rslt, const CMPIObjectPath * cop, const CMPIInstance *ci, const char **properties) { CMPIStatus st = { CMPI_RC_OK, NULL }; unsigned long len; void *blob; CMPIString *cn = CMGetClassName(cop, NULL); CMPIString *ns = CMGetNameSpace(cop, NULL); char *key = normalizeObjectPathCharsDup(cop); const char *nss = ns->ft->getCharPtr(ns, NULL); const char *cns = cn->ft->getCharPtr(cn, NULL); const char *bnss = repositoryNs(nss); const char **keyList; _SFCB_ENTER(TRACE_INTERNALPROVIDER, "InternalProviderSetInstance"); if (testNameSpace(bnss, &st) == 0) { free(key); _SFCB_RETURN(st); } if (existingBlob(bnss, cns, key) == 0) { CMPIStatus st = { CMPI_RC_ERR_NOT_FOUND, NULL }; free(key); _SFCB_RETURN(st); } if (properties) { keyList = getKeyList(ci->ft->getObjectPath(ci, NULL)); ci->ft->setPropertyFilter((CMPIInstance *) ci, properties, keyList); if (keyList) { free(keyList); } } len = getInstanceSerializedSize(ci); blob = malloc(len + 64); getSerializedInstance(ci, blob); addBlob(bnss, cns, key, blob, (int) len); free(blob); free(key); _SFCB_RETURN(st); }
int enqRetry(RTElement * element, const CMPIContext * ctx, int repo) { _SFCB_ENTER(TRACE_INDPROVIDER, "enqRetry"); // Put this one on the retry queue if (pthread_mutex_lock(&RQlock) != 0) { // lock failed return 1; } if (RQhead == NULL) { // Queue is empty _SFCB_TRACE(1,("--- Adding indication to new retry queue.")); RQhead = element; RQtail = element; RQtail->next = element; RQtail->prev = element; } else { _SFCB_TRACE(1,("--- Adding indication to retry queue.")); element->next = RQtail->next; element->next->prev = element; RQtail->next = element; element->prev = RQtail; RQtail = element; } if (pthread_mutex_unlock(&RQlock) != 0) { // lock failed return 1; } _SFCB_RETURN(0); }
CMPIStatus IndCIMXMLHandlerGetInstance(CMPIInstanceMI * mi, const CMPIContext *ctx, const CMPIResult *rslt, const CMPIObjectPath * cop, const char **properties) { CMPIStatus st; CMPIInstance* ci; const char** keyList; _SFCB_ENTER(TRACE_INDPROVIDER, "IndCIMXMLHandlerGetInstance"); ci = internalProviderGetInstance(cop, &st); if (st.rc == CMPI_RC_OK) { if (isa("root/interop", CMGetCharPtr(CMGetClassName(cop,NULL)), "cim_indicationhandler")) { filterInternalProps(ci); } if (properties) { keyList = getKeyList(ci->ft->getObjectPath(ci, NULL)); ci->ft->setPropertyFilter(ci, properties, keyList); if (keyList) { free(keyList); } } CMReturnInstance(rslt, ci); } _SFCB_RETURN(st); }
static int refValue2xml(CMPIObjectPath * ci, UtilStringBuffer * sb) { _SFCB_ENTER(TRACE_CIMXMLPROC, "refValue2xml"); SFCB_APPENDCHARS_BLOCK(sb, "<VALUE.REFERENCE>\n"); if (ci && ci->hdl) { char *ns = CMGetCharPtr(CMGetNameSpace(ci, NULL)); char *hn = CMGetCharPtr(CMGetHostname(ci, NULL)); if (hn && *hn && ns && *ns) { SFCB_APPENDCHARS_BLOCK(sb, "<INSTANCEPATH>\n"); nsPath2xml(ci, sb); } else if (ns && *ns) { SFCB_APPENDCHARS_BLOCK(sb, "<LOCALINSTANCEPATH>\n"); lnsPath2xml(ci, sb); } instanceName2xml(ci, sb); if (hn && *hn && ns && *ns) { SFCB_APPENDCHARS_BLOCK(sb, "</INSTANCEPATH>\n"); } else if (ns && *ns) { SFCB_APPENDCHARS_BLOCK(sb, "</LOCALINSTANCEPATH>\n"); } } SFCB_APPENDCHARS_BLOCK(sb, "</VALUE.REFERENCE>\n"); _SFCB_RETURN(0); }
int dqRetry(CMPIContext * ctx, RTElement * cur) { _SFCB_ENTER(TRACE_INDPROVIDER, "dqRetry"); // Delete the instance in the repo CMPIObjectPath * op=CMNewObjectPath(_broker,"root/interop","SFCB_IndicationElement",NULL); CMAddKey(op,"IndicationID",&cur->instanceID,CMPI_uint32); CBDeleteInstance(_broker,ctx,op); CBDeleteInstance(_broker,ctx,cur->ind); CMRelease(op); // Remove the entry from the queue, closing the hole if (cur->next == cur) { // queue is empty free(cur); RQhead = NULL; } else { // not last cur->prev->next = cur->next; cur->next->prev = cur->prev; CMRelease(cur->ref); CMRelease(cur->sub); if (cur) free(cur); } _SFCB_RETURN(0); }
static int nsPath2xml(CMPIObjectPath * ci, UtilStringBuffer * sb) { _SFCB_ENTER(TRACE_CIMXMLPROC, "nsPath2xml"); char *hn = CMGetCharPtr(CMGetHostname(ci, NULL)); SFCB_APPENDCHARS_BLOCK(sb, "<NAMESPACEPATH>\n"); SFCB_APPENDCHARS_BLOCK(sb, "<HOST>"); if (hn && *hn) { // Use hostname from request sb->ft->appendChars(sb, hn); } else { // get the hostname hn = malloc(HOST_NAME_MAX); if (gethostname(hn, HOST_NAME_MAX) == 0) { sb->ft->appendChars(sb, hn); } else { // Using localhost SFCB_APPENDCHARS_BLOCK(sb, "localhost"); } free(hn); } SFCB_APPENDCHARS_BLOCK(sb, "</HOST>\n"); lnsPath2xml(ci, sb); SFCB_APPENDCHARS_BLOCK(sb, "</NAMESPACEPATH>\n"); _SFCB_RETURN(0); }
static int lnsPath2xml(CMPIObjectPath * ci, UtilStringBuffer * sb) { _SFCB_ENTER(TRACE_CIMXMLPROC, "lnsPath2xml"); char *ns = CMGetCharPtr(CMGetNameSpace(ci, NULL)); if (ns && *ns) { char *nsc = strdup(ns); char *nsp; ns = nsc; SFCB_APPENDCHARS_BLOCK(sb, "<LOCALNAMESPACEPATH>\n"); do { nsp = strchr(ns, '/'); if (nsp) { *nsp = 0; } SFCB_APPENDCHARS_BLOCK(sb, "<NAMESPACE NAME=\""); sb->ft->appendChars(sb, ns); SFCB_APPENDCHARS_BLOCK(sb, "\"/>\n"); if (nsp) { ns = nsp + 1; } } while (nsp); free(nsc); SFCB_APPENDCHARS_BLOCK(sb, "</LOCALNAMESPACEPATH>\n"); } _SFCB_RETURN(0); }
static int keyBinding2xml(CMPIObjectPath * op, UtilStringBuffer * sb) { int i, m; _SFCB_ENTER(TRACE_CIMXMLPROC, "keyBinding2xml"); for (i = 0, m = CMGetKeyCount(op, NULL); i < m; i++) { const char *name; char *type; CMPIData data; data = opGetKeyCharsAt(op, i, &name, NULL); SFCB_APPENDCHARS_BLOCK(sb, "<KEYBINDING NAME=\""); sb->ft->appendChars(sb, name); SFCB_APPENDCHARS_BLOCK(sb, "\">\n"); type = keyType(data.type); if (*type == '*' && data.value.ref) { refValue2xml(data.value.ref, sb); } else { SFCB_APPENDCHARS_BLOCK(sb, "<KEYVALUE VALUETYPE=\""); sb->ft->appendChars(sb, type); SFCB_APPENDCHARS_BLOCK(sb, "\">"); value2xml(data, sb, 0); SFCB_APPENDCHARS_BLOCK(sb, "</KEYVALUE>\n"); } SFCB_APPENDCHARS_BLOCK(sb, "</KEYBINDING>\n"); } _SFCB_RETURN(0); }
static int xferResultBuffer(NativeResult * nr, int to, int more, int rc, unsigned long length) { long l = sizeof(BinResponseHdr) + ((nr->sNext - 1) * sizeof(MsgSegment)); unsigned int i; int dmy = -1, s1 = l; _SFCB_ENTER(TRACE_PROVIDERDRV, "xferResultBuffer"); if (nr->data == NULL) prepResultBuffer(nr, length); for (i = 0; i < nr->sMax; i++) { nr->resp->object[i].data = (void *) l; l += nr->resp->object[i].length; } nr->resp->moreChunks = more; nr->resp->rc = rc; nr->resp->count = nr->sNext; rc = spSendResult2(&to, &dmy, nr->resp, s1, nr->data, nr->dNext); if (more) spRcvAck(to); _SFCB_RETURN(rc); }
CMPIStatus InternalProviderGetInstance(CMPIInstanceMI * mi, const CMPIContext *ctx, const CMPIResult *rslt, const CMPIObjectPath * cop, const char **properties) { CMPIStatus st = { CMPI_RC_OK, NULL }; CMPIInstance *ci; const char **keyList; _SFCB_ENTER(TRACE_INTERNALPROVIDER, "InternalProviderGetInstance"); ci = internalProviderGetInstance(cop, &st); if (st.rc == CMPI_RC_OK && properties) { keyList = getKeyList(ci->ft->getObjectPath(ci, NULL)); ci->ft->setPropertyFilter(ci, properties, keyList); if (keyList) { free(keyList); } } if (st.rc == CMPI_RC_OK) { CMReturnInstance(rslt, ci); } _SFCB_RETURN(st); }
static CMPIInstance *__beft_newInstance(const CMPIBroker * broker, const CMPIObjectPath * cop, CMPIStatus * rc) { _SFCB_ENTER(TRACE_ENCCALLS,"newInstance"); CMPIInstance *inst=TrackedCMPIInstance(cop, rc); _SFCB_RETURN(inst); }
static CMPIStatus ClassProviderGetClass(CMPIClassMI * mi, const CMPIContext *ctx, const CMPIResult *rslt, const CMPIObjectPath * ref, const char **properties) { CMPIStatus st = { CMPI_RC_OK, NULL }; CMPIString *cn = CMGetClassName(ref, NULL); CMPIConstClass *cl, *clLocal; ClassRegister *cReg; int rc; ReadCtl ctl; _SFCB_ENTER(TRACE_PROVIDERS, "ClassProviderGetClass"); _SFCB_TRACE(1, ("--- ClassName=\"%s\"", (char *) cn->hdl)); cReg = getNsReg(ref, &rc); if (cReg == NULL) { CMPIStatus st = { CMPI_RC_ERR_INVALID_NAMESPACE, NULL }; _SFCB_RETURN(st); } cReg->ft->wLock(cReg); ctl = stdRead; clLocal = getResolvedClass(cReg, (char *) cn->hdl, NULL, &ctl); if (clLocal) { /* * Make a cloned copy of the cached results to prevent thread * interference. */ _SFCB_TRACE(1, ("--- Class found")); cl = clLocal->ft->clone(clLocal, NULL); memLinkInstance((CMPIInstance *) cl); CMReturnInstance(rslt, (CMPIInstance *) cl); if (ctl != cached) CMRelease(cl); } else { _SFCB_TRACE(1, ("--- Class not found")); st.rc = CMPI_RC_ERR_NOT_FOUND; } cReg->ft->wUnLock(cReg); _SFCB_RETURN(st); }
int xferLastResultBuffer(CMPIResult *result, int to, int rc) { NativeResult *r = (NativeResult*) result; _SFCB_ENTER(TRACE_PROVIDERDRV, "xferLastResultBuffer"); rc=xferResultBuffer(r,to,0,rc, 1); /* passing 1 should be fine */ _SFCB_RETURN(rc); }
CMPIStatus IndCIMXMLHandlerCleanup(CMPIInstanceMI * mi, const CMPIContext *ctx, CMPIBoolean terminating) { CMPIStatus st = { CMPI_RC_OK, NULL }; _SFCB_ENTER(TRACE_INDPROVIDER, "IndCIMXMLHandlerCleanup"); _SFCB_RETURN(st); }
CMPIStatus InternalProviderCleanup(CMPIInstanceMI * mi, const CMPIContext *ctx, CMPIBoolean terminate) { CMPIStatus st = { CMPI_RC_OK, NULL }; _SFCB_ENTER(TRACE_INTERNALPROVIDER, "InternalProviderCleanup"); _SFCB_RETURN(st); }
static CMPIConstClass * getClass(ClassRegister * cr, const char *clsName) { _SFCB_ENTER(TRACE_PROVIDERS, "getClass"); _SFCB_TRACE(1, ("--- classname %s cReg %p", clsName, cr)); ClassBase *cb = (ClassBase *) cr->hdl; CMPIConstClass *cls = cb->ht->ft->get(cb->ht, clsName); _SFCB_RETURN(cls); }
CMPIStatus IndCIMXMLHandlerExecQuery(CMPIInstanceMI * mi, const CMPIContext * ctx, const CMPIResult * rslt, const CMPIObjectPath * cop, const char *lang, const char *query) { CMPIStatus st = { CMPI_RC_ERR_NOT_SUPPORTED, NULL }; _SFCB_ENTER(TRACE_INDPROVIDER, "IndCIMXMLHandlerExecQuery"); _SFCB_RETURN(st); }
/* * find the next position where we can stick the next object of type that * is 'length' long in 'nr'. If necessary, send what's in the buffer * already. */ static void * nextResultBufferPos(NativeResult * nr, int type, int length) { long pos, npos; _SFCB_ENTER(TRACE_PROVIDERDRV, "nextResultBufferPos"); if (nr->data == NULL) prepResultBuffer(nr, length); /* * if there won't be enough room, send it off or make nr->data bigger */ if (nr->dNext + length >= nr->dMax) { /* * either we aren't chunking or length > buffer size */ if (!nr->requestor || length >= nr->dMax) { while (nr->dNext + length >= nr->dMax) nr->dMax *= 2; nr->data = (char *) realloc(nr->data, nr->dMax); } /* * xfering current contents to make enough room */ else { xferResultBuffer(nr, nr->requestor, 1, 1, length); nr->dNext = 0; nr->sNext = 0; } } if (nr->sNext == nr->sMax) { nr->sMax *= 2; nr->resp = (BinResponseHdr *) realloc(nr->resp, sizeof(BinResponseHdr) + ((nr->sMax - 1) * sizeof(MsgSegment))); } /* * store the pointer to the location within nr->data where this object * will be */ nr->resp->object[nr->sNext].data = (void *) nr->dNext; nr->resp->object[nr->sNext].length = length; nr->resp->object[nr->sNext++].type = type; pos = nr->dNext; nr->dNext += length; /* set the position for next object after * this one. ready for memcpy */ npos = (long) (nr->data + pos); _SFCB_RETURN((void *) npos); }
int enqRetry(RTElement * element, const CMPIContext * ctx, int repo) { _SFCB_ENTER(TRACE_INDPROVIDER, "enqRetry"); // Put this one on the retry queue if (pthread_mutex_lock(&RQlock) != 0) { // lock failed return 1; } if (RQhead == NULL) { // Queue is empty _SFCB_TRACE(1,("--- Adding indication to new retry queue.")); RQhead = element; RQtail = element; RQtail->next = element; RQtail->prev = element; } else { _SFCB_TRACE(1,("--- Adding indication to retry queue.")); element->next = RQtail->next; element->next->prev = element; RQtail->next = element; element->prev = RQtail; RQtail = element; } if (repo==1) { // If this needs to be persisted in the repo // (not the initial fill from refillRetryQ) _SFCB_TRACE(1,("--- Creating SFCB_IndicationElement instance.")); CMPIObjectPath * op=CMNewObjectPath(_broker,"root/interop","SFCB_IndicationElement",NULL); // Add the indID as the only key CMAddKey(op,"IndicationID",&element->instanceID,CMPI_uint32); // Create the instance //element->SFCBIndEle=op; element->SFCBIndEle=op->ft->clone(op,NULL); CMPIInstance * ci=CMNewInstance(_broker,op,NULL); // Set all the properties CMSetProperty(ci,"IndicationID",&element->instanceID,CMPI_uint32); CMSetProperty(ci,"RetryCount",&(RQtail->count),CMPI_uint32); CMSetProperty(ci,"LastDelivery",&(RQtail->lasttry),CMPI_sint32); CMSetProperty(ci,"ld",&(element->ref),CMPI_ref); CMSetProperty(ci,"ind",&element->ind,CMPI_ref); CMSetProperty(ci,"sub",&element->sub,CMPI_ref); CBCreateInstance(_broker, ctx, op, ci, NULL); CMRelease(op); CMRelease(ci); } if (pthread_mutex_unlock(&RQlock) != 0) { // lock failed return 1; } _SFCB_RETURN(0); }
static int isa(const char *sns, const char *child, const char *parent) { int rv; _SFCB_ENTER(TRACE_INDPROVIDER, "isa"); if (strcasecmp(child, parent) == 0) return 1; rv = isChild(sns, parent, child); _SFCB_RETURN(rv); }
int instanceName2xml(CMPIObjectPath * cop, UtilStringBuffer * sb) { _SFCB_ENTER(TRACE_CIMXMLPROC, "instanceName2xml"); SFCB_APPENDCHARS_BLOCK(sb, "<INSTANCENAME CLASSNAME=\""); sb->ft->appendChars(sb, opGetClassNameChars(cop)); SFCB_APPENDCHARS_BLOCK(sb, "\">\n"); keyBinding2xml(cop, sb); SFCB_APPENDCHARS_BLOCK(sb, "</INSTANCENAME>\n"); _SFCB_RETURN(0); }
static int repCandidate(ClassRegister *cReg, char *cn) { ReadCtl ctl=stdRead; CMPIConstClass *cl = getClass(cReg,cn,&ctl); if (isAbstract(cl)) return 0; ProviderInfo *info; _SFCB_ENTER(TRACE_PROVIDERS, "repCandidate"); if (strcasecmp(cn,"cim_indicationfilter")==0 || strcasecmp(cn,"cim_indicationsubscription")==0) _SFCB_RETURN(0); while (cn != NULL) { info = pReg->ft->getProvider(pReg, cn, INSTANCE_PROVIDER); if (info) _SFCB_RETURN(0); cn = (char*)cl->ft->getCharSuperClassName(cl); if (cn==NULL) break; cl = getClass(cReg,cn,&ctl); } _SFCB_RETURN(1); }
static CMPIConstClass * assocForName(const char *nameSpace, const char *assocClass, const char *role, const char *resultRole) { CMPIConstClass *cc = getConstClass(nameSpace, assocClass); _SFCB_ENTER(TRACE_INTERNALPROVIDER, "assocForName"); _SFCB_TRACE(1, ("--- nameSpace: %s assocClass: %s cc: %p", nameSpace, assocClass, cc)); if (cc != NULL && cc->ft->isAssociation(cc) != 0 && (role == NULL || (cc->ft->getProperty(cc, role, NULL).state & CMPI_notFound) == 0) && (resultRole == NULL || (cc->ft->getProperty(cc, resultRole, NULL).state & CMPI_notFound) == 0)) { _SFCB_RETURN(cc); } else _SFCB_RETURN(NULL); }