Reporting mechanism.
More...
Data Structures |
struct | oscap_reporter_context |
struct | oscap_reporter_message |
| Represents a message to be reported. More...
|
struct | oscap_reporter_switch_ctxt |
| Switch reporter context. More...
|
Defines |
#define | XREPORTER(r) ((struct oscap_reporter*) r) |
| Reporter cast.
|
Typedefs |
typedef enum oscap_reporter_family | oscap_reporter_family_t |
| Reporter message family.
|
typedef unsigned int | oscap_reporter_code_t |
| Reporter message code type.
|
typedef int(* | oscap_reporter )(const struct oscap_reporter_message *msg, void *arg) |
| Reporter prototype.
|
Enumerations |
enum | oscap_reporter_family { OSCAP_REPORTER_FAMILY_XML = 1,
OSCAP_REPORTER_FAMILY_XCCDF = 2,
OSCAP_REPORTER_FAMILY_USER_START = 1024
} |
| Reporter message family.
More...
|
Functions |
int | oscap_reporter_fd (const struct oscap_reporter_message *msg, void *arg) |
| File descriptor reporter.
|
struct oscap_reporter_message * | oscap_reporter_message::oscap_reporter_message_new (void) |
struct oscap_reporter_message * | oscap_reporter_message::oscap_reporter_message_new_fill (oscap_reporter_family_t family, oscap_reporter_code_t code, const char *string) |
struct oscap_reporter_message * | oscap_reporter_message::oscap_reporter_message_new_fmt (oscap_reporter_family_t family, oscap_reporter_code_t code, const char *fmt,...) |
struct oscap_reporter_message * | oscap_reporter_message::oscap_reporter_message_clone (const struct oscap_reporter_message *msg) |
oscap_reporter_family_t | oscap_reporter_message::oscap_reporter_message_get_family (const struct oscap_reporter_message *item) |
oscap_reporter_code_t | oscap_reporter_message::oscap_reporter_message_get_code (const struct oscap_reporter_message *item) |
const char * | oscap_reporter_message::oscap_reporter_message_get_string (const struct oscap_reporter_message *item) |
const char * | oscap_reporter_message::oscap_reporter_message_get_user1str (const struct oscap_reporter_message *msg) |
int | oscap_reporter_message::oscap_reporter_message_get_user1num (const struct oscap_reporter_message *msg) |
void * | oscap_reporter_message::oscap_reporter_message_get_user1ptr (const struct oscap_reporter_message *msg) |
const char * | oscap_reporter_message::oscap_reporter_message_get_user2str (const struct oscap_reporter_message *msg) |
int | oscap_reporter_message::oscap_reporter_message_get_user2num (const struct oscap_reporter_message *msg) |
void * | oscap_reporter_message::oscap_reporter_message_get_user2ptr (const struct oscap_reporter_message *msg) |
const char * | oscap_reporter_message::oscap_reporter_message_get_user3str (const struct oscap_reporter_message *msg) |
int | oscap_reporter_message::oscap_reporter_message_get_user3num (const struct oscap_reporter_message *msg) |
void * | oscap_reporter_message::oscap_reporter_message_get_user3ptr (const struct oscap_reporter_message *msg) |
struct oscap_reporter_switch_ctxt * | oscap_reporter_switch_ctxt::oscap_reporter_switch_ctxt_new (void) |
void | oscap_reporter_switch_ctxt::oscap_reporter_switch_ctxt_add_range_reporter (struct oscap_reporter_switch_ctxt *ctxt, oscap_reporter reporter, void *arg, oscap_reporter_family_t family, oscap_reporter_code_t min_code, oscap_reporter_code_t max_code) |
void | oscap_reporter_switch_ctxt::oscap_reporter_switch_ctxt_add_family_reporter (struct oscap_reporter_switch_ctxt *ctxt, oscap_reporter reporter, void *arg, oscap_reporter_family_t family) |
void | oscap_reporter_switch_ctxt::oscap_reporter_switch_ctxt_add_reporter (struct oscap_reporter_switch_ctxt *ctxt, oscap_reporter reporter, void *arg) |
void | oscap_reporter_switch_ctxt::oscap_reporter_switch_ctxt_free (struct oscap_reporter_switch_ctxt *ctxt) |
int | oscap_reporter_switch_ctxt::oscap_reporter_switch (const struct oscap_reporter_message *msg, void *arg) |
void | oscap_reporter_message::oscap_reporter_message_free (struct oscap_reporter_message *msg) |
bool | oscap_reporter_message::oscap_reporter_message_set_family (struct oscap_reporter_message *obj, oscap_reporter_family_t newval) |
bool | oscap_reporter_message::oscap_reporter_message_set_code (struct oscap_reporter_message *obj, oscap_reporter_code_t newval) |
bool | oscap_reporter_message::oscap_reporter_message_set_string (struct oscap_reporter_message *obj, const char *newval) |
bool | oscap_reporter_message::oscap_reporter_message_set_user1str (struct oscap_reporter_message *msg, const char *newval) |
bool | oscap_reporter_message::oscap_reporter_message_set_user1num (struct oscap_reporter_message *msg, int newval) |
bool | oscap_reporter_message::oscap_reporter_message_set_user1ptr (struct oscap_reporter_message *msg, void *newval) |
bool | oscap_reporter_message::oscap_reporter_message_set_user2str (struct oscap_reporter_message *msg, const char *newval) |
bool | oscap_reporter_message::oscap_reporter_message_set_user2num (struct oscap_reporter_message *msg, int newval) |
bool | oscap_reporter_message::oscap_reporter_message_set_user2ptr (struct oscap_reporter_message *msg, void *newval) |
bool | oscap_reporter_message::oscap_reporter_message_set_user3str (struct oscap_reporter_message *msg, const char *newval) |
bool | oscap_reporter_message::oscap_reporter_message_set_user3num (struct oscap_reporter_message *msg, int newval) |
bool | oscap_reporter_message::oscap_reporter_message_set_user3ptr (struct oscap_reporter_message *msg, void *newval) |
struct oscap_reporter_message * | oscap_reporter_message::oscap_reporter_message_new_arg (oscap_reporter_family_t family, oscap_reporter_code_t code, const char *fmt, va_list ap) |
Variables |
const oscap_reporter_code_t | OSCAP_REPORTER_CODE_MAX |
| Maximum code.
|
Detailed Description
Reporting mechanism.
Can be used for e.g. returning individual errors during a SCAP document validation, reporting progress of some processing etc. Reporeter is a callback function that processes messages (see oscap_reporter).
Aim of reporters is to separate message content from their final representation and provide reasonable modularity. You can have reporters that print messages, log messages to a file, update a GUI and more.
- Handling messages
Messages (oscap_reporter_message) are organized in families to avoid code clashes. Message code distiguishes different types of messages. In addition to that, messages cointain human-readable string description of the event.
It is also possible to attach up to three machine-readable items to the message. These are domain-specific for given family or even code and shall be well-documented so they can be handeled properly.
One function that makes use of reporters is oscap_validate_xml(). It takes XML file name, schema file name and a reporter as a parameter. To print encountered defects to standard output, you would use it as follows:
- Sending messages
In order to send a message from a function, you have to create the message (oscap_reporter_message) and send it. To send a message use oscap_reporter_report(). To forward a message from one reporter to another (used in the special reporters) use oscap_reporter_dispatch().
There are also shortcut functions, like oscap_reporter_report_fmt(), that allows you to create and send a message in one step.
Enumeration Type Documentation
Reporter message family.
- Enumerator:
OSCAP_REPORTER_FAMILY_XML |
libxml codes
|
OSCAP_REPORTER_FAMILY_XCCDF |
XCCDF codes.
|
Function Documentation
bool oscap_reporter_message_set_string |
( |
struct oscap_reporter_message * |
obj, |
|
|
const char * |
newval | |
|
) |
| | [inherited] |
bool oscap_reporter_message_set_user1str |
( |
struct oscap_reporter_message * |
msg, |
|
|
const char * |
newval | |
|
) |
| | [inherited] |
bool oscap_reporter_message_set_user2str |
( |
struct oscap_reporter_message * |
msg, |
|
|
const char * |
newval | |
|
) |
| | [inherited] |
bool oscap_reporter_message_set_user3str |
( |
struct oscap_reporter_message * |
msg, |
|
|
const char * |
newval | |
|
) |
| | [inherited] |