| 1 |
/* SPDX-License-Identifier: MIT-0 */ |
| 2 |
|
| 3 |
#include <errno.h> |
| 4 |
#include <stdio.h> |
| 5 |
#include <systemd/sd-journal.h> |
| 6 |
|
| 7 |
int 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) { |
| 15 |
fprintf(stderr, "Failed to open journal: %s\n", strerror(-r)); |
| 16 |
return 1; |
| 17 |
} |
| 18 |
r = sd_journal_query_unique(j, "_SYSTEMD_UNIT"); |
| 19 |
if (r < 0) { |
| 20 |
fprintf(stderr, "Failed to query journal: %s\n", strerror(-r)); |
| 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 |
} |