Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <systemd/sd-journal.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <assert.h>
- int main(int argc, const char **argv) {
- int res;
- sd_journal *j;
- const char *journal_dir = "/var/log/journal";
- if (argc > 1) {
- journal_dir = argv[1];
- }
- printf("Using journal in %s\n", journal_dir);
- assert(sd_journal_open_directory(&j, journal_dir, SD_JOURNAL_SYSTEM) == 0);
- assert(sd_journal_seek_tail(j) == 0);
- res = sd_journal_previous_skip(j, 2);
- printf("prev skip res: %d\n", res);
- char *cursor = malloc(1024);
- cursor[0] = '\0';
- sd_journal_get_cursor(j, &cursor);
- printf("Cursor: %s\n", cursor);
- free(cursor);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement