diff options
Diffstat (limited to 'src/lib/dump_dir.c')
-rw-r--r-- | src/lib/dump_dir.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/lib/dump_dir.c b/src/lib/dump_dir.c index fefec608..045149ac 100644 --- a/src/lib/dump_dir.c +++ b/src/lib/dump_dir.c @@ -731,6 +731,37 @@ void dd_save_binary(struct dump_dir* dd, const char* name, const char* data, uns free(full_path); } +void add_reported_to(struct dump_dir *dd, const char *line) +{ + if (!dd->locked) + error_msg_and_die("dump_dir is not opened"); /* bug */ + + char *reported_to = dd_load_text_ext(dd, FILENAME_REPORTED_TO, DD_FAIL_QUIETLY_ENOENT | DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE); + if (reported_to) + { + unsigned len_line = strlen(line); + char *p = reported_to; + while (*p) + { + if (strncmp(p, line, len_line) == 0 && (p[len_line] == '\n' || p[len_line] == '\0')) + goto ret; + p = strchrnul(p, '\n'); + if (!*p) + break; + p++; + } + if (p != reported_to && p[-1] != '\n') + reported_to = append_to_malloced_string(reported_to, "\n"); + reported_to = append_to_malloced_string(reported_to, line); + reported_to = append_to_malloced_string(reported_to, "\n"); + } + else + reported_to = xasprintf("%s\n", line); + dd_save_text(dd, FILENAME_REPORTED_TO, reported_to); + ret: + free(reported_to); +} + DIR *dd_init_next_file(struct dump_dir *dd) { // if (!dd->locked) |