src/thirdparty/binreloc/prefix.h

Go to the documentation of this file.
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 
00017 #ifndef _PREFIX_H_
00018 #define _PREFIX_H_
00019 
00020 #ifdef __cplusplus
00021 extern "C" {
00022 #endif /* __cplusplus */
00023 
00024     /* WARNING, BEFORE YOU MODIFY PREFIX.C:
00025      *
00026      * If you make changes to any of the functions in prefix.c, you MUST
00027      * change the BR_NAMESPACE macro.
00028      * This way you can avoid symbol table conflicts with other libraries
00029      * that also happen to use BinReloc.
00030      *
00031      * Example:
00032      * #define BR_NAMESPACE(funcName) foobar_ ## funcName
00033      * --> expands br_locate to foobar_br_locate
00034      */
00035 #undef BR_NAMESPACE
00036 #define BR_NAMESPACE(funcName) funcName
00037 
00038 
00039 #ifdef ENABLE_BINRELOC
00040 
00041 #define br_thread_local_store BR_NAMESPACE(br_thread_local_store)
00042 #define br_locate BR_NAMESPACE(br_locate)
00043 #define br_locate_prefix BR_NAMESPACE(br_locate_prefix)
00044 #define br_prepend_prefix BR_NAMESPACE(br_prepend_prefix)
00045 
00046 #ifndef BR_NO_MACROS
00047     /* These are convience macros that replace the ones usually used
00048        in Autoconf/Automake projects */
00049         #undef SELFPATH
00050         #undef PREFIX
00051         #undef PREFIXDIR
00052         #undef BINDIR
00053         #undef SBINDIR
00054         #undef DATADIR
00055         #undef LIBDIR
00056         #undef LIBEXECDIR
00057         #undef ETCDIR
00058         #undef SYSCONFDIR
00059         #undef CONFDIR
00060         #undef LOCALEDIR
00061 
00062     #define BR_LOCATE_CHAR( x ) br_locate(const_cast< void * >(static_cast< void const * >( x ) ) )
00063     #define BR_LOCATE_PREFIX_CHAR( x ) br_locate_prefix(const_cast< void * >(static_cast< void const * >( x ) ) )
00064     #define BR_PREPEND_PREFIX_CHAR( x ) br_prepend_prefix(const_cast< void * >(static_cast< void const * >( x ) ) )
00065 
00066         #define SELFPATH        (br_thread_local_store (BR_LOCATE_CHAR("")))
00067         #define PREFIX          (br_thread_local_store (BR_LOCATE_PREFIX_CHAR ((void *) "")))
00068         #define PREFIXDIR       (br_thread_local_store (BR_LOCATE_PREFIX_CHAR ((void *) "")))
00069         #define BINDIR          (br_thread_local_store (BR_PREPEND_PREFIX_CHAR ((void *) "", "/bin")))
00070         #define SBINDIR         (br_thread_local_store (BR_PREPEND_PREFIX_CHAR ((void *) "", "/sbin")))
00071         #define DATADIR         (br_thread_local_store (BR_PREPEND_PREFIX_CHAR ((void *) "", "/share")))
00072         #define LIBDIR          (br_thread_local_store (BR_PREPEND_PREFIX_CHAR ((void *) "", "/lib")))
00073         #define LIBEXECDIR      (br_thread_local_store (BR_PREPEND_PREFIX_CHAR ((void *) "", "/libexec")))
00074         #define ETCDIR          (br_thread_local_store (BR_PREPEND_PREFIX_CHAR ((void *) "", "/etc")))
00075         #define SYSCONFDIR      (br_thread_local_store (BR_PREPEND_PREFIX_CHAR ((void *) "", "/etc")))
00076         #define CONFDIR         (br_thread_local_store (BR_PREPEND_PREFIX_CHAR ((void *) "", "/etc")))
00077         #define LOCALEDIR       (br_thread_local_store (BR_PREPEND_PREFIX_CHAR ((void *) "", "/share/locale")))
00078 #endif /* BR_NO_MACROS */
00079 
00080 
00081     /* The following functions are used internally by BinReloc
00082        and shouldn't be used directly in applications. */
00083 
00084     char *br_locate             (void *symbol);
00085     char *br_locate_prefix      (void *symbol);
00086     char *br_prepend_prefix     (void *symbol, char *path);
00087 
00088 #endif /* ENABLE_BINRELOC */
00089 
00090     const char *br_thread_local_store (char *str);
00091 
00092 
00093     /* These macros and functions are not guarded by the ENABLE_BINRELOC
00094      * macro because they are portable. You can use these functions.
00095      */
00096 
00097 #define br_strcat BR_NAMESPACE(br_strcat)
00098 #define br_extract_dir BR_NAMESPACE(br_extract_dir)
00099 #define br_extract_prefix BR_NAMESPACE(br_extract_prefix)
00100 #define br_set_locate_fallback_func BR_NAMESPACE(br_set_locate_fallback_func)
00101 
00102 #ifndef BR_NO_MACROS
00103   #ifndef ENABLE_BINRELOC        
00104         #define BR_SELFPATH(suffix)     SELFPATH suffix
00105         #define BR_PREFIX(suffix)       PREFIX suffix
00106         #define BR_PREFIXDIR(suffix)    BR_PREFIX suffix
00107         #define BR_BINDIR(suffix)       BINDIR suffix
00108         #define BR_SBINDIR(suffix)      SBINDIR suffix
00109         #define BR_DATADIR(suffix)      DATADIR suffix
00110         #define BR_LIBDIR(suffix)       LIBDIR suffix
00111         #define BR_LIBEXECDIR(suffix)   LIBEXECDIR suffix
00112         #define BR_ETCDIR(suffix)       ETCDIR suffix
00113         #define BR_SYSCONFDIR(suffix)   SYSCONFDIR suffix
00114         #define BR_CONFDIR(suffix)      CONFDIR suffix
00115         #define BR_LOCALEDIR(suffix)    LOCALEDIR suffix
00116   #else
00117         #define BR_SELFPATH(suffix)     (br_thread_local_store (br_strcat (SELFPATH, suffix)))
00118         #define BR_PREFIX(suffix)       (br_thread_local_store (br_strcat (PREFIX, suffix)))
00119         #define BR_PREFIXDIR(suffix)    (br_thread_local_store (br_strcat (BR_PREFIX, suffix)))
00120         #define BR_BINDIR(suffix)       (br_thread_local_store (br_strcat (BINDIR, suffix)))
00121         #define BR_SBINDIR(suffix)      (br_thread_local_store (br_strcat (SBINDIR, suffix)))
00122         #define BR_DATADIR(suffix)      (br_thread_local_store (br_strcat (DATADIR, suffix)))
00123         #define BR_LIBDIR(suffix)       (br_thread_local_store (br_strcat (LIBDIR, suffix)))
00124         #define BR_LIBEXECDIR(suffix)   (br_thread_local_store (br_strcat (LIBEXECDIR, suffix)))
00125         #define BR_ETCDIR(suffix)       (br_thread_local_store (br_strcat (ETCDIR, suffix)))
00126         #define BR_SYSCONFDIR(suffix)   (br_thread_local_store (br_strcat (SYSCONFDIR, suffix)))
00127         #define BR_CONFDIR(suffix)      (br_thread_local_store (br_strcat (CONFDIR, suffix)))
00128         #define BR_LOCALEDIR(suffix)    (br_thread_local_store (br_strcat (LOCALEDIR, suffix)))        
00129   #endif
00130 #endif
00131 
00132     char *br_strcat     (const char *str1, const char *str2);
00133     char *br_extract_dir        (const char *path);
00134     char *br_extract_prefix(const char *path);
00135     typedef char *(*br_locate_fallback_func) (void *symbol, void *data);
00136     void br_set_locate_fallback_func (br_locate_fallback_func func, void *data);
00137 
00138 
00139 #ifdef __cplusplus
00140 }
00141 #endif /* __cplusplus */
00142 
00143 #endif /* _PREFIX_H_ */

Generated on Sat Mar 15 22:55:56 2008 for Armagetron Advanced by  doxygen 1.5.4