2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
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
{
25 uint32 magic
; // "hpkg"
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
;
38 uint32 toc_compression
;
39 uint64 toc_length_compressed
;
40 uint64 toc_length_uncompressed
;
41 uint64 toc_strings_length
;
42 uint64 toc_strings_count
;
47 struct hpkg_repo_header
{
48 uint32 magic
; // "hpkr"
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)
70 compose_attribute_tag(uint16 id
, uint16 type
, uint16 encoding
, bool hasChildren
)
72 return ((encoding
<< 10) | (uint16(hasChildren
? 1 : 0) << 9) | (type
<< 6)
79 attribute_tag_encoding(uint16 tag
)
81 return ((tag
- 1) >> 10) & 0x3;
86 attribute_tag_has_children(uint16 tag
)
88 return (((tag
- 1) >> 9) & 0x1) != 0;
93 attribute_tag_type(uint16 tag
)
95 return ((tag
- 1) >> 6) & 0x7;
100 attribute_tag_id(uint16 tag
)
102 return (tag
- 1) & 0x3f;
106 } // namespace BPrivate
112 } // namespace BPackageKit
115 #endif // _PACKAGE__HPKG__V1__PRIVATE__HAIKU_PACKAGE_H_