# HG changeset patch # User Tim Ringenbach # Date 1101241522 0 # Node ID 645eb980404006235c424a8694486dc7eb94d0fd # Parent 89a25444401c9f5b0c835e55ffcea1b97af0a79d [gaim-migrate @ 11391] This lets us register a fallback function, so we can do binreloc methods 2 and 3 without messing with prefix.c. This is already in autopackage cvs. committer: Tailor Script diff -r 89a25444401c -r 645eb9804040 src/prefix.c --- a/src/prefix.c Tue Nov 23 06:37:42 2004 +0000 +++ b/src/prefix.c Tue Nov 23 20:25:22 2004 +0000 @@ -63,6 +63,25 @@ #include +static br_locate_fallback_func fallback_func = NULL; +static void *fallback_data = NULL; +/** + * br_set_fallback_function: + * func: A function to call to find the binary. + * data: User data to pass to func. + * + * Sets a function to call to find the path to the binary, in + * case "/proc/self/maps" can't be opened. The function set should + * return a string that is safe to free with free(). + */ +void +br_set_locate_fallback_func (br_locate_fallback_func func, void *data) +{ + fallback_func = func; + fallback_data = data; +} + + /** * br_locate: * symbol: A symbol that belongs to the app/library you want to locate. @@ -104,8 +123,12 @@ br_return_val_if_fail (symbol != NULL, NULL); f = fopen ("/proc/self/maps", "r"); - if (!f) - return NULL; + if (!f) { + if (fallback_func) + return fallback_func(symbol, fallback_data); + else + return NULL; + } while (!feof (f)) { diff -r 89a25444401c -r 645eb9804040 src/prefix.h --- a/src/prefix.h Tue Nov 23 06:37:42 2004 +0000 +++ b/src/prefix.h Tue Nov 23 20:25:22 2004 +0000 @@ -104,6 +104,7 @@ #define br_strcat BR_NAMESPACE(br_strcat) #define br_extract_dir BR_NAMESPACE(br_extract_dir) #define br_extract_prefix BR_NAMESPACE(br_extract_prefix) +#define br_set_locate_fallback_func BR_NAMESPACE(br_set_locate_fallback_func) #ifndef BR_NO_MACROS /* Convenience functions for concatenating paths */ @@ -124,6 +125,8 @@ char *br_strcat (const char *str1, const char *str2); char *br_extract_dir (const char *path); char *br_extract_prefix(const char *path); +typedef char *(*br_locate_fallback_func) (void *symbol, void *data); +void br_set_locate_fallback_func (br_locate_fallback_func func, void *data); #ifdef __cplusplus