00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00032 #ifndef OSCAP_H_
00033 #define OSCAP_H_
00034 #include <stdbool.h>
00035 #include <wchar.h>
00036
00037 #include "text.h"
00038 #include "reporter.h"
00039
00063 #define OSCAP_FOREACH_GENERIC(itype, vtype, val, init_val, code) \
00064 { \
00065 struct itype##_iterator *val##_iter = (init_val); \
00066 vtype val; \
00067 while (itype##_iterator_has_more(val##_iter)) { \
00068 val = itype##_iterator_next(val##_iter); \
00069 code \
00070 } \
00071 itype##_iterator_free(val##_iter); \
00072 }
00073
00082 #define OSCAP_FOREACH(type, val, init_val, code) \
00083 OSCAP_FOREACH_GENERIC(type, struct type *, val, init_val, code)
00084
00092 #define OSCAP_FOREACH_STR(val, init_val, code) \
00093 OSCAP_FOREACH_GENERIC(oscap_string, const char *, val, init_val, code)
00094
00106 #define OSCAP_FOR_GENERIC(itype, vtype, val, init_val) \
00107 vtype val = NULL; struct itype##_iterator *val##_iter = (init_val); \
00108 while (itype##_iterator_has_more(val##_iter) \
00109 ? (val = itype##_iterator_next(val##_iter), true) \
00110 : (itype##_iterator_free(val##_iter), val##_iter = NULL, false))
00111
00119 #define OSCAP_FOR(type, val, init_val) OSCAP_FOR_GENERIC(type, struct type *, val, init_val)
00120
00127 #define OSCAP_FOR_STR(val, init_val) OSCAP_FOR_GENERIC(oscap_string, const char *, val, init_val)
00128
00144 struct xml_metadata;
00145
00151 struct xml_metadata_iterator;
00152
00157 struct xml_metadata *xml_metadata_new(void);
00158
00159
00171 const char *xml_metadata_get_nspace(const struct xml_metadata *xml);
00172
00177 const char *xml_metadata_get_lang(const struct xml_metadata *xml);
00178
00183 const char *xml_metadata_get_URI(const struct xml_metadata *xml);
00184
00185
00188
00200 bool xml_metadata_set_nspace(struct xml_metadata *xml, const char *new_namespace);
00201
00206 bool xml_metadata_set_lang(struct xml_metadata *xml, const char *new_lang);
00207
00212 bool xml_metadata_set_URI(struct xml_metadata *xml, const char *new_uri);
00213
00214
00221 void xml_metadata_free(struct xml_metadata *xml);
00222
00223
00230
00231 struct xml_metadata *xml_metadata_iterator_next(struct xml_metadata_iterator *it);
00232
00234 bool xml_metadata_iterator_has_more(struct xml_metadata_iterator *it);
00235
00237 void xml_metadata_iterator_free(struct xml_metadata_iterator *it);
00238
00240 void xml_metadata_iterator_remove(struct xml_metadata_iterator *it);
00241
00242
00243
00254 void oscap_cleanup(void);
00255
00256
00266 struct oscap_export_target;
00270 struct oscap_import_source;
00275 struct oscap_nsinfo;
00282 struct oscap_nsinfo_entry;
00288 struct oscap_nsinfo_entry_iterator;
00289
00293 typedef enum {
00294 OSCAP_STREAM_UNKNOWN = 0,
00295 OSCAP_STREAM_FILE = 1,
00296 OSCAP_STREAM_URL = 2,
00297 } oscap_stream_type_t;
00298
00299
00304 struct oscap_export_target *oscap_export_target_new_file(const char *filename, const char *encoding);
00305
00310 struct oscap_export_target *oscap_export_target_new_URL(const char *url, const char *encoding);
00311
00316 void oscap_export_target_free(struct oscap_export_target *target);
00317
00318
00319
00330 oscap_stream_type_t oscap_export_target_get_type(const struct oscap_export_target *item);
00331
00336 const char *oscap_export_target_get_name(const struct oscap_export_target *item);
00337
00342 const char *oscap_export_target_get_encoding(const struct oscap_export_target *item);
00343
00348 int oscap_export_target_get_indent(const struct oscap_export_target *item);
00349
00354 const char *oscap_export_target_get_indent_string(const struct oscap_export_target *item);
00355
00356
00364 struct oscap_import_source *oscap_import_source_new_file(const char *filename, const char *encoding);
00365
00370 struct oscap_import_source *oscap_import_source_new_URL(const char *url, const char *encoding);
00371
00376 void oscap_import_source_free(struct oscap_import_source *target);
00377
00378
00379
00390 oscap_stream_type_t oscap_import_source_get_type(const struct oscap_import_source *item);
00391
00396 const char *oscap_import_source_get_name(const struct oscap_import_source *item);
00397
00398
00402
00403 struct oscap_nsinfo *oscap_nsinfo_new(void);
00405 struct oscap_nsinfo *oscap_nsinfo_new_file(const char *fname);
00407 void oscap_nsinfo_free(struct oscap_nsinfo *info);
00408
00409
00415
00416 struct oscap_nsinfo_entry_iterator *oscap_nsinfo_get_entries(const struct oscap_nsinfo *item);
00418 struct oscap_nsinfo_entry *oscap_nsinfo_get_root_entry(const struct oscap_nsinfo *item);
00420 struct oscap_nsinfo_entry *oscap_nsinfo_get_entry_by_ns(struct oscap_nsinfo *info, const char *ns);
00421
00430
00431 bool oscap_nsinfo_add_entry(struct oscap_nsinfo *obj, struct oscap_nsinfo_entry *item);
00433 bool oscap_nsinfo_set_root_entry(struct oscap_nsinfo *obj, struct oscap_nsinfo_entry *newval);
00434
00438
00439 struct oscap_nsinfo_entry *oscap_nsinfo_entry_new(void);
00441 struct oscap_nsinfo_entry *oscap_nsinfo_entry_new_fill(const char *nsprefix, const char *nsname);
00443 void oscap_nsinfo_entry_free(struct oscap_nsinfo_entry *entry);
00444
00450
00451 const char *oscap_nsinfo_entry_get_nsname(const struct oscap_nsinfo_entry *item);
00453 const char *oscap_nsinfo_entry_get_nsprefix(const struct oscap_nsinfo_entry *item);
00455 const char *oscap_nsinfo_entry_get_schema_location(const struct oscap_nsinfo_entry *item);
00456
00465
00466 bool oscap_nsinfo_entry_set_nsname(struct oscap_nsinfo_entry *obj, const char *newval);
00468 bool oscap_nsinfo_entry_set_nsprefix(struct oscap_nsinfo_entry *obj, const char *newval);
00470 bool oscap_nsinfo_entry_set_schema_location(struct oscap_nsinfo_entry *obj, const char *newval);
00471
00474
00479
00480 bool oscap_nsinfo_entry_iterator_has_more(struct oscap_nsinfo_entry_iterator *it);
00482 struct oscap_nsinfo_entry *oscap_nsinfo_entry_iterator_next(struct oscap_nsinfo_entry_iterator *it);
00484 void oscap_nsinfo_entry_iterator_free(struct oscap_nsinfo_entry_iterator *it);
00485
00492
00493 bool oscap_validate_xml(const char *xmlfile, const char *schemafile, struct oscap_reporter* reporter);
00494
00499 #endif