journalctl.c revision c2373f848dddcc1827cf715c5ef778dc8d475761
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2011 Lennart Poettering
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <fcntl.h>
#include <errno.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include "sd-journal.h"
#include "log.h"
int r;
sd_journal *j = NULL;
log_open();
r = sd_journal_open(&j);
if (r < 0) {
goto finish;
}
SD_JOURNAL_FOREACH(j) {
const void *data;
char *cursor;
r = sd_journal_get_cursor(j, &cursor);
if (r < 0) {
goto finish;
}
printf("realtime: %llu\n"
"monotonic: %llu\n",
(unsigned long long) realtime,
(unsigned long long) monotonic);
}
if (j)
sd_journal_close(j);
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}