|
|
@ -18,6 +18,7 @@
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif /* ENABLE_BINRELOC */
|
|
|
|
#endif /* ENABLE_BINRELOC */
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <limits.h>
|
|
|
@ -29,7 +30,6 @@ extern "C" {
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @internal
|
|
|
|
/** @internal
|
|
|
|
* Find the canonical filename of the executable. Returns the filename
|
|
|
|
* Find the canonical filename of the executable. Returns the filename
|
|
|
|
* (which must be freed) or NULL on error. If the parameter 'error' is
|
|
|
|
* (which must be freed) or NULL on error. If the parameter 'error' is
|
|
|
@ -342,7 +342,8 @@ br_init_lib (BrInitError *error)
|
|
|
|
char *
|
|
|
|
char *
|
|
|
|
br_find_exe(const char *default_exe)
|
|
|
|
br_find_exe(const char *default_exe)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (exe == (char *) NULL) {
|
|
|
|
if (exe == (char *) NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
/* BinReloc is not initialized. */
|
|
|
|
/* BinReloc is not initialized. */
|
|
|
|
if (default_exe != (const char *) NULL)
|
|
|
|
if (default_exe != (const char *) NULL)
|
|
|
|
return strdup(default_exe);
|
|
|
|
return strdup(default_exe);
|
|
|
@ -370,7 +371,8 @@ br_find_exe (const char *default_exe)
|
|
|
|
char *
|
|
|
|
char *
|
|
|
|
br_find_exe_dir(const char *default_dir)
|
|
|
|
br_find_exe_dir(const char *default_dir)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (exe == NULL) {
|
|
|
|
if (exe == NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
/* BinReloc not initialized. */
|
|
|
|
/* BinReloc not initialized. */
|
|
|
|
if (default_dir != NULL)
|
|
|
|
if (default_dir != NULL)
|
|
|
|
return strdup(default_dir);
|
|
|
|
return strdup(default_dir);
|
|
|
@ -400,7 +402,8 @@ br_find_prefix (const char *default_prefix)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char *dir1, *dir2;
|
|
|
|
char *dir1, *dir2;
|
|
|
|
|
|
|
|
|
|
|
|
if (exe == (char *) NULL) {
|
|
|
|
if (exe == (char *) NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
/* BinReloc not initialized. */
|
|
|
|
/* BinReloc not initialized. */
|
|
|
|
if (default_prefix != (const char *) NULL)
|
|
|
|
if (default_prefix != (const char *) NULL)
|
|
|
|
return strdup(default_prefix);
|
|
|
|
return strdup(default_prefix);
|
|
|
@ -434,7 +437,8 @@ br_find_bin_dir (const char *default_bin_dir)
|
|
|
|
char *prefix, *dir;
|
|
|
|
char *prefix, *dir;
|
|
|
|
|
|
|
|
|
|
|
|
prefix = br_find_prefix((const char *) NULL);
|
|
|
|
prefix = br_find_prefix((const char *) NULL);
|
|
|
|
if (prefix == (char *) NULL) {
|
|
|
|
if (prefix == (char *) NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
/* BinReloc not initialized. */
|
|
|
|
/* BinReloc not initialized. */
|
|
|
|
if (default_bin_dir != (const char *) NULL)
|
|
|
|
if (default_bin_dir != (const char *) NULL)
|
|
|
|
return strdup(default_bin_dir);
|
|
|
|
return strdup(default_bin_dir);
|
|
|
@ -467,7 +471,8 @@ br_find_sbin_dir (const char *default_sbin_dir)
|
|
|
|
char *prefix, *dir;
|
|
|
|
char *prefix, *dir;
|
|
|
|
|
|
|
|
|
|
|
|
prefix = br_find_prefix((const char *) NULL);
|
|
|
|
prefix = br_find_prefix((const char *) NULL);
|
|
|
|
if (prefix == (char *) NULL) {
|
|
|
|
if (prefix == (char *) NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
/* BinReloc not initialized. */
|
|
|
|
/* BinReloc not initialized. */
|
|
|
|
if (default_sbin_dir != (const char *) NULL)
|
|
|
|
if (default_sbin_dir != (const char *) NULL)
|
|
|
|
return strdup(default_sbin_dir);
|
|
|
|
return strdup(default_sbin_dir);
|
|
|
@ -501,7 +506,8 @@ br_find_data_dir (const char *default_data_dir)
|
|
|
|
char *prefix, *dir;
|
|
|
|
char *prefix, *dir;
|
|
|
|
|
|
|
|
|
|
|
|
prefix = br_find_prefix((const char *) NULL);
|
|
|
|
prefix = br_find_prefix((const char *) NULL);
|
|
|
|
if (prefix == (char *) NULL) {
|
|
|
|
if (prefix == (char *) NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
/* BinReloc not initialized. */
|
|
|
|
/* BinReloc not initialized. */
|
|
|
|
if (default_data_dir != (const char *) NULL)
|
|
|
|
if (default_data_dir != (const char *) NULL)
|
|
|
|
return strdup(default_data_dir);
|
|
|
|
return strdup(default_data_dir);
|
|
|
@ -534,7 +540,8 @@ br_find_locale_dir (const char *default_locale_dir)
|
|
|
|
char *data_dir, *dir;
|
|
|
|
char *data_dir, *dir;
|
|
|
|
|
|
|
|
|
|
|
|
data_dir = br_find_data_dir((const char *) NULL);
|
|
|
|
data_dir = br_find_data_dir((const char *) NULL);
|
|
|
|
if (data_dir == (char *) NULL) {
|
|
|
|
if (data_dir == (char *) NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
/* BinReloc not initialized. */
|
|
|
|
/* BinReloc not initialized. */
|
|
|
|
if (default_locale_dir != (const char *) NULL)
|
|
|
|
if (default_locale_dir != (const char *) NULL)
|
|
|
|
return strdup(default_locale_dir);
|
|
|
|
return strdup(default_locale_dir);
|
|
|
@ -567,7 +574,8 @@ br_find_lib_dir (const char *default_lib_dir)
|
|
|
|
char *prefix, *dir;
|
|
|
|
char *prefix, *dir;
|
|
|
|
|
|
|
|
|
|
|
|
prefix = br_find_prefix((const char *) NULL);
|
|
|
|
prefix = br_find_prefix((const char *) NULL);
|
|
|
|
if (prefix == (char *) NULL) {
|
|
|
|
if (prefix == (char *) NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
/* BinReloc not initialized. */
|
|
|
|
/* BinReloc not initialized. */
|
|
|
|
if (default_lib_dir != (const char *) NULL)
|
|
|
|
if (default_lib_dir != (const char *) NULL)
|
|
|
|
return strdup(default_lib_dir);
|
|
|
|
return strdup(default_lib_dir);
|
|
|
@ -600,7 +608,8 @@ br_find_libexec_dir (const char *default_libexec_dir)
|
|
|
|
char *prefix, *dir;
|
|
|
|
char *prefix, *dir;
|
|
|
|
|
|
|
|
|
|
|
|
prefix = br_find_prefix((const char *) NULL);
|
|
|
|
prefix = br_find_prefix((const char *) NULL);
|
|
|
|
if (prefix == (char *) NULL) {
|
|
|
|
if (prefix == (char *) NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
/* BinReloc not initialized. */
|
|
|
|
/* BinReloc not initialized. */
|
|
|
|
if (default_libexec_dir != (const char *) NULL)
|
|
|
|
if (default_libexec_dir != (const char *) NULL)
|
|
|
|
return strdup(default_libexec_dir);
|
|
|
|
return strdup(default_libexec_dir);
|
|
|
@ -633,7 +642,8 @@ br_find_etc_dir (const char *default_etc_dir)
|
|
|
|
char *prefix, *dir;
|
|
|
|
char *prefix, *dir;
|
|
|
|
|
|
|
|
|
|
|
|
prefix = br_find_prefix((const char *) NULL);
|
|
|
|
prefix = br_find_prefix((const char *) NULL);
|
|
|
|
if (prefix == (char *) NULL) {
|
|
|
|
if (prefix == (char *) NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
/* BinReloc not initialized. */
|
|
|
|
/* BinReloc not initialized. */
|
|
|
|
if (default_etc_dir != (const char *) NULL)
|
|
|
|
if (default_etc_dir != (const char *) NULL)
|
|
|
|
return strdup(default_etc_dir);
|
|
|
|
return strdup(default_etc_dir);
|
|
|
@ -688,7 +698,8 @@ br_build_path (const char *dir, const char *file)
|
|
|
|
int must_free = 0;
|
|
|
|
int must_free = 0;
|
|
|
|
|
|
|
|
|
|
|
|
len = strlen(dir);
|
|
|
|
len = strlen(dir);
|
|
|
|
if (len > 0 && dir[len - 1] != '/') {
|
|
|
|
if (len > 0 && dir[len - 1] != '/')
|
|
|
|
|
|
|
|
{
|
|
|
|
dir2 = br_strcat(dir, "/");
|
|
|
|
dir2 = br_strcat(dir, "/");
|
|
|
|
must_free = 1;
|
|
|
|
must_free = 1;
|
|
|
|
} else
|
|
|
|
} else
|
|
|
@ -751,7 +762,8 @@ br_dirname (const char *path)
|
|
|
|
while (end > path && *end == '/')
|
|
|
|
while (end > path && *end == '/')
|
|
|
|
end--;
|
|
|
|
end--;
|
|
|
|
result = br_strndup(path, end - path + 1);
|
|
|
|
result = br_strndup(path, end - path + 1);
|
|
|
|
if (result[0] == 0) {
|
|
|
|
if (result[0] == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
free(result);
|
|
|
|
free(result);
|
|
|
|
return strdup("/");
|
|
|
|
return strdup("/");
|
|
|
|
} else
|
|
|
|
} else
|
|
|
|