Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields

prefix.h

00001 /*
00002  * BinReloc - a library for creating relocatable executables
00003  * Written by: Mike Hearn <mike@theoretic.com>
00004  *             Hongli Lai <h.lai@chello.nl>
00005  * http://autopackage.org/
00006  *
00007  * This source code is public domain. You can relicense this code
00008  * under whatever license you want.
00009  *
00010  * See http://autopackage.org/docs/binreloc/ for
00011  * more information and how to use this.
00012  *
00013  * NOTE: if you're using C++ and are getting "undefined reference
00014  * to br_*", try renaming prefix.c to prefix.cpp
00015  */
00016 #ifndef WIN32
00017 
00018 #ifndef _PREFIX_H_
00019 #define _PREFIX_H_
00020 
00021 #ifdef __cplusplus
00022 extern "C" {
00023 #endif /* __cplusplus */
00024 
00025 /* WARNING, BEFORE YOU MODIFY PREFIX.C:
00026  *
00027  * If you make changes to any of the functions in prefix.c, you MUST
00028  * change the BR_NAMESPACE macro.
00029  * This way you can avoid symbol table conflicts with other libraries
00030  * that also happen to use BinReloc.
00031  *
00032  * Example:
00033  * #define BR_NAMESPACE(funcName) foobar_ ## funcName
00034  * --> expands br_locate to foobar_br_locate
00035  */
00036 #undef BR_NAMESPACE
00037 #define BR_NAMESPACE(funcName) funcName
00038 
00039 
00040 #ifdef ENABLE_BINRELOC
00041 
00042 #define br_thread_local_store BR_NAMESPACE(br_thread_local_store)
00043 #define br_locate BR_NAMESPACE(br_locate)
00044 #define br_locate_prefix BR_NAMESPACE(br_locate_prefix)
00045 #define br_prepend_prefix BR_NAMESPACE(br_prepend_prefix)
00046 
00047 #ifndef BR_NO_MACROS
00048         /* These are convience macros that replace the ones usually used
00049            in Autoconf/Automake projects */
00050         #undef SELFPATH
00051         #undef PREFIX
00052         #undef PREFIXDIR
00053         #undef BINDIR
00054         #undef SBINDIR
00055         #undef DATADIR
00056         #undef LIBDIR
00057         #undef LIBEXECDIR
00058         #undef ETCDIR
00059         #undef SYSCONFDIR
00060         #undef CONFDIR
00061         #undef LOCALEDIR
00062 
00063         #define SELFPATH        (br_thread_local_store (br_locate ((void *) "")))
00064         #define PREFIX          (br_thread_local_store (br_locate_prefix ((void *) "")))
00065         #define PREFIXDIR       (br_thread_local_store (br_locate_prefix ((void *) "")))
00066         #define BINDIR          (br_thread_local_store (br_prepend_prefix ((void *) "", "/bin")))
00067         #define SBINDIR         (br_thread_local_store (br_prepend_prefix ((void *) "", "/sbin")))
00068         #define DATADIR         (br_thread_local_store (br_prepend_prefix ((void *) "", "/share")))
00069         #define LIBDIR          (br_thread_local_store (br_prepend_prefix ((void *) "", "/lib")))
00070         #define LIBEXECDIR      (br_thread_local_store (br_prepend_prefix ((void *) "", "/libexec")))
00071         #define ETCDIR          (br_thread_local_store (br_prepend_prefix ((void *) "", "/etc")))
00072         #define SYSCONFDIR      (br_thread_local_store (br_prepend_prefix ((void *) "", "/etc")))
00073         #define CONFDIR         (br_thread_local_store (br_prepend_prefix ((void *) "", "/etc")))
00074         #define LOCALEDIR       (br_thread_local_store (br_prepend_prefix ((void *) "", "/share/locale")))
00075 #endif /* BR_NO_MACROS */
00076 
00077 
00078 /* The following functions are used internally by BinReloc
00079    and shouldn't be used directly in applications. */
00080 
00081 char *br_locate         (void *symbol);
00082 char *br_locate_prefix  (void *symbol);
00083 char *br_prepend_prefix (void *symbol, char *path);
00084 
00085 #endif /* ENABLE_BINRELOC */
00086 
00087 const char *br_thread_local_store (char *str);
00088 
00089 
00090 /* These macros and functions are not guarded by the ENABLE_BINRELOC
00091  * macro because they are portable. You can use these functions.
00092  */
00093 
00094 #define br_strcat BR_NAMESPACE(br_strcat)
00095 #define br_extract_dir BR_NAMESPACE(br_extract_dir)
00096 #define br_extract_prefix BR_NAMESPACE(br_extract_prefix)
00097 #define br_set_locate_fallback_func BR_NAMESPACE(br_set_locate_fallback_func)
00098 
00099 #ifndef BR_NO_MACROS
00100   #ifndef ENABLE_BINRELOC        
00101         #define BR_SELFPATH(suffix)     SELFPATH suffix
00102         #define BR_PREFIX(suffix)       PREFIX suffix
00103         #define BR_PREFIXDIR(suffix)    BR_PREFIX suffix
00104         #define BR_BINDIR(suffix)       BINDIR suffix
00105         #define BR_SBINDIR(suffix)      SBINDIR suffix
00106         #define BR_DATADIR(suffix)      DATADIR suffix
00107         #define BR_LIBDIR(suffix)       LIBDIR suffix
00108         #define BR_LIBEXECDIR(suffix)   LIBEXECDIR suffix
00109         #define BR_ETCDIR(suffix)       ETCDIR suffix
00110         #define BR_SYSCONFDIR(suffix)   SYSCONFDIR suffix
00111         #define BR_CONFDIR(suffix)      CONFDIR suffix
00112         #define BR_LOCALEDIR(suffix)    LOCALEDIR suffix
00113   #else
00114         #define BR_SELFPATH(suffix)     (br_thread_local_store (br_strcat (SELFPATH, suffix)))
00115         #define BR_PREFIX(suffix)       (br_thread_local_store (br_strcat (PREFIX, suffix)))
00116         #define BR_PREFIXDIR(suffix)    (br_thread_local_store (br_strcat (BR_PREFIX, suffix)))
00117         #define BR_BINDIR(suffix)       (br_thread_local_store (br_strcat (BINDIR, suffix)))
00118         #define BR_SBINDIR(suffix)      (br_thread_local_store (br_strcat (SBINDIR, suffix)))
00119         #define BR_DATADIR(suffix)      (br_thread_local_store (br_strcat (DATADIR, suffix)))
00120         #define BR_LIBDIR(suffix)       (br_thread_local_store (br_strcat (LIBDIR, suffix)))
00121         #define BR_LIBEXECDIR(suffix)   (br_thread_local_store (br_strcat (LIBEXECDIR, suffix)))
00122         #define BR_ETCDIR(suffix)       (br_thread_local_store (br_strcat (ETCDIR, suffix)))
00123         #define BR_SYSCONFDIR(suffix)   (br_thread_local_store (br_strcat (SYSCONFDIR, suffix)))
00124         #define BR_CONFDIR(suffix)      (br_thread_local_store (br_strcat (CONFDIR, suffix)))
00125         #define BR_LOCALEDIR(suffix)    (br_thread_local_store (br_strcat (LOCALEDIR, suffix)))        
00126   #endif
00127 #endif
00128 
00129 char *br_strcat (const char *str1, const char *str2);
00130 char *br_extract_dir    (const char *path);
00131 char *br_extract_prefix(const char *path);
00132 typedef char *(*br_locate_fallback_func) (void *symbol, void *data);
00133 void br_set_locate_fallback_func (br_locate_fallback_func func, void *data);
00134 
00135 
00136 #ifdef __cplusplus
00137 }
00138 #endif /* __cplusplus */
00139 
00140 #endif /* _PREFIX_H_ */
00141 
00142 #endif /* WIN32 */

Generated on Thu Jun 16 21:50:43 2005 for scourge by  doxygen 1.4.0