binreloc.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. #ifndef __BINRELOC_H__
  13. #define __BINRELOC_H__
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif /* __cplusplus */
  17. /** These error codes can be returned by br_init(), br_init_lib(), gbr_init() or gbr_init_lib(). */
  18. typedef enum {
  19. /** Cannot allocate memory. */
  20. BR_INIT_ERROR_NOMEM,
  21. /** Unable to open /proc/self/maps; see errno for details. */
  22. BR_INIT_ERROR_OPEN_MAPS,
  23. /** Unable to read from /proc/self/maps; see errno for details. */
  24. BR_INIT_ERROR_READ_MAPS,
  25. /** The file format of /proc/self/maps is invalid; kernel bug? */
  26. BR_INIT_ERROR_INVALID_MAPS,
  27. /** BinReloc is disabled (the ENABLE_BINRELOC macro is not defined). */
  28. BR_INIT_ERROR_DISABLED
  29. } BrInitError;
  30. #ifndef BINRELOC_RUNNING_DOXYGEN
  31. /* Mangle symbol names to avoid symbol collisions with other ELF objects. */
  32. #define br_init zLhm65070058860608_br_init
  33. #define br_init_lib zLhm65070058860608_br_init_lib
  34. #define br_find_exe zLhm65070058860608_br_find_exe
  35. #define br_find_exe_dir zLhm65070058860608_br_find_exe_dir
  36. #define br_find_prefix zLhm65070058860608_br_find_prefix
  37. #define br_find_bin_dir zLhm65070058860608_br_find_bin_dir
  38. #define br_find_sbin_dir zLhm65070058860608_br_find_sbin_dir
  39. #define br_find_data_dir zLhm65070058860608_br_find_data_dir
  40. #define br_find_locale_dir zLhm65070058860608_br_find_locale_dir
  41. #define br_find_lib_dir zLhm65070058860608_br_find_lib_dir
  42. #define br_find_libexec_dir zLhm65070058860608_br_find_libexec_dir
  43. #define br_find_etc_dir zLhm65070058860608_br_find_etc_dir
  44. #define br_strcat zLhm65070058860608_br_strcat
  45. #define br_build_path zLhm65070058860608_br_build_path
  46. #define br_dirname zLhm65070058860608_br_dirname
  47. #endif
  48. int br_init (BrInitError *error);
  49. int br_init_lib (BrInitError *error);
  50. char *br_find_exe (const char *default_exe);
  51. char *br_find_exe_dir (const char *default_dir);
  52. char *br_find_prefix (const char *default_prefix);
  53. char *br_find_bin_dir (const char *default_bin_dir);
  54. char *br_find_sbin_dir (const char *default_sbin_dir);
  55. char *br_find_data_dir (const char *default_data_dir);
  56. char *br_find_locale_dir (const char *default_locale_dir);
  57. char *br_find_lib_dir (const char *default_lib_dir);
  58. char *br_find_libexec_dir (const char *default_libexec_dir);
  59. char *br_find_etc_dir (const char *default_etc_dir);
  60. /* Utility functions */
  61. char *br_strcat (const char *str1, const char *str2);
  62. char *br_build_path (const char *dir, const char *file);
  63. char *br_dirname (const char *path);
  64. #ifdef __cplusplus
  65. }
  66. #endif /* __cplusplus */
  67. #endif /* __BINRELOC_H__ */