1 /* 2 * Copyright 2009-2013, Haiku, Inc. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _PACKAGE__HPKG__HPKG_DEFS_H_ 6 #define _PACKAGE__HPKG__HPKG_DEFS_H_ 7 8 9 #include <SupportDefs.h> 10 11 12 namespace BPackageKit { 13 14 namespace BHPKG { 15 16 17 // magic & version of package and repository files 18 enum { 19 B_HPKG_MAGIC = 'hpkg', 20 B_HPKG_VERSION = 2, 21 B_HPKG_MINOR_VERSION = 1, 22 // 23 B_HPKG_REPO_MAGIC = 'hpkr', 24 B_HPKG_REPO_VERSION = 2, 25 B_HPKG_REPO_MINOR_VERSION = 1 26 }; 27 28 29 // package attribute IDs 30 enum BHPKGPackageSectionID { 31 B_HPKG_SECTION_HEADER = 0, 32 B_HPKG_SECTION_HEAP = 1, 33 B_HPKG_SECTION_PACKAGE_TOC = 2, 34 B_HPKG_SECTION_PACKAGE_ATTRIBUTES = 3, 35 B_HPKG_SECTION_REPOSITORY_INFO = 4, 36 // 37 B_HPKG_SECTION_ENUM_COUNT 38 }; 39 40 41 // attribute types 42 enum { 43 // types 44 B_HPKG_ATTRIBUTE_TYPE_INVALID = 0, 45 B_HPKG_ATTRIBUTE_TYPE_INT = 1, 46 B_HPKG_ATTRIBUTE_TYPE_UINT = 2, 47 B_HPKG_ATTRIBUTE_TYPE_STRING = 3, 48 B_HPKG_ATTRIBUTE_TYPE_RAW = 4, 49 // 50 B_HPKG_ATTRIBUTE_TYPE_ENUM_COUNT 51 }; 52 53 54 // attribute encodings 55 enum { 56 // signed/unsigned int encodings 57 B_HPKG_ATTRIBUTE_ENCODING_INT_8_BIT = 0, 58 B_HPKG_ATTRIBUTE_ENCODING_INT_16_BIT = 1, 59 B_HPKG_ATTRIBUTE_ENCODING_INT_32_BIT = 2, 60 B_HPKG_ATTRIBUTE_ENCODING_INT_64_BIT = 3, 61 62 // string encodings 63 B_HPKG_ATTRIBUTE_ENCODING_STRING_INLINE = 0, 64 // null-terminated string 65 B_HPKG_ATTRIBUTE_ENCODING_STRING_TABLE = 1, 66 // unsigned LEB128 index into string table 67 68 // raw data encodings 69 B_HPKG_ATTRIBUTE_ENCODING_RAW_INLINE = 0, 70 // unsigned LEB128 size, raw bytes 71 B_HPKG_ATTRIBUTE_ENCODING_RAW_HEAP = 1 72 // unsigned LEB128 size, unsigned LEB128 offset into the heap 73 }; 74 75 76 // maximum number of bytes of data to be encoded inline; more will be allocated 77 // on the heap 78 enum { 79 B_HPKG_MAX_INLINE_DATA_SIZE = 8 80 }; 81 82 83 // name of file containing package information (in package's root folder) 84 extern const char* const B_HPKG_PACKAGE_INFO_FILE_NAME; 85 86 87 // package attribute IDs 88 enum BHPKGAttributeID { 89 #define B_DEFINE_HPKG_ATTRIBUTE(id, type, name, constant) \ 90 B_HPKG_ATTRIBUTE_ID_##constant = id, 91 #include <package/hpkg/PackageAttributes.h> 92 #undef B_DEFINE_HPKG_ATTRIBUTE 93 // 94 B_HPKG_ATTRIBUTE_ID_ENUM_COUNT, 95 }; 96 97 98 // compression types 99 enum { 100 B_HPKG_COMPRESSION_NONE = 0, 101 B_HPKG_COMPRESSION_ZLIB = 1, 102 B_HPKG_COMPRESSION_ZSTD = 2 103 }; 104 105 106 // file types (B_HPKG_ATTRIBUTE_ID_FILE_TYPE) 107 enum { 108 B_HPKG_FILE_TYPE_FILE = 0, 109 B_HPKG_FILE_TYPE_DIRECTORY = 1, 110 B_HPKG_FILE_TYPE_SYMLINK = 2 111 }; 112 113 114 // default values 115 enum { 116 B_HPKG_DEFAULT_FILE_TYPE = B_HPKG_FILE_TYPE_FILE, 117 B_HPKG_DEFAULT_FILE_PERMISSIONS = 0644, 118 B_HPKG_DEFAULT_DIRECTORY_PERMISSIONS = 0755, 119 B_HPKG_DEFAULT_SYMLINK_PERMISSIONS = 0777 120 }; 121 122 123 // Writer Init() flags 124 enum { 125 B_HPKG_WRITER_UPDATE_PACKAGE = 0x01, 126 // update the package (don't truncate) 127 B_HPKG_WRITER_FORCE_ADD = 0x02, 128 // when updating a pre-existing entry, don't fail, but replace the 129 // entry, if possible (directories will be merged, but won't replace a 130 // non-directory) 131 }; 132 133 134 // Reader Init() flags 135 enum { 136 B_HPKG_READER_DONT_PRINT_VERSION_MISMATCH_MESSAGE = 0x01 137 // Fail silently when encountering a package format version mismatch. 138 // Don't print anything to the error output. 139 }; 140 141 142 enum { 143 B_HPKG_COMPRESSION_LEVEL_NONE = 0, 144 B_HPKG_COMPRESSION_LEVEL_FASTEST = 1, 145 B_HPKG_COMPRESSION_LEVEL_BEST = 9 146 }; 147 148 149 } // namespace BHPKG 150 151 } // namespace BPackageKit 152 153 154 #endif // _PACKAGE__HPKG__HPKG_DEFS_H_ 155