| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
#ifdef HAVE_CONFIG_H |
| 9 |
#include <config.h> |
| 10 |
#endif |
| 11 |
|
| 12 |
#include <stdlib.h> |
| 13 |
#include <stdio.h> |
| 14 |
#include "oval_agent_api.h" |
| 15 |
#include "oscap.h" |
| 16 |
#include "oscap_error.h" |
| 17 |
#include "oscap_source.h" |
| 18 |
|
| 19 |
|
| 20 |
static int _test_error(void) |
| 21 |
{ |
| 22 |
if (oscap_err ()) { |
| 23 |
oscap_errfamily_t f; |
| 24 |
const char *d; |
| 25 |
|
| 26 |
fprintf (stderr, "GOT error: %d, %s.\n", |
| 27 |
f = oscap_err_family (), |
| 28 |
d = oscap_err_desc ()); |
| 29 |
} |
| 30 |
|
| 31 |
return 0; |
| 32 |
} |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
int main(int argc, char **argv) |
| 37 |
{ |
| 38 |
printf("START\n"); |
| 39 |
if (argc > 1) { |
| 40 |
struct oscap_source *source = oscap_source_new_from_file(argv[1]); |
| 41 |
struct oval_definition_model *model; |
| 42 |
printf("LOAD OVAL DEFINITIONS\n"); |
| 43 |
model = oval_definition_model_import_source(source); |
| 44 |
oscap_source_free(source); |
| 45 |
if (model == NULL) { |
| 46 |
_test_error(); |
| 47 |
} |
| 48 |
printf("OVAL DEFINITIONS LOADED\n"); |
| 49 |
if (argc > 2) { |
| 50 |
printf("LOAD OVAL SYSCHAR\n"); |
| 51 |
struct oval_syschar_model *syschar_model = oval_syschar_model_new(model); |
| 52 |
source = oscap_source_new_from_file(argv[2]); |
| 53 |
if (oval_syschar_model_import_source(syschar_model, source) < 1) |
| 54 |
_test_error(); |
| 55 |
printf("OVAL SYSCHAR LOADED\n"); |
| 56 |
|
| 57 |
int count; |
| 58 |
struct oval_syschar_iterator *syschars = oval_syschar_model_get_syschars(syschar_model); |
| 59 |
for (count = 0; oval_syschar_iterator_has_more(syschars); count++) { |
| 60 |
oval_syschar_iterator_next(syschars); |
| 61 |
} |
| 62 |
oval_syschar_iterator_free(syschars); |
| 63 |
|
| 64 |
if (count) |
| 65 |
printf("THERE ARE %d SYSCHARS\n", count); |
| 66 |
else |
| 67 |
printf("NO DEFINITIONS FOUND\n"); |
| 68 |
|
| 69 |
oval_syschar_model_export(syschar_model, "-"); |
| 70 |
oval_syschar_model_free(syschar_model); |
| 71 |
} |
| 72 |
oval_definition_model_free(model); |
| 73 |
} else |
| 74 |
printf("USAGE:Test <oval_definitions.xml> [<system_characteristics.xml>]"); |
| 75 |
oscap_cleanup(); |
| 76 |
} |