static CMPIStatus mergeParents(ClassRegister * cr, ClClass * cl, char *p, CMPIConstClass * cc, ReadCtl * rctl) { CMPIStatus st = { CMPI_RC_OK, NULL }; CMPIConstClass *pcc = NULL; unsigned char originId = 0; char *np = NULL; ReadCtl ctl; if (cc) { if (p) originId = ClClassAddGrandParent(cl, p); cpyClass(cl, cc, originId); } if (p) { ctl = *rctl; pcc = getClass(cr, p, &ctl); if (pcc == NULL) { st.rc = CMPI_RC_ERR_INVALID_SUPERCLASS; return st; } np = (char *) pcc->ft->getCharSuperClassName(pcc); st = mergeParents(cr, cl, np, pcc, rctl); if (ctl != cached) CMRelease(pcc); } return st; }
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); }
static CMPIStatus addClass(ClassRegister * cr, CMPIConstClass * ccp, char *cn, char *p) { CMPIStatus st = { CMPI_RC_OK, NULL }; ClassBase *cb = (ClassBase *) (cr + 1); UtilHashTable *it = cb->it; UtilList *ul; char *pn = p; CMPIConstClass *cc = ccp; ClClass *mc; if (p) { mc = ClClassNew(cn, p); st = mergeParents(cr, mc, pn, ccp); if (st.rc != CMPI_RC_OK) { ClClassFreeClass(mc); return st; } ccp->hdl = mc; } cc = ccp->ft->clone(ccp, NULL); mc = (ClClass *) cc->hdl; cb->ht->ft->put(cb->ht, strdup(cn), cc); if (cc->ft->isAssociation(cc)) { cr->assocs++; if (p == NULL) cr->topAssocs++; } if (p) { ul = it->ft->get(it, p); if (ul == NULL) { ul = UtilFactory->newList(NULL, memUnlinkEncObj); it->ft->put(it, p, ul); } ul->ft->prepend(ul, cn); } return st; }