xref: /haiku/headers/os/package/hpkg/HPKGDefs.h (revision a8de2761c70d71d57ee17373eafac58bfd6ac8b8)
15fb1c6ffSOliver Tappe /*
2fc0cec53SIngo Weinhold  * Copyright 2009-2013, Haiku, Inc.
35fb1c6ffSOliver Tappe  * Distributed under the terms of the MIT License.
45fb1c6ffSOliver Tappe  */
55fb1c6ffSOliver Tappe #ifndef _PACKAGE__HPKG__HPKG_DEFS_H_
65fb1c6ffSOliver Tappe #define _PACKAGE__HPKG__HPKG_DEFS_H_
75fb1c6ffSOliver Tappe 
85fb1c6ffSOliver Tappe 
95fb1c6ffSOliver Tappe #include <SupportDefs.h>
105fb1c6ffSOliver Tappe 
115fb1c6ffSOliver Tappe 
125fb1c6ffSOliver Tappe namespace BPackageKit {
135fb1c6ffSOliver Tappe 
145fb1c6ffSOliver Tappe namespace BHPKG {
155fb1c6ffSOliver Tappe 
165fb1c6ffSOliver Tappe 
17aaf05784SOliver Tappe // magic & version of package and repository files
185fb1c6ffSOliver Tappe enum {
195fb1c6ffSOliver Tappe 	B_HPKG_MAGIC				= 'hpkg',
20fc0cec53SIngo Weinhold 	B_HPKG_VERSION				= 2,
2147039b85SIngo Weinhold 	B_HPKG_MINOR_VERSION		= 0,
22aaf05784SOliver Tappe 	//
23aaf05784SOliver Tappe 	B_HPKG_REPO_MAGIC			= 'hpkr',
2447039b85SIngo Weinhold 	B_HPKG_REPO_VERSION			= 2,
2547039b85SIngo Weinhold 	B_HPKG_REPO_MINOR_VERSION	= 0
265fb1c6ffSOliver Tappe };
275fb1c6ffSOliver Tappe 
285fb1c6ffSOliver Tappe 
29b3211314SIngo Weinhold // package attribute IDs
30b3211314SIngo Weinhold enum BHPKGPackageSectionID {
31b3211314SIngo Weinhold 	B_HPKG_SECTION_HEADER					= 0,
32b3211314SIngo Weinhold 	B_HPKG_SECTION_HEAP						= 1,
33b3211314SIngo Weinhold 	B_HPKG_SECTION_PACKAGE_TOC				= 2,
34b3211314SIngo Weinhold 	B_HPKG_SECTION_PACKAGE_ATTRIBUTES		= 3,
35b3211314SIngo Weinhold 	B_HPKG_SECTION_REPOSITORY_INFO			= 4,
36b3211314SIngo Weinhold 	//
37b3211314SIngo Weinhold 	B_HPKG_SECTION_ENUM_COUNT
38b3211314SIngo Weinhold };
39b3211314SIngo Weinhold 
40b3211314SIngo Weinhold 
415fb1c6ffSOliver Tappe // attribute types
425fb1c6ffSOliver Tappe enum {
435fb1c6ffSOliver Tappe 	// types
445fb1c6ffSOliver Tappe 	B_HPKG_ATTRIBUTE_TYPE_INVALID			= 0,
455fb1c6ffSOliver Tappe 	B_HPKG_ATTRIBUTE_TYPE_INT				= 1,
465fb1c6ffSOliver Tappe 	B_HPKG_ATTRIBUTE_TYPE_UINT				= 2,
475fb1c6ffSOliver Tappe 	B_HPKG_ATTRIBUTE_TYPE_STRING			= 3,
486f0278cdSOliver Tappe 	B_HPKG_ATTRIBUTE_TYPE_RAW				= 4,
496f0278cdSOliver Tappe 	//
506f0278cdSOliver Tappe 	B_HPKG_ATTRIBUTE_TYPE_ENUM_COUNT
515fb1c6ffSOliver Tappe };
525fb1c6ffSOliver Tappe 
535fb1c6ffSOliver Tappe 
545fb1c6ffSOliver Tappe // attribute encodings
555fb1c6ffSOliver Tappe enum {
565fb1c6ffSOliver Tappe 	// signed/unsigned int encodings
575fb1c6ffSOliver Tappe 	B_HPKG_ATTRIBUTE_ENCODING_INT_8_BIT		= 0,
585fb1c6ffSOliver Tappe 	B_HPKG_ATTRIBUTE_ENCODING_INT_16_BIT	= 1,
595fb1c6ffSOliver Tappe 	B_HPKG_ATTRIBUTE_ENCODING_INT_32_BIT	= 2,
605fb1c6ffSOliver Tappe 	B_HPKG_ATTRIBUTE_ENCODING_INT_64_BIT	= 3,
615fb1c6ffSOliver Tappe 
625fb1c6ffSOliver Tappe 	// string encodings
635fb1c6ffSOliver Tappe 	B_HPKG_ATTRIBUTE_ENCODING_STRING_INLINE	= 0,
645fb1c6ffSOliver Tappe 		// null-terminated string
655fb1c6ffSOliver Tappe 	B_HPKG_ATTRIBUTE_ENCODING_STRING_TABLE	= 1,
665fb1c6ffSOliver Tappe 		// unsigned LEB128 index into string table
675fb1c6ffSOliver Tappe 
685fb1c6ffSOliver Tappe 	// raw data encodings
695fb1c6ffSOliver Tappe 	B_HPKG_ATTRIBUTE_ENCODING_RAW_INLINE	= 0,
705fb1c6ffSOliver Tappe 		// unsigned LEB128 size, raw bytes
715fb1c6ffSOliver Tappe 	B_HPKG_ATTRIBUTE_ENCODING_RAW_HEAP		= 1
725fb1c6ffSOliver Tappe 		// unsigned LEB128 size, unsigned LEB128 offset into the heap
735fb1c6ffSOliver Tappe };
745fb1c6ffSOliver Tappe 
755fb1c6ffSOliver Tappe 
765fb1c6ffSOliver Tappe // maximum number of bytes of data to be encoded inline; more will be allocated
775fb1c6ffSOliver Tappe // on the heap
78171fd58cSIngo Weinhold enum {
79171fd58cSIngo Weinhold 	B_HPKG_MAX_INLINE_DATA_SIZE	= 8
80171fd58cSIngo Weinhold };
815fb1c6ffSOliver Tappe 
825fb1c6ffSOliver Tappe 
835fb1c6ffSOliver Tappe // name of file containing package information (in package's root folder)
84171fd58cSIngo Weinhold extern const char* const B_HPKG_PACKAGE_INFO_FILE_NAME;
855fb1c6ffSOliver Tappe 
865fb1c6ffSOliver Tappe 
876f0278cdSOliver Tappe // package attribute IDs
8833bc4425SOliver Tappe enum BHPKGAttributeID {
89*a8de2761SIngo Weinhold 	#define B_DEFINE_HPKG_ATTRIBUTE(id, type, name, constant)	\
90*a8de2761SIngo Weinhold 		B_HPKG_ATTRIBUTE_ID_##constant	= id,
91*a8de2761SIngo Weinhold 	#include <package/hpkg/PackageAttributes.h>
92*a8de2761SIngo Weinhold 	#undef B_DEFINE_HPKG_ATTRIBUTE
936f0278cdSOliver Tappe 	//
9433bc4425SOliver Tappe 	B_HPKG_ATTRIBUTE_ID_ENUM_COUNT,
956f0278cdSOliver Tappe };
966f0278cdSOliver Tappe 
976f0278cdSOliver Tappe 
98aaf05784SOliver Tappe // compression types
99aaf05784SOliver Tappe enum {
100aaf05784SOliver Tappe 	B_HPKG_COMPRESSION_NONE	= 0,
101aaf05784SOliver Tappe 	B_HPKG_COMPRESSION_ZLIB	= 1
102aaf05784SOliver Tappe };
103aaf05784SOliver Tappe 
104aaf05784SOliver Tappe 
10533bc4425SOliver Tappe // file types (B_HPKG_ATTRIBUTE_ID_FILE_TYPE)
106aaf05784SOliver Tappe enum {
107aaf05784SOliver Tappe 	B_HPKG_FILE_TYPE_FILE		= 0,
108aaf05784SOliver Tappe 	B_HPKG_FILE_TYPE_DIRECTORY	= 1,
109aaf05784SOliver Tappe 	B_HPKG_FILE_TYPE_SYMLINK	= 2
110aaf05784SOliver Tappe };
111aaf05784SOliver Tappe 
112aaf05784SOliver Tappe 
1135fb1c6ffSOliver Tappe // default values
1145fb1c6ffSOliver Tappe enum {
115aaf05784SOliver Tappe 	B_HPKG_DEFAULT_FILE_TYPE				= B_HPKG_FILE_TYPE_FILE,
116aaf05784SOliver Tappe 	B_HPKG_DEFAULT_FILE_PERMISSIONS			= 0644,
117aaf05784SOliver Tappe 	B_HPKG_DEFAULT_DIRECTORY_PERMISSIONS	= 0755,
1181f633814SIngo Weinhold 	B_HPKG_DEFAULT_SYMLINK_PERMISSIONS		= 0777
1195fb1c6ffSOliver Tappe };
1205fb1c6ffSOliver Tappe 
1215fb1c6ffSOliver Tappe 
122327b38d6SIngo Weinhold // Writer Init() flags
123327b38d6SIngo Weinhold enum {
124327b38d6SIngo Weinhold 	B_HPKG_WRITER_UPDATE_PACKAGE	= 0x01,
125327b38d6SIngo Weinhold 		// update the package (don't truncate)
126327b38d6SIngo Weinhold 	B_HPKG_WRITER_FORCE_ADD			= 0x02,
127327b38d6SIngo Weinhold 		// when updating a pre-existing entry, don't fail, but replace the
128327b38d6SIngo Weinhold 		// entry, if possible (directories will be merged, but won't replace a
129327b38d6SIngo Weinhold 		// non-directory)
130327b38d6SIngo Weinhold };
131327b38d6SIngo Weinhold 
132327b38d6SIngo Weinhold 
133d59e0febSIngo Weinhold // Reader Init() flags
134d59e0febSIngo Weinhold enum {
135d59e0febSIngo Weinhold 	B_HPKG_READER_DONT_PRINT_VERSION_MISMATCH_MESSAGE	= 0x01
136d59e0febSIngo Weinhold 		// Fail silently when encountering a package format version mismatch.
137d59e0febSIngo Weinhold 		// Don't print anything to the error output.
138d59e0febSIngo Weinhold };
139d59e0febSIngo Weinhold 
140d59e0febSIngo Weinhold 
141796343edSIngo Weinhold enum {
142796343edSIngo Weinhold 	B_HPKG_COMPRESSION_LEVEL_NONE		= 0,
143796343edSIngo Weinhold 	B_HPKG_COMPRESSION_LEVEL_FASTEST	= 1,
144796343edSIngo Weinhold 	B_HPKG_COMPRESSION_LEVEL_BEST		= 9
145796343edSIngo Weinhold };
146796343edSIngo Weinhold 
147796343edSIngo Weinhold 
1485fb1c6ffSOliver Tappe }	// namespace BHPKG
1495fb1c6ffSOliver Tappe 
1505fb1c6ffSOliver Tappe }	// namespace BPackageKit
1515fb1c6ffSOliver Tappe 
1525fb1c6ffSOliver Tappe 
1535fb1c6ffSOliver Tappe #endif	// _PACKAGE__HPKG__HPKG_DEFS_H_
154