chiark / gitweb /
Prep v220: Apply "Fixes to user and session saving"
[elogind.git] / src / libelogind / sd-hwdb / hwdb-internal.h
1 /***
2   This file is part of systemd.
3
4   Copyright 2012 Kay Sievers <kay@vrfy.org>
5
6   systemd is free software; you can redistribute it and/or modify it
7   under the terms of the GNU Lesser General Public License as published by
8   the Free Software Foundation; either version 2.1 of the License, or
9   (at your option) any later version.
10
11   systemd is distributed in the hope that it will be useful, but
12   WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14   Lesser General Public License for more details.
15
16   You should have received a copy of the GNU Lesser General Public License
17   along with systemd; If not, see <http://www.gnu.org/licenses/>.
18 ***/
19 #pragma once
20
21 #include "sparse-endian.h"
22
23 #define HWDB_SIG { 'K', 'S', 'L', 'P', 'H', 'H', 'R', 'H' }
24
25 /* on-disk trie objects */
26 struct trie_header_f {
27         uint8_t signature[8];
28
29         /* version of tool which created the file */
30         le64_t tool_version;
31         le64_t file_size;
32
33         /* size of structures to allow them to grow */
34         le64_t header_size;
35         le64_t node_size;
36         le64_t child_entry_size;
37         le64_t value_entry_size;
38
39         /* offset of the root trie node */
40         le64_t nodes_root_off;
41
42         /* size of the nodes and string section */
43         le64_t nodes_len;
44         le64_t strings_len;
45 } _packed_;
46
47 struct trie_node_f {
48         /* prefix of lookup string, shared by all children  */
49         le64_t prefix_off;
50         /* size of children entry array appended to the node */
51         uint8_t children_count;
52         uint8_t padding[7];
53         /* size of value entry array appended to the node */
54         le64_t values_count;
55 } _packed_;
56
57 /* array of child entries, follows directly the node record */
58 struct trie_child_entry_f {
59         /* index of the child node */
60         uint8_t c;
61         uint8_t padding[7];
62         /* offset of the child node */
63         le64_t child_off;
64 } _packed_;
65
66 /* array of value entries, follows directly the node record/child array */
67 struct trie_value_entry_f {
68         le64_t key_off;
69         le64_t value_off;
70 } _packed_;