prefix.h

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

Generated on Sun Feb 18 08:39:33 2007 for gaim by  doxygen 1.5.1