| 1 | /* |
| 2 | * Copyright 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 | * Simon Lukasik <[email protected]> |
| 21 | */ |
| 22 | |
| 23 | #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:411:9`! |
| 24 | #include <config.h>cxx . . $ `<file>/build/config.h`/ |
| 25 | #endif |
| 26 | |
| 27 | #include <stdio.h> |
| 28 | #include <stdlib.h> |
| 29 | #include <string.h> |
| 30 | #include <oscap_error.h>cxx . . $ `<file>/src/common/public/oscap_error.h`/ |
| 31 | #include <oscap_source.h>cxx . . $ `<file>/src/source/public/oscap_source.h`/ |
| 32 | #include "oscap_assert.h"cxx . . $ `<file>/tests/oscap_assert.h`/ |
| 33 | |
| 34 | static unsigned long read_filecxx . . $ read_file(4799418afc4b51a3).(char *filename, char **buffer) |
| 35 | { |
| 36 | FILEcxx . . $ FILE# *file = fopencxx . . $ fopen(82ec0787cd37e0a3).(filename, "rb"); |
| 37 | oscap_assertcxx . . $ `tests/oscap_assert.h:29:9`!(file != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 38 | |
| 39 | fseekcxx . . $ fseek(543fae30d249f6b1).(file, 0, SEEK_ENDcxx . . $ `<external>/232824719582829767/stdio.h:112:9`!); |
| 40 | unsigned long len = ftellcxx . . $ ftell(1dcafcd8ef4c6e6c).(file); |
| 41 | fseekcxx . . $ fseek(543fae30d249f6b1).(file, 0, SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:110:9`!); |
| 42 | |
| 43 | oscap_assertcxx . . $ `tests/oscap_assert.h:29:9`!(buffer != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 44 | *buffer = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(len + 1); |
| 45 | oscap_assertcxx . . $ `tests/oscap_assert.h:29:9`!(*buffer != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 46 | |
| 47 | freadcxx . . $ fread(738fc8ac1d711e58).(*buffer, len, 1, file); |
| 48 | fclosecxx . . $ fclose(89bc1efcdac0ca22).(file); |
| 49 | return len; |
| 50 | } |
| 51 | |
| 52 | |
| 53 | int maincxx . . $ main(afcd3168fc1188a4).(int argc, char *argv[]) |
| 54 | { |
| 55 | oscap_initcxx . . $ oscap_init(49f6e7a06ebc5aa8).(); |
| 56 | oscap_assertcxx . . $ `tests/oscap_assert.h:29:9`!(argc == 2); |
| 57 | char *buffer; |
| 58 | unsigned long buff_size = read_filecxx . . $ read_file(4799418afc4b51a3).(argv[1], &buffer); |
| 59 | oscap_assertcxx . . $ `tests/oscap_assert.h:29:9`!(buff_size != 0); |
| 60 | |
| 61 | struct oscap_sourcecxx . . $ oscap_source# *src = oscap_source_new_from_memorycxx . . $ oscap_source_new_from_memory(86df49a7a06e860a).(buffer, buff_size, "file.xml.bz2"); |
| 62 | printfcxx . . $ printf(581fddd72a8db8fc).("SCAP TYPE: %s\n", oscap_document_type_to_stringcxx . . $ oscap_document_type_to_string(1cec73a42285d610).(oscap_source_get_scap_typecxx . . $ oscap_source_get_scap_type(1b623b3fe9f5b871).(src))); |
| 63 | oscap_assertcxx . . $ `tests/oscap_assert.h:29:9`!(oscap_source_validate(src, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) == 0); |
| 64 | oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(src); |
| 65 | freecxx . . $ free(5d22bdacc48458e8).(buffer); |
| 66 | |
| 67 | if (oscap_errcxx . . $ oscap_err(c9857a73d68e59ba).()) { |
| 68 | char *err = oscap_err_get_full_errorcxx . . $ oscap_err_get_full_error(41208ce6ca65dd58).(); |
| 69 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s", err); |
| 70 | oscap_assertcxx . . $ `tests/oscap_assert.h:29:9`!(strlen(err)==0); |
| 71 | freecxx . . $ free(5d22bdacc48458e8).(err); |
| 72 | } |
| 73 | |
| 74 | oscap_cleanupcxx . . $ oscap_cleanup(49f6e7a06ebc5aa8).(); |
| 75 | return 0; |
| 76 | } |
| 77 |