]>
git.ipfire.org Git - thirdparty/systemd.git/blob - man/journal-iterate-wait.c
1 /* SPDX-License-Identifier: MIT-0 */
5 #include <systemd/sd-journal.h>
7 int main(int argc
, char *argv
[]) {
10 r
= sd_journal_open(&j
, SD_JOURNAL_LOCAL_ONLY
);
13 fprintf(stderr
, "Failed to open journal: %m\n");
19 r
= sd_journal_next(j
);
22 fprintf(stderr
, "Failed to iterate to next entry: %m\n");
26 /* Reached the end, let's wait for changes, and try again */
27 r
= sd_journal_wait(j
, (uint64_t) -1);
30 fprintf(stderr
, "Failed to wait for changes: %m\n");
35 r
= sd_journal_get_data(j
, "MESSAGE", &d
, &l
);
38 fprintf(stderr
, "Failed to read message field: %m\n");
41 printf("%.*s\n", (int) l
, (const char*) d
);