annotate src/prefix.c @ 12442:8edb08af68c7

[gaim-migrate @ 14749] Inlcude .h file to clear up some warnings committer: Tailor Script <tailor@pidgin.im>
author Stu Tomlinson <stu@nosnilmot.com>
date Fri, 09 Dec 2005 12:52:45 +0000
parents 7f487c725a90
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10245
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
1 /*
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
2 * BinReloc - a library for creating relocatable executables
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
3 * Written by: Mike Hearn <mike@theoretic.com>
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
4 * Hongli Lai <h.lai@chello.nl>
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
5 * http://autopackage.org/
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
6 *
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
7 * This source code is public domain. You can relicense this code
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
8 * under whatever license you want.
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
9 *
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
10 * NOTE: if you're using C++ and are getting "undefined reference
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
11 * to br_*", try renaming prefix.c to prefix.cpp
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
12 */
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
13
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
14 /* WARNING, BEFORE YOU MODIFY PREFIX.C:
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
15 *
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
16 * If you make changes to any of the functions in prefix.c, you MUST
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
17 * change the BR_NAMESPACE macro (in prefix.h).
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
18 * This way you can avoid symbol table conflicts with other libraries
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
19 * that also happen to use BinReloc.
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
20 *
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
21 * Example:
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
22 * #define BR_NAMESPACE(funcName) foobar_ ## funcName
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
23 * --> expands br_locate to foobar_br_locate
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
24 */
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
25
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
26 #ifndef _PREFIX_C_
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
27 #define _PREFIX_C_
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
28
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
29 #ifdef HAVE_CONFIG_H
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
30 #include "config.h"
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
31 #endif
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
32
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
33 #ifndef BR_PTHREADS
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
34 /* Change 1 to 0 if you don't want pthread support */
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
35 #define BR_PTHREADS 1
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
36 #endif /* BR_PTHREADS */
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
37
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
38 #include <stdlib.h>
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
39 #include <stdio.h>
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
40 #include <limits.h>
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
41 #include <string.h>
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
42 #include "prefix.h"
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
43
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
44 #ifdef __cplusplus
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
45 extern "C" {
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
46 #endif /* __cplusplus */
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
47
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
48
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
49 #undef NULL
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
50 #define NULL ((void *) 0)
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
51
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
52 #ifdef __GNUC__
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
53 #define br_return_val_if_fail(expr,val) if (!(expr)) {fprintf (stderr, "** BinReloc (%s): assertion %s failed\n", __PRETTY_FUNCTION__, #expr); return val;}
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
54 #else
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
55 #define br_return_val_if_fail(expr,val) if (!(expr)) return val
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
56 #endif /* __GNUC__ */
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
57
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
58
10257
b98f856e2e5e [gaim-migrate @ 11398]
Tim Ringenbach <marv@pidgin.im>
parents: 10251
diff changeset
59 static br_locate_fallback_func fallback_func = NULL;
b98f856e2e5e [gaim-migrate @ 11398]
Tim Ringenbach <marv@pidgin.im>
parents: 10251
diff changeset
60 static void *fallback_data = NULL;
b98f856e2e5e [gaim-migrate @ 11398]
Tim Ringenbach <marv@pidgin.im>
parents: 10251
diff changeset
61
b98f856e2e5e [gaim-migrate @ 11398]
Tim Ringenbach <marv@pidgin.im>
parents: 10251
diff changeset
62
10245
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
63 #ifdef ENABLE_BINRELOC
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
64 #include <sys/types.h>
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
65 #include <sys/stat.h>
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
66 #include <sys/param.h>
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
67 #include <unistd.h>
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
68
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
69
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
70 /**
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
71 * br_locate:
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
72 * symbol: A symbol that belongs to the app/library you want to locate.
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
73 * Returns: A newly allocated string containing the full path of the
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
74 * app/library that func belongs to, or NULL on error. This
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
75 * string should be freed when not when no longer needed.
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
76 *
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
77 * Finds out to which application or library symbol belongs, then locate
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
78 * the full path of that application or library.
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
79 * Note that symbol cannot be a pointer to a function. That will not work.
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
80 *
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
81 * Example:
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
82 * --> main.c
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
83 * #include "prefix.h"
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
84 * #include "libfoo.h"
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
85 *
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
86 * int main (int argc, char *argv[]) {
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
87 * printf ("Full path of this app: %s\n", br_locate (&argc));
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
88 * libfoo_start ();
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
89 * return 0;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
90 * }
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
91 *
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
92 * --> libfoo.c starts here
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
93 * #include "prefix.h"
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
94 *
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
95 * void libfoo_start () {
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
96 * --> "" is a symbol that belongs to libfoo (because it's called
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
97 * --> from libfoo_start()); that's why this works.
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
98 * printf ("libfoo is located in: %s\n", br_locate (""));
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
99 * }
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
100 */
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
101 char *
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
102 br_locate (void *symbol)
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
103 {
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
104 char line[5000];
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
105 FILE *f;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
106 char *path;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
107
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
108 br_return_val_if_fail (symbol != NULL, NULL);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
109
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
110 f = fopen ("/proc/self/maps", "r");
10251
645eb9804040 [gaim-migrate @ 11391]
Tim Ringenbach <marv@pidgin.im>
parents: 10245
diff changeset
111 if (!f) {
645eb9804040 [gaim-migrate @ 11391]
Tim Ringenbach <marv@pidgin.im>
parents: 10245
diff changeset
112 if (fallback_func)
645eb9804040 [gaim-migrate @ 11391]
Tim Ringenbach <marv@pidgin.im>
parents: 10245
diff changeset
113 return fallback_func(symbol, fallback_data);
645eb9804040 [gaim-migrate @ 11391]
Tim Ringenbach <marv@pidgin.im>
parents: 10245
diff changeset
114 else
645eb9804040 [gaim-migrate @ 11391]
Tim Ringenbach <marv@pidgin.im>
parents: 10245
diff changeset
115 return NULL;
645eb9804040 [gaim-migrate @ 11391]
Tim Ringenbach <marv@pidgin.im>
parents: 10245
diff changeset
116 }
10245
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
117
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
118 while (!feof (f))
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
119 {
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
120 unsigned long start, end;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
121
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
122 if (!fgets (line, sizeof (line), f))
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
123 continue;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
124 if (!strstr (line, " r-xp ") || !strchr (line, '/'))
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
125 continue;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
126
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
127 sscanf (line, "%lx-%lx ", &start, &end);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
128 if (symbol >= (void *) start && symbol < (void *) end)
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
129 {
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
130 char *tmp;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
131 size_t len;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
132
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
133 /* Extract the filename; it is always an absolute path */
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
134 path = strchr (line, '/');
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
135
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
136 /* Get rid of the newline */
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
137 tmp = strrchr (path, '\n');
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
138 if (tmp) *tmp = 0;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
139
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
140 /* Get rid of "(deleted)" */
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
141 len = strlen (path);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
142 if (len > 10 && strcmp (path + len - 10, " (deleted)") == 0)
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
143 {
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
144 tmp = path + len - 10;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
145 *tmp = 0;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
146 }
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
147
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
148 fclose(f);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
149 return strdup (path);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
150 }
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
151 }
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
152
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
153 fclose (f);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
154 return NULL;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
155 }
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
156
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
157
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
158 /**
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
159 * br_locate_prefix:
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
160 * symbol: A symbol that belongs to the app/library you want to locate.
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
161 * Returns: A prefix. This string should be freed when no longer needed.
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
162 *
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
163 * Locates the full path of the app/library that symbol belongs to, and return
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
164 * the prefix of that path, or NULL on error.
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
165 * Note that symbol cannot be a pointer to a function. That will not work.
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
166 *
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
167 * Example:
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
168 * --> This application is located in /usr/bin/foo
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
169 * br_locate_prefix (&argc); --> returns: "/usr"
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
170 */
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
171 char *
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
172 br_locate_prefix (void *symbol)
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
173 {
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
174 char *path, *prefix;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
175
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
176 br_return_val_if_fail (symbol != NULL, NULL);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
177
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
178 path = br_locate (symbol);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
179 if (!path) return NULL;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
180
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
181 prefix = br_extract_prefix (path);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
182 free (path);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
183 return prefix;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
184 }
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
185
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
186
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
187 /**
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
188 * br_prepend_prefix:
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
189 * symbol: A symbol that belongs to the app/library you want to locate.
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
190 * path: The path that you want to prepend the prefix to.
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
191 * Returns: The new path, or NULL on error. This string should be freed when no
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
192 * longer needed.
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
193 *
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
194 * Gets the prefix of the app/library that symbol belongs to. Prepend that prefix to path.
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
195 * Note that symbol cannot be a pointer to a function. That will not work.
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
196 *
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
197 * Example:
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
198 * --> The application is /usr/bin/foo
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
199 * br_prepend_prefix (&argc, "/share/foo/data.png"); --> Returns "/usr/share/foo/data.png"
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
200 */
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
201 char *
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
202 br_prepend_prefix (void *symbol, char *path)
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
203 {
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
204 char *tmp, *newpath;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
205
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
206 br_return_val_if_fail (symbol != NULL, NULL);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
207 br_return_val_if_fail (path != NULL, NULL);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
208
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
209 tmp = br_locate_prefix (symbol);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
210 if (!tmp) return NULL;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
211
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
212 if (strcmp (tmp, "/") == 0)
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
213 newpath = strdup (path);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
214 else
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
215 newpath = br_strcat (tmp, path);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
216
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
217 /* Get rid of compiler warning ("br_prepend_prefix never used") */
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
218 if (0) br_prepend_prefix (NULL, NULL);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
219
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
220 free (tmp);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
221 return newpath;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
222 }
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
223
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
224 #endif /* ENABLE_BINRELOC */
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
225
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
226
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
227 /* Pthread stuff for thread safetiness */
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
228 #if BR_PTHREADS
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
229
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
230 #include <pthread.h>
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
231
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
232 static pthread_key_t br_thread_key;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
233 static pthread_once_t br_thread_key_once = PTHREAD_ONCE_INIT;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
234
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
235
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
236 static void
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
237 br_thread_local_store_fini ()
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
238 {
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
239 char *specific;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
240
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
241 specific = (char *) pthread_getspecific (br_thread_key);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
242 if (specific)
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
243 {
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
244 free (specific);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
245 pthread_setspecific (br_thread_key, NULL);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
246 }
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
247 pthread_key_delete (br_thread_key);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
248 br_thread_key = 0;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
249 }
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
250
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
251
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
252 static void
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
253 br_str_free (void *str)
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
254 {
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
255 if (str)
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
256 free (str);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
257 }
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
258
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
259
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
260 static void
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
261 br_thread_local_store_init ()
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
262 {
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
263 if (pthread_key_create (&br_thread_key, br_str_free) == 0)
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
264 atexit (br_thread_local_store_fini);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
265 }
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
266
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
267 #else /* BR_PTHREADS */
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
268
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
269 static char *br_last_value = (char *) NULL;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
270
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
271 static void
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
272 br_free_last_value ()
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
273 {
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
274 if (br_last_value)
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
275 free (br_last_value);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
276 }
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
277
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
278 #endif /* BR_PTHREADS */
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
279
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
280
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
281 /**
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
282 * br_thread_local_store:
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
283 * str: A dynamically allocated string.
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
284 * Returns: str. This return value must not be freed.
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
285 *
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
286 * Store str in a thread-local variable and return str. The next
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
287 * you run this function, that variable is freed too.
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
288 * This function is created so you don't have to worry about freeing
10262
7f487c725a90 [gaim-migrate @ 11406]
Tim Ringenbach <marv@pidgin.im>
parents: 10257
diff changeset
289 * strings. Just be careful about doing this sort of thing:
7f487c725a90 [gaim-migrate @ 11406]
Tim Ringenbach <marv@pidgin.im>
parents: 10257
diff changeset
290 *
7f487c725a90 [gaim-migrate @ 11406]
Tim Ringenbach <marv@pidgin.im>
parents: 10257
diff changeset
291 * some_function( BR_DATADIR("/one.png"), BR_DATADIR("/two.png") )
10245
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
292 *
10262
7f487c725a90 [gaim-migrate @ 11406]
Tim Ringenbach <marv@pidgin.im>
parents: 10257
diff changeset
293 * Examples:
10245
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
294 * char *foo;
10262
7f487c725a90 [gaim-migrate @ 11406]
Tim Ringenbach <marv@pidgin.im>
parents: 10257
diff changeset
295 * foo = br_thread_local_store (strdup ("hello")); --> foo == "hello"
7f487c725a90 [gaim-migrate @ 11406]
Tim Ringenbach <marv@pidgin.im>
parents: 10257
diff changeset
296 * foo = br_thread_local_store (strdup ("world")); --> foo == "world"; "hello" is now freed.
10245
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
297 */
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
298 const char *
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
299 br_thread_local_store (char *str)
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
300 {
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
301 #if BR_PTHREADS
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
302 char *specific;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
303
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
304 pthread_once (&br_thread_key_once, br_thread_local_store_init);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
305
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
306 specific = (char *) pthread_getspecific (br_thread_key);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
307 br_str_free (specific);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
308 pthread_setspecific (br_thread_key, str);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
309
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
310 #else /* BR_PTHREADS */
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
311 static int initialized = 0;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
312
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
313 if (!initialized)
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
314 {
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
315 atexit (br_free_last_value);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
316 initialized = 1;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
317 }
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
318
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
319 if (br_last_value)
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
320 free (br_last_value);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
321 br_last_value = str;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
322 #endif /* BR_PTHREADS */
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
323
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
324 return (const char *) str;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
325 }
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
326
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
327
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
328 /**
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
329 * br_strcat:
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
330 * str1: A string.
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
331 * str2: Another string.
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
332 * Returns: A newly-allocated string. This string should be freed when no longer needed.
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
333 *
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
334 * Concatenate str1 and str2 to a newly allocated string.
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
335 */
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
336 char *
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
337 br_strcat (const char *str1, const char *str2)
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
338 {
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
339 char *result;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
340 size_t len1, len2;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
341
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
342 if (!str1) str1 = "";
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
343 if (!str2) str2 = "";
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
344
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
345 len1 = strlen (str1);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
346 len2 = strlen (str2);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
347
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
348 result = (char *) malloc (len1 + len2 + 1);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
349 memcpy (result, str1, len1);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
350 memcpy (result + len1, str2, len2);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
351 result[len1 + len2] = '\0';
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
352
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
353 return result;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
354 }
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
355
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
356
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
357 /* Emulates glibc's strndup() */
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
358 static char *
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
359 br_strndup (char *str, size_t size)
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
360 {
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
361 char *result = (char *) NULL;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
362 size_t len;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
363
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
364 br_return_val_if_fail (str != (char *) NULL, (char *) NULL);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
365
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
366 len = strlen (str);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
367 if (!len) return strdup ("");
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
368 if (size > len) size = len;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
369
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
370 result = (char *) calloc (sizeof (char), len + 1);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
371 memcpy (result, str, size);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
372 return result;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
373 }
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
374
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
375
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
376 /**
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
377 * br_extract_dir:
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
378 * path: A path.
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
379 * Returns: A directory name. This string should be freed when no longer needed.
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
380 *
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
381 * Extracts the directory component of path. Similar to g_dirname() or the dirname
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
382 * commandline application.
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
383 *
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
384 * Example:
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
385 * br_extract_dir ("/usr/local/foobar"); --> Returns: "/usr/local"
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
386 */
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
387 char *
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
388 br_extract_dir (const char *path)
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
389 {
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
390 char *end, *result;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
391
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
392 br_return_val_if_fail (path != (char *) NULL, (char *) NULL);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
393
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
394 end = strrchr (path, '/');
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
395 if (!end) return strdup (".");
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
396
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
397 while (end > path && *end == '/')
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
398 end--;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
399 result = br_strndup ((char *) path, end - path + 1);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
400 if (!*result)
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
401 {
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
402 free (result);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
403 return strdup ("/");
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
404 } else
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
405 return result;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
406 }
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
407
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
408
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
409 /**
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
410 * br_extract_prefix:
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
411 * path: The full path of an executable or library.
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
412 * Returns: The prefix, or NULL on error. This string should be freed when no longer needed.
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
413 *
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
414 * Extracts the prefix from path. This function assumes that your executable
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
415 * or library is installed in an LSB-compatible directory structure.
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
416 *
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
417 * Example:
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
418 * br_extract_prefix ("/usr/bin/gnome-panel"); --> Returns "/usr"
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
419 * br_extract_prefix ("/usr/local/lib/libfoo.so"); --> Returns "/usr/local"
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
420 * br_extract_prefix ("/usr/local/libfoo.so"); --> Returns "/usr"
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
421 */
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
422 char *
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
423 br_extract_prefix (const char *path)
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
424 {
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
425 char *end, *tmp, *result;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
426
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
427 br_return_val_if_fail (path != (char *) NULL, (char *) NULL);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
428
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
429 if (!*path) return strdup ("/");
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
430 end = strrchr (path, '/');
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
431 if (!end) return strdup (path);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
432
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
433 tmp = br_strndup ((char *) path, end - path);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
434 if (!*tmp)
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
435 {
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
436 free (tmp);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
437 return strdup ("/");
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
438 }
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
439 end = strrchr (tmp, '/');
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
440 if (!end) return tmp;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
441
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
442 result = br_strndup (tmp, end - tmp);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
443 free (tmp);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
444
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
445 if (!*result)
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
446 {
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
447 free (result);
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
448 result = strdup ("/");
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
449 }
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
450
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
451 return result;
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
452 }
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
453
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
454
10257
b98f856e2e5e [gaim-migrate @ 11398]
Tim Ringenbach <marv@pidgin.im>
parents: 10251
diff changeset
455 /**
b98f856e2e5e [gaim-migrate @ 11398]
Tim Ringenbach <marv@pidgin.im>
parents: 10251
diff changeset
456 * br_set_fallback_function:
b98f856e2e5e [gaim-migrate @ 11398]
Tim Ringenbach <marv@pidgin.im>
parents: 10251
diff changeset
457 * func: A function to call to find the binary.
b98f856e2e5e [gaim-migrate @ 11398]
Tim Ringenbach <marv@pidgin.im>
parents: 10251
diff changeset
458 * data: User data to pass to func.
b98f856e2e5e [gaim-migrate @ 11398]
Tim Ringenbach <marv@pidgin.im>
parents: 10251
diff changeset
459 *
b98f856e2e5e [gaim-migrate @ 11398]
Tim Ringenbach <marv@pidgin.im>
parents: 10251
diff changeset
460 * Sets a function to call to find the path to the binary, in
b98f856e2e5e [gaim-migrate @ 11398]
Tim Ringenbach <marv@pidgin.im>
parents: 10251
diff changeset
461 * case "/proc/self/maps" can't be opened. The function set should
b98f856e2e5e [gaim-migrate @ 11398]
Tim Ringenbach <marv@pidgin.im>
parents: 10251
diff changeset
462 * return a string that is safe to free with free().
b98f856e2e5e [gaim-migrate @ 11398]
Tim Ringenbach <marv@pidgin.im>
parents: 10251
diff changeset
463 */
b98f856e2e5e [gaim-migrate @ 11398]
Tim Ringenbach <marv@pidgin.im>
parents: 10251
diff changeset
464 void
b98f856e2e5e [gaim-migrate @ 11398]
Tim Ringenbach <marv@pidgin.im>
parents: 10251
diff changeset
465 br_set_locate_fallback_func (br_locate_fallback_func func, void *data)
b98f856e2e5e [gaim-migrate @ 11398]
Tim Ringenbach <marv@pidgin.im>
parents: 10251
diff changeset
466 {
b98f856e2e5e [gaim-migrate @ 11398]
Tim Ringenbach <marv@pidgin.im>
parents: 10251
diff changeset
467 fallback_func = func;
b98f856e2e5e [gaim-migrate @ 11398]
Tim Ringenbach <marv@pidgin.im>
parents: 10251
diff changeset
468 fallback_data = data;
b98f856e2e5e [gaim-migrate @ 11398]
Tim Ringenbach <marv@pidgin.im>
parents: 10251
diff changeset
469 }
b98f856e2e5e [gaim-migrate @ 11398]
Tim Ringenbach <marv@pidgin.im>
parents: 10251
diff changeset
470
b98f856e2e5e [gaim-migrate @ 11398]
Tim Ringenbach <marv@pidgin.im>
parents: 10251
diff changeset
471
10245
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
472 #ifdef __cplusplus
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
473 }
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
474 #endif /* __cplusplus */
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
475
c143a3fac58d [gaim-migrate @ 11385]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
476 #endif /* _PREFIX_C */