int REF_parse( const char* asc7, MOF_Object_Reference** obj_ref) { ref_error_code = 0; if (ref_error_message != 0) { free(ref_error_message); ref_error_message = 0; } ref_input_first = asc7; ref_input_last = asc7 + strlen(asc7); REF_parse(); if (ref_error_code) return ref_error_code; if (!ref_obj_ref) return -1; *obj_ref = ref_obj_ref; return 0; }
char* MOF_Object_Reference::normalize(const char* asc7) { /* * Parse the string (to create an obj-ref). */ MOF_Object_Reference* obj_ref; if (REF_parse(asc7, &obj_ref) != 0) { MOF_error_printf( "malformed object reference: \"%s\"", ref_error_message); } /* * Validate (causing further parsing of object references). */ obj_ref->validate(); /* * Normalize the obj-ref. */ obj_ref->normalize(); /* * Convert to string. */ char* tmp = obj_ref->to_string(); delete obj_ref; return tmp; }
static void _build_all_features_list( const MOF_Class_Decl* class_decl, MOF_Instance_Decl* inst_decl) { MOF_Feature_Info* p; MOF_Feature_Info* all_features = 0; MOF_Property* q; /* * Iterate the properties in the class and build the all-properties list. */ for (p = class_decl->all_features; p; p = (MOF_Feature_Info*)p->next) { MOF_Feature* feature = p->feature; MOF_Feature_Info* new_feature_info; MOF_Property* inst_prop = 0; /* * First, search for this feature in the instance declaration. */ for (q = inst_decl->properties; q; q = (MOF_Property*)q->next) { if (MOF_stricmp(feature->name, q->name) == 0) { inst_prop = q; break; } } /* * Create a new MOF_Feature_Info object. */ if ((new_feature_info = new MOF_Feature_Info()) == 0) { MOF_error("out of memory"); return; } /* * If instance contains a property with this name: */ if (inst_prop) { if (feature->type == MOF_FEATURE_PROP) { MOF_Property_Decl* prop_decl; /* * Clone the feature (and initialize). */ prop_decl = (MOF_Property_Decl*) ((MOF_Property_Decl*)feature)->clone(); if (prop_decl == 0) { MOF_error("out of memory"); return; } prop_decl->qualifiers = inst_prop->qualifiers; prop_decl->all_qualifiers = 0; prop_decl->qual_mask = 0; prop_decl->initializer = inst_prop->initializer; /* * Initialize the new_feature_info structure: */ new_feature_info->feature = (MOF_Feature*)prop_decl; new_feature_info->class_origin = p->class_origin; new_feature_info->propagated = p->propagated; /* * Build the all qualifiers list */ prop_decl->all_qualifiers = MOF_Qualifier_Info::make_all_qualifiers( class_decl->name, 0, inst_prop->name, 0, prop_decl->qualifiers, feature->all_qualifiers, &prop_decl->qual_mask, true); /* prop */ /* * Validate the initializer (if any). */ if (inst_prop->initializer) { inst_prop->initializer->validate("property", inst_prop->name, prop_decl->data_type, prop_decl->array_index); } } else if (feature->type == MOF_FEATURE_REF) { MOF_Reference_Decl* ref_decl; /* * Clone the feature (and initialize). */ ref_decl = (MOF_Reference_Decl*) ((MOF_Reference_Decl*)feature)->clone(); if (ref_decl == 0) { MOF_error("out of memory"); return; } ref_decl->qualifiers = inst_prop->qualifiers; ref_decl->all_qualifiers = 0; ref_decl->qual_mask = 0; ref_decl->alias = 0; /* * Initialize the new_feature_info structure: */ new_feature_info->feature = (MOF_Feature*)ref_decl; new_feature_info->class_origin = p->class_origin; new_feature_info->propagated = p->propagated; /* * Build the all qualifiers list */ ref_decl->all_qualifiers = MOF_Qualifier_Info::make_all_qualifiers( class_decl->name, 0, inst_prop->name, 0, ref_decl->qualifiers, feature->all_qualifiers, &ref_decl->qual_mask, false); /* prop */ /* * Validate the alias (ATTN) OR object reference. */ if (inst_prop->initializer) { MOF_Object_Reference* obj_ref = 0; /* * Since it's a reference, we expect a string initializer. */ if (inst_prop->initializer->value_type != TOK_STRING_VALUE) { MOF_error_printf( "bad ref initializer for property: \"%s\"", inst_prop->name); return; } /* * Parse the object reference string: */ if (REF_parse( inst_prop->initializer->string_value, &obj_ref) != 0) { MOF_error_printf( "bad ref initializer for property: \"%s\"", inst_prop->name); return; } /* * Validate and normalize new object reference. */ obj_ref->validate(); obj_ref->normalize(); /* * Be sure the class of the initializer is a sub-class * of the class of the class's ref decl. */ ref_decl->validate_obj_ref(obj_ref); ref_decl->obj_ref = obj_ref; } else if (inst_prop->alias) { MOF_Object_Reference* obj_ref = MOF_Instance_Decl::alias_to_obj_ref(inst_prop->alias); /* * Be sure the class of the initializer is a sub-class * of the class of the class's ref decl. */ ref_decl->validate_obj_ref(obj_ref); ref_decl->obj_ref = obj_ref; } } } else { /* * Propagate feature from class. */ new_feature_info->feature = p->feature; new_feature_info->class_origin = p->class_origin; new_feature_info->propagated = true; } /* * Append to list: */ if (all_features) all_features->append(new_feature_info); else all_features = new_feature_info; } inst_decl->all_features = all_features; }