btrfs: [] on the end of a struct field is a variable length array.
[haiku.git] / headers / private / package / hpkg / v1 / HPKGDefsPrivate.h
blobf5948b09f49b584320c1a7ab0ea4734b96d6e352
1 /*
2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _PACKAGE__HPKG__V1__PRIVATE__HAIKU_PACKAGE_H_
6 #define _PACKAGE__HPKG__V1__PRIVATE__HAIKU_PACKAGE_H_
9 #include <SupportDefs.h>
11 #include <package/hpkg/HPKGDefs.h>
14 namespace BPackageKit {
16 namespace BHPKG {
18 namespace V1 {
20 namespace BPrivate {
23 // header
24 struct hpkg_header {
25 uint32 magic; // "hpkg"
26 uint16 header_size;
27 uint16 version;
28 uint64 total_size;
30 // package attributes section
31 uint32 attributes_compression;
32 uint32 attributes_length_compressed;
33 uint32 attributes_length_uncompressed;
34 uint32 attributes_strings_length;
35 uint32 attributes_strings_count;
37 // TOC section
38 uint32 toc_compression;
39 uint64 toc_length_compressed;
40 uint64 toc_length_uncompressed;
41 uint64 toc_strings_length;
42 uint64 toc_strings_count;
46 // header
47 struct hpkg_repo_header {
48 uint32 magic; // "hpkr"
49 uint16 header_size;
50 uint16 version;
51 uint64 total_size;
53 // repository info section
54 uint32 info_compression;
55 uint32 info_length_compressed;
56 uint32 info_length_uncompressed;
58 // package attributes section
59 uint32 packages_compression;
60 uint64 packages_length_compressed;
61 uint64 packages_length_uncompressed;
62 uint64 packages_strings_length;
63 uint64 packages_strings_count;
67 // attribute tag arithmetics
68 // (using 6 bits for id, 3 for type, 1 for hasChildren and 2 for encoding)
69 static inline uint16
70 compose_attribute_tag(uint16 id, uint16 type, uint16 encoding, bool hasChildren)
72 return ((encoding << 10) | (uint16(hasChildren ? 1 : 0) << 9) | (type << 6)
73 | id)
74 + 1;
78 static inline uint16
79 attribute_tag_encoding(uint16 tag)
81 return ((tag - 1) >> 10) & 0x3;
85 static inline bool
86 attribute_tag_has_children(uint16 tag)
88 return (((tag - 1) >> 9) & 0x1) != 0;
92 static inline uint16
93 attribute_tag_type(uint16 tag)
95 return ((tag - 1) >> 6) & 0x7;
99 static inline uint16
100 attribute_tag_id(uint16 tag)
102 return (tag - 1) & 0x3f;
106 } // namespace BPrivate
108 } // namespace V1
110 } // namespace BHPKG
112 } // namespace BPackageKit
115 #endif // _PACKAGE__HPKG__V1__PRIVATE__HAIKU_PACKAGE_H_