comparison src/prefix.h @ 10245:c143a3fac58d

[gaim-migrate @ 11385] Binary relocation, step one. I had a fairly long commit message, and cvs ate it and said Read from remote host cvs.sourceforge.net: Connection reset by peer I'm displeased. This is just method one, method two to follow tomorrow after I add a way to register a fallback and try to push it upstream. That way I don't have to put method 2 inside prefix.c. As for as core/ui split goes, they can either each have their own copy after the divorce is final, or the UI can use the core's. It'll work either way, since #1 finds location of the caller, and #2 doesn't work on libraries anyway. That's one advantage I forgot to mention, btw, that #1 will let a library find its own location. So, I'm sure something isn't quite right and someone will want to fix it. So they can fix it while i implement phase two. Which won't take long at all, but the autopackage guy is in bed, and I should be too. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Tue, 23 Nov 2004 05:53:59 +0000
parents
children 645eb9804040
comparison
equal deleted inserted replaced
10244:13cb42ebb537 10245:c143a3fac58d
1 /*
2 * I made the following modifications, be sure to readd these when
3 * upgrading these files.
4 *
5 * Added this comment.
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?)
9 *
10 */
11
12 /*
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/
17 *
18 * This source code is public domain. You can relicense this code
19 * under whatever license you want.
20 *
21 * See http://autopackage.org/docs/binreloc/ for
22 * more information and how to use this.
23 *
24 * NOTE: if you're using C++ and are getting "undefined reference
25 * to br_*", try renaming prefix.c to prefix.cpp
26 */
27
28 #ifndef _PREFIX_H_
29 #define _PREFIX_H_
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif /* __cplusplus */
34
35 /* WARNING, BEFORE YOU MODIFY PREFIX.C:
36 *
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.
41 *
42 * Example:
43 * #define BR_NAMESPACE(funcName) foobar_ ## funcName
44 * --> expands br_locate to foobar_br_locate
45 */
46 #undef BR_NAMESPACE
47 #define BR_NAMESPACE(funcName) gaim_ ## funcName
48
49
50 #ifdef ENABLE_BINRELOC
51
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)
56
57 #ifndef BR_NO_MACROS
58 /* These are convience macros that replace the ones usually used
59 in Autoconf/Automake projects */
60 #undef SELFPATH
61 #undef PREFIX
62 #undef PREFIXDIR
63 #undef BINDIR
64 #undef SBINDIR
65 #undef DATADIR
66 #undef LIBDIR
67 #undef LIBEXECDIR
68 #undef ETCDIR
69 #undef SYSCONFDIR
70 #undef CONFDIR
71 #undef LOCALEDIR
72
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 */
86
87
88 /* The following functions are used internally by BinReloc
89 and shouldn't be used directly in applications. */
90
91 const char *br_thread_local_store (char *str);
92 char *br_locate (void *symbol);
93 char *br_locate_prefix (void *symbol);
94 char *br_prepend_prefix (void *symbol, char *path);
95
96
97 #endif /* ENABLE_BINRELOC */
98
99
100 /* These macros and functions are not guarded by the ENABLE_BINRELOC
101 * macro because they are portable. You can use these functions.
102 */
103
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
108 #ifndef BR_NO_MACROS
109 /* Convenience functions for concatenating paths */
110 #define BR_SELFPATH(suffix) (br_thread_local_store (br_strcat (SELFPATH, suffix)))
111 #define BR_PREFIX(suffix) (br_thread_local_store (br_strcat (PREFIX, suffix)))
112 #define BR_PREFIXDIR(suffix) (br_thread_local_store (br_strcat (BR_PREFIX, suffix)))
113 #define BR_BINDIR(suffix) (br_thread_local_store (br_strcat (BINDIR, suffix)))
114 #define BR_SBINDIR(suffix) (br_thread_local_store (br_strcat (SBINDIR, suffix)))
115 #define BR_DATADIR(suffix) (br_thread_local_store (br_strcat (DATADIR, suffix)))
116 #define BR_LIBDIR(suffix) (br_thread_local_store (br_strcat (LIBDIR, suffix)))
117 #define BR_LIBEXECDIR(suffix) (br_thread_local_store (br_strcat (LIBEXECDIR, suffix)))
118 #define BR_ETCDIR(suffix) (br_thread_local_store (br_strcat (ETCDIR, suffix)))
119 #define BR_SYSCONFDIR(suffix) (br_thread_local_store (br_strcat (SYSCONFDIR, suffix)))
120 #define BR_CONFDIR(suffix) (br_thread_local_store (br_strcat (CONFDIR, suffix)))
121 #define BR_LOCALEDIR(suffix) (br_thread_local_store (br_strcat (LOCALEDIR, suffix)))
122 #endif
123
124 char *br_strcat (const char *str1, const char *str2);
125 char *br_extract_dir (const char *path);
126 char *br_extract_prefix(const char *path);
127
128
129 #ifdef __cplusplus
130 }
131 #endif /* __cplusplus */
132
133 #endif /* _PREFIX_H_ */