* 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 {
struct hpkg_header {
uint32 magic;
uint16 header_size;
uint16 version;
uint64 total_size;
uint16 minor_version;
uint16 heap_compression;
uint32 heap_chunk_size;
uint64 heap_size_compressed;
uint64 heap_size_uncompressed;
uint32 attributes_length;
uint32 attributes_strings_length;
uint32 attributes_strings_count;
uint32 reserved1;
uint64 toc_length;
uint64 toc_strings_length;
uint64 toc_strings_count;
};
struct hpkg_repo_header {
uint32 magic;
uint16 header_size;
uint16 version;
uint64 total_size;
uint16 minor_version;
uint16 heap_compression;
uint32 heap_chunk_size;
uint64 heap_size_compressed;
uint64 heap_size_uncompressed;
uint32 info_length;
uint32 reserved1;
uint64 packages_length;
uint64 packages_strings_length;
uint64 packages_strings_count;
};
static inline uint16
compose_attribute_tag(uint16 id, uint16 type, uint16 encoding, bool hasChildren)
{
return ((encoding << 11) | (uint16(hasChildren ? 1 : 0) << 10) | (type << 7)
| id)
+ 1;
}
static inline uint16
attribute_tag_encoding(uint16 tag)
{
return ((tag - 1) >> 11) & 0x3;
}
static inline bool
attribute_tag_has_children(uint16 tag)
{
return (((tag - 1) >> 10) & 0x1) != 0;
}
static inline uint16
attribute_tag_type(uint16 tag)
{
return ((tag - 1) >> 7) & 0x7;
}
static inline uint16
attribute_tag_id(uint16 tag)
{
return (tag - 1) & 0x7f;
}
}
}
}
#endif