Mercurial > pidgin
changeset 10251:645eb9804040
[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 <tailor@pidgin.im>
author | Tim Ringenbach <marv@pidgin.im> |
---|---|
date | Tue, 23 Nov 2004 20:25:22 +0000 |
parents | 89a25444401c |
children | 5ce83aad6869 |
files | src/prefix.c src/prefix.h |
diffstat | 2 files changed, 28 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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 <unistd.h> +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)) {
--- 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