I need to parse reported_to for "attach a file to existing RHTS report"
functionality. (BZ will need the same soon). I need the latest
(most recent) reported_to line for a specific prefix.
Jiri needs to parse reported_to in order to display it in GUI.
He needs all lines parsed.
For this, I also needed to improve RHTS reported_to generation -
"MSG=Case created:
https://api.access.redhat.com/rs/cases/00512471"
is not parseable. So I changed it into
"URL=https://api.access.redhat.com/rs/cases/00512471 MSG=Case created".
Unfortunately, current API:
struct report_result {
char *event;
char *data;
enum report_result_type type;
time_t timestamp;
};
char *format_report_result(const struct report_result *result);
struct report_result *parse_report_result(const char *text);
is not well-suited for either of these purposes:
it does not allow to have both URL and MSG,
and struct report_result has no provisions to contain both.
Note that we also will need EMAIL=... and also might want
to combine it with URL, MSG etc.
I propose the following API instead:
struct report_result {
time_t timestamp;
char *url;
char *msg;
char *email;
...
};
/* Find latest "PFX: ...", parse and return it. If not found, return NULL */
report_result_t *find_reported_to(struct dump_dir *dd, const char *prefix);
/* Load, parse and return all lines as list of report_result_t's */
GList *parse_reported_to(struct dump_dir *dd);
find_reported_to() is for my needs, and parse_reported_to() is for Jiri.
Formatting of reported_to lines, IMO, is handled by xasprintf()
well enough already. I tried to imagine useful helper function API
but so far I have nothing.
Please let me know what you think.
--
vda