]>
Commit | Line | Data |
---|---|---|
787f78b6 ZJS |
1 | #include <stdio.h> |
2 | #include <string.h> | |
3 | #include <systemd/sd-journal.h> | |
4 | ||
5 | int main(int argc, char *argv[]) { | |
6 | sd_journal *j; | |
7 | const void *d; | |
8 | size_t l; | |
9 | int r; | |
10 | ||
11 | r = sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY); | |
12 | if (r < 0) { | |
13 | fprintf(stderr, "Failed to open journal: %s\n", strerror(-r)); | |
14 | return 1; | |
15 | } | |
16 | r = sd_journal_query_unique(j, "_SYSTEMD_UNIT"); | |
17 | if (r < 0) { | |
18 | fprintf(stderr, "Failed to query journal: %s\n", strerror(-r)); | |
19 | return 1; | |
20 | } | |
21 | SD_JOURNAL_FOREACH_UNIQUE(j, d, l) | |
22 | printf("%.*s\n", (int) l, (const char*) d); | |
23 | sd_journal_close(j); | |
24 | return 0; | |
25 | } |