gwenhywfar  4.3.1
Defines | Enumerations | Functions
binreloc.h File Reference

Go to the source code of this file.

Defines

#define br_build_path   pkND64590836275372_br_build_path
#define br_dirname   pkND64590836275372_br_dirname
#define br_find_bin_dir   pkND64590836275372_br_find_bin_dir
#define br_find_data_dir   pkND64590836275372_br_find_data_dir
#define br_find_etc_dir   pkND64590836275372_br_find_etc_dir
#define br_find_exe   pkND64590836275372_br_find_exe
#define br_find_exe_dir   pkND64590836275372_br_find_exe_dir
#define br_find_lib_dir   pkND64590836275372_br_find_lib_dir
#define br_find_libexec_dir   pkND64590836275372_br_find_libexec_dir
#define br_find_locale_dir   pkND64590836275372_br_find_locale_dir
#define br_find_prefix   pkND64590836275372_br_find_prefix
#define br_find_sbin_dir   pkND64590836275372_br_find_sbin_dir
#define br_init   pkND64590836275372_br_init
#define br_init_lib   pkND64590836275372_br_init_lib
#define br_strcat   pkND64590836275372_br_strcat

Enumerations

enum  BrInitError {
  BR_INIT_ERROR_NOMEM, BR_INIT_ERROR_OPEN_MAPS, BR_INIT_ERROR_READ_MAPS, BR_INIT_ERROR_INVALID_MAPS,
  BR_INIT_ERROR_DISABLED
}

Functions

char * br_build_path (const char *dir, const char *file)
char * br_dirname (const char *path)
char * br_find_bin_dir (const char *default_bin_dir)
char * br_find_data_dir (const char *default_data_dir)
char * br_find_etc_dir (const char *default_etc_dir)
char * br_find_exe (const char *default_exe)
char * br_find_exe_dir (const char *default_dir)
char * br_find_lib_dir (const char *default_lib_dir)
char * br_find_libexec_dir (const char *default_libexec_dir)
char * br_find_locale_dir (const char *default_locale_dir)
char * br_find_prefix (const char *default_prefix)
char * br_find_sbin_dir (const char *default_sbin_dir)
int br_init (BrInitError *error)
int br_init_lib (BrInitError *error)
char * br_strcat (const char *str1, const char *str2)

Define Documentation

#define br_build_path   pkND64590836275372_br_build_path
#define br_dirname   pkND64590836275372_br_dirname

Definition at line 52 of file binreloc.h.

Referenced by br_find_exe_dir(), and br_find_prefix().

#define br_find_bin_dir   pkND64590836275372_br_find_bin_dir

Definition at line 43 of file binreloc.h.

#define br_find_data_dir   pkND64590836275372_br_find_data_dir

Definition at line 45 of file binreloc.h.

Referenced by br_find_locale_dir().

#define br_find_etc_dir   pkND64590836275372_br_find_etc_dir

Definition at line 49 of file binreloc.h.

#define br_find_exe   pkND64590836275372_br_find_exe

Definition at line 40 of file binreloc.h.

#define br_find_exe_dir   pkND64590836275372_br_find_exe_dir

Definition at line 41 of file binreloc.h.

#define br_find_lib_dir   pkND64590836275372_br_find_lib_dir

Definition at line 47 of file binreloc.h.

#define br_find_libexec_dir   pkND64590836275372_br_find_libexec_dir

Definition at line 48 of file binreloc.h.

#define br_find_locale_dir   pkND64590836275372_br_find_locale_dir

Definition at line 46 of file binreloc.h.

#define br_find_prefix   pkND64590836275372_br_find_prefix
#define br_find_sbin_dir   pkND64590836275372_br_find_sbin_dir

Definition at line 44 of file binreloc.h.

#define br_init   pkND64590836275372_br_init

Definition at line 38 of file binreloc.h.

#define br_init_lib   pkND64590836275372_br_init_lib

Definition at line 39 of file binreloc.h.

Referenced by GWEN_Init().

#define br_strcat   pkND64590836275372_br_strcat

Definition at line 50 of file binreloc.h.

Referenced by br_build_path().


Enumeration Type Documentation

