171fd58c4b
* Use enums/constants/functions instead of preprocessor macros. * Missing include in PackageInfoAttributeValue.h. * PackageReaderImpl::Init(): Check version before header size and return B_MISMATCHED_VALUES instead of B_BAD_DATA, if the version doesn't match. This allows callers to determine the condition and try a reader for a different version. A more flexible interface for that case would be nice, but since we want to support the old package version only temporarily, the current solution should be good enough.
112 lines
2.0 KiB
C++
112 lines
2.0 KiB
C++
/*
|
|
* 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 {
|
|
|
|
|
|
// header
|
|
struct hpkg_header {
|
|
uint32 magic; // "hpkg"
|
|
uint16 header_size;
|
|
uint16 version;
|
|
uint64 total_size;
|
|
|
|
// package attributes section
|
|
uint32 attributes_compression;
|
|
uint32 attributes_length_compressed;
|
|
uint32 attributes_length_uncompressed;
|
|
uint32 attributes_strings_length;
|
|
uint32 attributes_strings_count;
|
|
|
|
// TOC section
|
|
uint32 toc_compression;
|
|
uint64 toc_length_compressed;
|
|
uint64 toc_length_uncompressed;
|
|
uint64 toc_strings_length;
|
|
uint64 toc_strings_count;
|
|
};
|
|
|
|
|
|
// header
|
|
struct hpkg_repo_header {
|
|
uint32 magic; // "hpkr"
|
|
uint16 header_size;
|
|
uint16 version;
|
|
uint64 total_size;
|
|
|
|
// repository info section
|
|
uint32 info_compression;
|
|
uint32 info_length_compressed;
|
|
uint32 info_length_uncompressed;
|
|
|
|
// package attributes section
|
|
uint32 packages_compression;
|
|
uint64 packages_length_compressed;
|
|
uint64 packages_length_uncompressed;
|
|
uint64 packages_strings_length;
|
|
uint64 packages_strings_count;
|
|
};
|
|
|
|
|
|
// attribute tag arithmetics
|
|
// (using 6 bits for id, 3 for type, 1 for hasChildren and 2 for encoding)
|
|
static inline uint16
|
|
compose_attribute_tag(uint16 id, uint16 type, uint16 encoding, bool hasChildren)
|
|
{
|
|
return ((encoding << 10) | (uint16(hasChildren ? 1 : 0) << 9) | (type << 6)
|
|
| id)
|
|
+ 1;
|
|
}
|
|
|
|
|
|
static inline uint16
|
|
attribute_tag_encoding(uint16 tag)
|
|
{
|
|
return ((tag - 1) >> 10) & 0x3;
|
|
}
|
|
|
|
|
|
static inline bool
|
|
attribute_tag_has_children(uint16 tag)
|
|
{
|
|
return (((tag - 1) >> 9) & 0x1) != 0;
|
|
}
|
|
|
|
|
|
static inline uint16
|
|
attribute_tag_type(uint16 tag)
|
|
{
|
|
return ((tag - 1) >> 6) & 0x7;
|
|
}
|
|
|
|
|
|
static inline uint16
|
|
attribute_tag_id(uint16 tag)
|
|
{
|
|
return (tag - 1) & 0x3f;
|
|
}
|
|
|
|
|
|
} // namespace BPrivate
|
|
|
|
} // namespace BHPKG
|
|
|
|
} // namespace BPackageKit
|
|
|
|
|
|
#endif // _PACKAGE__HPKG__PRIVATE__HAIKU_PACKAGE_H_
|