File: test_api_xccdf.c

package info (click to toggle)
openscap 1.0.9-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 129,588 kB
  • ctags: 26,325
  • sloc: xml: 611,156; ansic: 90,367; sh: 26,693; makefile: 2,463; python: 804; perl: 445; cpp: 123
file content (66 lines) | stat: -rw-r--r-- 1,798 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
 * Copyright 2010 Red Hat Inc., Durham, North Carolina.
 * All Rights Reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Authors:
 *      Lukas Kuklinek <lkuklinek@redhat.com>
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <xccdf_benchmark.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "common/public/oscap_error.h"


int main(int argc, char **argv)
{
	if (argc < 2) return 1;

	if (strcmp(argv[1], "--export") == 0) {
		if (argc != 4) return 1;
		struct xccdf_benchmark *bench = xccdf_benchmark_import(argv[2]);
		if (bench == NULL) return 1;
		xccdf_benchmark_export(bench, argv[3]);
		xccdf_benchmark_free(bench);
		oscap_cleanup();
		return 0;
	}
	else if (strcmp(argv[1], "--validate") == 0) {
		if (argc != 4) {
			fprintf(stderr, "Usage: %s --validate ver xccdf\n", argv[0]);
			return 1;
		}

		if (oscap_validate_document(argv[3], OSCAP_DOCUMENT_XCCDF, argv[2], NULL, stdout)) {
			fprintf(stderr, "ERROR: %s\n", oscap_err_desc());
			return 1;
		}
		return 0;

	}
	else {
		fprintf(stderr, "Unknown mode: %s\n", argv[1]);
	}

	return 1;
}