chiark / gitweb /
journal: move field index from file into journal object
[elogind.git] / src / journal / wjournal.c
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 /***
4   This file is part of systemd.
5
6   Copyright 2011 Lennart Poettering
7
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.
12
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.
17
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/>.
20 ***/
21
22 #include "wjournal.h"
23 #include "journal-def.h"
24
25 struct WJournal {
26         int fd;
27
28         Header *header;
29         HashItem *hash_table;
30         uint64_t *bisect_table;
31 };
32
33 int wjournal_open(const char *fn, WJournal **ret) {
34         assert(fn);
35         assert(ret);
36 }
37
38 void wjournal_close(WJournal *j) {
39         assert(j);
40
41         if (j->fd >= 0)
42                 close_nointr_nofail(j->fd);
43
44         if (j->header) {
45                 munmap(j->header, PAGE_ALIGN(sizeof(Header)));
46
47         }
48
49         free(j);
50 }
51
52 int wjournal_write_object_begin(WJournal *j, uint64_t type, uint64_t size, Object **ret);
53 int wjournal_write_object_finish(WJournal *j, Object *ret);
54
55 int wjournal_write_field(WJournal *j, const char *buffer, uint64_t size, Object **ret);
56 int wjournal_write_entry(WJournal *j, const Field *fields, unsigned n_fields, Object **ret);
57 int wjournal_write_eof(WJournal *j);