These error codes can be returned by br_init(), br_init_lib(), gbr_init() or gbr_init_lib().

Enumerator:
BR_INIT_ERROR_NOMEM 

Cannot allocate memory.

BR_INIT_ERROR_OPEN_MAPS 

Unable to open /proc/self/maps; see errno for details.

BR_INIT_ERROR_READ_MAPS 

Unable to read from /proc/self/maps; see errno for details.

BR_INIT_ERROR_INVALID_MAPS 

The file format of /proc/self/maps is invalid; kernel bug?

BR_INIT_ERROR_DISABLED 

BinReloc is disabled (the ENABLE_BINRELOC macro is not defined).

Definition at line 22 of file binreloc.h.


Function Documentation

char* br_build_path ( const char *  dir,
const char *  file 
)

Definition at line 693 of file binreloc.c.

References br_strcat, DIRSEP, and DIRSEP_C.

char* br_dirname ( const char *  path)

Extracts the directory component of a path.

Similar to g_dirname() or the dirname commandline application.

Example:

 br_dirname ("/usr/local/foobar");  --> Returns: "/usr/local"
Parameters:
pathA path.
Returns:
A directory name. This string should be freed when no longer needed.

Definition at line 749 of file binreloc.c.

References br_strndup(), DIRSEP, DIRSEP_C, and NULL.

char* br_find_bin_dir ( const char *  default_bin_dir)

Locate the application's binary folder.

The path is generated by the following pseudo-code evaluation:

 prefix + "/bin"
Parameters:
default_bin_dirA default path which will used as fallback.
Returns:
A string containing the bin folder's path, which must be freed when no longer necessary. If BinReloc is not initialized, or if the initialization function failed, then a copy of default_bin_dir will be returned. If default_bin_dir is NULL, then NULL will be returned.

Definition at line 441 of file binreloc.c.

References br_build_path, br_find_prefix, and NULL.

char* br_find_data_dir ( const char *  default_data_dir)

Locate the application's data folder.

The path is generated by the following pseudo-code evaluation:

 prefix + "/share"
Parameters:
default_data_dirA default path which will used as fallback.
Returns:
A string containing the data folder's path, which must be freed when no longer necessary. If BinReloc is not initialized, or if the initialization function failed, then a copy of default_data_dir will be returned. If default_data_dir is NULL, then NULL will be returned.

Definition at line 508 of file binreloc.c.

References br_build_path, br_find_prefix, and NULL.

char* br_find_etc_dir ( const char *  default_etc_dir)

Locate the application's configuration files folder.

The path is generated by the following pseudo-code evaluation:

 prefix + "/etc"
Parameters:
default_etc_dirA default path which will used as fallback.
Returns:
A string containing the etc folder's path, which must be freed when no longer necessary. If BinReloc is not initialized, or if the initialization function failed, then a copy of default_etc_dir will be returned. If default_etc_dir is NULL, then NULL will be returned.

Definition at line 640 of file binreloc.c.

References br_build_path, br_find_prefix, and NULL.

char* br_find_exe ( const char *  default_exe)

Find the canonical filename of the current application.

Parameters:
default_exeA default filename which will be used as fallback.
Returns:
A string containing the application's canonical filename, which must be freed when no longer necessary. If BinReloc is not initialized, or if br_init() failed, then a copy of default_exe will be returned. If default_exe is NULL, then NULL will be returned.

Definition at line 352 of file binreloc.c.

References NULL.

char* br_find_exe_dir ( const char *  default_dir)

Locate the directory in which the current application is installed.

The prefix is generated by the following pseudo-code evaluation:

 dirname(exename)
Parameters:
default_dirA default directory which will used as fallback.
Returns:
A string containing the directory, which must be freed when no longer necessary. If BinReloc is not initialized, or if the initialization function failed, then a copy of default_dir will be returned. If default_dir is NULL, then NULL will be returned.

Definition at line 380 of file binreloc.c.

References br_dirname, and NULL.

char* br_find_lib_dir ( const char *  default_lib_dir)

Locate the application's library folder.

The path is generated by the following pseudo-code evaluation:

 prefix + "/lib"
