/src/glib/subprojects/gvdb/gvdb/gvdb-format.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright © 2010 Codethink Limited |
3 | | * |
4 | | * SPDX-License-Identifier: LGPL-2.1-or-later |
5 | | * |
6 | | * This library is free software; you can redistribute it and/or |
7 | | * modify it under the terms of the GNU Lesser General Public |
8 | | * License as published by the Free Software Foundation; either |
9 | | * version 2.1 of the License, or (at your option) any later version. |
10 | | * |
11 | | * This library is distributed in the hope that it will be useful, |
12 | | * but 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 |
17 | | * License along with this library; if not, see <http://www.gnu.org/licenses/>. |
18 | | * |
19 | | * Author: Ryan Lortie <desrt@desrt.ca> |
20 | | */ |
21 | | |
22 | | #ifndef __gvdb_format_h__ |
23 | | #define __gvdb_format_h__ |
24 | | |
25 | | #include <glib.h> |
26 | | |
27 | | typedef struct { guint16 value; } guint16_le; |
28 | | typedef struct { guint32 value; } guint32_le; |
29 | | |
30 | | struct gvdb_pointer { |
31 | | guint32_le start; |
32 | | guint32_le end; |
33 | | }; |
34 | | |
35 | | struct gvdb_hash_header { |
36 | | guint32_le n_bloom_words; |
37 | | guint32_le n_buckets; |
38 | | }; |
39 | | |
40 | | struct gvdb_hash_item { |
41 | | guint32_le hash_value; |
42 | | guint32_le parent; |
43 | | |
44 | | guint32_le key_start; |
45 | | guint16_le key_size; |
46 | | gchar type; |
47 | | gchar unused; |
48 | | |
49 | | union |
50 | | { |
51 | | struct gvdb_pointer pointer; |
52 | | gchar direct[8]; |
53 | | } value; |
54 | | }; |
55 | | |
56 | | struct gvdb_header { |
57 | | guint32 signature[2]; |
58 | | guint32_le version; |
59 | | guint32_le options; |
60 | | |
61 | | struct gvdb_pointer root; |
62 | | }; |
63 | | |
64 | 0 | static inline guint32_le guint32_to_le (guint32 value) { |
65 | 0 | guint32_le result = { GUINT32_TO_LE (value) }; |
66 | 0 | return result; |
67 | 0 | } |
68 | | |
69 | 0 | static inline guint32 guint32_from_le (guint32_le value) { |
70 | 0 | return GUINT32_FROM_LE (value.value); |
71 | 0 | } |
72 | | |
73 | 0 | static inline guint16_le guint16_to_le (guint16 value) { |
74 | 0 | guint16_le result = { GUINT16_TO_LE (value) }; |
75 | 0 | return result; |
76 | 0 | } |
77 | | |
78 | 0 | static inline guint16 guint16_from_le (guint16_le value) { |
79 | 0 | return GUINT16_FROM_LE (value.value); |
80 | 0 | } |
81 | | |
82 | 0 | #define GVDB_SIGNATURE0 1918981703 |
83 | 0 | #define GVDB_SIGNATURE1 1953390953 |
84 | 0 | #define GVDB_SWAPPED_SIGNATURE0 GUINT32_SWAP_LE_BE (GVDB_SIGNATURE0) |
85 | 0 | #define GVDB_SWAPPED_SIGNATURE1 GUINT32_SWAP_LE_BE (GVDB_SIGNATURE1) |
86 | | |
87 | | #endif /* __gvdb_format_h__ */ |