static inline void _print_xccdf_tailoring(struct oscap_source *source, const char *prefix) { struct xccdf_tailoring *tailoring = xccdf_tailoring_import_source(source, NULL); if (tailoring == NULL) { return; } printf("%sBenchmark Hint: %s\n", prefix, xccdf_tailoring_get_benchmark_ref(tailoring)); _print_xccdf_profiles(xccdf_tailoring_get_profiles(tailoring), prefix); xccdf_tailoring_free(tailoring); }
struct xccdf_tailoring *xccdf_tailoring_import(const char *file, struct xccdf_benchmark *benchmark) { xmlTextReaderPtr reader = xmlReaderForFile(file, NULL, 0); if (!reader) { oscap_seterr(OSCAP_EFAMILY_GLIBC, "Unable to open file: '%s'", file); return NULL; } xmlTextReaderSetErrorHandler(reader, &libxml_error_handler, NULL); while (xmlTextReaderRead(reader) == 1 && xmlTextReaderNodeType(reader) != XML_READER_TYPE_ELEMENT) ; struct xccdf_tailoring *tailoring = xccdf_tailoring_parse(reader, XITEM(benchmark)); xmlFreeTextReader(reader); if (!tailoring) { // parsing fatal error oscap_seterr(OSCAP_EFAMILY_XML, "Failed to parse '%s'.", file); xccdf_tailoring_free(tailoring); return NULL; } return tailoring; }