Parameters:
default_lib_dirA default path which will used as fallback.
Returns:
A string containing the library folder's path, which must be freed when no longer necessary. If BinReloc is not initialized, or if the initialization function failed, then a copy of default_lib_dir will be returned. If default_lib_dir is NULL, then NULL will be returned.

Definition at line 574 of file binreloc.c.

References br_build_path, br_find_prefix, and NULL.

char* br_find_libexec_dir ( const char *  default_libexec_dir)

Locate the application's libexec folder.

The path is generated by the following pseudo-code evaluation:

 prefix + "/libexec"
Parameters:
default_libexec_dirA default path which will used as fallback.
Returns:
A string containing the libexec folder's path, which must be freed when no longer necessary. If BinReloc is not initialized, or if the initialization function failed, then a copy of default_libexec_dir will be returned. If default_libexec_dir is NULL, then NULL will be returned.

Definition at line 607 of file binreloc.c.

References br_build_path, br_find_prefix, and NULL.

char* br_find_locale_dir ( const char *  default_locale_dir)

Locate the application's localization folder.

The path is generated by the following pseudo-code evaluation:

 prefix + "/share/locale"
Parameters:
default_locale_dirA default path which will used as fallback.
Returns:
A string containing the localization folder's path, which must be freed when no longer necessary. If BinReloc is not initialized, or if the initialization function failed, then a copy of default_locale_dir will be returned. If default_locale_dir is NULL, then NULL will be returned.

Definition at line 541 of file binreloc.c.

References br_build_path, br_find_data_dir, and NULL.

char* br_find_prefix ( const char *  default_prefix)

Locate the prefix in which the current application is installed.

The prefix is generated by the following pseudo-code evaluation:

 dirname(dirname(exename))
Parameters:
default_prefixA default prefix which will used as fallback.
Returns:
A string containing the prefix, which must be freed when no longer necessary. If BinReloc is not initialized, or if the initialization function failed, then a copy of default_prefix will be returned. If default_prefix is NULL, then NULL will be returned.

Definition at line 408 of file binreloc.c.

References br_dirname, and NULL.

char* br_find_sbin_dir ( const char *  default_sbin_dir)

Locate the application's superuser binary folder.

The path is generated by the following pseudo-code evaluation:

 prefix + "/sbin"
Parameters:
default_sbin_dirA default path which will used as fallback.
Returns:
A string containing the sbin folder's path, which must be freed when no longer necessary. If BinReloc is not initialized, or if the initialization function failed, then a copy of default_sbin_dir will be returned. If default_bin_dir is NULL, then NULL will be returned.

Definition at line 474 of file binreloc.c.

References br_build_path, br_find_prefix, and NULL.

int br_init ( BrInitError error)

Initialize the BinReloc library (for applications).

This function must be called before using any other BinReloc functions. It attempts to locate the application's canonical filename.

Note:
If you want to use BinReloc for a library, then you should call br_init_lib() instead.
Parameters:
errorIf BinReloc failed to initialize, then the error code will be stored in this variable. Set to NULL if you want to ignore this. See BrInitError for a list of error codes.
Returns:
1 on success, 0 if BinReloc failed to initialize.

Definition at line 313 of file binreloc.c.

References _br_find_exe(), and NULL.

int br_init_lib ( BrInitError error)

Initialize the BinReloc library (for libraries).

This function must be called before using any other BinReloc functions. It attempts to locate the calling library's canonical filename.

Note:
The BinReloc source code MUST be included in your library, or this function won't work correctly.
Parameters:
errorIf BinReloc failed to initialize, then the error code will be stored in this variable. Set to NULL if you want to ignore this. See BrInitError for a list of error codes.
Returns:
1 on success, 0 if a filename cannot be found.

Definition at line 335 of file binreloc.c.

References _br_find_exe_for_symbol(), and NULL.

char* br_strcat ( const char *  str1,
const char *  str2 
)

Concatenate str1 and str2 to a newly allocated string.

Parameters:
str1A string.
str2Another string.
Returns:
A newly-allocated string. This string should be freed when no longer needed.

Definition at line 670 of file binreloc.c.

References NULL.