struct oval_result_test *oval_result_test_clone (struct oval_result_system *new_system, struct oval_result_test *old_test) { __attribute__nonnull__(old_test); const char *testid = oval_result_test_get_id(old_test); struct oval_result_test *new_test = oval_result_test_new(new_system, (char *) testid); struct oval_result_item_iterator *old_items = oval_result_test_get_items(old_test); while (oval_result_item_iterator_has_more(old_items)) { struct oval_result_item *old_item = oval_result_item_iterator_next(old_items); struct oval_result_item *new_item = oval_result_item_clone(new_system, old_item); oval_result_test_add_item(new_test, new_item); } oval_result_item_iterator_free(old_items); struct oval_variable_binding_iterator *old_bindings = oval_result_test_get_bindings(old_test); while (oval_variable_binding_iterator_has_more(old_bindings)) { struct oval_variable_binding *old_binding = oval_variable_binding_iterator_next(old_bindings); struct oval_variable_binding *new_binding = oval_variable_binding_clone(old_binding, NULL); oval_result_test_add_binding(new_test, new_binding); } oval_variable_binding_iterator_free(old_bindings); struct oval_message_iterator *old_messages = oval_result_test_get_messages(old_test); while (oval_message_iterator_has_more(old_messages)) { struct oval_message *old_message = oval_message_iterator_next(old_messages); struct oval_message *new_message = oval_message_clone(old_message); oval_result_test_add_message(new_test, new_message); } oval_message_iterator_free(old_messages); oval_result_test_set_instance(new_test, oval_result_test_get_instance(old_test)); oval_result_test_set_result(new_test, old_test->result); return new_test; }
struct oval_result_definition *oval_result_definition_clone (struct oval_result_system *new_system, struct oval_result_definition *old_definition) { const char *id = oval_result_definition_get_id(old_definition); struct oval_result_definition *new_definition = oval_result_definition_new(new_system, (char *) id); struct oval_result_criteria_node *old_crit = oval_result_definition_get_criteria(old_definition); if (old_crit) { struct oval_result_criteria_node *new_crit = oval_result_criteria_node_clone(new_system, old_crit); oval_result_definition_set_criteria(new_definition, new_crit); } struct oval_message_iterator *old_messages = oval_result_definition_get_messages(old_definition); while (oval_message_iterator_has_more(old_messages)) { struct oval_message *old_message = oval_message_iterator_next(old_messages); struct oval_message *new_message = oval_message_clone(old_message); oval_result_definition_add_message(new_definition, new_message); } oval_message_iterator_free(old_messages); oval_result_definition_set_result(new_definition, oval_result_definition_get_result(old_definition)); oval_result_definition_set_instance(new_definition, oval_result_definition_get_instance(old_definition)); oval_result_definition_set_variable_instance_hint(new_definition, oval_result_definition_get_variable_instance_hint(old_definition)); return new_definition; }