2 * I made the following modifications, be sure to readd these when
3 * upgrading these files.
6 * Added "gaim_ ## " to the namespace
7 * Changed the lib macro to use /lib/gaim instead of just /lib
8 * (why does gaim do that in the -DLIBDIR autoconf thing anyway?)
13 * BinReloc - a library for creating relocatable executables
14 * Written by: Mike Hearn <mike@theoretic.com>
15 * Hongli Lai <h.lai@chello.nl>
16 * http://autopackage.org/
18 * This source code is public domain. You can relicense this code
19 * under whatever license you want.
21 * See http://autopackage.org/docs/binreloc/ for
22 * more information and how to use this.
24 * NOTE: if you're using C++ and are getting "undefined reference
25 * to br_*", try renaming prefix.c to prefix.cpp
33 #endif /* __cplusplus */
35 /* WARNING, BEFORE YOU MODIFY PREFIX.C:
37 * If you make changes to any of the functions in prefix.c, you MUST
38 * change the BR_NAMESPACE macro.
39 * This way you can avoid symbol table conflicts with other libraries
40 * that also happen to use BinReloc.
43 * #define BR_NAMESPACE(funcName) foobar_ ## funcName
44 * --> expands br_locate to foobar_br_locate
47 #define BR_NAMESPACE(funcName) gaim_ ## funcName
50 #ifdef ENABLE_BINRELOC
52 #define br_thread_local_store BR_NAMESPACE(br_thread_local_store)
53 #define br_locate BR_NAMESPACE(br_locate)
54 #define br_locate_prefix BR_NAMESPACE(br_locate_prefix)
55 #define br_prepend_prefix BR_NAMESPACE(br_prepend_prefix)
58 /* These are convenience macros that replace the ones usually used
59 in Autoconf/Automake projects */
73 #define SELFPATH (br_thread_local_store (br_locate ((void *) "")))
74 #define PREFIX (br_thread_local_store (br_locate_prefix ((void *) "")))
75 #define PREFIXDIR (br_thread_local_store (br_locate_prefix ((void *) "")))
76 #define BINDIR (br_thread_local_store (br_prepend_prefix ((void *) "", "/bin")))
77 #define SBINDIR (br_thread_local_store (br_prepend_prefix ((void *) "", "/sbin")))
78 #define DATADIR (br_thread_local_store (br_prepend_prefix ((void *) "", "/share")))
79 #define LIBDIR (br_thread_local_store (br_prepend_prefix ((void *) "", "/lib/gaim")))
80 #define LIBEXECDIR (br_thread_local_store (br_prepend_prefix ((void *) "", "/libexec")))
81 #define ETCDIR (br_thread_local_store (br_prepend_prefix ((void *) "", "/etc")))
82 #define SYSCONFDIR (br_thread_local_store (br_prepend_prefix ((void *) "", "/etc")))
83 #define CONFDIR (br_thread_local_store (br_prepend_prefix ((void *) "", "/etc")))
84 #define LOCALEDIR (br_thread_local_store (br_prepend_prefix ((void *) "", "/share/locale")))
85 #endif /* BR_NO_MACROS */
88 /* The following functions are used internally by BinReloc
89 and shouldn't be used directly in applications. */
91 char *br_locate (void *symbol
);
92 char *br_locate_prefix (void *symbol
);
93 char *br_prepend_prefix (void *symbol
, char *path
);
95 #endif /* ENABLE_BINRELOC */
97 const char *br_thread_local_store (char *str
);
100 /* These macros and functions are not guarded by the ENABLE_BINRELOC
101 * macro because they are portable. You can use these functions.
104 #define br_strcat BR_NAMESPACE(br_strcat)
105 #define br_extract_dir BR_NAMESPACE(br_extract_dir)
106 #define br_extract_prefix BR_NAMESPACE(br_extract_prefix)
107 #define br_set_locate_fallback_func BR_NAMESPACE(br_set_locate_fallback_func)
110 /* Convenience functions for concatenating paths */
112 /* Each time you call one, the previous result will be freed. So don't do this:
114 * some_function( BR_DATADIR("/one"), BR_DATADIR("/two") )
116 * as the first parameter will now be bogus!
119 #define BR_SELFPATH(suffix) (br_thread_local_store (br_strcat (SELFPATH, suffix)))
120 #define BR_PREFIX(suffix) (br_thread_local_store (br_strcat (PREFIX, suffix)))
121 #define BR_PREFIXDIR(suffix) (br_thread_local_store (br_strcat (BR_PREFIX, suffix)))
122 #define BR_BINDIR(suffix) (br_thread_local_store (br_strcat (BINDIR, suffix)))
123 #define BR_SBINDIR(suffix) (br_thread_local_store (br_strcat (SBINDIR, suffix)))
124 #define BR_DATADIR(suffix) (br_thread_local_store (br_strcat (DATADIR, suffix)))
125 #define BR_LIBDIR(suffix) (br_thread_local_store (br_strcat (LIBDIR, suffix)))
126 #define BR_LIBEXECDIR(suffix) (br_thread_local_store (br_strcat (LIBEXECDIR, suffix)))
127 #define BR_ETCDIR(suffix) (br_thread_local_store (br_strcat (ETCDIR, suffix)))
128 #define BR_SYSCONFDIR(suffix) (br_thread_local_store (br_strcat (SYSCONFDIR, suffix)))
129 #define BR_CONFDIR(suffix) (br_thread_local_store (br_strcat (CONFDIR, suffix)))
130 #define BR_LOCALEDIR(suffix) (br_thread_local_store (br_strcat (LOCALEDIR, suffix)))
133 char *br_strcat (const char *str1
, const char *str2
);
134 char *br_extract_dir (const char *path
);
135 char *br_extract_prefix(const char *path
);
136 typedef char *(*br_locate_fallback_func
) (void *symbol
, void *data
);
137 void br_set_locate_fallback_func (br_locate_fallback_func func
, void *data
);
142 #endif /* __cplusplus */
144 #endif /* _PREFIX_H_ */