Only export symbols starting with razor_ in dynamic library.
Apart from being good practice to avoid clashes with higher-level
libraries and the application, this also fixes an obscure bug: The
gnulib library is used both by librazor (the dynamic library) and
by razor (the executable). In doing so, we want to have two separate
copies of the library despite the code duplication this involves.
Without the explicit limit to export only razor_ symbols, the razor
executable under mingw64 was picking up the getopt_long function
from librazor and the optind variable from libgnu which meant that
it did not see optind changing. Hiding librazor's copy of getopt
causes the linker to find libgnu's copy and everything works.
Note that under mingw librazor-#.dll still contains undocumented
(private) razor_ symbols but these will do no harm as long as nobody
tries to use them.
2 * Copyright (C) 2008 Kristian Høgsberg <krh@redhat.com>
3 * Copyright (C) 2008 Red Hat, Inc
4 * Copyright (C) 2009, 2011-2012, 2014 J. Ali Harlow <ali@juiblex.co.uk>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #ifndef _RAZOR_INTERNAL_H_
22 #define _RAZOR_INTERNAL_H_
33 #include "types/types.h"
36 #if defined(__GNUC__) && __GNUC__ >= 4
37 #define RAZOR_EXPORT __attribute__ ((visibility("default")))
42 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
43 #define PADDING(value, base) (-(value) & (base - 1))
44 #define ALIGN(value, base) ((value) + PADDING(value, base))
45 void *zalloc(size_t size);
47 struct razor_set_section {
53 struct razor_set_header {
56 uint32_t num_sections;
59 #define RAZOR_MAGIC 0x525a4442
61 #define RAZOR_STRING_POOL "string_pool"
62 #define RAZOR_PACKAGES "packages"
63 #define RAZOR_PROPERTIES "properties"
64 #define RAZOR_PACKAGE_POOL "package_pool"
65 #define RAZOR_PROPERTY_POOL "property_pool"
66 #define RAZOR_PREFIX_POOL "prefix_pool"
68 #define RAZOR_DETAILS_STRING_POOL "details_string_pool"
70 #define RAZOR_FILES "files"
71 #define RAZOR_FILE_POOL "file_pool"
72 #define RAZOR_FILE_STRING_POOL "file_string_pool"
79 struct razor_package {
80 unsigned int name : 24;
81 unsigned int flags : 8;
88 struct list_head properties;
89 struct list_head files;
90 struct list_head install_prefixes;
91 struct razor_script preun;
92 struct razor_script postun;
96 struct razor_property {
100 struct list_head packages;
107 struct list_head packages;
110 #define RAZOR_ENTRY_LAST 0x80
113 uint32_t header_version;
114 struct array string_pool;
115 struct array packages;
116 struct array properties;
118 struct array package_pool;
119 struct array property_pool;
120 struct array file_pool;
121 struct array prefix_pool;
122 struct array file_string_pool;
123 struct array details_string_pool;
124 struct razor_mapped_file *mapped_files;
125 int lock_fd, ref_count;
126 enum razor_set_flags flags;
129 struct import_entry {
134 struct import_directory {
135 uint32_t name, count;
137 struct array packages;
138 struct import_directory *last;
141 struct razor_importer {
142 struct razor_set *set;
143 struct hashtable table;
144 struct hashtable file_table;
145 struct hashtable details_table;
146 struct razor_package *package;
147 struct array properties;
149 struct array file_requires;
150 struct array install_prefixes;
153 struct razor_package_iterator {
154 struct razor_set *set;
155 struct razor_package *package, *end;
161 razor_package_iterator_init_for_property(struct razor_package_iterator *pi,
162 struct razor_set *set,
163 struct razor_property *property);
165 struct razor_property_iterator {
166 struct razor_set *set;
167 struct razor_property *property, *end;
171 struct razor_file_iterator {
172 struct razor_set *set;
179 razor_set_aquire_lock(struct razor_set *set, const char *path, int exclusive);
182 razor_set_find_entry(struct razor_set *set,
183 struct razor_entry *dir, const char *pattern);
185 struct razor_merger *
186 razor_merger_create(struct razor_set *set1, struct razor_set *set2);
188 razor_merger_add_package(struct razor_merger *merger,
189 struct razor_package *package);
191 razor_merger_commit(struct razor_merger *merger);
193 razor_merger_package_add_script(struct razor_merger *merger,
194 struct razor_package *package,
195 enum razor_property_flags script,
196 const char *program, const char *body);
198 razor_merger_destroy(struct razor_merger *merger);
200 int run_lua_script(const char *root, const char *name, const char *body,
201 ssize_t len, int arg1);
203 int razor_run_script(const char *root, enum razor_property_flags script,
204 const char *program, const char *body, int arg1);
206 /* Utility functions */
209 razor_package_get_details_varg(struct razor_set *set,
210 struct razor_package *package,
212 void razor_rpm_get_details_varg(struct razor_rpm *rpm, va_list args);
214 int razor_create_dir(const char *root, const char *path);
215 int razor_remove(const char *path);
216 int razor_write(int fd, const void *data, size_t size);
219 razor_file_get_contents(const char *filename, size_t *length, int private,
220 struct razor_error **error);
221 int razor_file_free_contents(void *addr, size_t length);
224 typedef int (*razor_compare_with_data_func_t)(const void *p1,
228 razor_qsort_with_data(void *base, size_t nelem, size_t size,
229 razor_compare_with_data_func_t compare, void *data);
233 struct array vars, string_pool;
236 void environment_init(struct environment *env);
237 void environment_add_variable(struct environment *env,
238 const char *variable, const char *value);
239 void environment_set(struct environment *env);
240 void environment_unset(struct environment *env);
241 void environment_release(struct environment *env);
244 char *razor_utf16_to_utf8(const wchar_t *utf16, int len);
245 wchar_t *razor_utf8_to_utf16(const char *utf8, int len);
248 /* Error functions */
259 #define razor_error_new_posix(object) \
260 razor_error_new_str(RAZOR_POSIX_ERROR, errno, object, strerror(errno))
261 #define razor_set_error_posix(error, object) \
263 *(error) = razor_error_new_posix(object); \
267 struct razor_error *razor_error_new_mswin(const wchar_t *object, DWORD error);
268 struct razor_error *razor_error_new_str2(int domain, int code,
269 const wchar_t *object,
272 #define razor_set_error_mswin(error, object, err) \
274 *(error) = razor_error_new_mswin(object, err); \
276 #define razor_set_error2(error, domain, code, object, str) \
278 *(error) = razor_error_new_str2(domain, code, object, str); \
280 #endif /* MSWIN_API */
282 /* Atomic functions */
285 struct razor_atomic {
288 struct razor_atomic_file {
293 struct razor_error *error;
296 struct atomic_action {
297 struct atomic_action *next;
298 enum atomic_action_type {
299 /* Complex actions */
302 /* Primitive actions */
305 ACTION_CREATE_SYMLINK,
311 union atomic_action_args {
330 struct razor_atomic {
331 struct atomic_action *actions;
334 unsigned next_file_tag;
336 struct razor_error *error;
339 char *atomic_action_attic_tmpnam(struct razor_atomic *atomic);
340 struct atomic_action *
341 atomic_action_list_prepend(struct atomic_action *list,
342 struct atomic_action *action);
343 struct atomic_action *atomic_action_new(enum atomic_action_type type);
344 void atomic_action_free(struct atomic_action *action);
345 struct atomic_action *atomic_action_list_reverse(struct atomic_action *list);
346 struct atomic_action *
347 atomic_action_do(struct razor_atomic *atomic, struct atomic_action *action);
349 atomic_action_undo(struct razor_atomic *atomic, struct atomic_action *action);
350 #else /* !HAVE_WINDOWS_KTM && !ENABLE_ATOMIC */
351 struct razor_atomic {
353 struct razor_error *error;
357 int razor_allow_all_root_names(void);
358 int razor_valid_root_name(const char *name);
360 #define RAZOR_ASCII_ISALPHA(c) \
361 ((c) >= 'A' && (c) <= 'Z' || (c) >= 'a' && (c) <= 'z')
364 #define SKIP_DRIVE_LETTER(path) \
365 ((RAZOR_ASCII_ISALPHA(path[0]) && (path)[1] == ':') ? \
368 #define SKIP_DRIVE_LETTER(path) (path)
369 #endif /* MSWIN_API */
371 #endif /* _RAZOR_INTERNAL_H_ */