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
00040
00064 #define OSCAP_FOREACH_GENERIC(itype, vtype, val, init_val, code) \
00065 { \
00066 struct itype##_iterator *val##_iter = (init_val); \
00067 vtype val; \
00068 while (itype##_iterator_has_more(val##_iter)) { \
00069 val = itype##_iterator_next(val##_iter); \
00070 code \
00071 } \
00072 itype##_iterator_free(val##_iter); \
00073 }
00074
00083 #define OSCAP_FOREACH(type, val, init_val, code) \
00084 OSCAP_FOREACH_GENERIC(type, struct type *, val, init_val, code)
00085
00093 #define OSCAP_FOREACH_STR(val, init_val, code) \
00094 OSCAP_FOREACH_GENERIC(oscap_string, const char *, val, init_val, code)
00095
00107 #define OSCAP_FOR_GENERIC(itype, vtype, val, init_val) \
00108 vtype val = NULL; struct itype##_iterator *val##_iter = (init_val); \
00109 while (itype##_iterator_has_more(val##_iter) \
00110 ? (val = itype##_iterator_next(val##_iter), true) \
00111 : (itype##_iterator_free(val##_iter), val##_iter = NULL, false))
00112
00120 #define OSCAP_FOR(type, val, init_val) OSCAP_FOR_GENERIC(type, struct type *, val, init_val)
00121
00128 #define OSCAP_FOR_STR(val, init_val) OSCAP_FOR_GENERIC(oscap_string, const char *, val, init_val)
00129
00145 struct xml_metadata;
00146
00152 struct xml_metadata_iterator;
00153
00158 struct xml_metadata *xml_metadata_new(void);
00159
00160
00172 const char *xml_metadata_get_nspace(const struct xml_metadata *xml);
00173
00178 const char *xml_metadata_get_lang(const struct xml_metadata *xml);
00179
00184 const char *xml_metadata_get_URI(const struct xml_metadata *xml);
00185
00186
00189
00201 bool xml_metadata_set_nspace(struct xml_metadata *xml, const char *new_namespace);
00202
00207 bool xml_metadata_set_lang(struct xml_metadata *xml, const char *new_lang);
00208
00213 bool xml_metadata_set_URI(struct xml_metadata *xml, const char *new_uri);
00214
00215
00222 void xml_metadata_free(struct xml_metadata *xml);
00223
00224
00231
00232 struct xml_metadata *xml_metadata_iterator_next(struct xml_metadata_iterator *it);
00233
00235 bool xml_metadata_iterator_has_more(struct xml_metadata_iterator *it);
00236
00238 void xml_metadata_iterator_free(struct xml_metadata_iterator *it);
00239
00241 void xml_metadata_iterator_remove(struct xml_metadata_iterator *it);
00242
00243
00244
00255 void oscap_cleanup(void);
00256
00257
00267 struct oscap_nsinfo;
00274 struct oscap_nsinfo_entry;
00280 struct oscap_nsinfo_entry_iterator;
00281
00283 struct oscap_nsinfo *oscap_nsinfo_new(void);
00285 struct oscap_nsinfo *oscap_nsinfo_new_file(const char *fname);
00287 void oscap_nsinfo_free(struct oscap_nsinfo *info);
00288
00289
00295
00296 struct oscap_nsinfo_entry_iterator *oscap_nsinfo_get_entries(const struct oscap_nsinfo *item);
00298 struct oscap_nsinfo_entry *oscap_nsinfo_get_root_entry(const struct oscap_nsinfo *item);
00300 struct oscap_nsinfo_entry *oscap_nsinfo_get_entry_by_ns(struct oscap_nsinfo *info, const char *ns);
00301
00310
00311 bool oscap_nsinfo_add_entry(struct oscap_nsinfo *obj, struct oscap_nsinfo_entry *item);
00313 bool oscap_nsinfo_set_root_entry(struct oscap_nsinfo *obj, struct oscap_nsinfo_entry *newval);
00314
00318
00319 struct oscap_nsinfo_entry *oscap_nsinfo_entry_new(void);
00321 struct oscap_nsinfo_entry *oscap_nsinfo_entry_new_fill(const char *nsprefix, const char *nsname);
00323 void oscap_nsinfo_entry_free(struct oscap_nsinfo_entry *entry);
00324
00330
00331 const char *oscap_nsinfo_entry_get_nsname(const struct oscap_nsinfo_entry *item);
00333 const char *oscap_nsinfo_entry_get_nsprefix(const struct oscap_nsinfo_entry *item);
00335 const char *oscap_nsinfo_entry_get_schema_location(const struct oscap_nsinfo_entry *item);
00336
00345
00346 bool oscap_nsinfo_entry_set_nsname(struct oscap_nsinfo_entry *obj, const char *newval);
00348 bool oscap_nsinfo_entry_set_nsprefix(struct oscap_nsinfo_entry *obj, const char *newval);
00350 bool oscap_nsinfo_entry_set_schema_location(struct oscap_nsinfo_entry *obj, const char *newval);
00351
00354
00359
00360 bool oscap_nsinfo_entry_iterator_has_more(struct oscap_nsinfo_entry_iterator *it);
00362 struct oscap_nsinfo_entry *oscap_nsinfo_entry_iterator_next(struct oscap_nsinfo_entry_iterator *it);
00364 void oscap_nsinfo_entry_iterator_free(struct oscap_nsinfo_entry_iterator *it);
00365
00375
00376 typedef enum oscap_document_type {
00377 OSCAP_DOCUMENT_OVAL_DEFINITIONS = 1,
00378 OSCAP_DOCUMENT_OVAL_SYSCHAR,
00379 OSCAP_DOCUMENT_OVAL_RESULTS,
00380 OSCAP_DOCUMENT_XCCDF,
00381 OSCAP_DOCUMENT_CPE_LANGUAGE,
00382 OSCAP_DOCUMENT_CPE_DICTIONARY,
00383 } oscap_document_type_t;
00384
00385
00403 bool oscap_validate_document(const char *xmlfile, oscap_document_type_t doctype, const char *version, oscap_reporter reporter, void *arg);
00404
00409 #endif