---
src/include/internal_libreport.h | 4 +++-
src/lib/report_result.c | 33 ++++++++++++++++++++++++++++++---
2 files changed, 33 insertions(+), 4 deletions(-)
diff --git a/src/include/internal_libreport.h b/src/include/internal_libreport.h
index ccfd597..8758166 100644
--- a/src/include/internal_libreport.h
+++ b/src/include/internal_libreport.h
@@ -670,9 +670,11 @@ struct report_result *new_report_result(enum report_result_type type,
char *data
#define format_report_result libreport_format_report_result
char *format_report_result(const struct report_result *result);
#define parse_report_result libreport_parse_report_result
-struct report_result *parse_report_result(const char *text);
+struct report_result *parse_report_result(const char *line);
#define free_report_result libreport_free_report_result
void free_report_result(struct report_result *result);
+#define parse_report_results libreport_parse_report_results
+GList *parse_report_results(const char *text);
#define log_problem_data libreport_log_problem_data
void log_problem_data(problem_data_t *problem_data, const char *pfx);
diff --git a/src/lib/report_result.c b/src/lib/report_result.c
index ddfc24b..d379b2f 100644
--- a/src/lib/report_result.c
+++ b/src/lib/report_result.c
@@ -54,7 +54,7 @@ char *format_report_result(const struct report_result *result)
iso_date_string(&result->timestamp), type_string, result->data);
}
-struct report_result *parse_report_result(const char *text)
+struct report_result *parse_report_result(const char *line)
{
struct report_result *res;
enum report_result_type type;
@@ -62,10 +62,10 @@ struct report_result *parse_report_result(const char *text)
int event_len, event_ts_len;
char event[256], timestamp[256], *data;
- if (sscanf(text, "%s%n %s%n", event, &event_len, timestamp,
&event_ts_len) != 2)
+ if (sscanf(line, "%s%n %s%n", event, &event_len, timestamp,
&event_ts_len) != 2)
return NULL;
- data = skip_whitespace(text + event_ts_len);
+ data = skip_whitespace(line + event_ts_len);
if (!strncmp(data, "URL=", 4))
{
data += 4;
@@ -98,3 +98,30 @@ void free_report_result(struct report_result *result)
free(result->data);
free(result);
}
+
+GList *parse_report_results(const char *text)
+{
+ const char *next_line;
+ char *line;
+ struct report_result *res;
+ GList *res_list;
+
+ res_list = NULL;
+
+ while (*text)
+ {
+ next_line = strchrnul(text, '\n');
+ line = xstrndup(text, next_line - text);
+ res = parse_report_result(line);
+ free(line);
+
+ if (res)
+ res_list = g_list_append(res_list, res);
+
+ text = next_line;
+ if (*text)
+ text++;
+ }
+
+ return res_list;
+}
--
1.7.6