#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>
#include "binreloc.h"
Go to the source code of this file.
Defines | |
#define | DIRSEP "/" |
#define | DIRSEP_C '/' |
#define | NULL ((void *) 0) |
Functions | |
static char * | _br_find_exe (BrInitError *error) |
static char * | _br_find_exe_for_symbol (const void *symbol, BrInitError *error) |
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) |
static char * | br_strndup (const char *str, size_t size) |
Variables | |
static char * | exe = (char *) NULL |
#define DIRSEP "/" |
Definition at line 38 of file binreloc.c.
Referenced by br_build_path(), and br_dirname().
#define DIRSEP_C '/' |
Definition at line 39 of file binreloc.c.
Referenced by _br_find_exe(), br_build_path(), and br_dirname().
#define NULL ((void *) 0) |
Definition at line 292 of file binreloc.c.
Referenced by _br_find_exe(), _br_find_exe_for_symbol(), _encode(), FOX16_HtmlCtx::_getFoxFont(), _gwenGuiSignalHandler(), br_dirname(), br_find_bin_dir(), br_find_data_dir(), br_find_etc_dir(), br_find_exe(), br_find_exe_dir(), br_find_lib_dir(), br_find_libexec_dir(), br_find_locale_dir(), br_find_prefix(), br_find_sbin_dir(), br_strcat(), br_strndup(), QT4_GuiDialog::closeDialog(), COCOA_Gui_CloseDialog(), Cocoa_Gui_Dialog_Run(), COCOA_Gui_OpenDialog(), CocoaGui_Dialog_Setup(), QT4_GuiDialog::execute(), QT4_Gui::extractHtml(), Qt4_W_ListBox::getCharProperty(), FOX16_HtmlText::getContentHeight(), FOX16_HtmlText::getContentWidth(), CppGui::getCppGui(), FOX16_HtmlLabel::getDefaultHeight(), FOX16_HtmlLabel::getDefaultWidth(), FOX16_Gui::getFileName(), FOX16_Gui::getHtmlText(), FOX16_GuiDialog::getIcon(), FOX16_HtmlCtx::getImage(), FOX16_GuiDialog::getIntProperty(), CppGui::getPassword(), FOX16_Gui::getRawText(), FOX16_HtmlCtx::getTextHeight(), FOX16_HtmlCtx::getTextWidth(), GTK2_Gui_CloseDialog(), GTK2_Gui_Dialog_Run(), GTK2_Gui_GetFileName(), GTK2_Gui_OpenDialog(), Gtk2Gui_Dialog_Setup(), Gtk2Gui_GetRawText(), Gtk2Gui_WComboBox_GetIntProperty(), Gtk2Gui_WComboBox_Setup(), Gtk2Gui_WListBox_GetCharProperty(), Gtk2Gui_WListBox_GetIntProperty(), Gtk2Gui_WListBox_SetCharProperty(), Gtk2Gui_WListBox_SetIntProperty(), Gtk2Gui_WListBox_Setup(), Gtk2Gui_WRadioButton_Setup(), Gtk2Gui_WScrollArea_Setup(), Gtk2Gui_WStack_AddChildGuiWidget(), Gtk2Gui_WTabBook_AddChildGuiWidget(), Gtk2Gui_WTextBrowser_Setup(), GWEN_Buffer_AllocRoom(), GWEN_ConfigMgr_Factory(), GWEN_Crypt_CryptAlgo_dup(), GWEN_Crypt_CryptAlgo_fromDb(), GWEN_Crypt_CryptAlgo_SetInitVector(), GWEN_Crypt_HashAlgo_dup(), GWEN_Crypt_HashAlgo_fromDb(), GWEN_Crypt_HashAlgo_SetInitVector(), GWEN_Crypt_Key_dup(), GWEN_Crypt_Key_fromDb(), GWEN_Crypt_KeyAes128_SetIV(), GWEN_Crypt_KeyDes3K_SetIV(), GWEN_Crypt_KeyRsa__ReadMpi(), GWEN_Crypt_KeyRsa_dup(), GWEN_Crypt_KeyRsa_fromDb(), GWEN_Crypt_KeyRsa_fromModExp(), GWEN_Crypt_KeyRsa_fromModPrivExp(), GWEN_Crypt_KeySym__fromDb(), GWEN_Crypt_KeySym_fromData(), GWEN_Crypt_KeySym_fromDb(), GWEN_Crypt_PaddAlgo_fromDb(), GWEN_Crypt_Token_Context_ReadDb(), GWEN_Crypt_Token_Context_ReadXml(), GWEN_Crypt_Token_PluginManager_CheckToken(), GWEN_Crypt_TokenFile__ActivateKey(), GWEN_Crypt_TokenFile__Decipher(), GWEN_Crypt_TokenFile__Encipher(), GWEN_Crypt_TokenFile__GenerateKey(), GWEN_Crypt_TokenFile__GetContext(), GWEN_Crypt_TokenFile__GetContextIdList(), GWEN_Crypt_TokenFile__GetKey(), GWEN_Crypt_TokenFile__GetKeyIdList(), GWEN_Crypt_TokenFile__GetKeyInfo(), GWEN_Crypt_TokenFile__SetContext(), GWEN_Crypt_TokenFile__SetKeyInfo(), GWEN_Crypt_TokenFile__Sign(), GWEN_Crypt_TokenFile__Verify(), GWEN_CryptHead_fromBuffer(), GWEN_CryptMgr_Decrypt(), GWEN_CryptMgr_Encrypt(), GWEN_CryptMgr_Verify(), GWEN_CryptMgrKeys_DecryptKey(), GWEN_CryptMgrKeys_EncryptKey(), GWEN_CryptMgrKeys_SignData(), GWEN_CryptMgrKeys_VerifyData(), GWEN_Date_fromStringWithTemplate(), GWEN_DB__ReadValues(), GWEN_DB_Node_Append_UnDirty(), GWEN_DB_Node_InsertUnDirty(), GWEN_DB_ReadFromFastBuffer(), GWEN_Dialog__ReadXmlWidget(), GWEN_Dialog_AddSubDialog(), GWEN_Dialog_FindWidgetByName(), GWEN_Dialog_new(), GWEN_Dialog_ReadXml(), GWEN_Dialog_ReadXmlFile(), GWEN_Directory_GetAbsoluteFolderPath(), GWEN_Directory_GetAllEntries(), GWEN_Directory_GetDirEntries(), GWEN_Directory_GetFileEntries(), GWEN_Directory_GetFileEntriesWithType(), GWEN_Directory_GetMatchingFilesRecursively(), GWEN_DlgInput_CheckInput(), GWEN_DlgInput_Fini(), GWEN_Gui_CGui_GetPassword(), GWEN_Gui_CGui_SetPasswordStatus(), GWEN_Gui_Internal_CheckShow(), GWEN_Gui_Internal_GetSyncIo(), GWEN_Gui_Internal_InputBox(), GWEN_Gui_Internal_MessageBox(), GWEN_Gui_Internal_ProgressAdvance(), GWEN_Gui_Internal_ProgressEnd(), GWEN_Gui_Internal_ProgressLog(), GWEN_Gui_Internal_ProgressSetTotal(), GWEN_Gui_Internal_ProgressStart(), GWEN_Gui_Internal_ShowBox(), GWEN_Gui_ShowError(), GWEN_Gui_ShowProgress(), GWEN_Gui_WaitForSockets(), GWEN_I18N_BindTextDomain_Codeset(), GWEN_I18N_BindTextDomain_Dir(), GWEN_I18N_SetLocale(), GWEN_IdList64_AddId(), GWEN_IdList64_AddTable(), GWEN_IdList64_AppendId(), GWEN_IdList64_GetIdAt(), GWEN_MDigest__HashFileTree(), GWEN_MDigest_HashFileTree(), GWEN_MemCache__MakeRoom(), GWEN_PluginDescription_new(), GWEN_PluginManager_GetPluginDescrs(), GWEN_PluginManager_LoadPlugin(), GWEN_Sar_ScanFile(), GWEN_Sar_SignArchive(), GWEN_Sar_UnpackArchive(), GWEN_Sar_VerifyArchive(), GWEN_SigHead_fromBuffer(), GWEN_SigTail_fromBuffer(), GWEN_SyncIo_Buffered_Read(), GWEN_SyncIo_Http_Read(), GWEN_SyncIo_Http_RecvBody(), GWEN_SyncIo_Http_RecvBodyToSio(), GWEN_SyncIo_Http_SetWriteIdle(), GWEN_SyncIo_Memory_fromBuffer(), GWEN_SyncIo_Memory_new(), GWEN_SyncIo_Memory_Read(), GWEN_SyncIo_Memory_TakeBuffer(), GWEN_SyncIo_Memory_Write(), GWEN_SyncIo_Socket_new(), GWEN_SyncIo_Socket_Read(), GWEN_SyncIo_Socket_TakeOver(), GWEN_SyncIo_Socket_Write(), GWEN_SyncIo_Tls__readFile(), GWEN_SyncIo_Tls_GetPeerCert(), GWEN_Text_DoubleToBuffer(), GWEN_Text_StringToDouble(), GWEN_Time__fromString(), GWEN_Tree_InsertChild(), GWEN_Widget_ReadXml(), GWEN_XML__ReadTag(), GWEN_XmlCtxStore_AddAttr(), GWEN_XmlCtxStore_AddData(), GWEN_XmlCtxStore_EndTag(), GWEN_XmlCtxStore_StartTag(), GWEN_XMLGL__SampleNameSpaces(), GWEN_XMLNode_toBuffer(), GWEN_XMLNode_WriteFile(), HtmlCtx_EndTag(), HtmlCtx_Layout(), HtmlCtx_new(), HtmlCtx_SetStandardProps(), HtmlCtx_SetText(), HtmlGroup_Box_StartTag(), HtmlGroup_new(), FOX16_HtmlText::layout(), FOX16_HtmlLabel::layout(), FOX16_GuiDialog::onSelChanged(), FOX16_GuiDialog::onSelCommand(), FOX16_GuiDialog::onSelKeyPress(), FOX16_GuiDialog::onSelKeyRelease(), QT4_GuiDialog::openDialog(), QT4_GuiDialog::runDialog(), FOX16_GuiDialog::setCharProperty(), Qt4_W_ListBox::setIntProperty(), FOX16_GuiDialog::setIntProperty(), CppGui::setPasswordStatus(), QT4_GuiDialog::setup(), FOX16_GuiDialog::setup(), QT4_GuiDialog::setupTree(), FOX16_GuiDialog::setupTree(), QT4_DialogBox::slotActivated(), QT4_DialogBox::slotValueChanged(), test1(), test3(), test8(), test9(), test_gui(), ThemeComboBox::ThemeComboBox(), and FOX16_GuiDialog::RadioButtonGroup::~RadioButtonGroup().
static char* _br_find_exe | ( | BrInitError * | error | ) | [static] |
For internal use only.
Find the canonical filename of the executable. Returns the filename (which must be freed) or NULL on error. If the parameter 'error' is not NULL, the error code will be stored there, if an error occured.
Definition at line 48 of file binreloc.c.
References DIRSEP_C, and NULL.
Referenced by br_init().
static char* _br_find_exe_for_symbol | ( | const void * | symbol, | |
BrInitError * | error | |||
) | [static] |
For internal use only.
Find the canonical filename of the executable which owns symbol. Returns a filename which must be freed, or NULL on error.
Definition at line 187 of file binreloc.c.
References NULL.
Referenced by br_init_lib().
char* br_build_path | ( | const char * | dir, | |
const char * | file | |||
) |
Definition at line 693 of file binreloc.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"
path | A path. |
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"
default_bin_dir | A default path which will used as fallback. |
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"
default_data_dir | A default path which will used as fallback. |
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"
default_etc_dir | A default path which will used as fallback. |
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.
default_exe | A default filename which will be used as fallback. |
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)
default_dir | A default directory which will used as fallback. |
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"
default_lib_dir | A default path which will used as fallback. |
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"
default_libexec_dir | A default path which will used as fallback. |
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"
default_locale_dir | A default path which will used as fallback. |
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))
default_prefix | A default prefix which will used as fallback. |
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"
default_sbin_dir | A default path which will used as fallback. |
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.
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 313 of file binreloc.c.
References _br_find_exe().
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 335 of file binreloc.c.
References _br_find_exe_for_symbol().
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 670 of file binreloc.c.
References NULL.
static char* br_strndup | ( | const char * | str, | |
size_t | size | |||
) | [static] |
char* exe = (char *) NULL [static] |
Definition at line 295 of file binreloc.c.