xref: /haiku/headers/os/package/hpkg/HPKGDefs.h (revision 040a81419dda83d1014e9dc94936a4cb3f027303)
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		= 0,
22 	//
23 	B_HPKG_REPO_MAGIC			= 'hpkr',
24 	B_HPKG_REPO_VERSION			= 2,
25 	B_HPKG_REPO_MINOR_VERSION	= 0
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 };
103 
104 
105 // file types (B_HPKG_ATTRIBUTE_ID_FILE_TYPE)
106 enum {
107 	B_HPKG_FILE_TYPE_FILE		= 0,
108 	B_HPKG_FILE_TYPE_DIRECTORY	= 1,
109 	B_HPKG_FILE_TYPE_SYMLINK	= 2
110 };
111 
112 
113 // default values
114 enum {
115 	B_HPKG_DEFAULT_FILE_TYPE				= B_HPKG_FILE_TYPE_FILE,
116 	B_HPKG_DEFAULT_FILE_PERMISSIONS			= 0644,
117 	B_HPKG_DEFAULT_DIRECTORY_PERMISSIONS	= 0755,
118 	B_HPKG_DEFAULT_SYMLINK_PERMISSIONS		= 0777
119 };
120 
121 
122 // Writer Init() flags
123 enum {
124 	B_HPKG_WRITER_UPDATE_PACKAGE	= 0x01,
125 		// update the package (don't truncate)
126 	B_HPKG_WRITER_FORCE_ADD			= 0x02,
127 		// when updating a pre-existing entry, don't fail, but replace the
128 		// entry, if possible (directories will be merged, but won't replace a
129 		// non-directory)
130 };
131 
132 
133 // Reader Init() flags
134 enum {
135 	B_HPKG_READER_DONT_PRINT_VERSION_MISMATCH_MESSAGE	= 0x01
136 		// Fail silently when encountering a package format version mismatch.
137 		// Don't print anything to the error output.
138 };
139 
140 
141 enum {
142 	B_HPKG_COMPRESSION_LEVEL_NONE		= 0,
143 	B_HPKG_COMPRESSION_LEVEL_FASTEST	= 1,
144 	B_HPKG_COMPRESSION_LEVEL_BEST		= 9
145 };
146 
147 
148 }	// namespace BHPKG
149 
150 }	// namespace BPackageKit
151 
152 
153 #endif	// _PACKAGE__HPKG__HPKG_DEFS_H_
154