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/
6  *
7  * This source code is public domain. You can relicense this code
8  * under whatever license you want.
9  *
10  * See http://autopackage.org/docs/binreloc/ for
11  * more information and how to use this.
12  *
13  * NOTE: if you're using C++ and are getting "undefined reference
14  * to br_*", try renaming prefix.c to prefix.cpp
15  */
16 
17 #ifndef GEANY_PREFIX_H
18 #define GEANY_PREFIX_H 1
19 
20 
21 /*
22  * enrico - all the code below is only compiled and used if ENABLE_BINRELOC is set in config.h,
23  *          this only happens if configure option --enable-binreloc was used
24  */
25 #ifdef ENABLE_BINRELOC
26 
27 #include <glib.h>
28 
29 G_BEGIN_DECLS
30 
31 
32 /* WARNING, BEFORE YOU MODIFY PREFIX.C:
33  *
34  * If you make changes to any of the functions in prefix.c, you MUST
35  * change the BR_NAMESPACE macro.
36  * This way you can avoid symbol table conflicts with other libraries
37  * that also happen to use BinReloc.
38  *
39  * Example:
40  * #define BR_NAMESPACE(funcName) foobar_ ## funcName
41  * --> expands br_locate to foobar_br_locate
42  */
43 #undef BR_NAMESPACE
44 #define BR_NAMESPACE(funcName) geany_ ## funcName
45 
46 
47 #define br_thread_local_store BR_NAMESPACE(br_thread_local_store)
48 #define br_locate BR_NAMESPACE(br_locate)
49 #define br_locate_prefix BR_NAMESPACE(br_locate_prefix)
50 #define br_prepend_prefix BR_NAMESPACE(br_prepend_prefix)
51 
52 #ifndef BR_NO_MACROS
53 	/* These are convience macros that replace the ones usually used
54 	   in Autoconf/Automake projects */
55 	#undef SELFPATH
56 	#undef PREFIX
57 	#undef PREFIXDIR
58 	#undef BINDIR
59 	#undef SBINDIR
60 	#undef DATADIR
61 	#undef LIBDIR
62 	#undef LIBEXECDIR
63 	#undef ETCDIR
64 	#undef SYSCONFDIR
65 	#undef CONFDIR
66 	#undef LOCALEDIR
67 	#undef GEANY_PREFIX
68 	#undef GEANY_DATADIR
69 	#undef GEANY_LIBDIR
70 	#undef GEANY_LIBEXECDIR
71 	#undef GEANY_DOCDIR
72 	#undef GEANY_LOCALEDIR
73 
74 	#define SELFPATH	(br_thread_local_store (br_locate ((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 LIBEXECDIR	(br_thread_local_store (br_prepend_prefix ((void *) "", "/libexec")))
79 	#define ETCDIR		(br_thread_local_store (br_prepend_prefix ((void *) "", "/etc")))
80 	#define SYSCONFDIR	(br_thread_local_store (br_prepend_prefix ((void *) "", "/etc")))
81 	#define CONFDIR		(br_thread_local_store (br_prepend_prefix ((void *) "", "/etc")))
82 	#define GEANY_PREFIX		(br_thread_local_store (br_locate_prefix ((void *) "")))
83 	#define GEANY_DATADIR		(br_thread_local_store (br_prepend_prefix ((void *) "", "/share")))
84 	#define GEANY_LIBDIR		(br_thread_local_store (br_prepend_prefix ((void *) "", "/lib")))
85 	#define GEANY_LIBEXECDIR	(br_thread_local_store (br_prepend_prefix ((void *) "", "/libexec/geany")))
86 	#define GEANY_DOCDIR		(br_thread_local_store (br_prepend_prefix ((void *) "", "/share/doc/geany")))
87 	#define GEANY_LOCALEDIR		(br_thread_local_store (br_prepend_prefix ((void *) "", "/share/locale")))
88 #endif /* BR_NO_MACROS */
89 
90 
91 /* The following functions are used internally by BinReloc
92    and shouldn't be used directly in applications. */
93 
94 const char *br_thread_local_store (char *str);
95 char *br_locate		(void *symbol);
96 char *br_locate_prefix	(void *symbol);
97 char *br_prepend_prefix	(void *symbol, char *path);
98 
99 G_END_DECLS
100 
101 #endif /* ENABLE_BINRELOC */
102 
103 #endif /* GEANY_PREFIX_H */
104