00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00028 #ifndef OSCAP_REPORTER_H_
00029 #define OSCAP_REPORTER_H_
00030
00031 #include <stdbool.h>
00032 #include <stdarg.h>
00033
00126
00127 typedef enum oscap_reporter_family {
00128 OSCAP_REPORTER_FAMILY_XML = 1,
00129 OSCAP_REPORTER_FAMILY_USER_START = 1024
00130 } oscap_reporter_family_t;
00131
00133 typedef unsigned int oscap_reporter_code_t;
00134
00136 extern const oscap_reporter_code_t OSCAP_REPORTER_CODE_MAX;
00137
00139 #define OSCAP_REPORTER_ALL 0, OSCAP_REPORTER_CODE_MAX
00140
00145 struct oscap_reporter_message;
00146
00151 struct oscap_reporter_type;
00152
00157 struct oscap_reporter;
00158
00159
00172 typedef bool(*oscap_reporter_init_func)(void **user);
00173
00180 typedef void(*oscap_reporter_report_func)(const struct oscap_reporter_message *msg, void *user);
00186 typedef void(*oscap_reporter_destroy_func)(void *user);
00187
00189 struct oscap_reporter_message *oscap_reporter_message_new(void);
00191 struct oscap_reporter_message *oscap_reporter_message_new_fill(oscap_reporter_family_t family, oscap_reporter_code_t code, const char *string);
00193 struct oscap_reporter_message *oscap_reporter_message_new_arg(oscap_reporter_family_t family, oscap_reporter_code_t code, const char *fmt, va_list ap);
00195 struct oscap_reporter_message *oscap_reporter_message_new_fmt(oscap_reporter_family_t family, oscap_reporter_code_t code, const char *fmt, ...);
00197 struct oscap_reporter_message *oscap_reporter_message_clone(const struct oscap_reporter_message *msg);
00199 oscap_reporter_family_t oscap_reporter_message_get_family(const struct oscap_reporter_message *item);
00201 oscap_reporter_code_t oscap_reporter_message_get_code(const struct oscap_reporter_message *item);
00203 const char *oscap_reporter_message_get_string(const struct oscap_reporter_message *item);
00204
00206 const char *oscap_reporter_message_get_user1str(const struct oscap_reporter_message *msg);
00208 int oscap_reporter_message_get_user1num(const struct oscap_reporter_message *msg);
00210 void *oscap_reporter_message_get_user1ptr(const struct oscap_reporter_message *msg);
00212 const char *oscap_reporter_message_get_user2str(const struct oscap_reporter_message *msg);
00214 int oscap_reporter_message_get_user2num(const struct oscap_reporter_message *msg);
00216 void *oscap_reporter_message_get_user2ptr(const struct oscap_reporter_message *msg);
00218 const char *oscap_reporter_message_get_user3str(const struct oscap_reporter_message *msg);
00220 int oscap_reporter_message_get_user3num(const struct oscap_reporter_message *msg);
00222 void *oscap_reporter_message_get_user3ptr(const struct oscap_reporter_message *msg);
00223
00224
00233 struct oscap_reporter_type *oscap_reporter_type_new(
00234 oscap_reporter_init_func init,
00235 oscap_reporter_report_func report,
00236 oscap_reporter_destroy_func destroy);
00237
00239 void oscap_reporter_type_free(struct oscap_reporter_type *reptype);
00240
00241
00248 struct oscap_reporter *oscap_reporter_new(const struct oscap_reporter_type *type, void *user);
00250 void oscap_reporter_free(struct oscap_reporter *reporter);
00251
00257 void oscap_reporter_dispatch(struct oscap_reporter *reporter, const struct oscap_reporter_message *msg);
00258
00266 void oscap_reporter_report(struct oscap_reporter *reporter, struct oscap_reporter_message *msg);
00268 void oscap_reporter_report_fmt(struct oscap_reporter *reporter, oscap_reporter_family_t family, oscap_reporter_code_t code, const char *fmt, ...);
00269
00271 const char *oscap_reporter_get_userdata(const struct oscap_reporter *item);
00273 bool oscap_reporter_set_userdata(struct oscap_reporter *obj, const char *newval);
00274
00286 extern const struct oscap_reporter_type OSCAP_REPORTER_STDOUT;
00287
00297 extern const struct oscap_reporter_type OSCAP_REPORTER_MULTI;
00298
00305 void oscap_reporter_multi_add_reporter(struct oscap_reporter *multi, struct oscap_reporter *reporter);
00306
00320 struct oscap_reporter *oscap_reporter_new_filter(struct oscap_reporter *pos_child, struct oscap_reporter *neg_child,
00321 oscap_reporter_family_t family, oscap_reporter_code_t min_code, oscap_reporter_code_t max_code);
00322
00325 #endif // OSCAP_REPORTER_H_