static int cpyClass(ClClass * cl, CMPIConstClass * cc, unsigned char originId) { ClClass *ccl = (ClClass *) cc->hdl; CMPIData d; // CMPIParameter p; // CMPIType t; char *name; char *refName = NULL; int i, m, iq, mq, propId; // int parmId, methId, mp, ip; unsigned long quals; ClProperty *prop; // ClMethod *meth; // ClParameter *parm; cl->quals |= ccl->quals; for (i = 0, m = ClClassGetQualifierCount(ccl); i < m; i++) { ClClassGetQualifierAt(ccl, i, &d, &name); ClClassAddQualifierSpecial(&cl->hdr, &cl->qualifiers, name, d, &ccl->hdr); if (!(d.type & CMPI_ARRAY)) sfcb_native_release_CMPIValue(d.type, &d.value); // free(name); } for (i = 0, m = ClClassGetPropertyCount(ccl); i < m; i++) { char *pname; ClClassGetPropertyAt(ccl, i, &d, &pname, &quals, &refName); propId = ClClassAddProperty(cl, pname, d, refName); prop = ((ClProperty *) ClObjectGetClSection(&cl->hdr, &cl->properties)) + propId - 1; if (refName) { // CJB free(refName); } for (iq = 0, mq = ClClassGetPropQualifierCount(ccl, i); iq < mq; iq++) { char *qname; ClClassGetPropQualifierAt(ccl, i, iq, &d, &qname); ClClassAddPropertyQualifierSpecial(&cl->hdr, prop, qname, d, &ccl->hdr); if (!(d.type & CMPI_ARRAY)) sfcb_native_release_CMPIValue(d.type, &d.value); // CJB free(qname); } // CJB free(pname); } /* * CJB for (i=0,m=ClClassGetMethodCount(ccl); i<m; i++) { * ClClassGetMethodAt(ccl,i,&t,&name,&quals); * methId=ClClassAddMethod(cl, name, t); * meth=((ClMethod*)ClObjectGetClSection(&cl->hdr,&cl->methods))+methId-1; * * // CJB // for (iq=0,mq=ClClassGetMethQualifierCount(ccl,methId-1); * iq<mq; iq++) { // ClClassGetMethQualifierAt(ccl, meth, iq, &d, * &name); // ClClassAddMethodQualifier(&cl->hdr, meth, name, d); // } * * * for (ip=0,mp=ClClassGetMethParameterCount(ccl,methId-1); ip<mp; ip++) * { ClClassGetMethParameterAt(ccl, meth, ip, &p, &name); * parmId=ClClassAddMethParameter(&cl->hdr, meth, name, p); * parm=((ClParameter*)ClObjectGetClSection(&cl->hdr,&meth->parameters))+parmId-1; * * for (iq=0,mq=ClClassGetMethParamQualifierCount(ccl,parm); iq<mq; * iq++) { ClClassGetMethParamQualifierAt(ccl, parm, iq, &d, &name); * ClClassAddMethParamQualifier(&cl->hdr, parm, name, d); } } } */ return 0; }
int cls2xml(CMPIConstClass * cls, UtilStringBuffer * sb, unsigned int flags) { ClClass *cl = (ClClass *) cls->hdl; int i, m, q, qm, p, pm; char *type, *superCls; CMPIString *name, *qname, *refName; CMPIData data, qdata; CMPIType mtype; unsigned long quals; UtilStringBuffer *qsb = UtilFactory->newStrinBuffer(1024); _SFCB_ENTER(TRACE_CIMXMLPROC, "cls2xml"); SFCB_APPENDCHARS_BLOCK(sb, "<CLASS NAME=\""); sb->ft->appendChars(sb, cls->ft->getCharClassName(cls)); superCls = (char *) cls->ft->getCharSuperClassName(cls); if (superCls) { SFCB_APPENDCHARS_BLOCK(sb, "\" SUPERCLASS=\""); sb->ft->appendChars(sb, superCls); } SFCB_APPENDCHARS_BLOCK(sb, "\">\n"); if (flags & FL_includeQualifiers) quals2xml(cl->quals, sb); if (flags & FL_includeQualifiers) for (i = 0, m = ClClassGetQualifierCount(cl); i < m; i++) { data = cls->ft->getQualifierAt(cls, i, &name, NULL); DATA2XML(&data, cls, name, NULL, "<QUALIFIER NAME=\"", "</QUALIFIER>\n", sb, NULL, 0, 0); } for (i = 0, m = ClClassGetPropertyCount(cl); i < m; i++) { qsb->ft->reset(qsb); data = getPropertyQualsAt(cls, i, &name, &quals, &refName, NULL); if (flags & FL_includeQualifiers) quals2xml(quals << 8, qsb); if (flags & FL_includeQualifiers) for (q = 0, qm = ClClassGetPropQualifierCount(cl, i); q < qm; q++) { qdata = internalGetPropQualAt(cls, i, q, &qname, NULL); DATA2XML(&qdata, cls, qname, NULL, "<QUALIFIER NAME=\"", "</QUALIFIER>\n", qsb, NULL, 0, 0); CMRelease(qname); sfcb_native_release_CMPIValue(qdata.type, &qdata.value); } if (data.type & CMPI_ARRAY) DATA2XML(&data, cls, name, NULL, "<PROPERTY.ARRAY NAME=\"", "</PROPERTY.ARRAY>\n", sb, qsb, 0, 0); else { type = dataType(data.type); if (*type == '*') { DATA2XML(&data, cls, name, refName, "<PROPERTY.REFERENCE NAME=\"", "</PROPERTY.REFERENCE>\n", sb, qsb, 0, 0); } else DATA2XML(&data, cls, name, NULL, "<PROPERTY NAME=\"", "</PROPERTY>\n", sb, qsb, 0, 0); } CMRelease(name); } for (i = 0, m = ClClassGetMethodCount(cl); i < m; i++) { ClMethod *meth; ClParameter *parm; char *sname, *smname; CMPIString *name, *mname; qsb->ft->reset(qsb); ClClassGetMethodAt(cl, i, &mtype, &smname, &quals); mname = sfcb_native_new_CMPIString(smname, NULL, 2); meth = ((ClMethod *) ClObjectGetClSection(&cl->hdr, &cl->methods)) + i; if (flags & FL_includeQualifiers) { for (q = 0, qm = ClClassGetMethQualifierCount(cl, i); q < qm; q++) { ClClassGetMethQualifierAt(cl, meth, q, &qdata, &sname); name = sfcb_native_new_CMPIString(sname, NULL, 2); DATA2XML(&qdata, cls, name, NULL, "<QUALIFIER NAME=\"", "</QUALIFIER>\n", qsb, NULL, 0, 0); } } for (p = 0, pm = ClClassGetMethParameterCount(cl, i); p < pm; p++) { CMPIParameter pdata; ClClassGetMethParameterAt(cl, meth, p, &pdata, &sname); name = sfcb_native_new_CMPIString(sname, NULL, 2); parm = ((ClParameter *) ClObjectGetClSection(&cl->hdr, &meth->parameters)) + p; param2xml(&pdata, cls, parm, name, qsb, flags); } method2xml(mtype, mname, "<METHOD NAME=\"", "</METHOD>\n", sb, qsb); } SFCB_APPENDCHARS_BLOCK(sb, "</CLASS>\n"); qsb->ft->release(qsb); _SFCB_RETURN(0); }
static int cpyClass(ClClass * cl, CMPIConstClass * cc) { ClClass *ccl = (ClClass *) cc->hdl; CMPIData d; CMPIParameter p; CMPIType t; char *name; char *refName = NULL; int i, m, iq, mq, ip, mp, propId, methId, parmId; unsigned long quals; ClProperty *prop; ClMethod *meth; ClParameter *parm; cl->quals |= ccl->quals; for (i = 0, m = ClClassGetQualifierCount(ccl); i < m; i++) { ClClassGetQualifierAt(ccl, i, &d, &name); ClClassAddQualifierSpecial(&cl->hdr, &cl->qualifiers, name, d, &ccl->hdr); } for (i = 0, m = ClClassGetPropertyCount(ccl); i < m; i++) { ClClassGetPropertyAt(ccl, i, &d, &name, &quals, &refName); propId = ClClassAddProperty(cl, name, d, refName); if (refName) { free(refName); } prop = ((ClProperty *) ClObjectGetClSection(&cl->hdr, &cl->properties)) + propId - 1; for (iq = 0, mq = ClClassGetPropQualifierCount(ccl, i); iq < mq; iq++) { ClClassGetPropQualifierAt(ccl, i, iq, &d, &name); ClClassAddPropertyQualifierSpecial(&cl->hdr, prop, name, d, &ccl->hdr); } } for (i = 0, m = ClClassGetMethodCount(ccl); i < m; i++) { ClClassGetMethodAt(ccl, i, &t, &name, &quals); methId = ClClassAddMethod(cl, name, t); meth = ((ClMethod *) ClObjectGetClSection(&cl->hdr, &cl->methods)) + methId - 1; for (iq = 0, mq = ClClassGetMethQualifierCount(ccl, methId - 1); iq < mq; iq++) { ClClassGetMethQualifierAt(ccl, meth, iq, &d, &name); ClClassAddMethodQualifier(&cl->hdr, meth, name, d); } for (ip = 0, mp = ClClassGetMethParameterCount(ccl, methId - 1); ip < mp; ip++) { ClClassGetMethParameterAt(ccl, meth, ip, &p, &name); parmId = ClClassAddMethParameter(&cl->hdr, meth, name, p); parm = ((ClParameter *) ClObjectGetClSection(&cl->hdr, &meth->parameters)) + parmId - 1; for (iq = 0, mq = ClClassGetMethParamQualifierCount(parm); iq < mq; iq++) { ClClassGetMethParamQualifierAt(ccl, parm, iq, &d, &name); ClClassAddMethParamQualifier(&cl->hdr, parm, name, d); } } } return 0; }
static int sfcb_add_class(FILE * f, hashentry * he, class_entry * ce, int endianMode) { /* SFCB related */ ClClass * sfcbClass; ClClass * sfcbClassRewritten; ClProperty * sfcbProp; ClMethod * sfcbMeth; ClParameter * sfcbParam; CMPIParameter param; CMPIData data; int prop_id; int meth_id; int meth_param_id; int size; /* Symtab related */ qual_chain * quals = ce -> class_quals; prop_chain * props = ce -> class_props; method_chain * meths = ce -> class_methods; param_chain * meth_params; /* postfix processing - recursive */ if ( ce -> class_parent) { sfcb_add_class( f, he, ce -> class_parent, endianMode ); } if ( htlookup(he, upstrdup(ce -> class_id, strlen(ce -> class_id)), strlen(ce -> class_id)) == NULL ) { if (sfcb_options & BACKEND_VERBOSE) { fprintf(stderr," adding class %s \n", ce -> class_id ); } /* remember we did this class already */ htinsert(he, upstrdup(ce -> class_id, strlen(ce -> class_id)), strlen(ce -> class_id), (void *)1); sfcbClass = ClClassNew( ce -> class_id, ce -> class_parent ? ce -> class_parent -> class_id : NULL ); if (sfcbClass == NULL) { fprintf(stderr,"Error: could not create SFCB class for %s\n",ce -> class_id); return 1; } while (quals) { if (sfcb_options & BACKEND_VERBOSE) { fprintf(stderr," adding qualifier %s for class %s \n", quals -> qual_id, ce -> class_id ); } if (!skipQuals(quals)) { ClClassAddQualifier(&sfcbClass->hdr, &sfcbClass->qualifiers, quals->qual_id, make_cmpi_data(quals->qual_qual->qual_type, quals->qual_qual->qual_array, quals->qual_vals)); } quals = quals -> qual_next; } while (props) { if (sfcb_options & BACKEND_VERBOSE) { if (props->prop_attr & PROPERTY_KEY) fprintf(stderr," adding key property %s for class %s \n", props -> prop_id, ce -> class_id ); else fprintf(stderr," adding property %s for class %s \n", props -> prop_id, ce -> class_id ); } data = make_cmpi_data(props->prop_type, props->prop_array, props->prop_value); prop_id = ClClassAddProperty(sfcbClass, props->prop_id, data, data.type == CMPI_ref ? props->prop_type.type_ref->class_id : NULL); if (prop_id == 0) { fprintf(stderr,"Error: could not add SFCB class property %s for %s\n", props -> prop_id, ce -> class_id); return 1; } quals = props -> prop_quals; sfcbProp=((ClProperty*)ClObjectGetClSection(&sfcbClass->hdr,&sfcbClass->properties))+prop_id-1; while (quals) { if (!skipQuals(quals)) { if (sfcb_options & BACKEND_VERBOSE) { fprintf(stderr," adding qualifier %s for property %s in class %s\n", quals -> qual_id, props -> prop_id, ce -> class_id ); } ClClassAddPropertyQualifier(&sfcbClass->hdr, sfcbProp, quals->qual_id, make_cmpi_data(quals->qual_qual->qual_type, quals->qual_qual->qual_array, quals->qual_vals)); } quals = quals -> qual_next; } props = props -> prop_next; } while (meths) { meth_id = ClClassAddMethod(sfcbClass, meths->method_id, make_cmpi_type(meths->method_type, meths->method_array)); quals = meths->method_quals; sfcbMeth=((ClMethod*)ClObjectGetClSection(&sfcbClass->hdr,&sfcbClass->methods))+meth_id-1; while(quals) { if (!skipQuals(quals)) { ClClassAddMethodQualifier(&sfcbClass->hdr, sfcbMeth, quals->qual_id, make_cmpi_data(quals->qual_qual->qual_type, quals->qual_qual->qual_array, quals->qual_vals)); } quals = quals->qual_next; } meth_params = meths->method_params; while(meth_params && meth_params->param_id) { param.type = make_cmpi_type(meth_params->param_type, meth_params->param_array); param.arraySize = meth_params->param_array; if((param.type == CMPI_ref || param.type == CMPI_refA) && meth_params->param_type.type_ref) { param.refName = meth_params->param_type.type_ref->class_id; } else { param.refName = NULL; } meth_param_id = ClClassAddMethParameter(&sfcbClass->hdr, sfcbMeth, meth_params->param_id, param); quals = meth_params->param_quals; sfcbParam=((ClParameter*)ClObjectGetClSection(&sfcbClass->hdr,&sfcbMeth->parameters))+meth_param_id-1; while(quals) { if (!skipQuals(quals)) { ClClassAddMethParamQualifier(&sfcbClass->hdr, sfcbParam, quals->qual_id, make_cmpi_data(quals->qual_qual->qual_type, quals->qual_qual->qual_array, quals->qual_vals)); } quals = quals->qual_next; } meth_params = meth_params->param_next; } meths = meths->method_next; } sfcbClassRewritten = ClClassRebuildClass(sfcbClass,NULL); if (opt_reduced) { sfcbClassRewritten->hdr.type = HDR_IncompleteClass; } size=sfcbClassRewritten->hdr.size; if (swapMode) { void *tmp=sfcbClassRewritten; sfcbClassRewritten = swapEntryClass(sfcbClassRewritten,&size); free(tmp); } fwrite(sfcbClassRewritten,size,1,f); free(sfcbClassRewritten); } return 0; }