struct rds_asset_index *rds_asset_index_new(void) { struct rds_asset_index *ret = oscap_calloc(1, sizeof(struct rds_asset_index)); ret->id = NULL; ret->reports = oscap_list_new(); return ret; }
struct xccdf_check *xccdf_check_new(void) { struct xccdf_check *check = oscap_calloc(1, sizeof(struct xccdf_check)); check->content_refs = oscap_list_new(); check->imports = oscap_list_new(); check->exports = oscap_list_new(); check->children = oscap_list_new(); return check; }
struct xccdf_rule *xccdf_rule_clone(const struct xccdf_rule * rule) { struct xccdf_item *new_rule = oscap_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_group * xccdf_group_clone(const struct xccdf_group * group) { struct xccdf_item *new_group = oscap_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_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); }
static struct oscap_tsort_context *oscap_tsort_context_new(oscap_tsort_edge_func edge_func, oscap_cmp_func cmp_func, void *userdata) { struct oscap_tsort_context *ctx = oscap_calloc(1, sizeof(struct oscap_tsort_context)); ctx->visited = oscap_list_new(); ctx->cur_stack = oscap_list_new(); ctx->result = oscap_list_new(); ctx->edge_func = edge_func; ctx->cmp_func = cmp_func; ctx->userdata = userdata; return ctx; }
/** * Allocate memory for new struct and init it with refine-rule values * @param rr Refine rule from profile * @return allocated internal refine-rule */ static inline struct xccdf_refine_rule_internal* _xccdf_refine_rule_internal_new_from_refine_rule(const struct xccdf_refine_rule* rr) { struct xccdf_refine_rule_internal* new_rr = oscap_calloc(1, sizeof(struct xccdf_refine_rule_internal)); if (new_rr != NULL) { new_rr->selector = oscap_strdup(xccdf_refine_rule_get_selector(rr)); new_rr->weight = rr->weight; new_rr->role = rr->role; new_rr->severity = rr->severity; } return new_rr; }
struct ds_rds_session *ds_rds_session_new_from_source(struct oscap_source *source) { if (oscap_source_get_scap_type(source) != OSCAP_DOCUMENT_ARF) { oscap_seterr(OSCAP_EFAMILY_OSCAP, "Could not create Result DataStream " "session: File is not Result DataStream."); return NULL; } struct ds_rds_session *rds_session = (struct ds_rds_session *) oscap_calloc(1, sizeof(struct ds_rds_session)); rds_session->source = source; rds_session->component_sources = oscap_htable_new(); return rds_session; }
struct cpe_testexpr *cpe_testexpr_new() { struct cpe_testexpr *ret; ret = oscap_calloc(1, sizeof(struct cpe_testexpr)); if (ret == NULL) return NULL; ret->oper = CPE_LANG_OPER_AND; ret->meta.expr = NULL; return ret; }
struct ds_sds_session *ds_sds_session_new_from_source(struct oscap_source *source) { if (oscap_source_get_scap_type(source) != OSCAP_DOCUMENT_SDS) { oscap_seterr(OSCAP_EFAMILY_OSCAP, "Could not create Source DataStream " "session: File is not Source DataStream."); return NULL; } struct ds_sds_session *sds_session = (struct ds_sds_session *) oscap_calloc(1, sizeof(struct ds_sds_session)); sds_session->source = source; sds_session->component_sources = oscap_htable_new(); sds_session->progress = download_progress_empty_calllback; return sds_session; }
struct oscap_reference *oscap_reference_new_parse(xmlTextReaderPtr reader) { assert(reader != NULL); struct oscap_reference *ref = oscap_calloc(1, sizeof(struct oscap_reference)); int depth = oscap_element_depth(reader); xmlNode* ref_node = xmlTextReaderExpand(reader); ref->href = (char*) xmlGetProp(ref_node, BAD_CAST "href"); for (xmlNode* cur = ref_node->children; cur != NULL; cur = cur->next) if (cur->type == XML_ELEMENT_NODE) { ref->is_dublincore = true; break; } if (ref->is_dublincore) { for (xmlNode* cur = ref_node->children; cur != NULL; cur = cur->next) { if (cur->type != XML_ELEMENT_NODE || cur->ns == NULL || !oscap_streq((const char* ) cur->ns->href, (const char *) NS_DUBLINCORE)) continue; DC_DOM_SCAN(title); DC_DOM_SCAN(creator); DC_DOM_SCAN(subject); DC_DOM_SCAN(description); DC_DOM_SCAN(publisher); DC_DOM_SCAN(contributor); DC_DOM_SCAN(date); DC_DOM_SCAN(type); DC_DOM_SCAN(format); DC_DOM_SCAN(identifier); DC_DOM_SCAN(source); DC_DOM_SCAN(language); DC_DOM_SCAN(relation); DC_DOM_SCAN(coverage); DC_DOM_SCAN(rights); } } else { ref->title = (char*) xmlNodeGetContent(ref_node); } if (!oscap_to_start_element(reader, depth)) dW("oscap_to_start_element returned `false'"); return ref; }
/* Creates a deep copy of a provided xccdf_fix, returns a pointer to that copy */ struct xccdf_fix *xccdf_fix_clone(const struct xccdf_fix *old_fix) { struct xccdf_fix *new_fix = oscap_calloc(1, sizeof(struct xccdf_fix)); new_fix->reboot = old_fix->reboot; new_fix->strategy = old_fix->strategy; new_fix->disruption = old_fix->disruption; new_fix->complexity = old_fix->complexity; new_fix->id = oscap_strdup(old_fix->id); new_fix->content = oscap_strdup(old_fix->content); new_fix->system = oscap_strdup(old_fix->system); new_fix->platform = oscap_strdup(old_fix->platform); return new_fix; }
/* Performs a deep copy of a provided xccdf_check, returns a pointer to that copy */ struct xccdf_check *xccdf_check_clone(const struct xccdf_check* old_check) { struct xccdf_check *new_check = oscap_calloc(1, sizeof(struct xccdf_check)); new_check->id = oscap_strdup(old_check->id); new_check->system = oscap_strdup(old_check->system); new_check->selector = oscap_strdup(old_check->selector); new_check->content = oscap_strdup(old_check->content); new_check->oper = old_check->oper; new_check->flags = old_check->flags; new_check->imports = oscap_list_clone(old_check->imports, (oscap_clone_func) xccdf_check_import_clone); new_check->exports = oscap_list_clone(old_check->exports, (oscap_clone_func) xccdf_check_export_clone); new_check->content_refs = oscap_list_clone(old_check->content_refs, (oscap_clone_func) xccdf_check_content_ref_clone); new_check->children = oscap_list_clone(old_check->children, (oscap_clone_func) xccdf_check_clone); return new_check; }
struct xccdf_tailoring *xccdf_tailoring_new(void) { struct xccdf_tailoring *tailoring = oscap_calloc(1, sizeof(struct xccdf_tailoring)); tailoring->id = NULL; tailoring->benchmark_ref = NULL; tailoring->benchmark_ref_version = NULL; tailoring->statuses = oscap_list_new(); tailoring->dc_statuses = oscap_list_new(); tailoring->version = NULL; tailoring->version_update = NULL; tailoring->version_time = NULL; tailoring->metadata = oscap_list_new(); tailoring->profiles = oscap_list_new(); return tailoring; }
struct oscap_reference *oscap_reference_new(void) { return oscap_calloc(1, sizeof(struct oscap_reference)); }
struct xccdf_ident *xccdf_ident_new(void) { return oscap_calloc(1, sizeof(struct xccdf_ident)); }
static struct cpe_ext_deprecation *cpe_ext_deprecation_new() { struct cpe_ext_deprecation *deprecation = oscap_calloc(1, sizeof(struct cpe_ext_deprecation)); deprecation->deprecatedbys = oscap_list_new(); return deprecation; }
static struct cpe_ext_deprecatedby *cpe_ext_deprecatedby_new() { return oscap_calloc(1, sizeof(struct cpe_ext_deprecatedby)); }
static struct cpe23_item *cpe23_item_new() { struct cpe23_item *item = oscap_calloc(1, sizeof(struct cpe23_item)); item->deprecations = oscap_list_new(); return item; }
struct xccdf_profile_note *xccdf_profile_note_new(void) { return oscap_calloc(1, sizeof(struct xccdf_profile_note)); }
struct xccdf_check_content_ref *xccdf_check_content_ref_new(void) { return oscap_calloc(1, sizeof(struct xccdf_check_content_ref)); }
struct xccdf_fixtext *xccdf_fixtext_new(void) { return oscap_calloc(1, sizeof(struct xccdf_fixtext)); }
struct xccdf_fix *xccdf_fix_new(void) { return oscap_calloc(1, sizeof(struct xccdf_fix)); }
struct xccdf_check_export *xccdf_check_export_new(void) { return oscap_calloc(1, sizeof(struct xccdf_check_export)); }