* some rearrangements and renames with respect to public/private

types and defines of HPKG
* added header, magic and version for haiku repository format

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40370 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Tappe 2011-02-07 13:04:00 +00:00
parent 5658c5ff2a
commit aaf05784d4
4 changed files with 170 additions and 156 deletions

View File

@ -14,10 +14,13 @@ namespace BPackageKit {
namespace BHPKG {
// magic, version
// magic & version of package and repository files
enum {
B_HPKG_MAGIC = 'hpkg',
B_HPKG_VERSION = 1
B_HPKG_VERSION = 1,
//
B_HPKG_REPO_MAGIC = 'hpkr',
B_HPKG_REPO_VERSION = 1
};
@ -92,9 +95,28 @@ enum BPackageAttributeID {
};
// TODO: make this accessible via a function
// compression types
enum {
B_HPKG_COMPRESSION_NONE = 0,
B_HPKG_COMPRESSION_ZLIB = 1
};
// file types (HPKG_ATTRIBUTE_NAME_FILE_TYPE)
enum {
B_HPKG_FILE_TYPE_FILE = 0,
B_HPKG_FILE_TYPE_DIRECTORY = 1,
B_HPKG_FILE_TYPE_SYMLINK = 2
};
// default values
enum {
B_HPKG_DEFAULT_FILE_TYPE = B_HPKG_FILE_TYPE_FILE,
B_HPKG_DEFAULT_FILE_PERMISSIONS = 0644,
B_HPKG_DEFAULT_DIRECTORY_PERMISSIONS = 0755,
B_HPKG_DEFAULT_SYMLINK_PERMISSIONS = 0777,
B_HPKG_DEFAULT_DATA_COMPRESSION = B_HPKG_COMPRESSION_NONE,
B_HPKG_DEFAULT_DATA_CHUNK_SIZE_ZLIB = 64 * 1024
};

View File

@ -42,116 +42,108 @@ struct hpkg_header {
};
// compression types
enum {
B_HPKG_COMPRESSION_NONE = 0,
B_HPKG_COMPRESSION_ZLIB = 1
// header
struct hpkg_repo_header {
uint32 magic; // "hpkr"
uint16 header_size;
uint16 version;
uint64 total_size;
// package attributes section
uint32 attributes_compression;
uint32 attributes_length_compressed;
uint32 attributes_length_uncompressed;
uint64 attributes_strings_length;
uint64 attributes_strings_count;
};
// attribute tag arithmetics
#define B_HPKG_ATTRIBUTE_TAG_COMPOSE(index, encoding, hasChildren) \
#define HPKG_ATTRIBUTE_TAG_COMPOSE(index, encoding, hasChildren) \
(((uint64(index) << 3) | uint64(encoding) << 1 \
| ((hasChildren) ? 1 : 0)) + 1)
#define B_HPKG_ATTRIBUTE_TAG_INDEX(tag) (uint64((tag) - 1) >> 3)
#define B_HPKG_ATTRIBUTE_TAG_ENCODING(tag) ((uint64((tag) - 1) >> 1) & 0x3)
#define B_HPKG_ATTRIBUTE_TAG_HAS_CHILDREN(tag) ((uint64((tag) - 1) & 0x1) != 0)
#define HPKG_ATTRIBUTE_TAG_INDEX(tag) (uint64((tag) - 1) >> 3)
#define HPKG_ATTRIBUTE_TAG_ENCODING(tag) ((uint64((tag) - 1) >> 1) & 0x3)
#define HPKG_ATTRIBUTE_TAG_HAS_CHILDREN(tag) ((uint64((tag) - 1) & 0x1) != 0)
// package attribute tag arithmetics
#define B_HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(id, type, encoding, hasChildren) \
(((uint16(encoding) << 9) | (((hasChildren) ? 1 : 0) << 8) \
#define HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(id, type, encoding, hasChildren) \
(((uint16(encoding) << 9) | (((hasChildren) ? 1 : 0) << 8) \
| (uint16(type) << 5) | (uint16(id))) + 1)
#define B_HPKG_PACKAGE_ATTRIBUTE_TAG_ENCODING(tag) \
#define HPKG_PACKAGE_ATTRIBUTE_TAG_ENCODING(tag) \
((uint16((tag) - 1) >> 9) & 0x3)
#define B_HPKG_PACKAGE_ATTRIBUTE_TAG_HAS_CHILDREN(tag) \
#define HPKG_PACKAGE_ATTRIBUTE_TAG_HAS_CHILDREN(tag) \
(((uint16((tag) - 1) >> 8) & 0x1) != 0)
#define B_HPKG_PACKAGE_ATTRIBUTE_TAG_TYPE(tag) \
#define HPKG_PACKAGE_ATTRIBUTE_TAG_TYPE(tag) \
((uint16((tag) - 1) >> 5) & 0x7)
#define B_HPKG_PACKAGE_ATTRIBUTE_TAG_ID(tag) \
#define HPKG_PACKAGE_ATTRIBUTE_TAG_ID(tag) \
(uint16((tag) - 1) & 0x1f)
// standard attribute names
#define B_HPKG_ATTRIBUTE_NAME_DIRECTORY_ENTRY "dir:entry"
#define HPKG_ATTRIBUTE_NAME_DIRECTORY_ENTRY "dir:entry"
// path/entry name (string)
#define B_HPKG_ATTRIBUTE_NAME_FILE_TYPE "file:type"
#define HPKG_ATTRIBUTE_NAME_FILE_TYPE "file:type"
// file type (uint)
#define B_HPKG_ATTRIBUTE_NAME_FILE_PERMISSIONS "file:permissions"
#define HPKG_ATTRIBUTE_NAME_FILE_PERMISSIONS "file:permissions"
// file permissions (uint)
#define B_HPKG_ATTRIBUTE_NAME_FILE_USER "file:user"
#define HPKG_ATTRIBUTE_NAME_FILE_USER "file:user"
// file user (string)
#define B_HPKG_ATTRIBUTE_NAME_FILE_GROUP "file:group"
#define HPKG_ATTRIBUTE_NAME_FILE_GROUP "file:group"
// file group (string)
#define B_HPKG_ATTRIBUTE_NAME_FILE_ATIME "file:atime"
#define HPKG_ATTRIBUTE_NAME_FILE_ATIME "file:atime"
// file access time in seconds (uint)
#define B_HPKG_ATTRIBUTE_NAME_FILE_MTIME "file:mtime"
#define HPKG_ATTRIBUTE_NAME_FILE_MTIME "file:mtime"
// file modification time in seconds (uint)
#define B_HPKG_ATTRIBUTE_NAME_FILE_CRTIME "file:crtime"
#define HPKG_ATTRIBUTE_NAME_FILE_CRTIME "file:crtime"
// file creation time in seconds (uint)
#define B_HPKG_ATTRIBUTE_NAME_FILE_ATIME_NANOS "file:atime:nanos"
#define HPKG_ATTRIBUTE_NAME_FILE_ATIME_NANOS "file:atime:nanos"
// file access time nanoseconds fraction (uint)
#define B_HPKG_ATTRIBUTE_NAME_FILE_MTIME_NANOS "file:mtime:nanos"
#define HPKG_ATTRIBUTE_NAME_FILE_MTIME_NANOS "file:mtime:nanos"
// file modification time nanoseconds fraction (uint)
#define B_HPKG_ATTRIBUTE_NAME_FILE_CRTIM_NANOS "file:crtime:nanos"
#define HPKG_ATTRIBUTE_NAME_FILE_CRTIM_NANOS "file:crtime:nanos"
// file creation time nanoseconds fraction (uint)
#define B_HPKG_ATTRIBUTE_NAME_FILE_ATTRIBUTE "file:attribute"
#define HPKG_ATTRIBUTE_NAME_FILE_ATTRIBUTE "file:attribute"
// file attribute (string)
#define B_HPKG_ATTRIBUTE_NAME_FILE_ATTRIBUTE_TYPE "file:attribute:type"
#define HPKG_ATTRIBUTE_NAME_FILE_ATTRIBUTE_TYPE "file:attribute:type"
// file attribute type (uint)
#define B_HPKG_ATTRIBUTE_NAME_DATA "data"
#define HPKG_ATTRIBUTE_NAME_DATA "data"
// (file/attribute) data (raw)
#define B_HPKG_ATTRIBUTE_NAME_DATA_COMPRESSION "data:compression"
#define HPKG_ATTRIBUTE_NAME_DATA_COMPRESSION "data:compression"
// (file/attribute) data compression (uint, default: none)
#define B_HPKG_ATTRIBUTE_NAME_DATA_SIZE "data:size"
#define HPKG_ATTRIBUTE_NAME_DATA_SIZE "data:size"
// (file/attribute) uncompressed data size (uint)
#define B_HPKG_ATTRIBUTE_NAME_DATA_CHUNK_SIZE "data:chunk_size"
#define HPKG_ATTRIBUTE_NAME_DATA_CHUNK_SIZE "data:chunk_size"
// the size of compressed (file/attribute) data chunks (uint)
#define B_HPKG_ATTRIBUTE_NAME_SYMLINK_PATH "symlink:path"
#define HPKG_ATTRIBUTE_NAME_SYMLINK_PATH "symlink:path"
// symlink path (string)
// file types (B_HPKG_ATTRIBUTE_NAME_FILE_TYPE)
enum {
B_HPKG_FILE_TYPE_FILE = 0,
B_HPKG_FILE_TYPE_DIRECTORY = 1,
B_HPKG_FILE_TYPE_SYMLINK = 2
};
// default values
enum {
B_HPKG_DEFAULT_FILE_TYPE = B_HPKG_FILE_TYPE_FILE,
B_HPKG_DEFAULT_FILE_PERMISSIONS = 0644,
B_HPKG_DEFAULT_DIRECTORY_PERMISSIONS = 0755,
B_HPKG_DEFAULT_SYMLINK_PERMISSIONS = 0777,
B_HPKG_DEFAULT_DATA_COMPRESSION = B_HPKG_COMPRESSION_NONE,
};
// package attribute IDs
enum BHPKGPackageAttributeID {
B_HPKG_PACKAGE_ATTRIBUTE_NAME = 0,
B_HPKG_PACKAGE_ATTRIBUTE_SUMMARY,
B_HPKG_PACKAGE_ATTRIBUTE_DESCRIPTION,
B_HPKG_PACKAGE_ATTRIBUTE_VENDOR,
B_HPKG_PACKAGE_ATTRIBUTE_PACKAGER,
B_HPKG_PACKAGE_ATTRIBUTE_ARCHITECTURE,
B_HPKG_PACKAGE_ATTRIBUTE_VERSION_MAJOR,
B_HPKG_PACKAGE_ATTRIBUTE_VERSION_MINOR,
B_HPKG_PACKAGE_ATTRIBUTE_VERSION_MICRO,
B_HPKG_PACKAGE_ATTRIBUTE_VERSION_RELEASE,
B_HPKG_PACKAGE_ATTRIBUTE_COPYRIGHT,
B_HPKG_PACKAGE_ATTRIBUTE_LICENSE,
B_HPKG_PACKAGE_ATTRIBUTE_PROVIDES,
B_HPKG_PACKAGE_ATTRIBUTE_PROVIDES_TYPE,
B_HPKG_PACKAGE_ATTRIBUTE_REQUIRES,
B_HPKG_PACKAGE_ATTRIBUTE_SUPPLEMENTS,
B_HPKG_PACKAGE_ATTRIBUTE_CONFLICTS,
B_HPKG_PACKAGE_ATTRIBUTE_FRESHENS,
B_HPKG_PACKAGE_ATTRIBUTE_REPLACES,
B_HPKG_PACKAGE_ATTRIBUTE_RESOLVABLE_OPERATOR,
enum HPKGPackageAttributeID {
HPKG_PACKAGE_ATTRIBUTE_NAME = 0,
HPKG_PACKAGE_ATTRIBUTE_SUMMARY,
HPKG_PACKAGE_ATTRIBUTE_DESCRIPTION,
HPKG_PACKAGE_ATTRIBUTE_VENDOR,
HPKG_PACKAGE_ATTRIBUTE_PACKAGER,
HPKG_PACKAGE_ATTRIBUTE_ARCHITECTURE,
HPKG_PACKAGE_ATTRIBUTE_VERSION_MAJOR,
HPKG_PACKAGE_ATTRIBUTE_VERSION_MINOR,
HPKG_PACKAGE_ATTRIBUTE_VERSION_MICRO,
HPKG_PACKAGE_ATTRIBUTE_VERSION_RELEASE,
HPKG_PACKAGE_ATTRIBUTE_COPYRIGHT,
HPKG_PACKAGE_ATTRIBUTE_LICENSE,
HPKG_PACKAGE_ATTRIBUTE_PROVIDES,
HPKG_PACKAGE_ATTRIBUTE_PROVIDES_TYPE,
HPKG_PACKAGE_ATTRIBUTE_REQUIRES,
HPKG_PACKAGE_ATTRIBUTE_SUPPLEMENTS,
HPKG_PACKAGE_ATTRIBUTE_CONFLICTS,
HPKG_PACKAGE_ATTRIBUTE_FRESHENS,
HPKG_PACKAGE_ATTRIBUTE_REPLACES,
HPKG_PACKAGE_ATTRIBUTE_RESOLVABLE_OPERATOR,
//
B_HPKG_PACKAGE_ATTRIBUTE_ENUM_COUNT,
HPKG_PACKAGE_ATTRIBUTE_ENUM_COUNT,
};

View File

@ -80,7 +80,7 @@ struct standard_attribute_index_entry {
#undef MAKE_ATTRIBUTE_INDEX_ENTRY
#define MAKE_ATTRIBUTE_INDEX_ENTRY(name, type) \
{ B_HPKG_ATTRIBUTE_NAME_##name, B_HPKG_ATTRIBUTE_TYPE_##type, \
{ HPKG_ATTRIBUTE_NAME_##name, B_HPKG_ATTRIBUTE_TYPE_##type, \
ATTRIBUTE_INDEX_##name }
static const standard_attribute_index_entry kStandardAttributeIndices[] = {
@ -1063,7 +1063,7 @@ PackageReaderImpl::_ParseAttributeTree(AttributeHandlerContext* context)
}
// get the type
uint64 typeIndex = B_HPKG_ATTRIBUTE_TAG_INDEX(tag);
uint64 typeIndex = HPKG_ATTRIBUTE_TAG_INDEX(tag);
if (typeIndex >= fTOCAttributeTypesCount) {
fErrorOutput->PrintError("Error: Invalid TOC section: "
"Invalid attribute type index\n");
@ -1074,11 +1074,11 @@ PackageReaderImpl::_ParseAttributeTree(AttributeHandlerContext* context)
// get the value
AttributeValue value;
error = _ReadAttributeValue(type->type->type,
B_HPKG_ATTRIBUTE_TAG_ENCODING(tag), value);
HPKG_ATTRIBUTE_TAG_ENCODING(tag), value);
if (error != B_OK)
return error;
bool hasChildren = B_HPKG_ATTRIBUTE_TAG_HAS_CHILDREN(tag);
bool hasChildren = HPKG_ATTRIBUTE_TAG_HAS_CHILDREN(tag);
AttributeHandler* childHandler = NULL;
error = _CurrentAttributeHandler()->HandleChildAttribute(context,
type->type, type->standardIndex, value,
@ -1124,31 +1124,31 @@ PackageReaderImpl::_ParsePackageAttributes(AttributeHandlerContext* context)
return B_OK;
switch (id) {
case B_HPKG_PACKAGE_ATTRIBUTE_NAME:
case HPKG_PACKAGE_ATTRIBUTE_NAME:
handlerValue.SetTo(B_PACKAGE_INFO_NAME, attributeValue.string);
break;
case B_HPKG_PACKAGE_ATTRIBUTE_SUMMARY:
case HPKG_PACKAGE_ATTRIBUTE_SUMMARY:
handlerValue.SetTo(B_PACKAGE_INFO_SUMMARY,
attributeValue.string);
break;
case B_HPKG_PACKAGE_ATTRIBUTE_DESCRIPTION:
case HPKG_PACKAGE_ATTRIBUTE_DESCRIPTION:
handlerValue.SetTo(B_PACKAGE_INFO_DESCRIPTION,
attributeValue.string);
break;
case B_HPKG_PACKAGE_ATTRIBUTE_VENDOR:
case HPKG_PACKAGE_ATTRIBUTE_VENDOR:
handlerValue.SetTo(B_PACKAGE_INFO_VENDOR,
attributeValue.string);
break;
case B_HPKG_PACKAGE_ATTRIBUTE_PACKAGER:
case HPKG_PACKAGE_ATTRIBUTE_PACKAGER:
handlerValue.SetTo(B_PACKAGE_INFO_PACKAGER,
attributeValue.string);
break;
case B_HPKG_PACKAGE_ATTRIBUTE_ARCHITECTURE:
case HPKG_PACKAGE_ATTRIBUTE_ARCHITECTURE:
if (attributeValue.unsignedInt
>= B_PACKAGE_ARCHITECTURE_ENUM_COUNT) {
fErrorOutput->PrintError(
@ -1161,7 +1161,7 @@ PackageReaderImpl::_ParsePackageAttributes(AttributeHandlerContext* context)
(uint8)attributeValue.unsignedInt);
break;
case B_HPKG_PACKAGE_ATTRIBUTE_VERSION_MAJOR:
case HPKG_PACKAGE_ATTRIBUTE_VERSION_MAJOR:
error = _ParsePackageVersion(handlerValue.version,
attributeValue.string);
if (error != B_OK)
@ -1169,17 +1169,17 @@ PackageReaderImpl::_ParsePackageAttributes(AttributeHandlerContext* context)
handlerValue.attributeIndex = B_PACKAGE_INFO_VERSION;
break;
case B_HPKG_PACKAGE_ATTRIBUTE_COPYRIGHT:
case HPKG_PACKAGE_ATTRIBUTE_COPYRIGHT:
handlerValue.SetTo(B_PACKAGE_INFO_COPYRIGHTS,
attributeValue.string);
break;
case B_HPKG_PACKAGE_ATTRIBUTE_LICENSE:
case HPKG_PACKAGE_ATTRIBUTE_LICENSE:
handlerValue.SetTo(B_PACKAGE_INFO_LICENSES,
attributeValue.string);
break;
case B_HPKG_PACKAGE_ATTRIBUTE_PROVIDES_TYPE:
case HPKG_PACKAGE_ATTRIBUTE_PROVIDES_TYPE:
error = _ParsePackageProvides(handlerValue.resolvable,
(BPackageResolvableType)attributeValue.unsignedInt);
if (error != B_OK)
@ -1187,7 +1187,7 @@ PackageReaderImpl::_ParsePackageAttributes(AttributeHandlerContext* context)
handlerValue.attributeIndex = B_PACKAGE_INFO_PROVIDES;
break;
case B_HPKG_PACKAGE_ATTRIBUTE_REQUIRES:
case HPKG_PACKAGE_ATTRIBUTE_REQUIRES:
error = _ParsePackageResolvableExpression(
handlerValue.resolvableExpression, attributeValue.string,
hasChildren);
@ -1196,7 +1196,7 @@ PackageReaderImpl::_ParsePackageAttributes(AttributeHandlerContext* context)
handlerValue.attributeIndex = B_PACKAGE_INFO_REQUIRES;
break;
case B_HPKG_PACKAGE_ATTRIBUTE_SUPPLEMENTS:
case HPKG_PACKAGE_ATTRIBUTE_SUPPLEMENTS:
error = _ParsePackageResolvableExpression(
handlerValue.resolvableExpression, attributeValue.string,
hasChildren);
@ -1205,7 +1205,7 @@ PackageReaderImpl::_ParsePackageAttributes(AttributeHandlerContext* context)
handlerValue.attributeIndex = B_PACKAGE_INFO_SUPPLEMENTS;
break;
case B_HPKG_PACKAGE_ATTRIBUTE_CONFLICTS:
case HPKG_PACKAGE_ATTRIBUTE_CONFLICTS:
error = _ParsePackageResolvableExpression(
handlerValue.resolvableExpression, attributeValue.string,
hasChildren);
@ -1214,7 +1214,7 @@ PackageReaderImpl::_ParsePackageAttributes(AttributeHandlerContext* context)
handlerValue.attributeIndex = B_PACKAGE_INFO_CONFLICTS;
break;
case B_HPKG_PACKAGE_ATTRIBUTE_FRESHENS:
case HPKG_PACKAGE_ATTRIBUTE_FRESHENS:
error = _ParsePackageResolvableExpression(
handlerValue.resolvableExpression, attributeValue.string,
hasChildren);
@ -1223,7 +1223,7 @@ PackageReaderImpl::_ParsePackageAttributes(AttributeHandlerContext* context)
handlerValue.attributeIndex = B_PACKAGE_INFO_FRESHENS;
break;
case B_HPKG_PACKAGE_ATTRIBUTE_REPLACES:
case HPKG_PACKAGE_ATTRIBUTE_REPLACES:
handlerValue.SetTo(B_PACKAGE_INFO_REPLACES,
attributeValue.string);
break;
@ -1261,7 +1261,7 @@ PackageReaderImpl::_ParsePackageVersion(BPackageVersionData& _version,
error = _ReadPackageAttribute(id, value);
if (error != B_OK)
return error;
if (id != B_HPKG_PACKAGE_ATTRIBUTE_VERSION_MAJOR) {
if (id != HPKG_PACKAGE_ATTRIBUTE_VERSION_MAJOR) {
fErrorOutput->PrintError("Error: Invalid package attribute section:"
" Invalid package version, expected major\n");
return B_BAD_DATA;
@ -1274,7 +1274,7 @@ PackageReaderImpl::_ParsePackageVersion(BPackageVersionData& _version,
error = _ReadPackageAttribute(id, value);
if (error != B_OK)
return error;
if (id != B_HPKG_PACKAGE_ATTRIBUTE_VERSION_MINOR) {
if (id != HPKG_PACKAGE_ATTRIBUTE_VERSION_MINOR) {
fErrorOutput->PrintError("Error: Invalid package attribute section:"
" Invalid package version, expected minor\n");
return B_BAD_DATA;
@ -1285,7 +1285,7 @@ PackageReaderImpl::_ParsePackageVersion(BPackageVersionData& _version,
error = _ReadPackageAttribute(id, value);
if (error != B_OK)
return error;
if (id != B_HPKG_PACKAGE_ATTRIBUTE_VERSION_MICRO) {
if (id != HPKG_PACKAGE_ATTRIBUTE_VERSION_MICRO) {
fErrorOutput->PrintError("Error: Invalid package attribute section:"
" Invalid package version, expected micro\n");
return B_BAD_DATA;
@ -1296,7 +1296,7 @@ PackageReaderImpl::_ParsePackageVersion(BPackageVersionData& _version,
error = _ReadPackageAttribute(id, value);
if (error != B_OK)
return error;
if (id != B_HPKG_PACKAGE_ATTRIBUTE_VERSION_RELEASE) {
if (id != HPKG_PACKAGE_ATTRIBUTE_VERSION_RELEASE) {
fErrorOutput->PrintError("Error: Invalid package attribute section:"
" Invalid package version, expected release\n");
return B_BAD_DATA;
@ -1327,7 +1327,7 @@ PackageReaderImpl::_ParsePackageProvides(BPackageResolvableData& _resolvable,
status_t error = _ReadPackageAttribute(id, value, &hasChildren);
if (error != B_OK)
return error;
if (id != B_HPKG_PACKAGE_ATTRIBUTE_PROVIDES) {
if (id != HPKG_PACKAGE_ATTRIBUTE_PROVIDES) {
fErrorOutput->PrintError("Error: Invalid package attribute section: "
"Invalid package provides, expected name of resolvable\n");
return B_BAD_DATA;
@ -1372,7 +1372,7 @@ PackageReaderImpl::_ParsePackageResolvableExpression(
status_t error = _ReadPackageAttribute(id, value);
if (error != B_OK)
return error;
if (id != B_HPKG_PACKAGE_ATTRIBUTE_RESOLVABLE_OPERATOR) {
if (id != HPKG_PACKAGE_ATTRIBUTE_RESOLVABLE_OPERATOR) {
fErrorOutput->PrintError("Error: Invalid package attribute section:"
" Invalid package resolvable expression, expected operator\n");
return B_BAD_DATA;
@ -1419,7 +1419,7 @@ PackageReaderImpl::_ReadPackageAttribute(uint8& _id, AttributeValue& _value,
if (tag != 0) {
// get the type
uint16 type = B_HPKG_PACKAGE_ATTRIBUTE_TAG_TYPE(tag);
uint16 type = HPKG_PACKAGE_ATTRIBUTE_TAG_TYPE(tag);
if (type >= B_HPKG_ATTRIBUTE_TYPE_ENUM_COUNT) {
fErrorOutput->PrintError("Error: Invalid package attribute "
"section: attribute type %d not supported!\n", type);
@ -1428,12 +1428,12 @@ PackageReaderImpl::_ReadPackageAttribute(uint8& _id, AttributeValue& _value,
// get the value
error = _ReadAttributeValue(type,
B_HPKG_PACKAGE_ATTRIBUTE_TAG_ENCODING(tag), _value);
HPKG_PACKAGE_ATTRIBUTE_TAG_ENCODING(tag), _value);
if (error != B_OK)
return error;
_id = B_HPKG_PACKAGE_ATTRIBUTE_TAG_ID(tag);
if (_id >= B_HPKG_PACKAGE_ATTRIBUTE_ENUM_COUNT) {
_id = HPKG_PACKAGE_ATTRIBUTE_TAG_ID(tag);
if (_id >= HPKG_PACKAGE_ATTRIBUTE_ENUM_COUNT) {
fErrorOutput->PrintError("Error: Invalid package attribute section: "
"attribute id %d not supported!\n", _id);
return B_BAD_DATA;
@ -1441,7 +1441,7 @@ PackageReaderImpl::_ReadPackageAttribute(uint8& _id, AttributeValue& _value,
}
if (_hasChildren != NULL)
*_hasChildren = B_HPKG_PACKAGE_ATTRIBUTE_TAG_HAS_CHILDREN(tag);
*_hasChildren = HPKG_PACKAGE_ATTRIBUTE_TAG_HAS_CHILDREN(tag);
if (_tag != NULL)
*_tag = tag;

View File

@ -990,7 +990,7 @@ PackageWriterImpl::_WriteAttributeChildren(Attribute* attribute)
// write tag
uint8 encoding = child->value.PreferredEncoding();
_WriteUnsignedLEB128(B_HPKG_ATTRIBUTE_TAG_COMPOSE(type->index,
_WriteUnsignedLEB128(HPKG_ATTRIBUTE_TAG_COMPOSE(type->index,
encoding, !child->children.IsEmpty()));
// write value
@ -1015,38 +1015,38 @@ PackageWriterImpl::_WritePackageAttributes(hpkg_header& header)
zlibWriter.Init();
// name
_WriteUnsignedLEB128(B_HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
B_HPKG_PACKAGE_ATTRIBUTE_NAME, B_HPKG_ATTRIBUTE_TYPE_STRING,
_WriteUnsignedLEB128(HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
HPKG_PACKAGE_ATTRIBUTE_NAME, B_HPKG_ATTRIBUTE_TYPE_STRING,
B_HPKG_ATTRIBUTE_ENCODING_STRING_INLINE, 0));
_WriteString(fPackageInfo.Name().String());
// summary
_WriteUnsignedLEB128(B_HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
B_HPKG_PACKAGE_ATTRIBUTE_SUMMARY, B_HPKG_ATTRIBUTE_TYPE_STRING,
_WriteUnsignedLEB128(HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
HPKG_PACKAGE_ATTRIBUTE_SUMMARY, B_HPKG_ATTRIBUTE_TYPE_STRING,
B_HPKG_ATTRIBUTE_ENCODING_STRING_INLINE, 0));
_WriteString(fPackageInfo.Summary().String());
// description
_WriteUnsignedLEB128(B_HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
B_HPKG_PACKAGE_ATTRIBUTE_DESCRIPTION, B_HPKG_ATTRIBUTE_TYPE_STRING,
_WriteUnsignedLEB128(HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
HPKG_PACKAGE_ATTRIBUTE_DESCRIPTION, B_HPKG_ATTRIBUTE_TYPE_STRING,
B_HPKG_ATTRIBUTE_ENCODING_STRING_INLINE, 0));
_WriteString(fPackageInfo.Description().String());
// vendor
_WriteUnsignedLEB128(B_HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
B_HPKG_PACKAGE_ATTRIBUTE_VENDOR, B_HPKG_ATTRIBUTE_TYPE_STRING,
_WriteUnsignedLEB128(HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
HPKG_PACKAGE_ATTRIBUTE_VENDOR, B_HPKG_ATTRIBUTE_TYPE_STRING,
B_HPKG_ATTRIBUTE_ENCODING_STRING_INLINE, 0));
_WriteString(fPackageInfo.Vendor().String());
// packager
_WriteUnsignedLEB128(B_HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
B_HPKG_PACKAGE_ATTRIBUTE_PACKAGER, B_HPKG_ATTRIBUTE_TYPE_STRING,
_WriteUnsignedLEB128(HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
HPKG_PACKAGE_ATTRIBUTE_PACKAGER, B_HPKG_ATTRIBUTE_TYPE_STRING,
B_HPKG_ATTRIBUTE_ENCODING_STRING_INLINE, 0));
_WriteString(fPackageInfo.Packager().String());
// architecture
_WriteUnsignedLEB128(B_HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
B_HPKG_PACKAGE_ATTRIBUTE_ARCHITECTURE, B_HPKG_ATTRIBUTE_TYPE_UINT,
_WriteUnsignedLEB128(HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
HPKG_PACKAGE_ATTRIBUTE_ARCHITECTURE, B_HPKG_ATTRIBUTE_TYPE_UINT,
B_HPKG_ATTRIBUTE_ENCODING_INT_8_BIT, 0));
_Write<uint8>(fPackageInfo.Architecture());
@ -1056,8 +1056,8 @@ PackageWriterImpl::_WritePackageAttributes(hpkg_header& header)
// copyright list
const BObjectList<BString>& copyrightList = fPackageInfo.CopyrightList();
for (int i = 0; i < copyrightList.CountItems(); ++i) {
_WriteUnsignedLEB128(B_HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
B_HPKG_PACKAGE_ATTRIBUTE_COPYRIGHT, B_HPKG_ATTRIBUTE_TYPE_STRING,
_WriteUnsignedLEB128(HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
HPKG_PACKAGE_ATTRIBUTE_COPYRIGHT, B_HPKG_ATTRIBUTE_TYPE_STRING,
B_HPKG_ATTRIBUTE_ENCODING_STRING_INLINE, 0));
_WriteString(copyrightList.ItemAt(i)->String());
}
@ -1065,8 +1065,8 @@ PackageWriterImpl::_WritePackageAttributes(hpkg_header& header)
// license list
const BObjectList<BString>& licenseList = fPackageInfo.LicenseList();
for (int i = 0; i < licenseList.CountItems(); ++i) {
_WriteUnsignedLEB128(B_HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
B_HPKG_PACKAGE_ATTRIBUTE_LICENSE, B_HPKG_ATTRIBUTE_TYPE_STRING,
_WriteUnsignedLEB128(HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
HPKG_PACKAGE_ATTRIBUTE_LICENSE, B_HPKG_ATTRIBUTE_TYPE_STRING,
B_HPKG_ATTRIBUTE_ENCODING_STRING_INLINE, 0));
_WriteString(licenseList.ItemAt(i)->String());
}
@ -1077,12 +1077,12 @@ PackageWriterImpl::_WritePackageAttributes(hpkg_header& header)
for (int i = 0; i < providesList.CountItems(); ++i) {
BPackageResolvable* resolvable = providesList.ItemAt(i);
bool hasVersion = resolvable->Version().InitCheck() == B_OK;
_WriteUnsignedLEB128(B_HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
B_HPKG_PACKAGE_ATTRIBUTE_PROVIDES_TYPE, B_HPKG_ATTRIBUTE_TYPE_UINT,
_WriteUnsignedLEB128(HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
HPKG_PACKAGE_ATTRIBUTE_PROVIDES_TYPE, B_HPKG_ATTRIBUTE_TYPE_UINT,
B_HPKG_ATTRIBUTE_ENCODING_INT_8_BIT, 0));
_Write<uint8>((uint8)resolvable->Type());
_WriteUnsignedLEB128(B_HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
B_HPKG_PACKAGE_ATTRIBUTE_PROVIDES, B_HPKG_ATTRIBUTE_TYPE_STRING,
_WriteUnsignedLEB128(HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
HPKG_PACKAGE_ATTRIBUTE_PROVIDES, B_HPKG_ATTRIBUTE_TYPE_STRING,
B_HPKG_ATTRIBUTE_ENCODING_STRING_INLINE, hasVersion));
_WriteString(resolvable->Name().String());
if (hasVersion) {
@ -1093,25 +1093,25 @@ PackageWriterImpl::_WritePackageAttributes(hpkg_header& header)
// requires list
_WritePackageResolvableExpressionList(fPackageInfo.RequiresList(),
B_HPKG_PACKAGE_ATTRIBUTE_REQUIRES);
HPKG_PACKAGE_ATTRIBUTE_REQUIRES);
// supplements list
_WritePackageResolvableExpressionList(fPackageInfo.SupplementsList(),
B_HPKG_PACKAGE_ATTRIBUTE_SUPPLEMENTS);
HPKG_PACKAGE_ATTRIBUTE_SUPPLEMENTS);
// conflicts list
_WritePackageResolvableExpressionList(fPackageInfo.ConflictsList(),
B_HPKG_PACKAGE_ATTRIBUTE_CONFLICTS);
HPKG_PACKAGE_ATTRIBUTE_CONFLICTS);
// freshens list
_WritePackageResolvableExpressionList(fPackageInfo.FreshensList(),
B_HPKG_PACKAGE_ATTRIBUTE_FRESHENS);
HPKG_PACKAGE_ATTRIBUTE_FRESHENS);
// replaces list
const BObjectList<BString>& replacesList = fPackageInfo.ReplacesList();
for (int i = 0; i < replacesList.CountItems(); ++i) {
_WriteUnsignedLEB128(B_HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
B_HPKG_PACKAGE_ATTRIBUTE_REPLACES, B_HPKG_ATTRIBUTE_TYPE_STRING,
_WriteUnsignedLEB128(HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
HPKG_PACKAGE_ATTRIBUTE_REPLACES, B_HPKG_ATTRIBUTE_TYPE_STRING,
B_HPKG_ATTRIBUTE_ENCODING_STRING_INLINE, 0));
_WriteString(replacesList.ItemAt(i)->String());
}
@ -1139,20 +1139,20 @@ PackageWriterImpl::_WritePackageAttributes(hpkg_header& header)
void
PackageWriterImpl::_WritePackageVersion(const BPackageVersion& version)
{
_WriteUnsignedLEB128(B_HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
B_HPKG_PACKAGE_ATTRIBUTE_VERSION_MAJOR, B_HPKG_ATTRIBUTE_TYPE_STRING,
_WriteUnsignedLEB128(HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
HPKG_PACKAGE_ATTRIBUTE_VERSION_MAJOR, B_HPKG_ATTRIBUTE_TYPE_STRING,
B_HPKG_ATTRIBUTE_ENCODING_STRING_INLINE, 0));
_WriteString(version.Major());
_WriteUnsignedLEB128(B_HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
B_HPKG_PACKAGE_ATTRIBUTE_VERSION_MINOR, B_HPKG_ATTRIBUTE_TYPE_STRING,
_WriteUnsignedLEB128(HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
HPKG_PACKAGE_ATTRIBUTE_VERSION_MINOR, B_HPKG_ATTRIBUTE_TYPE_STRING,
B_HPKG_ATTRIBUTE_ENCODING_STRING_INLINE, 0));
_WriteString(version.Minor());
_WriteUnsignedLEB128(B_HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
B_HPKG_PACKAGE_ATTRIBUTE_VERSION_MICRO, B_HPKG_ATTRIBUTE_TYPE_STRING,
_WriteUnsignedLEB128(HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
HPKG_PACKAGE_ATTRIBUTE_VERSION_MICRO, B_HPKG_ATTRIBUTE_TYPE_STRING,
B_HPKG_ATTRIBUTE_ENCODING_STRING_INLINE, 0));
_WriteString(version.Micro());
_WriteUnsignedLEB128(B_HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
B_HPKG_PACKAGE_ATTRIBUTE_VERSION_RELEASE, B_HPKG_ATTRIBUTE_TYPE_UINT,
_WriteUnsignedLEB128(HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
HPKG_PACKAGE_ATTRIBUTE_VERSION_RELEASE, B_HPKG_ATTRIBUTE_TYPE_UINT,
B_HPKG_ATTRIBUTE_ENCODING_INT_8_BIT, 0));
_Write<uint8>(version.Release());
}
@ -1165,13 +1165,13 @@ PackageWriterImpl::_WritePackageResolvableExpressionList(
for (int i = 0; i < list.CountItems(); ++i) {
BPackageResolvableExpression* resolvableExpr = list.ItemAt(i);
bool hasVersion = resolvableExpr->Version().InitCheck() == B_OK;
_WriteUnsignedLEB128(B_HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
_WriteUnsignedLEB128(HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
id, B_HPKG_ATTRIBUTE_TYPE_STRING,
B_HPKG_ATTRIBUTE_ENCODING_STRING_INLINE, hasVersion));
_WriteString(resolvableExpr->Name().String());
if (hasVersion) {
_WriteUnsignedLEB128(B_HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
B_HPKG_PACKAGE_ATTRIBUTE_RESOLVABLE_OPERATOR,
_WriteUnsignedLEB128(HPKG_PACKAGE_ATTRIBUTE_TAG_COMPOSE(
HPKG_PACKAGE_ATTRIBUTE_RESOLVABLE_OPERATOR,
B_HPKG_ATTRIBUTE_TYPE_UINT, B_HPKG_ATTRIBUTE_ENCODING_INT_8_BIT,
0));
_Write<uint8>(resolvableExpr->Operator());
@ -1339,19 +1339,19 @@ PackageWriterImpl::_AddEntry(int dirFD, Entry* entry, const char* fileName,
// add attribute entry
Attribute* entryAttribute = _AddStringAttribute(
B_HPKG_ATTRIBUTE_NAME_DIRECTORY_ENTRY, fileName);
HPKG_ATTRIBUTE_NAME_DIRECTORY_ENTRY, fileName);
Stacker<Attribute> entryAttributeStacker(fTopAttribute, entryAttribute);
// add stat data
if (fileType != B_HPKG_DEFAULT_FILE_TYPE)
_AddAttribute(B_HPKG_ATTRIBUTE_NAME_FILE_TYPE, fileType);
_AddAttribute(HPKG_ATTRIBUTE_NAME_FILE_TYPE, fileType);
if (defaultPermissions != uint32(st.st_mode & ALLPERMS)) {
_AddAttribute(B_HPKG_ATTRIBUTE_NAME_FILE_PERMISSIONS,
_AddAttribute(HPKG_ATTRIBUTE_NAME_FILE_PERMISSIONS,
uint32(st.st_mode & ALLPERMS));
}
_AddAttribute(B_HPKG_ATTRIBUTE_NAME_FILE_ATIME, uint32(st.st_atime));
_AddAttribute(B_HPKG_ATTRIBUTE_NAME_FILE_MTIME, uint32(st.st_mtime));
_AddAttribute(B_HPKG_ATTRIBUTE_NAME_FILE_CRTIME, uint32(st.st_crtime));
_AddAttribute(HPKG_ATTRIBUTE_NAME_FILE_ATIME, uint32(st.st_atime));
_AddAttribute(HPKG_ATTRIBUTE_NAME_FILE_MTIME, uint32(st.st_mtime));
_AddAttribute(HPKG_ATTRIBUTE_NAME_FILE_CRTIME, uint32(st.st_crtime));
// TODO: File user/group!
// add file data/symlink path
@ -1375,7 +1375,7 @@ PackageWriterImpl::_AddEntry(int dirFD, Entry* entry, const char* fileName,
}
path[bytesRead] = '\0';
_AddStringAttribute(B_HPKG_ATTRIBUTE_NAME_SYMLINK_PATH, path);
_AddStringAttribute(HPKG_ATTRIBUTE_NAME_SYMLINK_PATH, path);
}
// add attributes
@ -1393,12 +1393,12 @@ PackageWriterImpl::_AddEntry(int dirFD, Entry* entry, const char* fileName,
// create attribute entry
Attribute* attributeAttribute = _AddStringAttribute(
B_HPKG_ATTRIBUTE_NAME_FILE_ATTRIBUTE, entry->d_name);
HPKG_ATTRIBUTE_NAME_FILE_ATTRIBUTE, entry->d_name);
Stacker<Attribute> attributeAttributeStacker(fTopAttribute,
attributeAttribute);
// add type
_AddAttribute(B_HPKG_ATTRIBUTE_NAME_FILE_ATTRIBUTE_TYPE,
_AddAttribute(HPKG_ATTRIBUTE_NAME_FILE_ATTRIBUTE_TYPE,
(uint32)attrInfo.type);
// add data
@ -1547,7 +1547,7 @@ PackageWriterImpl::_AddData(BDataReader& dataReader, off_t size)
return error;
}
_AddDataAttribute(B_HPKG_ATTRIBUTE_NAME_DATA, size, buffer);
_AddDataAttribute(HPKG_ATTRIBUTE_NAME_DATA, size, buffer);
return B_OK;
}
@ -1571,14 +1571,14 @@ PackageWriterImpl::_AddData(BDataReader& dataReader, off_t size)
fHeapEnd = dataOffset + compressedSize;
// add data attribute
Attribute* dataAttribute = _AddDataAttribute(B_HPKG_ATTRIBUTE_NAME_DATA,
Attribute* dataAttribute = _AddDataAttribute(HPKG_ATTRIBUTE_NAME_DATA,
compressedSize, dataOffset - fHeapOffset);
Stacker<Attribute> attributeAttributeStacker(fTopAttribute, dataAttribute);
// if compressed, add compression attributes
if (compression != B_HPKG_COMPRESSION_NONE) {
_AddAttribute(B_HPKG_ATTRIBUTE_NAME_DATA_COMPRESSION, compression);
_AddAttribute(B_HPKG_ATTRIBUTE_NAME_DATA_SIZE, (uint64)size);
_AddAttribute(HPKG_ATTRIBUTE_NAME_DATA_COMPRESSION, compression);
_AddAttribute(HPKG_ATTRIBUTE_NAME_DATA_SIZE, (uint64)size);
// uncompressed size
}