Main Page | File List | Globals

glib-binreloc File Reference


Detailed Description

Binary relocation support (with glib-style API).

#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>
#include "glib.h"

Enumerations

enum  GbrInitError {
  GBR_INIT_ERROR_NOMEM, GBR_INIT_ERROR_OPEN_MAPS, GBR_INIT_ERROR_READ_MAPS, GBR_INIT_ERROR_INVALID_MAPS,
  GBR_INIT_ERROR_DISABLED
}

Functions

gboolean gbr_init (GError **error)
gboolean gbr_init_lib (GError **error)
gchar * gbr_find_exe (const gchar *default_exe)
gchar * gbr_find_exe_dir (const gchar *default_dir)
gchar * gbr_find_prefix (const gchar *default_prefix)
gchar * gbr_find_bin_dir (const gchar *default_bin_dir)
gchar * gbr_find_sbin_dir (const gchar *default_sbin_dir)
gchar * gbr_find_data_dir (const gchar *default_data_dir)
gchar * gbr_find_locale_dir (const gchar *default_locale_dir)
gchar * gbr_find_lib_dir (const gchar *default_lib_dir)
gchar * gbr_find_libexec_dir (const gchar *default_libexec_dir)
gchar * gbr_find_etc_dir (const gchar *default_etc_dir)


Enumeration Type Documentation

enum GbrInitError
 

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

Enumerator:
GBR_INIT_ERROR_NOMEM  Cannot allocate memory.
GBR_INIT_ERROR_OPEN_MAPS  Unable to open /proc/self/maps; see errno for details.
GBR_INIT_ERROR_READ_MAPS  Unable to read from /proc/self/maps; see errno for details.
GBR_INIT_ERROR_INVALID_MAPS  The file format of /proc/self/maps is invalid; kernel bug?
GBR_INIT_ERROR_DISABLED  BinReloc is disabled (the ENABLE_BINRELOC macro is not defined).


Function Documentation

gchar * gbr_find_bin_dir const gchar *  default_bin_dir  ) 
 

Locate the application's binary folder.

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

 prefix + "/bin"

Parameters:
default_bin_dir A 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.

gchar * gbr_find_data_dir const gchar *  default_data_dir  ) 
 

Locate the application's data folder.

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

 prefix + "/share"

Parameters:
default_data_dir A 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.

gchar * gbr_find_etc_dir const gchar *  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_dir A 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.

gchar * gbr_find_exe const gchar *  default_exe  ) 
 

Find the canonical filename of the current application.

Parameters:
default_exe A 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 the initialization function failed, then a copy of default_exe will be returned. If default_exe is NULL, then NULL will be returned.

gchar * gbr_find_exe_dir const gchar *  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_dir A 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.

gchar * gbr_find_lib_dir const gchar *  default_lib_dir  ) 
 

Locate the application's library folder.

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

 prefix + "/lib"

Parameters:
default_lib_dir A 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.

gchar * gbr_find_libexec_dir const gchar *  default_libexec_dir  ) 
 

Locate the application's libexec folder.

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

 prefix + "/libexec"

Parameters:
default_libexec_dir A 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.

gchar * gbr_find_locale_dir const gchar *  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_dir A 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.

gchar * gbr_find_prefix const gchar *  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_prefix A 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.

gchar * gbr_find_sbin_dir const gchar *  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_dir A 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.

gboolean gbr_init GError **  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 gbr_init_lib() instead.

Initialization failure is not fatal. BinReloc functions will just fallback to the supplied default path.

Parameters:
error If BinReloc failed to initialize, then the error report will be stored in this variable. Set to NULL if you don't want an error report. See the GbrInitError for a list of error codes.
Returns:
TRUE on success, FALSE if BinReloc failed to initialize.

gboolean gbr_init_lib GError **  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.

Initialization failure is not fatal. BinReloc functions will just fallback to the supplied default path.

Returns:
TRUE on success, FALSE if a filename cannot be found.


Generated on Mon Aug 22 12:49:07 2005 for BinReloc by  doxygen 1.4.4