chiark / gitweb /
test: hook up more tests with make check
[elogind.git] / src / journal / journal-internal.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 #ifndef foojournalinternalhfoo
4 #define foojournalinternalhfoo
5
6 /***
7   This file is part of systemd.
8
9   Copyright 2011 Lennart Poettering
10
11   systemd is free software; you can redistribute it and/or modify it
12   under the terms of the GNU Lesser General Public License as published by
13   the Free Software Foundation; either version 2.1 of the License, or
14   (at your option) any later version.
15
16   systemd is distributed in the hope that it will be useful, but
17   WITHOUT ANY WARRANTY; without even the implied warranty of
18   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19   Lesser General Public License for more details.
20
21   You should have received a copy of the GNU Lesser General Public License
22   along with systemd; If not, see <http://www.gnu.org/licenses/>.
23 ***/
24
25 #include <sys/types.h>
26 #include <inttypes.h>
27 #include <stdbool.h>
28
29 #include <systemd/sd-id128.h>
30
31 #include "journal-def.h"
32 #include "list.h"
33 #include "hashmap.h"
34 #include "journal-file.h"
35
36 typedef enum MatchType MatchType;
37 typedef enum LocationType LocationType;
38
39 typedef struct Match Match;
40 typedef struct Location Location;
41 typedef struct Directory Directory;
42
43 typedef enum MatchType {
44         MATCH_DISCRETE,
45         MATCH_OR_TERM,
46         MATCH_AND_TERM
47 } MatchType;
48
49 struct Match {
50         MatchType type;
51         Match *parent;
52         LIST_FIELDS(Match, matches);
53
54         /* For concrete matches */
55         char *data;
56         size_t size;
57         le64_t le_hash;
58
59         /* For terms */
60         LIST_HEAD(Match, matches);
61 };
62
63 typedef enum LocationType {
64         LOCATION_HEAD,
65         LOCATION_TAIL,
66         LOCATION_DISCRETE
67 } LocationType;
68
69 struct Location {
70         LocationType type;
71
72         uint64_t seqnum;
73         sd_id128_t seqnum_id;
74         bool seqnum_set;
75
76         uint64_t realtime;
77         bool realtime_set;
78
79         uint64_t monotonic;
80         sd_id128_t boot_id;
81         bool monotonic_set;
82
83         uint64_t xor_hash;
84         bool xor_hash_set;
85 };
86
87 struct Directory {
88         char *path;
89         int wd;
90         bool is_root;
91 };
92
93 struct sd_journal {
94         int flags;
95
96         Hashmap *files;
97
98         Location current_location;
99
100         JournalFile *current_file;
101         uint64_t current_field;
102
103         Hashmap *directories_by_path;
104         Hashmap *directories_by_wd;
105
106         int inotify_fd;
107
108         Match *level0, *level1;
109
110         unsigned current_invalidate_counter, last_invalidate_counter;
111 };
112
113 char *journal_make_match_string(sd_journal *j);
114
115 #endif