Debian Codegraph @

tests/API/XCCDF/parser/test_api_xccdf.c

raw symbols SCIP
1 /*
2 * Copyright 2010--2014 Red Hat Inc., Durham, North Carolina.
3 * All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 * Authors:
20 * Lukas Kuklinek <[email protected]>
21 */
22
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26
27 #include <xccdf_benchmark.h>
28 #include <stdio.h>
29 #include <string.h>
30 #include <stdlib.h>
31 #include <oscap_source.h>
32 #include "common/public/oscap_error.h"
33
34
35 int main(int argc, char **argv)
36 {
37 if (argc < 2) return 1;
38
39 if (strcmp(argv[1], "--export") == 0) {
40 if (argc != 4) return 1;
41 struct oscap_source *source = oscap_source_new_from_file(argv[2]);
42 struct xccdf_benchmark *bench = xccdf_benchmark_import_source(source);
43 oscap_source_free(source);
44 if (bench == NULL) return 1;
45 xccdf_benchmark_export(bench, argv[3]);
46 xccdf_benchmark_free(bench);
47 oscap_cleanup();
48 return 0;
49 }
50 else if (strcmp(argv[1], "--validate") == 0) {
51 if (argc != 4) {
52 fprintf(stderr, "Usage: %s --validate ver xccdf\n", argv[0]);
53 return 1;
54 }
55
56 struct oscap_source *source = oscap_source_new_from_file(argv[3]);
57 if (oscap_source_validate(source, NULL, stdout)) {
58 fprintf(stderr, "ERROR: %s\n", oscap_err_desc());
59 oscap_source_free(source);
60 return 1;
61 }
62 oscap_source_free(source);
63 return 0;
64
65 }
66 else {
67 fprintf(stderr, "Unknown mode: %s\n", argv[1]);
68 }
69
70 return 1;
71 }
72