2011-02-12 22:21:37 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef _PACKAGE__HPKG__PRIVATE__HAIKU_PACKAGE_H_
|
|
|
|
#define _PACKAGE__HPKG__PRIVATE__HAIKU_PACKAGE_H_
|
|
|
|
|
|
|
|
|
|
|
|
#include <SupportDefs.h>
|
|
|
|
|
|
|
|
#include <package/hpkg/HPKGDefs.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace BPackageKit {
|
|
|
|
|
|
|
|
namespace BHPKG {
|
|
|
|
|
|
|
|
namespace BPrivate {
|
|
|
|
|
|
|
|
|
2013-05-18 06:11:01 +04:00
|
|
|
// package file header
|
2011-02-12 22:21:37 +03:00
|
|
|
struct hpkg_header {
|
|
|
|
uint32 magic; // "hpkg"
|
|
|
|
uint16 header_size;
|
|
|
|
uint16 version;
|
|
|
|
uint64 total_size;
|
2013-05-22 02:20:13 +04:00
|
|
|
uint16 minor_version;
|
2011-02-12 22:21:37 +03:00
|
|
|
|
2013-05-14 20:59:57 +04:00
|
|
|
// heap
|
2013-05-22 02:20:13 +04:00
|
|
|
uint16 heap_compression;
|
2013-05-18 06:11:01 +04:00
|
|
|
uint32 heap_chunk_size;
|
|
|
|
uint64 heap_size_compressed;
|
|
|
|
uint64 heap_size_uncompressed;
|
2013-05-14 20:59:57 +04:00
|
|
|
|
2011-02-12 22:21:37 +03:00
|
|
|
// package attributes section
|
2013-05-18 06:11:01 +04:00
|
|
|
uint32 attributes_length;
|
2011-02-12 22:21:37 +03:00
|
|
|
uint32 attributes_strings_length;
|
|
|
|
uint32 attributes_strings_count;
|
2013-05-20 16:22:39 +04:00
|
|
|
uint32 reserved1;
|
2011-02-12 22:21:37 +03:00
|
|
|
|
|
|
|
// TOC section
|
2013-05-18 06:11:01 +04:00
|
|
|
uint64 toc_length;
|
2011-02-12 22:21:37 +03:00
|
|
|
uint64 toc_strings_length;
|
|
|
|
uint64 toc_strings_count;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-05-18 06:11:01 +04:00
|
|
|
// repository file header
|
2011-02-12 22:21:37 +03:00
|
|
|
struct hpkg_repo_header {
|
|
|
|
uint32 magic; // "hpkr"
|
|
|
|
uint16 header_size;
|
|
|
|
uint16 version;
|
2011-02-14 23:25:10 +03:00
|
|
|
uint64 total_size;
|
2013-05-22 02:20:13 +04:00
|
|
|
uint16 minor_version;
|
2011-02-12 22:21:37 +03:00
|
|
|
|
2013-05-18 06:11:01 +04:00
|
|
|
// heap
|
2013-05-22 02:20:13 +04:00
|
|
|
uint16 heap_compression;
|
2013-05-18 06:11:01 +04:00
|
|
|
uint32 heap_chunk_size;
|
|
|
|
uint64 heap_size_compressed;
|
|
|
|
uint64 heap_size_uncompressed;
|
|
|
|
|
2011-02-12 22:21:37 +03:00
|
|
|
// repository info section
|
2013-05-18 06:11:01 +04:00
|
|
|
uint32 info_length;
|
2013-05-20 16:22:39 +04:00
|
|
|
uint32 reserved1;
|
2011-02-12 22:21:37 +03:00
|
|
|
|
|
|
|
// package attributes section
|
2013-05-18 06:11:01 +04:00
|
|
|
uint64 packages_length;
|
2011-02-14 23:25:10 +03:00
|
|
|
uint64 packages_strings_length;
|
|
|
|
uint64 packages_strings_count;
|
2011-02-12 22:21:37 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// attribute tag arithmetics
|
2013-05-23 23:17:29 +04:00
|
|
|
// (using 7 bits for id, 3 for type, 1 for hasChildren and 2 for encoding)
|
2013-05-13 03:04:52 +04:00
|
|
|
static inline uint16
|
|
|
|
compose_attribute_tag(uint16 id, uint16 type, uint16 encoding, bool hasChildren)
|
|
|
|
{
|
2013-05-23 23:17:29 +04:00
|
|
|
return ((encoding << 11) | (uint16(hasChildren ? 1 : 0) << 10) | (type << 7)
|
2013-05-13 03:04:52 +04:00
|
|
|
| id)
|
|
|
|
+ 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline uint16
|
|
|
|
attribute_tag_encoding(uint16 tag)
|
|
|
|
{
|
2013-05-23 23:17:29 +04:00
|
|
|
return ((tag - 1) >> 11) & 0x3;
|
2013-05-13 03:04:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline bool
|
|
|
|
attribute_tag_has_children(uint16 tag)
|
|
|
|
{
|
2013-05-23 23:17:29 +04:00
|
|
|
return (((tag - 1) >> 10) & 0x1) != 0;
|
2013-05-13 03:04:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline uint16
|
|
|
|
attribute_tag_type(uint16 tag)
|
|
|
|
{
|
2013-05-23 23:17:29 +04:00
|
|
|
return ((tag - 1) >> 7) & 0x7;
|
2013-05-13 03:04:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline uint16
|
|
|
|
attribute_tag_id(uint16 tag)
|
|
|
|
{
|
2013-05-23 23:17:29 +04:00
|
|
|
return (tag - 1) & 0x7f;
|
2013-05-13 03:04:52 +04:00
|
|
|
}
|
2011-02-12 22:21:37 +03:00
|
|
|
|
|
|
|
|
|
|
|
} // namespace BPrivate
|
|
|
|
|
|
|
|
} // namespace BHPKG
|
|
|
|
|
|
|
|
} // namespace BPackageKit
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _PACKAGE__HPKG__PRIVATE__HAIKU_PACKAGE_H_
|