Fixes for datatype size on amd64.
[crack-attack.git] / src / prefix.h
blob9e1b2198c06c35c93b93dd23cc039fc88541bf93
1 /*
2 * BinReloc - a library for creating relocatable executables
3 * Written by: Mike Hearn <mike@theoretic.com>
4 * Hongli Lai <h.lai@chello.nl>
5 * http://autopackage.org/
7 * This source code is public domain. You can relicense this code
8 * under whatever license you want.
10 * See http://autopackage.org/docs/binreloc/ for
11 * more information and how to use this.
13 * NOTE: if you're using C++ and are getting "undefined reference
14 * to br_*", try renaming prefix.c to prefix.cpp
17 #ifndef _PREFIX_H_
18 #define _PREFIX_H_
20 #ifdef __cplusplus
21 extern "C" {
22 #endif /* __cplusplus */
24 /* WARNING, BEFORE YOU MODIFY PREFIX.C:
26 * If you make changes to any of the functions in prefix.c, you MUST
27 * change the BR_NAMESPACE macro.
28 * This way you can avoid symbol table conflicts with other libraries
29 * that also happen to use BinReloc.
31 * Example:
32 * #define BR_NAMESPACE(funcName) foobar_ ## funcName
33 * --> expands br_locate to foobar_br_locate
35 #undef BR_NAMESPACE
36 #define BR_NAMESPACE(funcName) funcName
39 #ifdef ENABLE_BINRELOC
41 #define br_thread_local_store BR_NAMESPACE(br_thread_local_store)
42 #define br_locate BR_NAMESPACE(br_locate)
43 #define br_locate_prefix BR_NAMESPACE(br_locate_prefix)
44 #define br_prepend_prefix BR_NAMESPACE(br_prepend_prefix)
46 #ifndef BR_NO_MACROS
47 /* These are convience macros that replace the ones usually used
48 in Autoconf/Automake projects */
49 #undef SELFPATH
50 #undef PREFIX
51 #undef PREFIXDIR
52 #undef BINDIR
53 #undef SBINDIR
54 #undef DATADIR
55 #undef LIBDIR
56 #undef LIBEXECDIR
57 #undef ETCDIR
58 #undef SYSCONFDIR
59 #undef CONFDIR
60 #undef LOCALEDIR
62 #define SELFPATH (br_thread_local_store (br_locate ((void *) "")))
63 #define PREFIX (br_thread_local_store (br_locate_prefix ((void *) "")))
64 #define PREFIXDIR (br_thread_local_store (br_locate_prefix ((void *) "")))
65 #define BINDIR (br_thread_local_store (br_prepend_prefix ((void *) "", "/bin")))
66 #define SBINDIR (br_thread_local_store (br_prepend_prefix ((void *) "", "/sbin")))
67 #define DATADIR (br_thread_local_store (br_prepend_prefix ((void *) "", "/share")))
68 #define LIBDIR (br_thread_local_store (br_prepend_prefix ((void *) "", "/lib")))
69 #define LIBEXECDIR (br_thread_local_store (br_prepend_prefix ((void *) "", "/libexec")))
70 #define ETCDIR (br_thread_local_store (br_prepend_prefix ((void *) "", "/etc")))
71 #define SYSCONFDIR (br_thread_local_store (br_prepend_prefix ((void *) "", "/etc")))
72 #define CONFDIR (br_thread_local_store (br_prepend_prefix ((void *) "", "/etc")))
73 #define LOCALEDIR (br_thread_local_store (br_prepend_prefix ((void *) "", "/share/locale")))
74 #endif /* BR_NO_MACROS */
77 /* The following functions are used internally by BinReloc
78 and shouldn't be used directly in applications. */
80 char *br_locate (void *symbol);
81 char *br_locate_prefix (void *symbol);
82 char *br_prepend_prefix (void *symbol, char *path);
84 #endif /* ENABLE_BINRELOC */
86 const char *br_thread_local_store (char *str);
89 /* These macros and functions are not guarded by the ENABLE_BINRELOC
90 * macro because they are portable. You can use these functions.
93 #define br_strcat BR_NAMESPACE(br_strcat)
94 #define br_extract_dir BR_NAMESPACE(br_extract_dir)
95 #define br_extract_prefix BR_NAMESPACE(br_extract_prefix)
96 #define br_set_locate_fallback_func BR_NAMESPACE(br_set_locate_fallback_func)
98 #ifndef BR_NO_MACROS
99 #ifndef ENABLE_BINRELOC
100 #define BR_SELFPATH(suffix) SELFPATH suffix
101 #define BR_PREFIX(suffix) PREFIX suffix
102 #define BR_PREFIXDIR(suffix) BR_PREFIX suffix
103 #define BR_BINDIR(suffix) BINDIR suffix
104 #define BR_SBINDIR(suffix) SBINDIR suffix
105 #define BR_DATADIR(suffix) DATADIR suffix
106 #define BR_LIBDIR(suffix) LIBDIR suffix
107 #define BR_LIBEXECDIR(suffix) LIBEXECDIR suffix
108 #define BR_ETCDIR(suffix) ETCDIR suffix
109 #define BR_SYSCONFDIR(suffix) SYSCONFDIR suffix
110 #define BR_CONFDIR(suffix) CONFDIR suffix
111 #define BR_LOCALEDIR(suffix) LOCALEDIR suffix
112 #else
113 #define BR_SELFPATH(suffix) (br_thread_local_store (br_strcat (SELFPATH, suffix)))
114 #define BR_PREFIX(suffix) (br_thread_local_store (br_strcat (PREFIX, suffix)))
115 #define BR_PREFIXDIR(suffix) (br_thread_local_store (br_strcat (BR_PREFIX, suffix)))
116 #define BR_BINDIR(suffix) (br_thread_local_store (br_strcat (BINDIR, suffix)))
117 #define BR_SBINDIR(suffix) (br_thread_local_store (br_strcat (SBINDIR, suffix)))
118 #define BR_DATADIR(suffix) (br_thread_local_store (br_strcat (DATADIR, suffix)))
119 #define BR_LIBDIR(suffix) (br_thread_local_store (br_strcat (LIBDIR, suffix)))
120 #define BR_LIBEXECDIR(suffix) (br_thread_local_store (br_strcat (LIBEXECDIR, suffix)))
121 #define BR_ETCDIR(suffix) (br_thread_local_store (br_strcat (ETCDIR, suffix)))
122 #define BR_SYSCONFDIR(suffix) (br_thread_local_store (br_strcat (SYSCONFDIR, suffix)))
123 #define BR_CONFDIR(suffix) (br_thread_local_store (br_strcat (CONFDIR, suffix)))
124 #define BR_LOCALEDIR(suffix) (br_thread_local_store (br_strcat (LOCALEDIR, suffix)))
125 #endif
126 #endif
128 char *br_strcat (const char *str1, const char *str2);
129 char *br_extract_dir (const char *path);
130 char *br_extract_prefix(const char *path);
131 typedef char *(*br_locate_fallback_func) (void *symbol, void *data);
132 void br_set_locate_fallback_func (br_locate_fallback_func func, void *data);
135 #ifdef __cplusplus
137 #endif /* __cplusplus */
139 #endif /* _PREFIX_H_ */