Only in a/src/OVAL: Makefile.am Only in b/src/OVAL/api: .svn diff -u -r a/src/OVAL/api/oval_agent_api.h b/src/OVAL/api/oval_agent_api.h --- a/src/OVAL/api/oval_agent_api.h 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/api/oval_agent_api.h 2009-10-08 11:11:31 -0400 @@ -75,13 +75,20 @@ /** * @struct oval_definition_model - * OVAL object model. - * Object model holds OVAL definitions as a list of oval_definition + * OVAL definition model. + * Definition model holds OVAL definitions as a list of oval_definition * structure instances. */ struct oval_definition_model; /** + * @struct oval_variable_model + * OVAL variable model. + * The OVAL variable model facilitates access to external variable value bindings used to to constrain the evaluation of OVAL objects. + */ +struct oval_variable_model; + +/** * @struct oval_syschar_model * OVAL object model. * Object model holds OVAL system characteristics as a list of oval_syschar @@ -102,6 +109,12 @@ */ struct oval_definition_model *oval_definition_model_new(); +/** + * Copy an oval_definition_model. + */ +struct oval_definition_model *oval_definition_model_clone(struct oval_definition_model *); + + /*** * Free OVAL object model. */ @@ -263,17 +276,98 @@ void oval_definition_model_add_variable(struct oval_definition_model *, struct oval_variable *); /** + * Bind an oval_variable_model to the specified oval_definition_model. + */ +void oval_definition_model_bind_variable_model + (struct oval_definition_model *, struct oval_variable_model *); + +/** + * Create a new OVAL variable model + */ +struct oval_variable_model *oval_variable_model_new(); + +/** + * Create an OVAL variable model + */ +struct oval_variable_model *oval_variable_model_copy(struct oval_variable_model *); + +/** + * Free memory allocated to a specified oval_variable_model + * @param variable_model the specified oval_variable_model + */ +void oval_variable_model_free(struct oval_variable_model *); + +/** + * Load the specified oval_variable_model from an XML stream. + * The stream document element must be a valid instance of . + * If the oval_variable model is not empty, the loaded content will be appended to the existing content. + * @param variable_model the specified oval_variable_model. + * @param import_source the oval_import_source that resolves the XML stream. + * @param error_handler the oval_xml_error_handler that tracks the parsing of the XML stream (may be NULL) + * @param user_param a user parameter that is passed the the error handler implementation. + */ +void oval_variable_model_load + (struct oval_variable_model *, + struct oval_import_source *, + oval_xml_error_handler, void*); + +/** + * Export the specified oval_variable_model to an XML stream. + * The exported document element is a valid instance of . + * @param variable_model the specified oval_variable_model. + * @param export_target the oval_export_target that resolves the output XML stream. + */ +void oval_variable_model_export + (struct oval_variable_model *, + struct oval_export_target *); + +/** + * Get all external variables managed by a specified oval_variable_model. + * @param variable_model the specified oval_variable_model. + */ +struct oval_string_iterator *oval_variable_model_get_variable_ids + (struct oval_variable_model *); + +/** + * Get a specified external variable datatype. + * If the varid does not resolve to a managed external variable, this method returns 0. + * @param variable_model the specified oval_variable_model. + * @param varid the identifier of the required oval_variable. + */ +oval_datatype_t oval_variable_model_get_datatype + (struct oval_variable_model *, char *); + +/** + * Get a specified external variable comment. + * If the varid does not resolve to a managed external variable, this method returns NULL. + * @param variable_model the specified oval_variable_model. + * @param varid the identifier of the required oval_variable. + */ +const char *oval_variable_model_get_comment + (struct oval_variable_model *, char *); + +/** + * Get the values bound to a specified external variable. + * If the varid does not resolve to a managed external variable, this method returns NULL. + * @param variable_model the specified oval_variable_model. + * @param varid the identifier of the required oval_variable. + */ +struct oval_string_iterator *oval_variable_model_get_values + (struct oval_variable_model *, char *); + +/** * Create new oval_syschar_model. * The new model is bound to a specified oval_definition_model and variable bindings. * @relates oval_definition_model * @param definition_model the specified oval_definition_model. - * @param bindings the specified oval_variable_bindings. */ struct oval_syschar_model *oval_syschar_model_new( - struct oval_definition_model *definition_model, - struct oval_variable_binding_iterator *bindings); - + struct oval_definition_model *definition_model); +/** + * Copy an oval_syschar_model. + */ +struct oval_syschar_model *oval_syschar_model_copy(struct oval_syschar_model *); /** * free memory allocated to a specified syschar model. @@ -317,7 +411,14 @@ struct oval_syschar_model *model, char *object_id); -bool oval_syschar_model_add_variable_binding(struct oval_syschar_model *, struct oval_variable_binding *); + +/** + * Bind a variable model to the definitions bound to the syschar model. + */ +void oval_syschar_model_bind_variable_model + (struct oval_syschar_model *, struct oval_variable_model *); + +bool oval_syschar_model_add_variable_binding(/*struct oval_syschar_model *, struct oval_variable_binding **/); /** * Export system characteristics as a XML file. @@ -343,6 +444,11 @@ struct oval_definition_model *definition_model, struct oval_syschar_model **); /** + * Copy an oval_results_model. + */ +struct oval_results_model *oval_results_model_copy(struct oval_results_model *); + +/** * free memory allocated to a specified oval results model. * @relates oval_results_model * @param the specified oval_results model diff -u -r a/src/OVAL/api/oval_definitions.h b/src/OVAL/api/oval_definitions.h --- a/src/OVAL/api/oval_definitions.h 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/api/oval_definitions.h 2009-10-06 12:19:46 -0400 @@ -615,13 +615,13 @@ * Get platforms from an affected platform description. * @relates oval_affected */ -struct oval_string_iterator *oval_affected_get_platform(struct oval_affected *); +struct oval_string_iterator *oval_affected_get_platforms(struct oval_affected *); /** * Get product names from an affected platform description. * @relates oval_affected */ -struct oval_string_iterator *oval_affected_get_product (struct oval_affected *); +struct oval_string_iterator *oval_affected_get_products (struct oval_affected *); struct oval_criteria_node *oval_criteria_node_new(oval_criteria_node_type_t); void oval_criteria_node_free(struct oval_criteria_node *); @@ -798,7 +798,7 @@ void oval_object_set_deprecated(struct oval_object *, int); void oval_object_set_version(struct oval_object *, int); void oval_object_add_object_content(struct oval_object *, struct oval_object_content *); -void oval_object_add_behaviors(struct oval_object *, struct oval_behavior *); +void oval_object_add_behavior(struct oval_object *, struct oval_behavior *); int oval_object_iterator_has_more(struct oval_object_iterator *); struct oval_object *oval_object_iterator_next (struct oval_object_iterator *); @@ -851,7 +851,7 @@ * @relates oval_object */ int oval_object_get_version (struct oval_object *); -struct oval_object_content_iterator *oval_object_get_object_content(struct oval_object *); +struct oval_object_content_iterator *oval_object_get_object_contents(struct oval_object *); struct oval_behavior_iterator *oval_object_get_behaviors (struct oval_object *); struct oval_test *oval_test_new(char *); @@ -1020,6 +1020,8 @@ void oval_entity_set_varref_type(struct oval_entity *, oval_entity_varref_type_t); void oval_entity_set_variable(struct oval_entity *, struct oval_variable *); void oval_entity_set_value(struct oval_entity *, struct oval_value *); +void oval_entity_set_name(struct oval_entity *, char *); +void oval_entity_set_operation(struct oval_entity *, oval_operation_t); int oval_state_content_iterator_has_more(struct oval_state_content_iterator *); struct oval_state_content *oval_state_content_iterator_next (struct oval_state_content_iterator *); @@ -1147,7 +1149,7 @@ struct oval_behavior *oval_behavior_new(); void oval_behavior_free(struct oval_behavior *); -void behavior_set_keyval(struct oval_behavior *behavior, const char* key, const char* value); +void oval_behavior_set_keyval(struct oval_behavior *behavior, const char* key, const char* value); int oval_behavior_iterator_has_more(struct oval_behavior_iterator *); struct oval_behavior *oval_behavior_iterator_next (struct oval_behavior_iterator *); @@ -1248,7 +1250,7 @@ * Get OVAL state name. * @relates oval_state */ -char *oval_state_get_name (struct oval_state *); +const char *oval_state_get_name (struct oval_state *); /** * Get OVAL state comment. @@ -1289,7 +1291,9 @@ struct oval_variable *oval_variable_new(char *, oval_variable_type_t); void oval_variable_free(struct oval_variable *); -void oval_variable_set_type(struct oval_variable *, oval_variable_type_t); +void oval_variable_set_comment (struct oval_variable *, char *); +void oval_variable_set_deprecated(struct oval_variable *, bool); +void oval_variable_set_version (struct oval_variable *, int); void oval_variable_set_datatype(struct oval_variable *, oval_datatype_t); void oval_variable_add_value(struct oval_variable *, struct oval_value *); //type==OVAL_VARIABLE_CONSTANT void oval_variable_set_component(struct oval_variable *, struct oval_component *); //type==OVAL_VARIABLE_LOCAL @@ -1463,6 +1467,99 @@ * @relates oval_component */ char *oval_component_get_regex_pattern (struct oval_component *); //type==OVAL_COMPONENT_REGEX_CAPTURE +struct oval_value *oval_component_get_literal_value (struct oval_component *);//type==OVAL_COMPONENT_LITERAL + +/** + * Get OVAL component object. + * @see OVAL_COMPONENT_OBJECTREF + * @relates oval_component + */ +struct oval_object *oval_component_get_object (struct oval_component *);//type==OVAL_COMPONENT_OBJECTREF + +/** + * Get OVAL component object field. + * @see OVAL_COMPONENT_OBJECTREF + * @relates oval_component + */ +char *oval_component_get_object_field (struct oval_component *);//type==OVAL_COMPONENT_OBJECTREF + +/** + * Get OVAL component variable. + * @see OVAL_COMPONENT_VARREF + * @relates oval_component + */ +struct oval_variable *oval_component_get_variable (struct oval_component *);//type==OVAL_COMPONENT_VARREF + +/** + * Get OVAL component function components. + * @see OVAL_COMPONENT_FUNCTION + * @relates oval_component + */ +struct oval_component_iterator *oval_component_get_function_components (struct oval_component *);//type==OVAL_COMPONENT_FUNCTION + +/** + * Set OVAL component arithmetic operation. + * @see OVAL_COMPONENT_ARITHMETIC + * @relates oval_component + */ +void oval_component_set_arithmetic_operation + (struct oval_component *,oval_arithmetic_operation_t);//type==OVAL_COMPONENT_ARITHMETIC + +/** + * Set OVAL component begin character. + * @see OVAL_COMPONENT_BEGIN + * @relates oval_component + */ +void oval_component_set_begin_character(struct oval_component *,char *);//type==OVAL_COMPONENT_BEGIN + +/** + * Set OVAL component end character. + * @see OVAL_COMPONENT_END + * @relates oval_component + */ +void oval_component_set_end_character(struct oval_component *, char *);//type==OVAL_COMPONENT_END + +/** + * Set OVAL component split delimiter. + * @see OVAL_COMPONENT_SPLIT + * @relates oval_component + */ +void oval_component_set_split_delimiter(struct oval_component *, char *);//type==OVAL_COMPONENT_SPLIT + +/** + * Set OVAL component start of a substring. + * @see OVAL_COMPONENT_SUBSTRING + * @relates oval_component + */ +void oval_component_set_substring_start(struct oval_component *, int);//type==OVAL_COMPONENT_SUBSTRING + +/** + * Set OVAL component substring length. + * @see OVAL_COMPONENT_SUBSTRING + * @relates oval_component + */ +void oval_component_set_substring_length (struct oval_component *, int);//type==OVAL_COMPONENT_SUBSTRING + +/** + * Set OVAL component timedif format 1. + * @see OVAL_COMPONENT_TIMEDIF + * @relates oval_component + */ +void oval_component_set_timedif_format_1(struct oval_component *, oval_datetime_format_t);//type==OVAL_COMPONENT_TIMEDIF + +/** + * Set OVAL component timedif format 2. + * @see OVAL_COMPONENT_TIMEDIF + * @relates oval_component + */ +void oval_component_set_timedif_format_2(struct oval_component *, oval_datetime_format_t);//type==OVAL_COMPONENT_TIMEDIF + +/** + * Set OVAL component regex pattern. + * @see OVAL_COMPONENT_REGEX_CAPTURE + * @relates oval_component + */ +void oval_component_set_regex_pattern(struct oval_component *, char *); //type==OVAL_COMPONENT_REGEX_CAPTURE struct oval_message *oval_message_new(); void oval_message_free(struct oval_message *); diff -u -r a/src/OVAL/oval_affected.c b/src/OVAL/oval_affected.c --- a/src/OVAL/oval_affected.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/oval_affected.c 2009-10-07 16:59:55 -0400 @@ -65,14 +65,14 @@ return ((struct oval_affected *)affected)->family; } -struct oval_string_iterator *oval_affected_get_platform(struct oval_affected +struct oval_string_iterator *oval_affected_get_platforms(struct oval_affected *affected) { return (struct oval_string_iterator *) oval_collection_iterator(affected->platforms); } -struct oval_string_iterator *oval_affected_get_product(struct oval_affected +struct oval_string_iterator *oval_affected_get_products(struct oval_affected *affected) { return (struct oval_string_iterator *) @@ -89,6 +89,28 @@ return affected; } +struct oval_affected *oval_affected_clone(struct oval_affected *old_affected) +{ + struct oval_affected *new_affected = oval_affected_new(); + + oval_affected_set_family(new_affected, old_affected->family); + + struct oval_string_iterator *platforms = oval_affected_get_platforms(old_affected); + while(oval_string_iterator_has_more(platforms)){ + char *platform = oval_string_iterator_next(platforms); + oval_affected_add_platform(new_affected, platform); + } + oval_string_iterator_free(platforms); + struct oval_string_iterator *products = oval_affected_get_products(old_affected); + while(oval_string_iterator_has_more(products)){ + char *product = oval_string_iterator_next(products); + oval_affected_add_product(new_affected, product); + } + oval_string_iterator_free(products); + + return new_affected; +} + void oval_affected_free(struct oval_affected *affected) { oval_collection_free_items(affected->platforms, &free); diff -u -r a/src/OVAL/oval_agent.c b/src/OVAL/oval_agent.c --- a/src/OVAL/oval_agent.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/oval_agent.c 2009-10-08 11:15:07 -0400 @@ -38,11 +38,6 @@ int oval_errno; -typedef struct oval_export_target { - char *filename; - char *encoding; -} oval_export_target_t; - struct oval_export_target *oval_export_target_new_file(char *filename, char* encoding){ oval_export_target_t *target = (oval_export_target_t *)malloc(sizeof(oval_export_target_t)); target->filename = strdup(filename); @@ -58,10 +53,6 @@ free(target); } -typedef struct oval_import_source { - char *import_source_filename; -} oval_import_source_t; - struct oval_import_source *oval_import_source_new_file(char *filename) { oval_import_source_t *source = @@ -102,6 +93,42 @@ return newmodel; } +typedef void (*_oval_definition_model_clone_func)(void *, struct oval_definition_model *); + +void _oval_definition_model_clone + (struct oval_string_map *oldmap, struct oval_definition_model *newmodel, _oval_definition_model_clone_func cloner) +{ + struct oval_string_iterator *keys = (struct oval_string_iterator *)oval_string_map_keys(oldmap); + while(oval_string_iterator_has_more(keys)){ + char *key = oval_string_iterator_next(keys); + void *olditem = oval_string_map_get_value(oldmap, key); + (*cloner)(olditem, newmodel); + } + oval_string_iterator_free(keys); +} + +struct oval_definition_model *oval_definition_model_clone + (struct oval_definition_model *oldmodel) +{ + struct oval_definition_model *newmodel = oval_definition_model_new(); + _oval_definition_model_clone + (oldmodel->definition_map, newmodel, + (_oval_definition_model_clone_func)oval_definition_clone); + _oval_definition_model_clone + (oldmodel->object_map, newmodel, + (_oval_definition_model_clone_func)oval_object_clone); + _oval_definition_model_clone + (oldmodel->state_map, newmodel, + (_oval_definition_model_clone_func)oval_state_clone); + _oval_definition_model_clone + (oldmodel->test_map, newmodel, + (_oval_definition_model_clone_func)oval_test_clone); + _oval_definition_model_clone + (oldmodel->variable_map, newmodel, + (_oval_definition_model_clone_func)oval_variable_clone); + return newmodel; +} + void oval_definition_model_free(struct oval_definition_model * model) { oval_string_map_free(model->definition_map, (oscap_destruct_func)oval_definition_free); @@ -128,27 +155,13 @@ } oval_syschar_model_t; struct oval_syschar_model *oval_syschar_model_new( - struct oval_definition_model *definition_model, - struct oval_variable_binding_iterator *bindings){ + struct oval_definition_model *definition_model){ oval_syschar_model_t *newmodel = (oval_syschar_model_t *) malloc(sizeof(oval_syschar_model_t)); - newmodel->definition_model = definition_model; + newmodel->definition_model = definition_model; newmodel->syschar_map = oval_string_map_new(); newmodel->sysdata_map = oval_string_map_new(); newmodel->variable_binding_map = oval_string_map_new(); - if(bindings!=NULL){ - while(oval_variable_binding_iterator_has_more(bindings)){ - struct oval_variable_binding *binding = oval_variable_binding_iterator_next(bindings); - oval_syschar_model_add_variable_binding(newmodel, binding); - /* - struct oval_variable *variable = oval_variable_binding_variable(binding); - char *varid = oval_variable_id(variable); - char *value = oval_variable_binding_value(binding); - oval_string_map_put_string(newmodel->variable_binding_map, varid, value); - */ - } - oval_variable_binding_iterator_free(bindings); - } return newmodel; } void oval_syschar_model_free(struct oval_syschar_model *model){ @@ -320,6 +333,51 @@ key); } +void oval_definition_model_bind_variable_model + (struct oval_definition_model *sysmodel, struct oval_variable_model *varmodel) +{ + //Bind values to all external variables specified in the variable model. + struct oval_variable_iterator *variables = oval_definition_model_get_variables(sysmodel); + while(oval_variable_iterator_has_more(variables)){ + struct oval_variable *variable = oval_variable_iterator_next(variables); + if(oval_variable_get_type(variable)==OVAL_VARIABLE_EXTERNAL){ + char *varid = oval_variable_get_id(variable); + oval_datatype_t var_datatype = oval_variable_model_get_datatype(varmodel, varid); + if(var_datatype){//values are bound in the variable model + oval_datatype_t def_datatype = oval_variable_get_datatype(variable); + if(def_datatype==var_datatype){ + struct oval_string_iterator *values = oval_variable_model_get_values(varmodel, varid); + while(oval_string_iterator_has_more(values)){ + char *text = oval_string_iterator_next(values); + struct oval_value *value = oval_value_new(); + oval_value_set_datatype(value, var_datatype); + oval_value_set_text(value, text); + oval_variable_add_value(variable, value); + } + oval_string_iterator_free(values); + }else{ + fprintf(stderr, + "WARNING: Unmatched variable datatypes\n" + " varid = %s\n" + " definition_model datatype = %s\n" + " variable_model datatype = %s\n", + varid, + oval_datatype_get_text(def_datatype), + oval_datatype_get_text(var_datatype)); + } + } + } + } + oval_variable_iterator_free(variables); +} + +void oval_syschar_model_bind_variable_model + (struct oval_syschar_model *sysmodel, struct oval_variable_model *varmodel) +{ + oval_definition_model_bind_variable_model(sysmodel->definition_model, varmodel); +} + + struct oval_syschar *oval_syschar_model_get_syschar(struct oval_syschar_model *model, char *object_id) { @@ -371,14 +429,6 @@ return iterator; } -static struct oval_syschar_iterator *get_oval_syschars(struct oval_syschar_model - *model) -{ - struct oval_syschar_iterator *iterator = (struct oval_syschar_iterator *)oval_string_map_values(model-> - syschar_map); - return iterator; -} - struct oval_syschar *get_oval_syschar_new (struct oval_syschar_model *model, struct oval_object *object) { @@ -597,7 +647,7 @@ struct oval_string_map *sttmap, struct oval_string_map *varmap) { - struct oval_object_content_iterator *contents = oval_object_get_object_content(object); + struct oval_object_content_iterator *contents = oval_object_get_object_contents(object); while(oval_object_content_iterator_has_more(contents)){ struct oval_object_content *content = oval_object_content_iterator_next(contents); struct oval_entity *entity = oval_object_content_get_entity(content); diff -u -r a/src/OVAL/oval_agent_api_impl.h b/src/OVAL/oval_agent_api_impl.h --- a/src/OVAL/oval_agent_api_impl.h 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/oval_agent_api_impl.h 2009-10-07 17:09:12 -0400 @@ -57,6 +57,12 @@ struct oval_state *get_oval_state_new(struct oval_definition_model *, char *); struct oval_variable *get_oval_variable_new(struct oval_definition_model *, char *, oval_variable_type_t type); +struct oval_definition *oval_definition_clone(struct oval_definition *, struct oval_definition_model *); +struct oval_test *oval_test_clone (struct oval_test *, struct oval_definition_model *); +struct oval_object *oval_object_clone (struct oval_object *, struct oval_definition_model *); +struct oval_state *oval_state_clone (struct oval_state *, struct oval_definition_model *); +struct oval_variable *oval_variable_clone (struct oval_variable *, struct oval_definition_model *); + struct oval_syschar *get_oval_syschar_new(struct oval_syschar_model *, struct oval_object *); struct oval_syschar_item *get_oval_syschar_item_new(struct oval_syschar_model *, char *); @@ -68,6 +74,14 @@ struct oval_sysdata *get_oval_sysdata_new(struct oval_syschar_model *, char *); -OSCAP_HIDDEN_END; +typedef struct oval_export_target { + char *filename; + char *encoding; +} oval_export_target_t; + + +typedef struct oval_import_source { + char *import_source_filename; +} oval_import_source_t; #endif /* OVAL_AGENT_API_IMPL_H_ */ diff -u -r a/src/OVAL/oval_behavior.c b/src/OVAL/oval_behavior.c --- a/src/OVAL/oval_behavior.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/oval_behavior.c 2009-10-05 16:58:09 -0400 @@ -78,6 +78,14 @@ return behavior; } +struct oval_behavior *oval_behavior_clone(struct oval_behavior *old_behavior) +{ + struct oval_behavior *new_behavior = oval_behavior_new(); + oval_behavior_set_keyval + (new_behavior, oval_behavior_get_key(old_behavior), oval_behavior_get_value(old_behavior)); + return new_behavior; +} + void oval_behavior_free(struct oval_behavior *behavior) { if (behavior->value)free(behavior->value); @@ -87,7 +95,7 @@ free(behavior); } -void behavior_set_keyval(struct oval_behavior *behavior, const char* key, const char* value) +void oval_behavior_set_keyval(struct oval_behavior *behavior, const char* key, const char* value) { behavior->key = strdup(key); behavior->value = strdup(value); @@ -104,7 +112,7 @@ const char *value = (const char *) xmlTextReaderConstValue(reader); if (name && value) { oval_behavior_t *behavior = oval_behavior_new(); - behavior_set_keyval(behavior, name, value); + oval_behavior_set_keyval(behavior, name, value); (*consumer) (behavior, user); } } diff -u -r a/src/OVAL/oval_collection.c b/src/OVAL/oval_collection.c --- a/src/OVAL/oval_collection.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/oval_collection.c 2009-10-08 11:20:47 -0400 @@ -163,6 +163,7 @@ } } +/* static struct oval_string_iterator *oval_collection_string_iterator(struct oval_collection *os_string) @@ -170,6 +171,8 @@ return (struct oval_string_iterator *) oval_collection_iterator(os_string); } +*///TODO: REVIEW + struct oval_iterator *oval_collection_iterator_new() { @@ -217,8 +220,11 @@ printf("FREEFUNC: item = %s\n", (char *) item); } -//TEST MAIN -static int oval_collection_main(int argc, char **argv) + +/** + * This procedure is included as a test stub. + */ +int oval_collection_main(int argc, char **argv) { char *array[] = diff -u -r a/src/OVAL/oval_component.c b/src/OVAL/oval_component.c --- a/src/OVAL/oval_component.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/oval_component.c 2009-10-08 09:29:46 -0400 @@ -126,8 +126,8 @@ return component->type; } -struct oval_value *oval_component_get_literal_value(struct oval_component - *component) +struct oval_value *oval_component_get_literal_value + (struct oval_component *component) { //type==OVAL_COMPONENT_LITERAL struct oval_value *value = NULL; @@ -137,7 +137,17 @@ return value; } -struct oval_object *oval_component_get_object(struct oval_component *component) +void oval_component_set_literal_value + (struct oval_component *component, struct oval_value *value) +{ + //type==OVAL_COMPONENT_LITERAL + if (oval_component_get_type(component) == OVAL_COMPONENT_LITERAL) { + ((struct oval_component_LITERAL *)component)->value = value; + } +} + +struct oval_object *oval_component_get_object + (struct oval_component *component) { //type==OVAL_COMPONENT_OBJECTREF struct oval_object *object = NULL; @@ -146,8 +156,17 @@ } return object; } +void oval_component_set_object + (struct oval_component *component, struct oval_object *object) +{ + //type==OVAL_COMPONENT_OBJECTREF + if (oval_component_get_type(component) == OVAL_COMPONENT_OBJECTREF) { + ((struct oval_component_OBJECTREF *)component)->object = object; + } +} -char *oval_component_get_object_field(struct oval_component *component) +char *oval_component_get_object_field + (struct oval_component *component) { //type==OVAL_COMPONENT_OBJECTREF char *field = NULL; @@ -158,8 +177,18 @@ } return field; } +void oval_component_set_object_field + (struct oval_component *component, char *field) +{ + //type==OVAL_COMPONENT_OBJECTREF + if (oval_component_get_type(component) == OVAL_COMPONENT_OBJECTREF) { + ((struct oval_component_OBJECTREF *)component)-> + object_field = strdup(field); + } +} -struct oval_variable *oval_component_get_variable(struct oval_component *component) +struct oval_variable *oval_component_get_variable + (struct oval_component *component) { //type==OVAL_COMPONENT_VARREF struct oval_variable *variable = NULL; @@ -201,6 +230,16 @@ operation = OVAL_ARITHMETIC_UNKNOWN; return operation; } +void oval_component_set_arithmetic_operation + (struct oval_component *component, oval_arithmetic_operation_t operation) +{ + //type==OVAL_COMPONENT_ARITHMETIC + if (component->type == OVAL_FUNCTION_ARITHMETIC) { + oval_component_ARITHMETIC_t *arithmetic = + (oval_component_ARITHMETIC_t *) component; + arithmetic->operation = operation; + } +} char *oval_component_get_begin_character(struct oval_component *component) { @@ -214,6 +253,16 @@ character = NULL; return character; } +void oval_component_set_begin_character + (struct oval_component *component, char *character) +{ + //type==OVAL_COMPONENT_BEGIN + if (component->type == OVAL_FUNCTION_BEGIN) { + oval_component_BEGEND_t *begin = + (oval_component_BEGEND_t *) component; + begin->character = strdup(character); + } +} char *oval_component_get_end_character(struct oval_component *component) { @@ -227,6 +276,16 @@ character = NULL; return character; } +void oval_component_set_end_character + (struct oval_component *component, char *character) +{ + //type==OVAL_COMPONENT_END + if (component->type == OVAL_FUNCTION_END) { + oval_component_BEGEND_t *funcend = + (oval_component_BEGEND_t *) component; + funcend->character = strdup(character); + } +} char *oval_component_get_split_delimiter(struct oval_component *component) { @@ -240,6 +299,16 @@ delimiter = NULL; return delimiter; } +void oval_component_set_split_delimiter + (struct oval_component *component, char *delimeter) +{ + //type==OVAL_COMPONENT_SPLIT + if (component->type == OVAL_FUNCTION_SPLIT) { + oval_component_SPLIT_t *split = + (oval_component_SPLIT_t *) component; + split->delimiter = strdup(delimeter); + } +} int oval_component_get_substring_start(struct oval_component *component) { @@ -253,6 +322,15 @@ start = -1; return start; } +void oval_component_set_substring_start(struct oval_component *component, int start) +{ + //type==OVAL_COMPONENT_SUBSTRING + if (component->type == OVAL_FUNCTION_SUBSTRING) { + oval_component_SUBSTRING_t *substring = + (oval_component_SUBSTRING_t *) component; + substring->start = start; + } +} int oval_component_get_substring_length(struct oval_component *component) { @@ -266,6 +344,16 @@ length = -1; return length; } +void oval_component_set_substring_length + (struct oval_component *component, int length) +{ + //type==OVAL_COMPONENT_SUBSTRING + if (component->type == OVAL_FUNCTION_SUBSTRING) { + oval_component_SUBSTRING_t *substring = + (oval_component_SUBSTRING_t *) component; + substring->length = length; + } +} oval_datetime_format_t oval_component_get_timedif_format_1(struct oval_component * component) @@ -280,6 +368,16 @@ format = OVAL_DATETIME_UNKNOWN; return format; } +void oval_component_set_timedif_format_1 + (struct oval_component *component, oval_datetime_format_t format) +{ + //type==OVAL_COMPONENT_TIMEDIF + if (component->type == OVAL_FUNCTION_TIMEDIF) { + oval_component_TIMEDIF_t *timedif = + (oval_component_TIMEDIF_t *) component; + timedif->format_1 = format; + } +} oval_datetime_format_t oval_component_get_timedif_format_2(struct oval_component * component) @@ -294,6 +392,16 @@ format = OVAL_DATETIME_UNKNOWN; return format; } +void oval_component_set_timedif_format_2 + (struct oval_component *component, oval_datetime_format_t format) +{ + //type==OVAL_COMPONENT_TIMEDIF + if (component->type == OVAL_FUNCTION_TIMEDIF) { + oval_component_TIMEDIF_t *timedif = + (oval_component_TIMEDIF_t *) component; + timedif->format_2 = format; + } +} char *oval_component_get_regex_pattern (struct oval_component *component) @@ -307,6 +415,16 @@ } return pattern; } +void oval_component_set_regex_pattern + (struct oval_component *component, char *pattern) +{ + //type==OVAL_COMPONENT_REGEX_CAPTURE + if (component->type == OVAL_FUNCTION_REGEX_CAPTURE) { + oval_component_REGEX_CAPTURE_t *regex = + (oval_component_REGEX_CAPTURE_t *) component; + regex->pattern = (pattern)?NULL:strdup(pattern); + } +} struct oval_component *oval_component_new(oval_component_type_t type) { @@ -427,6 +545,80 @@ return component; } +void _oval_component_clone_subcomponents + (struct oval_component *old_component, struct oval_component *new_component, struct oval_definition_model *model) +{ + struct oval_component_iterator *subcomps = oval_component_get_function_components(old_component); + if(subcomps)while(oval_component_iterator_has_more(subcomps)){ + struct oval_component *subcomp = oval_component_iterator_next(subcomps); + oval_component_add_function_component(new_component, oval_component_clone(subcomp, model)); + } + oval_component_iterator_free(subcomps); +} + +struct oval_component *oval_component_clone(struct oval_component *old_component, struct oval_definition_model *model) +{ + struct oval_component *new_component = oval_component_new(old_component->type); + switch(new_component->type){ + case OVAL_FUNCTION_ARITHMETIC:{ + oval_arithmetic_operation_t operation = oval_component_get_arithmetic_operation(old_component); + if(operation)oval_component_set_arithmetic_operation(new_component, operation); + }break; + case OVAL_FUNCTION_BEGIN:{ + char *begchar = oval_component_get_begin_character(old_component); + if(begchar)oval_component_set_begin_character(new_component, begchar); + }break; + case OVAL_FUNCTION_END:{ + char *endchar = oval_component_get_end_character(old_component); + if(endchar)oval_component_set_end_character(new_component, endchar); + }break; + case OVAL_COMPONENT_LITERAL:{ + struct oval_value *value = oval_component_get_literal_value(old_component); + if(value)oval_component_set_literal_value(new_component, oval_value_clone(value)); + }break; + case OVAL_COMPONENT_OBJECTREF:{ + struct oval_object *old_object = oval_component_get_object(old_component); + if(old_object){ + struct oval_object *new_object = oval_object_clone(old_object, model); + oval_component_set_object(new_component, new_object); + } + char *field = oval_component_get_object_field(old_component); + if(field)oval_component_set_object_field(new_component, field); + }break; + case OVAL_FUNCTION_REGEX_CAPTURE:{ + char *pattern = oval_component_get_regex_pattern(old_component); + if(pattern)oval_component_set_regex_pattern(new_component, pattern); + }break; + case OVAL_FUNCTION_SPLIT:{ + char *delimiter = oval_component_get_split_delimiter(old_component); + if(delimiter)oval_component_set_split_delimiter(new_component, delimiter); + }break; + case OVAL_FUNCTION_SUBSTRING:{ + int length = oval_component_get_substring_length(old_component); + if(length>0)oval_component_set_substring_length(new_component, length); + int start = oval_component_get_substring_start(old_component); + oval_component_set_substring_start(new_component, start); + }break; + case OVAL_FUNCTION_TIMEDIF:{ + oval_datetime_format_t format1 = oval_component_get_timedif_format_1(old_component); + if(format1)oval_component_set_timedif_format_1(new_component, format1); + oval_datetime_format_t format2 = oval_component_get_timedif_format_2(old_component); + if(format2)oval_component_set_timedif_format_1(new_component, format2); + }break; + case OVAL_COMPONENT_VARREF:{ + struct oval_variable *old_variable = oval_component_get_variable(old_component); + if(old_variable){ + struct oval_variable *new_variable = oval_variable_clone(old_variable, model); + oval_component_set_variable(new_component, new_variable); + } + }break; + default: /*NOOP*/break; + } + if(new_component->type>OVAL_FUNCTION)_oval_component_clone_subcomponents(old_component, new_component, model); + + return new_component; +} + void oval_component_free(struct oval_component *component) { switch (component->type) { @@ -446,87 +638,50 @@ objectref->object_field = NULL; } break; + case OVAL_FUNCTION_BEGIN: + case OVAL_FUNCTION_END:{ + oval_component_BEGEND_t *begin = (oval_component_BEGEND_t *)component; + free(begin->character); + begin->character = NULL; + }; + break; + case OVAL_FUNCTION_SPLIT:{ + oval_component_SPLIT_t *split = (oval_component_SPLIT_t *) component; + free(split->delimiter); + split->delimiter = NULL; + }; + break; + case OVAL_FUNCTION_REGEX_CAPTURE:{ + oval_component_REGEX_CAPTURE_t *regex = (oval_component_REGEX_CAPTURE_t *) component; + free(regex->pattern); + regex->pattern = NULL; + }; + break; + case OVAL_FUNCTION_CONCAT: + case OVAL_FUNCTION_SUBSTRING: + case OVAL_FUNCTION_TIMEDIF: + case OVAL_FUNCTION_ESCAPE_REGEX: + case OVAL_FUNCTION_ARITHMETIC: + case OVAL_COMPONENT_VARREF: + case OVAL_COMPONENT_FUNCTION: case OVAL_COMPONENT_UNKNOWN: - /*NOOP*/ break; - default:{ - oval_component_FUNCTION_t *function = - (oval_component_FUNCTION_t *) component; - oval_collection_free_items(function-> - function_components, - (oscap_destruct_func)oval_component_free); - switch (component->type) { - case OVAL_FUNCTION_BEGIN: - case OVAL_FUNCTION_END:{ - oval_component_BEGEND_t *begin = - (oval_component_BEGEND_t *) - function; - free(begin->character); - begin->character = NULL; - }; - break; - case OVAL_FUNCTION_SPLIT:{ - oval_component_SPLIT_t *split = - (oval_component_SPLIT_t *) function; - free(split->delimiter); - split->delimiter = NULL; - }; - break; - case OVAL_FUNCTION_REGEX_CAPTURE:{ - oval_component_REGEX_CAPTURE_t *regex = - (oval_component_REGEX_CAPTURE_t *) function; - free(regex->pattern); - regex->pattern = NULL; - }; - break; - case OVAL_FUNCTION_CONCAT: - case OVAL_FUNCTION_SUBSTRING: - case OVAL_FUNCTION_TIMEDIF: - case OVAL_FUNCTION_ESCAPE_REGEX: - case OVAL_FUNCTION_ARITHMETIC: - case OVAL_COMPONENT_UNKNOWN: - case OVAL_COMPONENT_LITERAL: - case OVAL_COMPONENT_OBJECTREF: - case OVAL_COMPONENT_VARREF: - case OVAL_COMPONENT_FUNCTION: - break; - } - function->function_components = NULL; - } - } - free(component); -} - -void oval_component_set_literal_value(struct oval_component *component, - struct oval_value *value) -{ - //type==OVAL_COMPONENT_LITERAL - if (component->type == OVAL_COMPONENT_LITERAL) { - oval_component_LITERAL_t *literal = - (oval_component_LITERAL_t *) component; - literal->value = value; + /*NOOP*/break; } -} - -void oval_component_set_object(struct oval_component *component, - struct oval_object *object) -{ - //type==OVAL_COMPONENT_OBJECTREF - if (component->type == OVAL_COMPONENT_OBJECTREF) { - oval_component_OBJECTREF_t *objref = - (oval_component_OBJECTREF_t *) component; - objref->object = object; + if(component->type>OVAL_FUNCTION){ + oval_component_FUNCTION_t *function = + (oval_component_FUNCTION_t *) component; + oval_collection_free_items(function-> + function_components, + (oscap_destruct_func)oval_component_free); + function->function_components = NULL; } + free(component); } - -void oval_component_set_object_field(struct oval_component *component, - char *field) -{ - //type==OVAL_COMPONENT_OBJECTREF - if (component->type == OVAL_COMPONENT_OBJECTREF) { - oval_component_OBJECTREF_t *objref = - (oval_component_OBJECTREF_t *) component; - if(objref->object_field!=NULL)free(objref->object_field); - objref->object_field = field==NULL?NULL:strdup(field); +void oval_component_add_function_component + (struct oval_component *component, struct oval_component *func_component){ + if(component->type>OVAL_FUNCTION){ + oval_component_FUNCTION_t *function = (oval_component_FUNCTION_t *)component; + if(func_component)oval_collection_add(function->function_components, func_component); } } diff -u -r a/src/OVAL/oval_criteriaNode.c b/src/OVAL/oval_criteriaNode.c --- a/src/OVAL/oval_criteriaNode.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/oval_criteriaNode.c 2009-10-08 09:30:12 -0400 @@ -104,36 +104,39 @@ oval_operator_t oval_criteria_node_get_operator(struct oval_criteria_node *node) { - //type==NODETYPE_CRITERIA - return ((struct oval_criteria_node_CRITERIA *)node)->operator; + return (node->type==OVAL_NODETYPE_CRITERIA) + ?((struct oval_criteria_node_CRITERIA *)node)->operator:OVAL_OPERATOR_UNKNOWN; } struct oval_criteria_node_iterator *oval_criteria_node_get_subnodes(struct oval_criteria_node *node) { - //type==NODETYPE_CRITERIA - struct oval_criteria_node_CRITERIA *criteria = - (struct oval_criteria_node_CRITERIA *)node; - return (struct oval_criteria_node_iterator *) - oval_collection_iterator(criteria->subnodes); + struct oval_criteria_node_iterator *subnodes = NULL; + if(OVAL_NODETYPE_CRITERIA){ + struct oval_criteria_node_CRITERIA *criteria = + (struct oval_criteria_node_CRITERIA *)node; + subnodes = (struct oval_criteria_node_iterator *) + oval_collection_iterator(criteria->subnodes); + } + return subnodes; } struct oval_test *oval_criteria_node_get_test(struct oval_criteria_node *node) { //type==NODETYPE_CRITERION - return ((struct oval_criteria_node_CRITERION *)node)->test; + return (node->type==OVAL_NODETYPE_CRITERION) + ?((struct oval_criteria_node_CRITERION *)node)->test:NULL; } -struct oval_definition *oval_criteria_node_get_definition(struct oval_criteria_node - *node) +struct oval_definition *oval_criteria_node_get_definition + (struct oval_criteria_node *node) { - //type==NODETYPE_EXTENDDEF - return ((struct oval_criteria_node_EXTENDDEF *)node)->definition; + return (node->type==OVAL_NODETYPE_EXTENDDEF) + ?((struct oval_criteria_node_EXTENDDEF *)node)->definition:NULL; } -struct oval_criteria_node *oval_criteria_node_new(oval_criteria_node_type_t - type) +struct oval_criteria_node *oval_criteria_node_new(oval_criteria_node_type_t type) { struct oval_criteria_node *node; switch (type) { @@ -169,6 +172,42 @@ return node; } +struct oval_criteria_node *oval_criteria_node_clone + (struct oval_criteria_node *old_node, struct oval_definition_model *model) +{ + struct oval_criteria_node *new_node = oval_criteria_node_new(old_node->type); + char *comment = oval_criteria_node_get_comment(old_node); + oval_criteria_node_set_comment(new_node, comment); + int negate = oval_criteria_node_get_negate(old_node); + oval_criteria_node_set_negate(new_node, negate); + switch(new_node->type) + { + case OVAL_NODETYPE_CRITERIA:{ + oval_operator_t operator = oval_criteria_node_get_operator(old_node); + oval_criteria_node_set_operator(new_node, operator); + struct oval_criteria_node_iterator *subnodes = oval_criteria_node_get_subnodes(old_node); + while(oval_criteria_node_iterator_has_more(subnodes)){ + struct oval_criteria_node *subnode = oval_criteria_node_iterator_next(subnodes); + oval_criteria_node_add_subnode(new_node, oval_criteria_node_clone(subnode, model)); + } + oval_criteria_node_iterator_free(subnodes); + }break; + case OVAL_NODETYPE_EXTENDDEF:{ + struct oval_definition *old_definition = oval_criteria_node_get_definition(old_node); + struct oval_definition *new_definition = oval_definition_clone(old_definition, model); + oval_criteria_node_set_definition(new_node, new_definition); + }break; + case OVAL_NODETYPE_CRITERION:{ + struct oval_test *old_test = oval_criteria_node_get_test(old_node); + struct oval_test *new_test = oval_test_clone(old_test, model); + oval_criteria_node_set_test(new_node, new_test); + }break; + default: /*NOOP*/; + } + + return new_node; +} + void oval_criteria_node_free(struct oval_criteria_node *node) { oval_criteria_node_type_t type = node->type; @@ -217,37 +256,41 @@ void oval_criteria_node_set_operator(struct oval_criteria_node *node, oval_operator_t operator) { - //type==NODETYPE_CRITERIA - struct oval_criteria_node_CRITERIA *criteria = - (struct oval_criteria_node_CRITERIA *)node; - criteria->operator = operator; + if(node->type==OVAL_NODETYPE_CRITERIA){ + struct oval_criteria_node_CRITERIA *criteria = + (struct oval_criteria_node_CRITERIA *)node; + criteria->operator = operator; + } } void oval_criteria_node_add_subnode(struct oval_criteria_node *node, struct oval_criteria_node *subnode) { - //type==NODETYPE_CRITERIA - struct oval_criteria_node_CRITERIA *criteria = - (struct oval_criteria_node_CRITERIA *)node; - oval_collection_add(criteria->subnodes, (void *)subnode); + if(node->type==OVAL_NODETYPE_CRITERIA){ + struct oval_criteria_node_CRITERIA *criteria = + (struct oval_criteria_node_CRITERIA *)node; + oval_collection_add(criteria->subnodes, (void *)subnode); + } } void oval_criteria_node_set_test(struct oval_criteria_node *node, struct oval_test *test) { - //type==NODETYPE_CRITERION - struct oval_criteria_node_CRITERION *criterion = - (struct oval_criteria_node_CRITERION *)node; - criterion->test = test; + if(node->type==OVAL_NODETYPE_CRITERION){ + struct oval_criteria_node_CRITERION *criterion = + (struct oval_criteria_node_CRITERION *)node; + criterion->test = test; + } } void oval_criteria_node_set_definition(struct oval_criteria_node *node, struct oval_definition *definition) { - //type==NODETYPE_EXTENDDEF - struct oval_criteria_node_EXTENDDEF *extenddef = - (struct oval_criteria_node_EXTENDDEF *)node; - extenddef->definition = definition; + if(node->type==OVAL_NODETYPE_EXTENDDEF){ + struct oval_criteria_node_EXTENDDEF *extenddef = + (struct oval_criteria_node_EXTENDDEF *)node; + extenddef->definition = definition; + } } static void _oval_criteria_subnode_consume(struct oval_criteria_node *subnode, void *criteria) { diff -u -r a/src/OVAL/oval_definition.c b/src/OVAL/oval_definition.c --- a/src/OVAL/oval_definition.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/oval_definition.c 2009-10-08 09:32:17 -0400 @@ -124,6 +124,43 @@ return definition; } +struct oval_definition *oval_definition_clone + (struct oval_definition *old_definition, struct oval_definition_model *model) +{ + struct oval_definition *new_definition = oval_definition_model_get_definition(model, old_definition->id); + if(new_definition==NULL){ + new_definition = oval_definition_new(old_definition->id); + oval_definition_set_version (new_definition, old_definition->version); + oval_definition_set_class (new_definition, old_definition->class); + oval_definition_set_deprecated (new_definition, old_definition->deprecated); + oval_definition_set_title (new_definition, old_definition->title); + oval_definition_set_description(new_definition, old_definition->description); + + struct oval_affected_iterator *affecteds = oval_definition_get_affected(old_definition); + while(oval_affected_iterator_has_more(affecteds)){ + struct oval_affected *old_affected = oval_affected_iterator_next(affecteds); + oval_definition_add_affected(new_definition, oval_affected_clone(old_affected)); + } + oval_affected_iterator_free(affecteds); + struct oval_reference_iterator *references = oval_definition_get_references(old_definition); + while(oval_reference_iterator_has_more(references)){ + struct oval_reference *old_reference = oval_reference_iterator_next(references); + oval_definition_add_reference(new_definition, oval_reference_clone(old_reference)); + } + oval_reference_iterator_free(references); + struct oval_string_iterator *notes = oval_definition_get_notes(old_definition); + while(oval_string_iterator_has_more(notes)){ + char *old_note = oval_string_iterator_next(notes); + oval_definition_add_note(new_definition, old_note); + } + oval_string_iterator_free(notes); + + oval_definition_set_criteria(new_definition, oval_criteria_node_clone(old_definition->criteria, model)); + + oval_definition_model_add_definition(model, new_definition); + } + return new_definition; +} void oval_definition_free(struct oval_definition *definition) { if (definition->id != NULL) @@ -200,7 +237,7 @@ char *description) { if(definition->description)free(definition->description); - definition->description = description==NULL?NULL:description; + definition->description = description==NULL?NULL:strdup(description); } void oval_definition_set_criteria(struct oval_definition *definition, @@ -454,13 +491,13 @@ struct oval_affected *affected = oval_affected_iterator_next(affecteds); oval_affected_family_t family = oval_affected_get_family(affected); xmlNewProp(affected_node, BAD_CAST "family", oval_affected_family_get_text(family)); - struct oval_string_iterator *platforms = oval_affected_get_platform(affected); + struct oval_string_iterator *platforms = oval_affected_get_platforms(affected); while(oval_string_iterator_has_more(platforms)){ char *platform = oval_string_iterator_next(platforms); xmlNewChild(affected_node, ns_definitions, BAD_CAST "platform", platform); } oval_string_iterator_free(platforms); - struct oval_string_iterator *products = oval_affected_get_product(affected); + struct oval_string_iterator *products = oval_affected_get_products(affected); while(oval_string_iterator_has_more(products)){ char *product = oval_string_iterator_next(products); xmlNewChild(affected_node, ns_definitions, BAD_CAST "product", product); diff -u -r a/src/OVAL/oval_definitions_impl.h b/src/OVAL/oval_definitions_impl.h --- a/src/OVAL/oval_definitions_impl.h 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/oval_definitions_impl.h 2009-10-07 17:28:31 -0400 @@ -73,6 +73,7 @@ +struct oval_affected *oval_affected_clone(struct oval_affected *); typedef void (*oval_affected_consumer) (struct oval_affected *, void *); int oval_affected_parse_tag(xmlTextReaderPtr reader, struct oval_parser_context *context, @@ -84,12 +85,14 @@ void oval_test_to_print(struct oval_test *test, char *indent, int index); xmlNode *oval_test_to_dom (struct oval_test *, xmlDoc *, xmlNode *); +struct oval_criteria_node *oval_criteria_node_clone(struct oval_criteria_node *, struct oval_definition_model *); void oval_criteria_node_to_print(struct oval_criteria_node *node, char *indent, int index); xmlNode *oval_criteria_node_to_dom (struct oval_criteria_node *, xmlDoc *, xmlNode *); typedef void (*oval_criteria_consumer) (struct oval_criteria_node *, void *); int oval_criteria_parse_tag(xmlTextReaderPtr, struct oval_parser_context *, oval_criteria_consumer, void *); +struct oval_reference *oval_reference_clone(struct oval_reference *); typedef void (*oval_reference_consumer) (struct oval_reference *, void *); int oval_reference_parse_tag(xmlTextReaderPtr, struct oval_parser_context *, oval_reference_consumer, void *); @@ -121,6 +124,7 @@ int oval_variable_binding_parse_tag (xmlTextReaderPtr, struct oval_parser_context *, oval_variable_binding_consumer, void *); +struct oval_object_content *oval_object_content_clone(struct oval_object_content *, struct oval_definition_model *); typedef void (*oval_object_content_consumer) (struct oval_object_content *, void *); xmlNode *oval_object_content_to_dom @@ -130,23 +134,27 @@ oval_object_content_consumer, void *); void oval_object_content_to_print(struct oval_object_content *, char *indent, int index); +struct oval_state_content *oval_state_content_clone(struct oval_state_content *, struct oval_definition_model *); int oval_state_content_parse_tag (xmlTextReaderPtr, struct oval_parser_context *, oscap_consumer_func, void *); xmlNode *oval_state_content_to_dom (struct oval_state_content *, xmlDoc *, xmlNode *); +struct oval_behavior *oval_behavior_clone(struct oval_behavior *); typedef void (*oval_behavior_consumer) (struct oval_behavior *, void *); int oval_behavior_parse_tag(xmlTextReaderPtr, struct oval_parser_context *, oval_family_t, oval_behavior_consumer, void *); void oval_behavior_to_print(struct oval_behavior *, char *indent, int index); +struct oval_entity *oval_entity_clone(struct oval_entity *, struct oval_definition_model *); int oval_entity_parse_tag(xmlTextReaderPtr, struct oval_parser_context *, oscap_consumer_func, void *); void oval_entity_to_print(struct oval_entity *, char *indent, int index); xmlNode *oval_entity_to_dom (struct oval_entity *, xmlDoc *, xmlNode *); +struct oval_setobject *oval_setobject_clone(struct oval_setobject *, struct oval_definition_model *); typedef void (*oval_set_consumer) (struct oval_setobject *, void *); int oval_set_parse_tag(xmlTextReaderPtr, struct oval_parser_context *, oval_set_consumer, void *); @@ -154,12 +162,14 @@ xmlNode *oval_set_to_dom (struct oval_setobject *, xmlDoc *, xmlNode *); +struct oval_value *oval_value_clone(struct oval_value *); typedef void (*oval_value_consumer) (struct oval_value *, void *); int oval_value_parse_tag(xmlTextReaderPtr, struct oval_parser_context *, oval_value_consumer, void *); void oval_value_to_print(struct oval_value *value, char *indent, int idx); xmlNode *oval_value_to_dom(struct oval_value *, xmlDoc *, xmlNode *); +struct oval_component *oval_component_clone(struct oval_component *, struct oval_definition_model *); typedef void (*oval_component_consumer) (struct oval_component *, void *); int oval_component_parse_tag(xmlTextReaderPtr, struct oval_parser_context *, oval_component_consumer, void *); diff -u -r a/src/OVAL/oval_entity.c b/src/OVAL/oval_entity.c --- a/src/OVAL/oval_entity.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/oval_entity.c 2009-10-08 09:24:09 -0400 @@ -119,6 +119,33 @@ return entity; } +struct oval_entity *oval_entity_clone + (struct oval_entity *old_entity, struct oval_definition_model *model) +{ + struct oval_entity *new_entity = oval_entity_new(); + oval_datatype_t datatype = oval_entity_get_datatype(old_entity); + oval_entity_set_datatype(new_entity, datatype); + int mask = oval_entity_get_mask(old_entity); + oval_entity_set_mask(new_entity, mask); + char *name = oval_entity_get_name(old_entity); + oval_entity_set_name(new_entity, name); + oval_operation_t operation = oval_entity_get_operation(old_entity); + oval_entity_set_operation(new_entity, operation); + oval_entity_type_t type = oval_entity_get_type(old_entity); + oval_entity_set_type(new_entity, type); + struct oval_value *value = oval_entity_get_value(old_entity); + oval_entity_set_value(new_entity, oval_value_clone(value)); + struct oval_variable *old_variable = oval_entity_get_variable(old_entity); + if(old_variable){ + struct oval_variable *new_variable = oval_variable_clone(old_variable, model); + oval_entity_set_variable(new_entity, new_variable); + } + oval_entity_varref_type_t reftype = oval_entity_get_varref_type(old_entity); + oval_entity_set_varref_type(new_entity, reftype); + return new_entity; +} + + void oval_entity_free(struct oval_entity *entity) { if (entity->value != NULL) @@ -144,7 +171,7 @@ entity->datatype = datatype; } -static void set_oval_entity_operation(struct oval_entity *entity, +void oval_entity_set_operation(struct oval_entity *entity, oval_operation_t operation) { entity->operation = operation; @@ -172,7 +199,7 @@ entity->value = value; } -static void set_oval_entity_name(struct oval_entity *entity, char *name) +void oval_entity_set_name(struct oval_entity *entity, char *name) { if(entity->name!=NULL)free(entity->name); entity->name = name==NULL?NULL:strdup(name); @@ -241,10 +268,10 @@ return_code = 1; free(varref);varref = NULL; } - set_oval_entity_name(entity, name); + oval_entity_set_name(entity, name); oval_entity_set_type(entity, type); oval_entity_set_datatype(entity, datatype); - set_oval_entity_operation(entity, operation); + oval_entity_set_operation(entity, operation); oval_entity_set_mask(entity, mask); oval_entity_set_varref_type(entity, varref_type); oval_entity_set_variable(entity, variable); diff -u -r a/src/OVAL/oval_enumerations.c b/src/OVAL/oval_enumerations.c --- a/src/OVAL/oval_enumerations.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/oval_enumerations.c 2009-10-08 09:34:50 -0400 @@ -529,32 +529,6 @@ return map[subidx-1].string; } -static void _test_oval_subtype_mapping(const struct oscap_string_map *map) -{ - printf("\n"); - int i;for(i=0;map[i].string;i++){ - printf("[%05d] %s\n", map[i].value, map[i].string); - } -} - -static void _test_oval_subtypes_mapping() -{ - _test_oval_subtype_mapping(OVAL_SUBTYPE_AIX_MAP );// 1000 - _test_oval_subtype_mapping(OVAL_SUBTYPE_APACHE_MAP );// 2000 - _test_oval_subtype_mapping(OVAL_SUBTYPE_CATOS_MAP );// 3000 - _test_oval_subtype_mapping(OVAL_SUBTYPE_ESX_MAP );// 4000 - _test_oval_subtype_mapping(OVAL_SUBTYPE_FREEBSD_MAP );// 5000 - _test_oval_subtype_mapping(OVAL_SUBTYPE_HPUX_MAP );// 6000 - _test_oval_subtype_mapping(OVAL_SUBTYPE_INDEPENDENT_MAP);// 7000 - _test_oval_subtype_mapping(OVAL_SUBTYPE_IOS_MAP );// 8000 - _test_oval_subtype_mapping(OVAL_SUBTYPE_LINUX_MAP );// 9000 - _test_oval_subtype_mapping(OVAL_SUBTYPE_MACOS_MAP );//10000 - _test_oval_subtype_mapping(OVAL_SUBTYPE_PIXOS_MAP );//11000 - _test_oval_subtype_mapping(OVAL_SUBTYPE_SOLARIS_MAP );//12000 - _test_oval_subtype_mapping(OVAL_SUBTYPE_UNIX_MAP );//13000 - _test_oval_subtype_mapping(OVAL_SUBTYPE_WINDOWS_MAP );//14000 -} - static const struct oscap_string_map OVAL_RESULT_MAP[] = { { OVAL_RESULT_TRUE, "true" }, { OVAL_RESULT_FALSE, "false" }, diff -u -r a/src/OVAL/oval_object.c b/src/OVAL/oval_object.c --- a/src/OVAL/oval_object.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/oval_object.c 2009-10-07 17:38:36 -0400 @@ -100,7 +100,7 @@ return ((struct oval_object *)object)->version; } -struct oval_object_content_iterator *oval_object_get_object_content(struct +struct oval_object_content_iterator *oval_object_get_object_contents(struct oval_object *object) { @@ -128,6 +128,41 @@ return object; } +struct oval_object *oval_object_clone + (struct oval_object *old_object, struct oval_definition_model *model) +{ + struct oval_object *new_object = oval_definition_model_get_object(model, old_object->id); + if(new_object==NULL){ + new_object = oval_object_new(old_object->id); + oval_object_set_comment (new_object, old_object->comment); + oval_object_set_subtype (new_object, old_object->subtype); + oval_object_set_deprecated(new_object, old_object->deprecated); + oval_object_set_version (new_object, old_object->version); + + struct oval_behavior_iterator *behaviors = oval_object_get_behaviors(old_object); + while(oval_behavior_iterator_has_more(behaviors)){ + struct oval_behavior *behavior = oval_behavior_iterator_next(behaviors); + oval_object_add_behavior(new_object, oval_behavior_clone(behavior)); + } + oval_behavior_iterator_free(behaviors); + struct oval_string_iterator *notes = oval_object_get_notes(old_object); + while(oval_string_iterator_has_more(notes)){ + char *note = oval_string_iterator_next(notes); + oval_object_add_note(new_object, note); + } + oval_string_iterator_free(notes); + struct oval_object_content_iterator *object_contents = oval_object_get_object_contents(old_object); + while(oval_object_content_iterator_has_more(object_contents)){ + struct oval_object_content *object_content = oval_object_content_iterator_next(object_contents); + oval_object_add_object_content(new_object, oval_object_content_clone(object_content, model)); + } + oval_object_content_iterator_free(object_contents); + + oval_definition_model_add_object(model, new_object); + } + return new_object; +} + void oval_object_free(struct oval_object *object) { if (object->comment != NULL) @@ -179,7 +214,7 @@ oval_collection_add(object->object_content, (void *)content); } -void oval_object_add_behaviors(struct oval_object *object, +void oval_object_add_behavior(struct oval_object *object, struct oval_behavior *behavior) { oval_collection_add(object->behaviors, (void *)behavior); @@ -197,7 +232,7 @@ static void oval_behavior_consume(struct oval_behavior *behavior, void *object) { - oval_object_add_behaviors(object, behavior); + oval_object_add_behavior(object, behavior); } static void oval_content_consume(struct oval_object_content *content, void *object) { @@ -300,7 +335,7 @@ } oval_behavior_iterator_free(behaviors); struct oval_object_content_iterator *contents = - oval_object_get_object_content(object); + oval_object_get_object_contents(object); for (idx = 1; oval_object_content_iterator_has_more(contents); idx++) { struct oval_object_content *content = @@ -365,7 +400,7 @@ } oval_behavior_iterator_free(behaviors); - struct oval_object_content_iterator *contents = oval_object_get_object_content(object); + struct oval_object_content_iterator *contents = oval_object_get_object_contents(object); int i;for(i=0;oval_object_content_iterator_has_more(contents); i++){ struct oval_object_content *content = oval_object_content_iterator_next(contents); oval_object_content_to_dom(content, doc, object_node); diff -u -r a/src/OVAL/oval_objectContent.c b/src/OVAL/oval_objectContent.c --- a/src/OVAL/oval_objectContent.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/oval_objectContent.c 2009-10-07 17:39:53 -0400 @@ -152,6 +152,29 @@ return content; } +struct oval_object_content *oval_object_content_clone + (struct oval_object_content *old_content, struct oval_definition_model *model) +{ + struct oval_object_content *new_content + = oval_object_content_new(old_content->type); + char *name = oval_object_content_get_field_name(old_content); + oval_object_content_set_field_name(new_content, name); + switch(new_content->type){ + case OVAL_OBJECTCONTENT_ENTITY:{ + struct oval_entity *entity = oval_object_content_get_entity(old_content); + oval_object_content_set_entity(new_content, entity); + oval_check_t check = oval_object_content_get_varCheck(old_content); + oval_object_content_set_varCheck(new_content, check); + }break; + case OVAL_OBJECTCONTENT_SET:{ + struct oval_setobject *set = oval_object_content_get_setobject(old_content); + oval_object_content_set_setobject(new_content, oval_setobject_clone(set, model)); + } + default: /*NOOP*/; + } + return new_content; +} + void oval_object_content_free(struct oval_object_content *content) { if(content->fieldName!=NULL)free(content->fieldName); Only in b/src/OVAL: oval_probe.H.bak diff -u -r a/src/OVAL/oval_reference.c b/src/OVAL/oval_reference.c --- a/src/OVAL/oval_reference.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/oval_reference.c 2009-10-06 10:56:39 -0400 @@ -86,6 +86,19 @@ return ref; } +struct oval_reference *oval_reference_clone + (struct oval_reference *old_reference) +{ + struct oval_reference *new_reference = oval_reference_new(); + char *id = oval_reference_get_id(old_reference); + oval_reference_set_id(new_reference, id); + char *source = oval_reference_get_source(old_reference); + oval_reference_set_source(new_reference, source); + char *url = oval_reference_get_url(old_reference); + oval_reference_set_url(new_reference, url); + return new_reference; +} + void oval_reference_free(struct oval_reference *ref) { if (ref->id != NULL) Only in a/src/OVAL: oval_result.c diff -u -r a/src/OVAL/oval_resultCriteriaNode.c b/src/OVAL/oval_resultCriteriaNode.c --- a/src/OVAL/oval_resultCriteriaNode.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/oval_resultCriteriaNode.c 2009-10-08 09:20:31 -0400 @@ -67,6 +67,7 @@ } oval_result_criteria_node_EXTENDDEF_t; +/* static struct oval_result_criteria_node *_oval_result_criteria_node_new() { oval_result_criteria_node_t *node = (oval_result_criteria_node_t *) @@ -75,6 +76,7 @@ node->negate = 0; return node; } +*///TODO: REVIEW struct oval_result_criteria_node *oval_result_criteria_node_new @@ -545,6 +547,7 @@ }else{ char message[200];*message = '\0'; sprintf("oval_result_criteria_node_parse: TODO handle criteria node <%s>", localName); + oval_parser_log_warn(context, message); oval_parser_skip_tag(reader, context); return_code = 0; } diff -u -r a/src/OVAL/oval_resultSystem.c b/src/OVAL/oval_resultSystem.c --- a/src/OVAL/oval_resultSystem.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/oval_resultSystem.c 2009-10-07 17:53:25 -0400 @@ -349,7 +349,7 @@ char *objid = oval_object_get_id(object); struct oval_syschar *syschar = oval_syschar_model_get_syschar(syschar_model, objid); if(syschar)oval_string_map_put(sysmap, objid, syschar); - struct oval_object_content_iterator *contents = oval_object_get_object_content(object); + struct oval_object_content_iterator *contents = oval_object_get_object_contents(object); while(oval_object_content_iterator_has_more(contents)){ struct oval_object_content *content = oval_object_content_iterator_next(contents); struct oval_entity *entity = oval_object_content_get_entity(content); diff -u -r a/src/OVAL/oval_resultTest.c b/src/OVAL/oval_resultTest.c --- a/src/OVAL/oval_resultTest.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/oval_resultTest.c 2009-10-08 11:30:12 -0400 @@ -36,6 +36,7 @@ #include "oval_collection_impl.h" #include "oval_string_map_impl.h" #include "oval_errno.h" +#include #define OVAL_RESULT_TEST_DEBUG 0 static int rpmvercmp(const char * a, const char * b); // don't really feel like creating a new header file just for this diff -u -r a/src/OVAL/oval_results_parser.c b/src/OVAL/oval_results_parser.c --- a/src/OVAL/oval_results_parser.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/oval_results_parser.c 2009-10-08 11:11:51 -0400 @@ -40,25 +40,31 @@ #define DEBUG_OVALRES_PARSER 1 +/* static int _ovalres_parser_process_node_consume_collected_objects(xmlTextReaderPtr reader, struct oval_parser_context *context, void *null) { return oval_syschar_parse_tag(reader, context); } +*///TODO: REVIEW +/* static int _ovalres_parser_process_node_consume_system_data(xmlTextReaderPtr reader, struct oval_parser_context *context, void *null) { return oval_sysdata_parse_tag(reader, context); } +*///TODO: REVIEW //typedef int (*oval_xml_tag_parser) (xmlTextReaderPtr, struct oval_parser_context*, void*); +/* static int _oval_results_parser_consume_definitions (xmlTextReaderPtr reader, struct oval_parser_context *context, void *null) { if(DEBUG_OVALRES_PARSER)oval_parser_log_debug(context,"Calling oval_parser_parse_node"); return ovaldef_parse_node(reader, context); } +*///TODO: REVIEW static void _oval_results_parser_consume_system (struct oval_result_system *sys, struct oval_results_model *model) @@ -72,7 +78,7 @@ { struct oval_results_model *model = context->results_model; struct oval_definition_model *definition_model = context->definition_model; - struct oval_syschar_model *syschar_model = oval_syschar_model_new(definition_model, NULL); + struct oval_syschar_model *syschar_model = oval_syschar_model_new(definition_model); return oval_result_system_parse (reader, context, syschar_model, (oscap_consumer_func)_oval_results_parser_consume_system, model); diff -u -r a/src/OVAL/oval_set.c b/src/OVAL/oval_set.c --- a/src/OVAL/oval_set.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/oval_set.c 2009-10-07 18:01:03 -0400 @@ -78,29 +78,40 @@ struct oval_setobject_iterator *oval_setobject_get_subsets(struct oval_setobject *set) { - //type==OVAL_SET_AGGREGATE; - struct oval_set_AGGREGATE *aggregate = - (struct oval_set_AGGREGATE *)set->extension; - return (struct oval_setobject_iterator *)oval_collection_iterator(aggregate-> - subsets); + struct oval_setobject_iterator *subsets = NULL; + if(set->type==OVAL_SET_AGGREGATE){ + struct oval_set_AGGREGATE *aggregate = + (struct oval_set_AGGREGATE *)set->extension; + subsets = (struct oval_setobject_iterator *) + oval_collection_iterator(aggregate->subsets); + } + return subsets; } struct oval_object_iterator *oval_setobject_get_objects(struct oval_setobject *set) { //type==OVAL_SET_COLLECTIVE; - struct oval_set_COLLECTIVE *collective = - (struct oval_set_COLLECTIVE *)set->extension; - return (struct oval_object_iterator *) - oval_collection_iterator(collective->objects); + struct oval_object_iterator *objects = NULL; + if(set->type==OVAL_SET_COLLECTIVE){ + struct oval_set_COLLECTIVE *collective = + (struct oval_set_COLLECTIVE *)set->extension; + objects = (struct oval_object_iterator *) + oval_collection_iterator(collective->objects); + } + return objects; } struct oval_state_iterator *oval_setobject_get_filters(struct oval_setobject *set) { //type==OVAL_SET_COLLECTIVE; - struct oval_set_COLLECTIVE *collective = - (struct oval_set_COLLECTIVE *)set->extension; - return (struct oval_state_iterator *) - oval_collection_iterator(collective->filters); + struct oval_state_iterator *filters = NULL; + if(set->type==OVAL_SET_COLLECTIVE){ + struct oval_set_COLLECTIVE *collective = + (struct oval_set_COLLECTIVE *)set->extension; + filters = (struct oval_state_iterator *) + oval_collection_iterator(collective->filters); + } + return filters; } struct oval_setobject *oval_setobject_new() @@ -112,6 +123,44 @@ return set; } +struct oval_setobject *oval_setobject_clone + (struct oval_setobject *old_setobject, struct oval_definition_model *model) +{ + struct oval_setobject *new_setobject = oval_setobject_new(); + oval_setobject_type_t type = oval_setobject_get_type(old_setobject); + oval_setobject_set_type(new_setobject, type); + oval_setobject_operation_t operation = oval_setobject_get_operation(old_setobject); + oval_setobject_set_operation(new_setobject, operation); + switch(type) + { + case OVAL_SET_COLLECTIVE:{ + struct oval_state_iterator *filters = oval_setobject_get_filters(old_setobject); + while(oval_state_iterator_has_more(filters)){ + struct oval_state *filter = oval_state_iterator_next(filters); + oval_setobject_add_filter(new_setobject, oval_state_clone(filter, model)); + } + oval_state_iterator_free(filters); + struct oval_object_iterator *objects = oval_setobject_get_objects(old_setobject); + while(oval_object_iterator_has_more(objects)){ + struct oval_object *object = oval_object_iterator_next(objects); + oval_setobject_add_object(new_setobject, oval_object_clone(object, model)); + } + oval_object_iterator_free(objects); + + }break; + case OVAL_SET_AGGREGATE:{ + struct oval_setobject_iterator *subsets = oval_setobject_get_subsets(old_setobject); + while(oval_setobject_iterator_has_more(subsets)){ + struct oval_setobject *subset = oval_setobject_iterator_next(subsets); + oval_setobject_add_subset(new_setobject, subset); + } + oval_setobject_iterator_free(subsets); + }break; + default: /*NOOP*/; + } + return new_setobject; +} + void oval_set_free(struct oval_setobject *set) { switch (set->type) { diff -u -r a/src/OVAL/oval_sexp.c b/src/OVAL/oval_sexp.c --- a/src/OVAL/oval_sexp.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/oval_sexp.c 2009-10-08 14:30:30 -0400 @@ -1,3 +1,4 @@ +#ifndef __STUB_PROBE #include #include #include @@ -624,3 +625,4 @@ return 1; } +#endif /* __STUB_PROBE */ Only in b/src/OVAL: oval_sexp.c.bak diff -u -r a/src/OVAL/oval_state.c b/src/OVAL/oval_state.c --- a/src/OVAL/oval_state.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/oval_state.c 2009-10-08 09:31:18 -0400 @@ -36,7 +36,6 @@ typedef struct oval_state { oval_subtype_t subtype; - char *name; char *comment; char *id; int deprecated; @@ -74,9 +73,9 @@ return ((struct oval_state *)state)->subtype; } -char *oval_state_get_name(struct oval_state *state) +const char *oval_state_get_name(struct oval_state *state) { - return ((struct oval_state *)state)->name; + return oval_subtype_get_text(oval_state_get_subtype(state)); } struct oval_string_iterator *oval_state_get_notes(struct oval_state *state) @@ -119,27 +118,52 @@ state->subtype = OVAL_SUBTYPE_UNKNOWN; state->comment = NULL; state->id = strdup(id); - state->name = NULL; state->notes = oval_collection_new(); state->contents = oval_collection_new(); return state; } +struct oval_state *oval_state_clone + (struct oval_state *old_state, struct oval_definition_model *model) +{ + oval_state_t *new_state = oval_definition_model_get_state(model, old_state->id); + if(new_state==NULL){ + new_state = oval_state_new(old_state->id); + oval_state_set_deprecated(new_state, old_state->deprecated); + oval_state_set_version (new_state, old_state->version); + oval_state_set_subtype (new_state, old_state->subtype); + oval_state_set_comment (new_state, old_state->comment); + + struct oval_string_iterator *notes = oval_state_get_notes(old_state); + while(oval_string_iterator_has_more(notes)){ + char *note = oval_string_iterator_next(notes); + oval_state_add_note(new_state, strdup(note)); + } + oval_string_iterator_free(notes); + struct oval_state_content_iterator *contents = oval_state_get_contents(old_state); + while(oval_state_content_iterator_has_more(contents)){ + struct oval_state_content *content = oval_state_content_iterator_next(contents); + oval_state_add_content(new_state, oval_state_content_clone(content, model)); + } + oval_state_content_iterator_free(contents); + + oval_definition_model_add_state(model, new_state); + } + return new_state; +} + void oval_state_free(struct oval_state *state) { if (state->comment != NULL) free(state->comment); if (state->id != NULL) free(state->id); - if (state->name != NULL) - free(state->name); oval_collection_free_items(state->notes, &free); oval_collection_free_items(state->contents, (oscap_destruct_func)oval_state_content_free); state->comment =NULL; state->contents =NULL; state->id =NULL; - state->name =NULL; state->notes =NULL; free(state); } @@ -149,12 +173,6 @@ state->subtype = subtype; } -void oval_state_set_name(struct oval_state *state, char *name) -{ - if(state->name!=NULL)free(state->name); - state->name = name==NULL?NULL:strdup(name); -} - void oval_state_add_note(struct oval_state *state, char *notes) { oval_collection_add(state->notes, (void *)strdup(notes)); diff -u -r a/src/OVAL/oval_stateContent.c b/src/OVAL/oval_stateContent.c --- a/src/OVAL/oval_stateContent.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/oval_stateContent.c 2009-10-08 09:30:34 -0400 @@ -92,6 +92,19 @@ return content; } +struct oval_state_content *oval_state_content_clone + (struct oval_state_content *old_content, struct oval_definition_model *model) +{ + struct oval_state_content *new_content = oval_state_content_new(); + oval_check_t echeck = oval_state_content_get_ent_check(old_content); + oval_state_content_set_entcheck(new_content, echeck); + struct oval_entity *entity = oval_state_content_get_entity(old_content); + oval_state_content_set_entity(new_content, oval_entity_clone(entity, model)); + oval_check_t vcheck = oval_state_content_get_var_check(old_content); + oval_state_content_set_varcheck(new_content, vcheck); + return new_content; +} + void oval_state_content_free(struct oval_state_content *content) { if(content->entity)oval_entity_free(content->entity); diff -u -r a/src/OVAL/oval_stringMap.c b/src/OVAL/oval_stringMap.c --- a/src/OVAL/oval_stringMap.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/oval_stringMap.c 2009-10-08 09:20:32 -0400 @@ -173,8 +173,10 @@ printf("FREEFUNC: item = %s\n", (const char *) item); } - //TEST MAIN -static int oval_string_map_main(int argc, char **argv) +/** + * This method is included as a test stub. + */ +int oval_string_map_main(int argc, char **argv) { printf("TEST::START\n"); diff -u -r a/src/OVAL/oval_syschar.c b/src/OVAL/oval_syschar.c --- a/src/OVAL/oval_syschar.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/oval_syschar.c 2009-10-08 09:41:00 -0400 @@ -118,12 +118,6 @@ oval_collection_iterator(syschar->variable_bindings); } -static void add_oval_syschar_variable_bindings - (struct oval_syschar *syschar, struct oval_variable_binding *binding) -{ - oval_collection_add(syschar->variable_bindings, binding); -} - struct oval_sysdata_iterator *oval_syschar_sysdata(struct oval_syschar *syschar) { return (struct oval_sysdata_iterator *) diff -u -r a/src/OVAL/oval_test.c b/src/OVAL/oval_test.c --- a/src/OVAL/oval_test.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/oval_test.c 2009-10-08 11:39:32 -0400 @@ -136,6 +136,40 @@ return test; } +struct oval_test *oval_test_clone + (struct oval_test *old_test, struct oval_definition_model *model) +{ + struct oval_test *new_test = oval_definition_model_get_test(model, old_test->id); + if(new_test==NULL){ + new_test = oval_test_new(old_test->id); + oval_test_set_deprecated(new_test, old_test->deprecated); + oval_test_set_version (new_test, old_test->version); + oval_test_set_check (new_test, old_test->check); + oval_test_set_existence (new_test, old_test->existence); + oval_test_set_subtype (new_test, old_test->subtype); + oval_test_set_comment (new_test, old_test->comment); + + if(old_test->object){ + struct oval_object *object = oval_object_clone(old_test->object, model); + oval_test_set_object(new_test, object); + } + if(old_test->state){ + struct oval_state *state = oval_state_clone(old_test->state, model); + oval_test_set_state(new_test, state); + } + + struct oval_string_iterator *notes = oval_test_get_notes(old_test); + while(oval_string_iterator_has_more(notes)){ + char *note = oval_string_iterator_next(notes); + oval_test_add_note(new_test, note); + } + oval_string_iterator_free(notes); + + oval_definition_model_add_test(model, new_test); + } + return new_test; +} + void oval_test_free(struct oval_test *test) { if (test->comment != NULL) diff -u -r a/src/OVAL/oval_value.c b/src/OVAL/oval_value.c --- a/src/OVAL/oval_value.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/oval_value.c 2009-10-07 18:20:10 -0400 @@ -100,6 +100,16 @@ return value; } +struct oval_value *oval_value_clone(struct oval_value *old_value) +{ + struct oval_value *new_value = oval_value_new(); + oval_datatype_t datatype = oval_value_get_datatype(old_value); + oval_value_set_datatype(new_value, datatype); + char *text = oval_value_get_text(old_value); + oval_value_set_text(new_value, text); + return new_value; +} + void oval_value_free(struct oval_value *value) { if (value) { Only in b/src/OVAL: oval_varModel.c diff -u -r a/src/OVAL/oval_variable.c b/src/OVAL/oval_variable.c --- a/src/OVAL/oval_variable.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/oval_variable.c 2009-10-08 10:51:37 -0400 @@ -32,6 +32,7 @@ #include #include "oval_definitions_impl.h" #include "oval_collection_impl.h" +#include "oval_string_map_impl.h" #include "oval_agent_api_impl.h" @@ -45,15 +46,15 @@ void *extension; } oval_variable_t; -typedef struct oval_variable_CONSTANT { +typedef struct oval_variable_CONEXT { char *id; char *comment; int version; int deprecated; oval_variable_type_t type; oval_datatype_t datatype; - struct oval_collection *values; //type==OVAL_VARIABLE_CONSTANT -} oval_variable_CONSTANT_t; + struct oval_string_map *values; //type==OVAL_VARIABLE_CONSTANT/EXTERNAL +} oval_variable_CONEXT_t; typedef struct oval_variable_LOCAL { char *id; @@ -119,14 +120,15 @@ struct oval_value_iterator *oval_variable_get_values(struct oval_variable *variable) { - //type==OVAL_VARIABLE_CONSTANT + //type==OVAL_VARIABLE_CONSTANT or OVAL_VARIABLE_EXTERNAL struct oval_value_iterator *values = NULL; - if (oval_variable_get_type(variable) == OVAL_VARIABLE_CONSTANT) { - oval_variable_CONSTANT_t *constant = - (oval_variable_CONSTANT_t *) variable; + oval_variable_type_t type = oval_variable_get_type(variable); + if (type == OVAL_VARIABLE_EXTERNAL || type==OVAL_VARIABLE_CONSTANT) { + oval_variable_CONEXT_t *constant = + (oval_variable_CONEXT_t *) variable; values = (struct oval_value_iterator *) - oval_collection_iterator(constant->values); + oval_string_map_values(constant->values); } return values; } @@ -149,10 +151,11 @@ variable->type = type; switch(type) { - case OVAL_VARIABLE_CONSTANT:{ - oval_variable_CONSTANT_t *constant - = (oval_variable_CONSTANT_t *)variable; - constant->values = oval_collection_new(); + case OVAL_VARIABLE_CONSTANT: + case OVAL_VARIABLE_EXTERNAL:{ + oval_variable_CONEXT_t *conext + = (oval_variable_CONEXT_t *)variable; + conext->values = oval_string_map_new(); }break; default: variable->extension = NULL; } @@ -169,37 +172,82 @@ return variable; } +void _oval_variable_clone_CONEXT + (struct oval_variable *new_variable, struct oval_variable *old_variable) +{ + struct oval_value_iterator *values = oval_variable_get_values(old_variable); + while(oval_value_iterator_has_more(values)){ + struct oval_value *value = oval_value_iterator_next(values); + oval_variable_add_value(new_variable, oval_value_clone(value)); + } + oval_value_iterator_free(values); +} + +void _oval_variable_clone_LOCAL + (struct oval_variable *new_variable, struct oval_variable *old_variable, + struct oval_definition_model *model) +{ + struct oval_component *component = oval_variable_get_component(old_variable); + oval_variable_set_component(new_variable, oval_component_clone(component, model)); +} + +struct oval_variable *oval_variable_clone + (struct oval_variable *old_variable, struct oval_definition_model *model) +{ + oval_variable_t *new_variable = oval_definition_model_get_variable(model, old_variable->id); + if(new_variable==NULL){ + new_variable = oval_variable_new(old_variable->id, old_variable->type); + + oval_variable_set_comment (new_variable, old_variable->comment); + oval_variable_set_version (new_variable, old_variable->version); + oval_variable_set_deprecated(new_variable, old_variable->deprecated); + oval_variable_set_datatype (new_variable, old_variable->datatype); + + switch(new_variable->type) + { + case OVAL_VARIABLE_EXTERNAL: + case OVAL_VARIABLE_CONSTANT: _oval_variable_clone_CONEXT(new_variable, old_variable);break; + case OVAL_VARIABLE_LOCAL : _oval_variable_clone_LOCAL (new_variable, old_variable, model);break; + default: /*NOOP*/break; + } + + oval_definition_model_add_variable(model, new_variable); + } + return new_variable; +} + + void oval_variable_free(struct oval_variable *variable) { - if (variable == NULL) - return; - if (variable->id)free(variable->id); - if (variable->comment)free(variable->comment); - if (variable->extension != NULL) { - switch (variable->type) { - case OVAL_VARIABLE_LOCAL:{ - oval_variable_LOCAL_t *local - = (oval_variable_LOCAL_t *)variable; - if(local->component) - oval_component_free(local->component); - local->component = NULL; + if (variable){ + if (variable->id)free(variable->id); + if (variable->comment)free(variable->comment); + if (variable->extension != NULL) { + switch (variable->type) { + case OVAL_VARIABLE_LOCAL:{ + oval_variable_LOCAL_t *local + = (oval_variable_LOCAL_t *)variable; + if(local->component) + oval_component_free(local->component); + local->component = NULL; + } + break; + case OVAL_VARIABLE_EXTERNAL: + case OVAL_VARIABLE_CONSTANT:{ + oval_variable_CONEXT_t *conext + = (oval_variable_CONEXT_t *)variable; + oval_string_map_free + (conext->values, (oscap_destruct_func)oval_value_free); + conext->values = NULL; + } break; + case OVAL_VARIABLE_UNKNOWN: break; } - break; - case OVAL_VARIABLE_CONSTANT:{ - oval_variable_CONSTANT_t *constant - = (oval_variable_CONSTANT_t *)variable; - oval_collection_free_items - (constant->values, (oscap_destruct_func)oval_value_free); - constant->values = NULL; - } break; - case OVAL_VARIABLE_EXTERNAL: break; - case OVAL_VARIABLE_UNKNOWN: break; } - } - variable->comment = NULL; - variable->id = NULL; + variable->comment = NULL; + variable->id = NULL; - free(variable); + free(variable); + } } void oval_variable_set_datatype(struct oval_variable *variable, @@ -208,19 +256,19 @@ variable->datatype = datatype; } -static void set_oval_variable_comment(struct oval_variable *variable, char *comm) +void oval_variable_set_comment(struct oval_variable *variable, char *comm) { if(variable->comment!=NULL)free(variable->comment); variable->comment = comm==NULL?NULL:strdup(comm); } -static void set_oval_variable_deprecated(struct oval_variable *variable, - int deprecated) +void oval_variable_set_deprecated(struct oval_variable *variable, + bool deprecated) { variable->deprecated = deprecated; } -static void set_oval_variable_version(struct oval_variable *variable, int version) +void oval_variable_set_version(struct oval_variable *variable, int version) { variable->version = version; } @@ -229,10 +277,11 @@ struct oval_value *value) { //type==OVAL_VARIABLE_CONSTANT - if (variable->type == OVAL_VARIABLE_CONSTANT) { - oval_variable_CONSTANT_t *constant = - (oval_variable_CONSTANT_t *) variable; - oval_collection_add(constant->values, (void *)value); + if (variable->type == OVAL_VARIABLE_CONSTANT || variable->type == OVAL_VARIABLE_EXTERNAL) { + oval_variable_CONEXT_t *conext = + (oval_variable_CONEXT_t *) variable; + char *text = oval_value_get_text(value); + oval_string_map_put(conext->values, text, (void *)value); } } @@ -327,13 +376,13 @@ char *comm = (char*) xmlTextReaderGetAttribute(reader, BAD_CAST "comment"); if(comm!=NULL){ - set_oval_variable_comment(variable, comm); + oval_variable_set_comment(variable, comm); free(comm);comm=NULL; } int deprecated = oval_parser_boolean_attribute(reader, "deprecated", 0); - set_oval_variable_deprecated(variable, deprecated); + oval_variable_set_deprecated(variable, deprecated); char *version = (char*) xmlTextReaderGetAttribute(reader, BAD_CAST "version"); - set_oval_variable_version(variable, atoi(version)); + oval_variable_set_version(variable, atoi(version)); free(version);version = NULL; oval_datatype_t datatype = diff -u -r a/src/OVAL/oval_variableBinding.c b/src/OVAL/oval_variableBinding.c --- a/src/OVAL/oval_variableBinding.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/oval_variableBinding.c 2009-10-08 15:05:28 -0400 @@ -33,7 +33,7 @@ #include "oval_definitions_impl.h" #include "oval_collection_impl.h" -static int DEBUG_OVAL_VARIABLE_BINDING = 0; +#define DEBUG_OVAL_VARIABLE_BINDING 0 typedef struct oval_variable_binding { Only in b/src/OVAL: oval_variableBinding.c.bak Only in b/src/OVAL/probes: .svn Only in a/src/OVAL/probes: Makefile.am Only in b/src/OVAL/probes/SEAP: .svn Only in a/src/OVAL/probes/SEAP: Makefile.am Only in b/src/OVAL/probes/SEAP/generic: .svn diff -u -r a/src/OVAL/probes/SEAP/generic/strbuf.c b/src/OVAL/probes/SEAP/generic/strbuf.c --- a/src/OVAL/probes/SEAP/generic/strbuf.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/probes/SEAP/generic/strbuf.c 2009-10-08 14:38:32 -0400 @@ -1,3 +1,4 @@ +#ifndef __STUB_PROBE #include #include #include @@ -279,3 +280,4 @@ return (size); } +#endif /*__STUB_PROBE */ Only in b/src/OVAL/probes/SEAP/generic: strbuf.c.bak Only in b/src/OVAL/probes/SEAP/public: .svn diff -u -r a/src/OVAL/probes/SEAP/public/sexp-manip.h b/src/OVAL/probes/SEAP/public/sexp-manip.h --- a/src/OVAL/probes/SEAP/public/sexp-manip.h 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/probes/SEAP/public/sexp-manip.h 2009-10-07 16:54:16 -0400 @@ -1,3 +1,4 @@ +#ifndef __STUB_PROBE #pragma once #ifndef SEXP_MANIP_H #define SEXP_MANIP_H @@ -136,3 +137,4 @@ #endif #endif /* SEXP_MANIP_H */ +#endif Only in b/src/OVAL/probes/SEAP/public: strbuf.h.txt diff -u -r a/src/OVAL/probes/SEAP/sch_generic.c b/src/OVAL/probes/SEAP/sch_generic.c --- a/src/OVAL/probes/SEAP/sch_generic.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/probes/SEAP/sch_generic.c 2009-10-05 10:10:06 -0400 @@ -1,3 +1,4 @@ +#ifndef __STUB_PROBE #include #include #include @@ -132,3 +133,4 @@ /* NOTREACHED */ return (-1); } +#endif diff -u -r a/src/OVAL/probes/SEAP/sch_pipe.c b/src/OVAL/probes/SEAP/sch_pipe.c --- a/src/OVAL/probes/SEAP/sch_pipe.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/probes/SEAP/sch_pipe.c 2009-09-29 10:21:09 -0400 @@ -1,3 +1,4 @@ +#ifndef __STUB_PROBE #include #include #include @@ -290,3 +291,4 @@ /* NOTREACHED */ return (-1); } +#endif diff -u -r a/src/OVAL/probes/SEAP/seap-packet.c b/src/OVAL/probes/SEAP/seap-packet.c --- a/src/OVAL/probes/SEAP/seap-packet.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/probes/SEAP/seap-packet.c 2009-10-08 08:24:41 -0400 @@ -1,3 +1,4 @@ +#ifndef __STUB_PROBE #include #include #include @@ -797,3 +798,4 @@ _LOGCALL_; return (-1); } +#endif diff -u -r a/src/OVAL/probes/SEAP/sexp-manip.c b/src/OVAL/probes/SEAP/sexp-manip.c --- a/src/OVAL/probes/SEAP/sexp-manip.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/probes/SEAP/sexp-manip.c 2009-10-08 14:48:27 -0400 @@ -1,3 +1,4 @@ +#ifndef __STUB_PROBE #include #include #include @@ -1701,3 +1702,4 @@ return; } #endif /* !NDEBUG || VALIDATE_SEXP */ +#endif Only in b/src/OVAL/probes/SEAP: sexp-manip.c.bak diff -u -r a/src/OVAL/probes/SEAP/sexp-output.c b/src/OVAL/probes/SEAP/sexp-output.c --- a/src/OVAL/probes/SEAP/sexp-output.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/probes/SEAP/sexp-output.c 2009-10-08 11:43:51 -0400 @@ -1,3 +1,4 @@ +#ifndef __STUB_PROBE #include #include #include @@ -879,3 +880,4 @@ return (-1); } #endif +#endif diff -u -r a/src/OVAL/probes/SEAP/sexp-parse.c b/src/OVAL/probes/SEAP/sexp-parse.c --- a/src/OVAL/probes/SEAP/sexp-parse.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/probes/SEAP/sexp-parse.c 2009-10-08 08:28:06 -0400 @@ -1,3 +1,4 @@ +#ifndef __STUB_PROBE #include #include #include @@ -1465,3 +1466,4 @@ return PARSER(label)(psetup, buf, buflen, pstate); } #endif +#endif diff -u -r a/src/OVAL/probes/SEAP/sexp-value.c b/src/OVAL/probes/SEAP/sexp-value.c --- a/src/OVAL/probes/SEAP/sexp-value.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/probes/SEAP/sexp-value.c 2009-10-08 14:50:33 -0400 @@ -1,3 +1,4 @@ +#ifndef __STUB_PROBE #include #include #include "_sexp-value.h" @@ -537,3 +538,4 @@ return; } +#endif Only in b/src/OVAL/probes/SEAP: sexp-value.c.bak diff -u -r a/src/OVAL/probes/findfile.c b/src/OVAL/probes/findfile.c --- a/src/OVAL/probes/findfile.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/probes/findfile.c 2009-10-08 11:44:32 -0400 @@ -1,3 +1,4 @@ +#ifndef __STUB_PROBE /*! \file findfile.c * \brief auxiliary find_files() function used in different probes * @@ -387,3 +388,4 @@ result->pathc=0; } +#endif Only in b/src/OVAL/probes/independent: .svn diff -u -r a/src/OVAL/probes/probe-api.c b/src/OVAL/probes/probe-api.c --- a/src/OVAL/probes/probe-api.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/probes/probe-api.c 2009-10-07 16:36:52 -0400 @@ -1,3 +1,4 @@ +#ifndef __STUB_PROBE #include #include #include @@ -788,3 +789,4 @@ { SEXP_free (obj); } +#endif diff -u -r a/src/OVAL/probes/probe-entcmp.c b/src/OVAL/probes/probe-entcmp.c --- a/src/OVAL/probes/probe-entcmp.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/probes/probe-entcmp.c 2009-10-01 09:55:13 -0400 @@ -1,3 +1,4 @@ +#ifndef __STUB_PROBE #include #include #include @@ -868,3 +869,4 @@ return result; } +#endif diff -u -r a/src/OVAL/probes/probe-main.c b/src/OVAL/probes/probe-main.c --- a/src/OVAL/probes/probe-main.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/probes/probe-main.c 2009-10-05 10:08:56 -0400 @@ -1,3 +1,4 @@ +#ifndef __STUB_PROBE #include #include #include @@ -619,3 +620,4 @@ SEAP_msg_free (seap_request); return (NULL); } +#endif Only in b/src/OVAL/probes/unix: .svn diff -u -r a/src/OVAL/probes/unix/file.c b/src/OVAL/probes/unix/file.c --- a/src/OVAL/probes/unix/file.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/probes/unix/file.c 2009-10-07 16:46:30 -0400 @@ -1,3 +1,4 @@ +#ifndef __STUB_PROBE #include #include #include @@ -277,3 +278,4 @@ *err = 0; return (items); } +#endif Only in b/src/OVAL/probes/unix/linux: .svn diff -u -r a/src/OVAL/probes/unix/linux/rpminfo.c b/src/OVAL/probes/unix/linux/rpminfo.c --- a/src/OVAL/probes/unix/linux/rpminfo.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/probes/unix/linux/rpminfo.c 2009-10-07 16:47:37 -0400 @@ -1,4 +1,5 @@ -/* +#ifndef __STUB_PROBE +/* * rpminfo probe: * * rpminfo_object(string name) @@ -309,3 +310,4 @@ return (probe_out); } +#endif diff -u -r a/src/OVAL/probes/unix/runlevel.c b/src/OVAL/probes/unix/runlevel.c --- a/src/OVAL/probes/unix/runlevel.c 2009-10-08 10:08:11 -0400 +++ b/src/OVAL/probes/unix/runlevel.c 2009-10-07 16:50:21 -0400 @@ -1,3 +1,4 @@ +#ifndef __STUB_PROBE /* * runlevel probe: * @@ -359,3 +360,4 @@ return (probe_out); } +#endif Only in a/src/common: Makefile.am Only in b/src/common: alloca.h Only in b/src/common: sys diff -u -r a/src/examples/OVAL/test_findfile.c b/src/examples/OVAL/test_findfile.c --- a/src/examples/OVAL/test_findfile.c 2009-10-08 10:08:11 -0400 +++ b/src/examples/OVAL/test_findfile.c 2009-10-08 12:50:25 -0400 @@ -1,4 +1,4 @@ - +#ifndef __STUB_PROBE #include #include #include @@ -40,4 +40,5 @@ return 0; } +#endif /*__STUB_PROBE*/ diff -u -r a/src/examples/OVAL/test_oval.c b/src/examples/OVAL/test_oval.c --- a/src/examples/OVAL/test_oval.c 2009-10-08 10:08:11 -0400 +++ b/src/examples/OVAL/test_oval.c 2009-10-08 13:12:19 -0400 @@ -7,15 +7,15 @@ #include #include #include "api/oval_agent_api.h" -#include "../../src/common/oscap.h" +#include -int _test_error_handler(struct oval_xml_error *error, void *null) +static int _test_error_handler(struct oval_xml_error *error, void *null) { //ERROR HANDLING IS TODO return 1; } -int main(int argc, char **argv) +int test_oval_main(int argc, char **argv) { struct oval_definition_model *model = oval_definition_model_new(); @@ -29,6 +29,9 @@ printf("NO DEFINITIONS FOUND\n"); return 1; } + oval_definition_iterator_free(definitions); + oval_definition_model_export(model, oval_export_target_new_file("-","UTF-8")); + /* int index; for (index = 1; oval_definition_iterator_has_more(definitions); index++) { struct oval_definition *definition = @@ -36,10 +39,18 @@ oval_definition_to_print(definition, "", index); } oval_definition_iterator_free(definitions); - + */ oval_definition_model_free(model); oscap_cleanup(); return 0; } + +#define IS_TEST_DRIVER 0 +#if IS_TEST_DRIVER +int main(int argc, char **argv) +{ + return test_oval_main(argc, argv); +} +#endif diff -u -r a/src/examples/OVAL/test_probe-api.c b/src/examples/OVAL/test_probe-api.c --- a/src/examples/OVAL/test_probe-api.c 2009-10-08 10:08:11 -0400 +++ b/src/examples/OVAL/test_probe-api.c 2009-10-08 14:55:16 -0400 @@ -1,3 +1,4 @@ +#ifndef __STUB_PROBE #include #include #include @@ -482,3 +483,4 @@ return (0); } +#endif /*__STUB_PROBE*/ Only in b/src/examples/OVAL: test_probe-api.c.bak diff -u -r a/src/examples/OVAL/test_probes.c b/src/examples/OVAL/test_probes.c --- a/src/examples/OVAL/test_probes.c 2009-10-08 10:08:11 -0400 +++ b/src/examples/OVAL/test_probes.c 2009-10-08 12:56:52 -0400 @@ -1,3 +1,4 @@ +#ifndef __STUB_PROBE /* * test_probes.c * @@ -9,7 +10,7 @@ #include #include "api/oval_agent_api.h" -int _test_error_handler(struct oval_xml_error *error, void *null) +static int _test_error_handler(struct oval_xml_error *error, void *null) { //ERROR HANDLING IS TODO return 1; @@ -46,4 +47,5 @@ return 0; } +#endif /*__STUB_PROBE*/ diff -u -r a/src/examples/OVAL/test_results.c b/src/examples/OVAL/test_results.c --- a/src/examples/OVAL/test_results.c 2009-10-08 10:08:11 -0400 +++ b/src/examples/OVAL/test_results.c 2009-10-08 13:39:38 -0400 @@ -13,7 +13,7 @@ //typedef int (*oval_xml_error_handler) (struct oval_xml_error *, void *user_arg); -int _test_error_handler (struct oval_xml_error *error, void *null){ +static int _test_error_handler (struct oval_xml_error *error, void *null){ char *label; switch(error->severity){ case XML_ERROR :label = "XML ERROR" ;break; @@ -34,7 +34,7 @@ } -int main(int argc, char **argv) +int test_results_main(int argc, char **argv) { printf("START\n"); if(argc>1){ @@ -65,5 +65,13 @@ oval_definition_model_free(model); }else printf("USAGE: %s [results.xml>]\n", argv[0]); oscap_cleanup(); + return 0; } +#define IS_TEST_DRIVER 1 +#if IS_TEST_DRIVER +int main(int argc, char **argv) +{ + return test_results_main(argc, argv); +} +#endif diff -u -r a/src/examples/OVAL/test_sexp_to_syschar.c b/src/examples/OVAL/test_sexp_to_syschar.c --- a/src/examples/OVAL/test_sexp_to_syschar.c 2009-10-08 10:08:11 -0400 +++ b/src/examples/OVAL/test_sexp_to_syschar.c 2009-10-08 14:57:47 -0400 @@ -1,3 +1,4 @@ +#ifndef __STUB_PROBE #include #include #include @@ -65,4 +66,5 @@ return 0; } +#endif Only in b/src/examples/OVAL: test_sexp_to_syschar.c.bak diff -u -r a/src/examples/OVAL/test_sexpoval.c b/src/examples/OVAL/test_sexpoval.c --- a/src/examples/OVAL/test_sexpoval.c 2009-10-08 10:08:11 -0400 +++ b/src/examples/OVAL/test_sexpoval.c 2009-10-08 14:59:46 -0400 @@ -1,3 +1,4 @@ +#ifndef __STUB_PROBE #include #include #include @@ -438,3 +439,4 @@ return (EXIT_SUCCESS); } +#endif /*__STUB_PROBE*/ Only in b/src/examples/OVAL: test_sexpoval.c.bak diff -u -r a/src/examples/OVAL/test_syschar.c b/src/examples/OVAL/test_syschar.c --- a/src/examples/OVAL/test_syschar.c 2009-10-08 10:08:11 -0400 +++ b/src/examples/OVAL/test_syschar.c 2009-10-08 13:40:14 -0400 @@ -34,7 +34,7 @@ } -int main(int argc, char **argv) +int test_syschar_main(int argc, char **argv) { printf("START\n"); if(argc>1){ @@ -47,20 +47,43 @@ if(argc>2){ printf("LOAD OVAL SYSCHAR\n"); source = oval_import_source_new_file(argv[2]); - struct oval_syschar_model *syschar_model = oval_syschar_model_new(model,NULL); + struct oval_syschar_model *syschar_model = oval_syschar_model_new(model); oval_syschar_model_load(syschar_model, source, &_test_error_handler, NULL); oval_import_source_free(source); printf("OVAL SYSCHAR LOADED\n"); + + struct oval_syschar_iterator *syschars = + oval_syschar_model_get_syschars(syschar_model); + int count; + for(count=0;oval_syschar_iterator_has_more(syschars);count++); + oval_syschar_iterator_free(syschars); + if(count){ + printf("THERE ARE %d SYSCHARS\n",count); + }else{ + printf("NO DEFINITIONS FOUND\n"); + return 1; + } + oval_syschar_model_export(syschar_model, oval_export_target_new_file("-","UTF-8")); + /* struct oval_syschar_iterator *syschars = oval_syschar_model_get_syschars(syschar_model); int numSyschars;for(numSyschars=0;oval_syschar_iterator_has_more(syschars);numSyschars++){ struct oval_syschar *syschar = oval_syschar_iterator_next(syschars); oval_syschar_to_print(syschar, "", numSyschars+1); } printf("THERE ARE %d SYSCHARS\n",numSyschars); + */ oval_syschar_model_free(syschar_model); } oval_definition_model_free(model); }else printf("USAGE:Test []"); oscap_cleanup(); + return 0; } +#define IS_TEST_DRIVER 1 +#if IS_TEST_DRIVER +int main(int argc, char **argv) +{ + return test_syschar_main(argc, argv); +} +#endif