1
0
Fork 0

Merge branch 'update-reportxml' into devel

This commit is contained in:
Philipp Schafft 2022-03-11 12:32:29 +00:00
commit 83f4ad89b3
5 changed files with 42 additions and 23 deletions

View File

@ -794,34 +794,45 @@ reportxml_t *client_get_reportxml(const char *state_definition, const char *stat
}
if (!report) {
reportxml_node_t *rootnode, *incidentnode, *statenode;
report = refobject_new(reportxml_t);
rootnode = reportxml_get_root_node(report);
incidentnode = reportxml_node_new(REPORTXML_NODE_TYPE_INCIDENT, NULL, NULL, NULL);
statenode = reportxml_node_new(REPORTXML_NODE_TYPE_STATE, NULL, state_definition, state_akindof);
if (state_text) {
reportxml_node_t *textnode;
textnode = reportxml_node_new(REPORTXML_NODE_TYPE_TEXT, NULL, NULL, NULL);
reportxml_node_set_content(textnode, state_text);
reportxml_node_add_child(statenode, textnode);
refobject_unref(textnode);
}
reportxml_node_add_child(incidentnode, statenode);
reportxml_node_add_child(rootnode, incidentnode);
refobject_unref(statenode);
refobject_unref(incidentnode);
refobject_unref(rootnode);
report = client_get_empty_reportxml();
refobject_unref(client_add_empty_incident(report, state_definition, state_akindof, state_text));
}
return report;
}
reportxml_t *client_get_empty_reportxml(void)
{
reportxml_t *report = refobject_new(reportxml_t);
client_get_reportxml__add_basic_stats(report);
return report;
}
reportxml_node_t *client_add_empty_incident(reportxml_t *report, const char *state_definition, const char *state_akindof, const char *state_text)
{
reportxml_node_t *rootnode = reportxml_get_root_node(report);
reportxml_node_t *incidentnode = reportxml_node_new(REPORTXML_NODE_TYPE_INCIDENT, NULL, NULL, NULL);
reportxml_node_t *statenode = reportxml_node_new(REPORTXML_NODE_TYPE_STATE, NULL, state_definition, state_akindof);;
if (state_text) {
reportxml_node_t *textnode;
textnode = reportxml_node_new(REPORTXML_NODE_TYPE_TEXT, NULL, NULL, NULL);
reportxml_node_set_content(textnode, state_text);
reportxml_node_add_child(statenode, textnode);
refobject_unref(textnode);
}
reportxml_node_add_child(incidentnode, statenode);
reportxml_node_add_child(rootnode, incidentnode);
refobject_unref(statenode);
refobject_unref(rootnode);
return incidentnode;
}
admin_format_t client_get_admin_format_by_content_negotiation(client_t *client)
{
const char *pref;

View File

@ -165,6 +165,8 @@ void client_send_redirect(client_t *client, const char *uuid, int status, const
void client_send_reportxml(client_t *client, reportxml_t *report, document_domain_t domain, const char *xsl, admin_format_t admin_format_hint, int status, const char *location);
void client_send_buffer(client_t *client, int status, const char *mediatype, const char *charset, const char *buffer, ssize_t len, const char *extra_headers);
reportxml_t *client_get_reportxml(const char *state_definition, const char *state_akindof, const char *state_text);
reportxml_t *client_get_empty_reportxml(void);
reportxml_node_t *client_add_empty_incident(reportxml_t *report, const char *state_definition, const char *state_akindof, const char *state_text);
admin_format_t client_get_admin_format_by_content_negotiation(client_t *client);
int client_send_bytes (client_t *client, const void *buf, unsigned len);
int client_read_bytes (client_t *client, void *buf, unsigned len);

View File

@ -134,7 +134,7 @@ static const struct nodeattr __attr_relative[1] = {{"relative", "iso
static const struct nodeattr __attr_name[1] = {{"name", "CDATA", NULL, 1, NULL, {NULL}}};
static const struct nodeattr __attr_member[1] = {{"member", "CDATA", NULL, 0, NULL, {NULL}}};
static const struct nodeattr __attr_value[1] = {{"value", "CDATA", NULL, 0, NULL, {NULL}}};
static const struct nodeattr __attr_state[1] = {{"state", NULL, "set", 1, NULL, {"declared", "set", "uninitialized", "missing", NULL}}};
static const struct nodeattr __attr_state[1] = {{"state", NULL, "set", 1, NULL, {"declared", "set", "unset", "uninitialized", "missing", NULL}}};
static const struct nodeattr __attr_href[1] = {{"href", "URI", NULL, 0, NULL, {NULL}}};
static const struct nodeattr __attr_application[1] = {{"application", "URI", NULL, 1, NULL, {NULL}}};
static const struct nodeattr __attr__action_type[1] = {{"type", NULL, NULL, 1, NULL, {"retry", "choice", "see-other", "authenticate", "pay", "change-protocol", "slow-down", "ask-user", "ask-admin", "bug", NULL}}};

View File

@ -27,7 +27,11 @@ void reportxml_helper_add_value(reportxml_node_t *parent, const char *type, cons
reportxml_node_set_attribute(value, "type", type);
if (member)
reportxml_node_set_attribute(value, "member", member);
reportxml_node_set_attribute(value, "value", str);
if (str) {
reportxml_node_set_attribute(value, "value", str);
} else {
reportxml_node_set_attribute(value, "state", "unset");
}
reportxml_node_add_child(parent, value);
refobject_unref(value);
}

View File

@ -17,6 +17,8 @@ void reportxml_helper_add_value(reportxml_node_t *parent, const char *type, cons
#define reportxml_helper_add_value_string(parent,member,str) reportxml_helper_add_value((parent), "string", (member), (str))
#define reportxml_helper_add_value_enum(parent,member,str) reportxml_helper_add_value((parent), "enum", (member), (str))
#define reportxml_helper_add_value_boolean(parent,member,value) reportxml_helper_add_value((parent), "boolean", (member), (value) ? "true" : "false")
#define reportxml_helper_add_value_flag(parent,member,value) reportxml_helper_add_value((parent), "flag", (member), (value) ? "true" : "false")
void reportxml_helper_add_value_int(reportxml_node_t *parent, const char *member, long long int val);
void reportxml_helper_add_text(reportxml_node_t *parent, const char *definition, const char *text);