struct xccdf_group * xccdf_group_clone(const struct xccdf_group * group) { struct xccdf_item *new_group = calloc(1, sizeof(struct xccdf_item) + sizeof(struct xccdf_group_item)); struct xccdf_item *old = XITEM(group); xccdf_item_base_clone(&new_group->item, &(old->item)); new_group->type = old->type; xccdf_group_item_clone(new_group, &(old->sub.group)); return XGROUP(new_group); }
struct xccdf_rule *xccdf_rule_clone(const struct xccdf_rule * rule) { struct xccdf_item *new_rule = calloc(1, sizeof(struct xccdf_item) + sizeof(struct xccdf_rule_item)); struct xccdf_item *old = XITEM(rule); xccdf_item_base_clone(&new_rule->item, &(old->item)); new_rule->type = old->type; xccdf_rule_item_clone(&new_rule->sub.rule, &old->sub.rule); return XRULE(new_rule); }
struct xccdf_benchmark *xccdf_benchmark_clone(const struct xccdf_benchmark *old_benchmark) { struct xccdf_item *new_benchmark = oscap_calloc(1, sizeof(struct xccdf_item) + sizeof(struct xccdf_benchmark_item)); struct xccdf_item *old = XITEM(old_benchmark); xccdf_item_base_clone(&new_benchmark->item, &old->item); new_benchmark->type = old->type; //second argument is a pointer to the benchmark being created which will be the parent of all of its sub elements. xccdf_benchmark_item_clone(new_benchmark, old_benchmark); return XBENCHMARK(new_benchmark); }