1 /* 2 * BinReloc - a library for creating relocatable executables 3 * Written by: Hongli Lai <h.lai@chello.nl> 4 * http://autopackage.org/ 5 * 6 * This source code is public domain. You can relicense this code 7 * under whatever license you want. 8 * 9 * See http://autopackage.org/docs/binreloc/ for 10 * more information and how to use this. 11 */ 12 13 #ifndef __BINRELOC_H__ 14 #define __BINRELOC_H__ 15 16 #ifdef __cplusplus 17 extern "C" { 18 #endif /* __cplusplus */ 19 20 21 /** These error codes can be returned by br_init(), br_init_lib(), gbr_init() or gbr_init_lib(). */ 22 typedef enum { 23 /** Cannot allocate memory. */ 24 BR_INIT_ERROR_NOMEM, 25 /** Unable to open /proc/self/maps; see errno for details. */ 26 BR_INIT_ERROR_OPEN_MAPS, 27 /** Unable to read from /proc/self/maps; see errno for details. */ 28 BR_INIT_ERROR_READ_MAPS, 29 /** The file format of /proc/self/maps is invalid; kernel bug? */ 30 BR_INIT_ERROR_INVALID_MAPS, 31 /** BinReloc is disabled (the ENABLE_BINRELOC macro is not defined). */ 32 BR_INIT_ERROR_DISABLED 33 } BrInitError; 34 35 36 #ifndef BINRELOC_RUNNING_DOXYGEN 37 /* Mangle symbol names to avoid symbol collisions with other ELF objects. */ 38 #define br_init kczN34157167993278_br_init 39 #define br_init_lib kczN34157167993278_br_init_lib 40 #define br_find_exe kczN34157167993278_br_find_exe 41 #define br_find_exe_dir kczN34157167993278_br_find_exe_dir 42 #define br_find_prefix kczN34157167993278_br_find_prefix 43 #define br_find_bin_dir kczN34157167993278_br_find_bin_dir 44 #define br_find_sbin_dir kczN34157167993278_br_find_sbin_dir 45 #define br_find_data_dir kczN34157167993278_br_find_data_dir 46 #define br_find_locale_dir kczN34157167993278_br_find_locale_dir 47 #define br_find_lib_dir kczN34157167993278_br_find_lib_dir 48 #define br_find_libexec_dir kczN34157167993278_br_find_libexec_dir 49 #define br_find_etc_dir kczN34157167993278_br_find_etc_dir 50 #define br_strcat kczN34157167993278_br_strcat 51 #define br_build_path kczN34157167993278_br_build_path 52 #define br_dirname kczN34157167993278_br_dirname 53 54 55 #endif 56 int br_init (BrInitError *error); 57 int br_init_lib (BrInitError *error); 58 59 char *br_find_exe (const char *default_exe); 60 char *br_find_exe_dir (const char *default_dir); 61 char *br_find_prefix (const char *default_prefix); 62 char *br_find_bin_dir (const char *default_bin_dir); 63 char *br_find_sbin_dir (const char *default_sbin_dir); 64 char *br_find_data_dir (const char *default_data_dir); 65 char *br_find_locale_dir (const char *default_locale_dir); 66 char *br_find_lib_dir (const char *default_lib_dir); 67 char *br_find_libexec_dir (const char *default_libexec_dir); 68 char *br_find_etc_dir (const char *default_etc_dir); 69 70 /* Utility functions */ 71 char *br_strcat (const char *str1, const char *str2); 72 char *br_build_path (const char *dir, const char *file); 73 char *br_dirname (const char *path); 74 75 76 #ifdef __cplusplus 77 } 78 #endif /* __cplusplus */ 79 80 #endif /* __BINRELOC_H__ */ 81