chiark / gitweb /
journal: make sure sd_journal_seek_cursor() seeks to the specified entry if it exists...
[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         LOCATION_SEEK
64 } LocationType;
65
66 struct Location {
67         LocationType type;
68
69         uint64_t seqnum;
70         sd_id128_t seqnum_id;
71         bool seqnum_set;
72
73         uint64_t realtime;
74         bool realtime_set;
75
76         uint64_t monotonic;
77         sd_id128_t boot_id;
78         bool monotonic_set;
79
80         uint64_t xor_hash;
81         bool xor_hash_set;
82 };
83
84 struct Directory {
85         char *path;
86         int wd;
87         bool is_root;
88 };
89
90 struct sd_journal {
91         int flags;
92
93         char *path;
94
95         Hashmap *files;
96         MMapCache *mmap;
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 void journal_print_header(sd_journal *j);