]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/journal-iterate-unique.c
Merge pull request #31648 from neighbourhoodie/review-content
[thirdparty/systemd.git] / man / journal-iterate-unique.c
CommitLineData
1fe6d37e 1/* SPDX-License-Identifier: MIT-0 */
f4d74c61 2
b4096cec 3#include <errno.h>
787f78b6 4#include <stdio.h>
787f78b6
ZJS
5#include <systemd/sd-journal.h>
6
7int main(int argc, char *argv[]) {
8 sd_journal *j;
9 const void *d;
10 size_t l;
11 int r;
12
13 r = sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY);
14 if (r < 0) {
e84f70e1 15 fprintf(stderr, "Failed to open journal: %s\n", strerror(-r));
787f78b6
ZJS
16 return 1;
17 }
18 r = sd_journal_query_unique(j, "_SYSTEMD_UNIT");
19 if (r < 0) {
e84f70e1 20 fprintf(stderr, "Failed to query journal: %s\n", strerror(-r));
787f78b6
ZJS
21 return 1;
22 }
23 SD_JOURNAL_FOREACH_UNIQUE(j, d, l)
24 printf("%.*s\n", (int) l, (const char*) d);
25 sd_journal_close(j);
26 return 0;
27}