]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/journal/journalctl.c
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright 2011 Lennart Poettering
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
26 #include "journal-private.h"
28 int main(int argc
, char *argv
[]) {
33 log_parse_environment();
36 r
= journal_file_open(NULL
, "/var/log/journal/system.journal", O_RDONLY
, 0644, &f
);
38 r
= journal_file_open(NULL
, "/run/log/journal/system.journal", O_RDONLY
, 0644, &f
);
41 log_error("Failed to open journal: %s", strerror(-r
));
49 r
= journal_file_next_entry(f
, o
, &o
, &offset
);
51 log_error("Failed to read journal: %s", strerror(-r
));
58 printf("entry: %llu\n", (unsigned long long) le64toh(o
->entry
.seqnum
));
60 n
= journal_file_entry_n_items(o
);
61 for (i
= 0; i
< n
; i
++) {
64 p
= le64toh(o
->entry
.items
[i
].object_offset
);
65 r
= journal_file_move_to_object(f
, p
, &o
);
67 log_error("Failed to move to data: %s", strerror(-r
));
71 if (le64toh(o
->object
.type
) != OBJECT_DATA
) {
72 log_error("Invalid file");
76 l
= o
->object
.size
- offsetof(Object
, data
.payload
);
77 printf("\t[%.*s]\n", (int) l
, o
->data
.payload
);
79 r
= journal_file_move_to_object(f
, offset
, &o
);
81 log_error("Failed to move back to entry: %s", strerror(-r
));
88 journal_file_close(f
);