This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Defines | |
#define | br_init OllY25605934475341_br_init |
#define | br_init_lib OllY25605934475341_br_init_lib |
#define | br_find_exe OllY25605934475341_br_find_exe |
#define | br_find_exe_dir OllY25605934475341_br_find_exe_dir |
#define | br_find_prefix OllY25605934475341_br_find_prefix |
#define | br_find_bin_dir OllY25605934475341_br_find_bin_dir |
#define | br_find_sbin_dir OllY25605934475341_br_find_sbin_dir |
#define | br_find_data_dir OllY25605934475341_br_find_data_dir |
#define | br_find_locale_dir OllY25605934475341_br_find_locale_dir |
#define | br_find_lib_dir OllY25605934475341_br_find_lib_dir |
#define | br_find_libexec_dir OllY25605934475341_br_find_libexec_dir |
#define | br_find_etc_dir OllY25605934475341_br_find_etc_dir |
#define | br_strcat OllY25605934475341_br_strcat |
#define | br_build_path OllY25605934475341_br_build_path |
#define | br_dirname OllY25605934475341_br_dirname |
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 | |
int | br_init (BrInitError *error) |
int | br_init_lib (BrInitError *error) |
char * | br_find_exe (const char *default_exe) |
char * | br_find_exe_dir (const char *default_dir) |
char * | br_find_prefix (const char *default_prefix) |
char * | br_find_bin_dir (const char *default_bin_dir) |
char * | br_find_sbin_dir (const char *default_sbin_dir) |
char * | br_find_data_dir (const char *default_data_dir) |
char * | br_find_locale_dir (const char *default_locale_dir) |
char * | br_find_lib_dir (const char *default_lib_dir) |
char * | br_find_libexec_dir (const char *default_libexec_dir) |
char * | br_find_etc_dir (const char *default_etc_dir) |
char * | br_strcat (const char *str1, const char *str2) |
char * | br_build_path (const char *dir, const char *file) |
char * | br_dirname (const char *path) |
#define br_build_path OllY25605934475341_br_build_path |
Definition at line 51 of file binreloc.h.
#define br_dirname OllY25605934475341_br_dirname |
Definition at line 52 of file binreloc.h.
#define br_find_bin_dir OllY25605934475341_br_find_bin_dir |
Definition at line 43 of file binreloc.h.
#define br_find_data_dir OllY25605934475341_br_find_data_dir |
Definition at line 45 of file binreloc.h.
#define br_find_etc_dir OllY25605934475341_br_find_etc_dir |
Definition at line 49 of file binreloc.h.
#define br_find_exe OllY25605934475341_br_find_exe |
Definition at line 40 of file binreloc.h.
#define br_find_exe_dir OllY25605934475341_br_find_exe_dir |
Definition at line 41 of file binreloc.h.
#define br_find_lib_dir OllY25605934475341_br_find_lib_dir |
Definition at line 47 of file binreloc.h.
#define br_find_libexec_dir OllY25605934475341_br_find_libexec_dir |
Definition at line 48 of file binreloc.h.
#define br_find_locale_dir OllY25605934475341_br_find_locale_dir |
Definition at line 46 of file binreloc.h.
#define br_find_prefix OllY25605934475341_br_find_prefix |
Definition at line 42 of file binreloc.h.
#define br_find_sbin_dir OllY25605934475341_br_find_sbin_dir |
Definition at line 44 of file binreloc.h.
#define br_init OllY25605934475341_br_init |
Definition at line 38 of file binreloc.h.
#define br_init_lib OllY25605934475341_br_init_lib |
Definition at line 39 of file binreloc.h.
#define br_strcat OllY25605934475341_br_strcat |
Definition at line 50 of file binreloc.h.
enum BrInitError |
These error codes can be returned by br_init(), br_init_lib(), gbr_init() or gbr_init_lib().
Definition at line 22 of file binreloc.h.
00022 { 00024 BR_INIT_ERROR_NOMEM, 00026 BR_INIT_ERROR_OPEN_MAPS, 00028 BR_INIT_ERROR_READ_MAPS, 00030 BR_INIT_ERROR_INVALID_MAPS, 00032 BR_INIT_ERROR_DISABLED 00033 } BrInitError;
char* br_build_path | ( | const char * | dir, | |
const char * | file | |||
) |
Definition at line 684 of file binreloc.c.
00685 { 00686 char *dir2, *result; 00687 size_t len; 00688 int must_free = 0; 00689 00690 len = strlen (dir); 00691 if (len > 0 && dir[len - 1] != '/') { 00692 dir2 = br_strcat (dir, "/"); 00693 must_free = 1; 00694 } else 00695 dir2 = (char *) dir; 00696 00697 result = br_strcat (dir2, file); 00698 if (must_free) 00699 free (dir2); 00700 return result; 00701 }
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"
path | A path. |
Definition at line 740 of file binreloc.c.
00741 { 00742 char *end, *result; 00743 00744 if (path == (const char *) NULL) 00745 return (char *) NULL; 00746 00747 end = strrchr (path, '/'); 00748 if (end == (const char *) NULL) 00749 return strdup ("."); 00750 00751 while (end > path && *end == '/') 00752 end--; 00753 result = br_strndup (path, end - path + 1); 00754 if (result[0] == 0) { 00755 free (result); 00756 return strdup ("/"); 00757 } else 00758 return result; 00759 }
Here is the call graph for this function:
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"
default_bin_dir | A default path which will used as fallback. |
Definition at line 432 of file binreloc.c.
00433 { 00434 char *prefix, *dir; 00435 00436 prefix = br_find_prefix ((const char *) NULL); 00437 if (prefix == (char *) NULL) { 00438 /* BinReloc not initialized. */ 00439 if (default_bin_dir != (const char *) NULL) 00440 return strdup (default_bin_dir); 00441 else 00442 return (char *) NULL; 00443 } 00444 00445 dir = br_build_path (prefix, "bin"); 00446 free (prefix); 00447 return dir; 00448 }
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"
default_data_dir | A default path which will used as fallback. |
Definition at line 499 of file binreloc.c.
00500 { 00501 char *prefix, *dir; 00502 00503 prefix = br_find_prefix ((const char *) NULL); 00504 if (prefix == (char *) NULL) { 00505 /* BinReloc not initialized. */ 00506 if (default_data_dir != (const char *) NULL) 00507 return strdup (default_data_dir); 00508 else 00509 return (char *) NULL; 00510 } 00511 00512 dir = br_build_path (prefix, "share"); 00513 free (prefix); 00514 return dir; 00515 }
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"
default_etc_dir | A default path which will used as fallback. |
Definition at line 631 of file binreloc.c.
00632 { 00633 char *prefix, *dir; 00634 00635 prefix = br_find_prefix ((const char *) NULL); 00636 if (prefix == (char *) NULL) { 00637 /* BinReloc not initialized. */ 00638 if (default_etc_dir != (const char *) NULL) 00639 return strdup (default_etc_dir); 00640 else 00641 return (char *) NULL; 00642 } 00643 00644 dir = br_build_path (prefix, "etc"); 00645 free (prefix); 00646 return dir; 00647 }
char* br_find_exe | ( | const char * | default_exe | ) |
Find the canonical filename of the current application.
default_exe | A default filename which will be used as fallback. |
Definition at line 343 of file binreloc.c.
00344 { 00345 if (exe == (char *) NULL) { 00346 /* BinReloc is not initialized. */ 00347 if (default_exe != (const char *) NULL) 00348 return strdup (default_exe); 00349 else 00350 return (char *) NULL; 00351 } 00352 return strdup (exe); 00353 }
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)
default_dir | A default directory which will used as fallback. |
Definition at line 371 of file binreloc.c.
00372 { 00373 if (exe == NULL) { 00374 /* BinReloc not initialized. */ 00375 if (default_dir != NULL) 00376 return strdup (default_dir); 00377 else 00378 return NULL; 00379 } 00380 00381 return br_dirname (exe); 00382 }
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"
default_lib_dir | A default path which will used as fallback. |
Definition at line 565 of file binreloc.c.
00566 { 00567 char *prefix, *dir; 00568 00569 prefix = br_find_prefix ((const char *) NULL); 00570 if (prefix == (char *) NULL) { 00571 /* BinReloc not initialized. */ 00572 if (default_lib_dir != (const char *) NULL) 00573 return strdup (default_lib_dir); 00574 else 00575 return (char *) NULL; 00576 } 00577 00578 dir = br_build_path (prefix, "lib"); 00579 free (prefix); 00580 return dir; 00581 }
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"
default_libexec_dir | A default path which will used as fallback. |
Definition at line 598 of file binreloc.c.
00599 { 00600 char *prefix, *dir; 00601 00602 prefix = br_find_prefix ((const char *) NULL); 00603 if (prefix == (char *) NULL) { 00604 /* BinReloc not initialized. */ 00605 if (default_libexec_dir != (const char *) NULL) 00606 return strdup (default_libexec_dir); 00607 else 00608 return (char *) NULL; 00609 } 00610 00611 dir = br_build_path (prefix, "libexec"); 00612 free (prefix); 00613 return dir; 00614 }
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"
default_locale_dir | A default path which will used as fallback. |
Definition at line 532 of file binreloc.c.
00533 { 00534 char *data_dir, *dir; 00535 00536 data_dir = br_find_data_dir ((const char *) NULL); 00537 if (data_dir == (char *) NULL) { 00538 /* BinReloc not initialized. */ 00539 if (default_locale_dir != (const char *) NULL) 00540 return strdup (default_locale_dir); 00541 else 00542 return (char *) NULL; 00543 } 00544 00545 dir = br_build_path (data_dir, "locale"); 00546 free (data_dir); 00547 return dir; 00548 }
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))
default_prefix | A default prefix which will used as fallback. |
Definition at line 399 of file binreloc.c.
00400 { 00401 char *dir1, *dir2; 00402 00403 if (exe == (char *) NULL) { 00404 /* BinReloc not initialized. */ 00405 if (default_prefix != (const char *) NULL) 00406 return strdup (default_prefix); 00407 else 00408 return (char *) NULL; 00409 } 00410 00411 dir1 = br_dirname (exe); 00412 dir2 = br_dirname (dir1); 00413 free (dir1); 00414 return dir2; 00415 }
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"
default_sbin_dir | A default path which will used as fallback. |
Definition at line 465 of file binreloc.c.
00466 { 00467 char *prefix, *dir; 00468 00469 prefix = br_find_prefix ((const char *) NULL); 00470 if (prefix == (char *) NULL) { 00471 /* BinReloc not initialized. */ 00472 if (default_sbin_dir != (const char *) NULL) 00473 return strdup (default_sbin_dir); 00474 else 00475 return (char *) NULL; 00476 } 00477 00478 dir = br_build_path (prefix, "sbin"); 00479 free (prefix); 00480 return dir; 00481 }
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.
error | If 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. |
Definition at line 304 of file binreloc.c.
00305 { 00306 exe = _br_find_exe (error); 00307 return exe != NULL; 00308 }
Here is the call graph for this function:
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.
error | If 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. |
Definition at line 326 of file binreloc.c.
00327 { 00328 exe = _br_find_exe_for_symbol ((const void *) "", error); 00329 return exe != NULL; 00330 }
Here is the call graph for this function:
char* br_strcat | ( | const char * | str1, | |
const char * | str2 | |||
) |
Concatenate str1 and str2 to a newly allocated string.
str1 | A string. | |
str2 | Another string. |
Definition at line 661 of file binreloc.c.
00662 { 00663 char *result; 00664 size_t len1, len2; 00665 00666 if (str1 == NULL) 00667 str1 = ""; 00668 if (str2 == NULL) 00669 str2 = ""; 00670 00671 len1 = strlen (str1); 00672 len2 = strlen (str2); 00673 00674 result = (char *) malloc (len1 + len2 + 1); 00675 memcpy (result, str1, len1); 00676 memcpy (result + len1, str2, len2); 00677 result[len1 + len2] = '\0'; 00678 00679 return result; 00680 }