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