]>
Commit | Line | Data |
---|---|---|
f39e126e LP |
1 | /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ |
2 | ||
c2f1db8f | 3 | #pragma once |
f39e126e LP |
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 | |
5430f7f2 LP |
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 | |
f39e126e LP |
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 | |
5430f7f2 | 18 | Lesser General Public License for more details. |
f39e126e | 19 | |
5430f7f2 | 20 | You should have received a copy of the GNU Lesser General Public License |
f39e126e LP |
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 | ||
81527be1 LP |
28 | #include <systemd/sd-id128.h> |
29 | ||
cbdca852 | 30 | #include "journal-def.h" |
f39e126e | 31 | #include "list.h" |
cbdca852 LP |
32 | #include "hashmap.h" |
33 | #include "journal-file.h" | |
34 | ||
f39e126e | 35 | typedef struct Match Match; |
a963990f LP |
36 | typedef struct Location Location; |
37 | typedef struct Directory Directory; | |
38 | ||
cbdca852 LP |
39 | typedef enum MatchType { |
40 | MATCH_DISCRETE, | |
41 | MATCH_OR_TERM, | |
42 | MATCH_AND_TERM | |
43 | } MatchType; | |
f39e126e LP |
44 | |
45 | struct Match { | |
cbdca852 LP |
46 | MatchType type; |
47 | Match *parent; | |
48 | LIST_FIELDS(Match, matches); | |
49 | ||
50 | /* For concrete matches */ | |
f39e126e LP |
51 | char *data; |
52 | size_t size; | |
4fd052ae | 53 | le64_t le_hash; |
f39e126e | 54 | |
cbdca852 LP |
55 | /* For terms */ |
56 | LIST_HEAD(Match, matches); | |
f39e126e LP |
57 | }; |
58 | ||
cbdca852 LP |
59 | typedef enum LocationType { |
60 | LOCATION_HEAD, | |
61 | LOCATION_TAIL, | |
62 | LOCATION_DISCRETE | |
63 | } LocationType; | |
64 | ||
a963990f | 65 | struct Location { |
cbdca852 | 66 | LocationType type; |
f39e126e LP |
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; | |
a963990f LP |
81 | }; |
82 | ||
83 | struct Directory { | |
84 | char *path; | |
85 | int wd; | |
86 | bool is_root; | |
87 | }; | |
f39e126e LP |
88 | |
89 | struct sd_journal { | |
90 | int flags; | |
91 | ||
7827b1a1 LP |
92 | char *path; |
93 | ||
f39e126e LP |
94 | Hashmap *files; |
95 | ||
96 | Location current_location; | |
cbdca852 | 97 | |
f39e126e LP |
98 | JournalFile *current_file; |
99 | uint64_t current_field; | |
100 | ||
a963990f LP |
101 | Hashmap *directories_by_path; |
102 | Hashmap *directories_by_wd; | |
103 | ||
f39e126e | 104 | int inotify_fd; |
f39e126e | 105 | |
cbdca852 | 106 | Match *level0, *level1; |
a963990f LP |
107 | |
108 | unsigned current_invalidate_counter, last_invalidate_counter; | |
f39e126e LP |
109 | }; |
110 | ||
cbdca852 | 111 | char *journal_make_match_string(sd_journal *j); |
dca6219e | 112 | void journal_print_header(sd_journal *j); |
cbdca852 | 113 |