2 * Copyright (C) 2008 Kristian Høgsberg <krh@redhat.com>
3 * Copyright (C) 2008 Red Hat, Inc
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef _RAZOR_INTERNAL_H_
21 #define _RAZOR_INTERNAL_H_
29 #include "types/types.h"
32 #if defined(__GNUC__) && __GNUC__ >= 4
33 #define RAZOR_EXPORT __attribute__ ((visibility("default")))
38 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
39 #define ALIGN(value, base) (((value) + (base - 1)) & ~((base) - 1))
41 void *zalloc(size_t size);
43 struct razor_set_section {
49 struct razor_set_header {
52 uint32_t num_sections;
55 #define RAZOR_MAGIC 0x525a4442
56 #define RAZOR_VERSION 1
58 #define RAZOR_STRING_POOL "string_pool"
59 #define RAZOR_PACKAGES "packages"
60 #define RAZOR_PROPERTIES "properties"
61 #define RAZOR_PACKAGE_POOL "package_pool"
62 #define RAZOR_PROPERTY_POOL "property_pool"
64 #define RAZOR_DETAILS_STRING_POOL "details_string_pool"
66 #define RAZOR_FILES "files"
67 #define RAZOR_FILE_POOL "file_pool"
68 #define RAZOR_FILE_STRING_POOL "file_string_pool"
70 struct razor_package {
71 unsigned int name : 24;
72 unsigned int flags : 8;
79 struct list_head properties;
80 struct list_head files;
84 struct razor_property {
88 struct list_head packages;
95 struct list_head packages;
98 #define RAZOR_ENTRY_LAST 0x80
101 struct array string_pool;
102 struct array packages;
103 struct array properties;
105 struct array package_pool;
106 struct array property_pool;
107 struct array file_pool;
108 struct array file_string_pool;
109 struct array details_string_pool;
111 struct razor_set_header *header;
114 struct razor_set_header *details_header;
115 size_t details_header_size;
117 struct razor_set_header *files_header;
118 size_t files_header_size;
121 struct import_entry {
126 struct import_directory {
127 uint32_t name, count;
129 struct array packages;
130 struct import_directory *last;
133 struct razor_importer {
134 struct razor_set *set;
135 struct hashtable table;
136 struct hashtable file_table;
137 struct hashtable details_table;
138 struct razor_package *package;
139 struct array properties;
141 struct array file_requires;
144 struct razor_package_iterator {
145 struct razor_set *set;
146 struct razor_package *package, *end;
152 razor_package_iterator_init_for_property(struct razor_package_iterator *pi,
153 struct razor_set *set,
154 struct razor_property *property);
156 struct razor_property_iterator {
157 struct razor_set *set;
158 struct razor_property *property, *end;
162 struct razor_file_iterator {
163 struct razor_set *set;
169 razor_set_find_entry(struct razor_set *set,
170 struct razor_entry *dir, const char *pattern);
172 struct razor_merger *
173 razor_merger_create(struct razor_set *set1, struct razor_set *set2);
175 razor_merger_add_package(struct razor_merger *merger,
176 struct razor_package *package);
178 razor_merger_finish(struct razor_merger *merger);
180 int run_lua_script(const char *root, const char *name, const char *body,
183 /* Utility functions */
186 razor_package_get_details_varg(struct razor_set *set,
187 struct razor_package *package,
190 int razor_create_dir(const char *root, const char *path);
191 int razor_write(int fd, const void *data, size_t size);
193 void *razor_file_get_contents(const char *filename, size_t *length);
194 int razor_file_free_contents(void *addr, size_t length);
197 typedef int (*razor_compare_with_data_func_t)(const void *p1,
201 razor_qsort_with_data(void *base, size_t nelem, size_t size,
202 razor_compare_with_data_func_t compare, void *data);
204 #endif /* _RAZOR_INTERNAL_H_ */