diff options
Diffstat (limited to 'src/journal/sd-journal.c')
-rw-r--r-- | src/journal/sd-journal.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index 9dcfc726ea..218df8cebe 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -30,11 +30,14 @@ #include "sd-journal.h" +#include "alloc-util.h" #include "catalog.h" #include "compress.h" +#include "dirent-util.h" #include "fd-util.h" #include "fileio.h" #include "formats-util.h" +#include "fs-util.h" #include "hashmap.h" #include "hostname-util.h" #include "io-util.h" @@ -46,6 +49,8 @@ #include "missing.h" #include "path-util.h" #include "replace-var.h" +#include "stat-util.h" +#include "stdio-util.h" #include "string-util.h" #include "strv.h" @@ -1020,8 +1025,6 @@ _public_ int sd_journal_seek_cursor(sd_journal *j, const char *cursor) { _public_ int sd_journal_test_cursor(sd_journal *j, const char *cursor) { int r; - const char *word, *state; - size_t l; Object *o; assert_return(j, -EINVAL); @@ -1035,20 +1038,23 @@ _public_ int sd_journal_test_cursor(sd_journal *j, const char *cursor) { if (r < 0) return r; - FOREACH_WORD_SEPARATOR(word, l, cursor, ";", state) { + for(;;) { _cleanup_free_ char *item = NULL; - sd_id128_t id; unsigned long long ll; + sd_id128_t id; int k = 0; - if (l < 2 || word[1] != '=') - return -EINVAL; + r = extract_first_word(&cursor, &item, ";", EXTRACT_DONT_COALESCE_SEPARATORS); + if (r < 0) + return r; - item = strndup(word, l); - if (!item) - return -ENOMEM; + if (r == 0) + break; - switch (word[0]) { + if (strlen(item) < 2 || item[1] != '=') + return -EINVAL; + + switch (item[0]) { case 's': k = sd_id128_from_string(item+2, &id); |