Go to the source code of this file.
Defines | |
#define | BR_NAMESPACE(funcName) funcName |
#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) |
#define | BR_SELFPATH(suffix) SELFPATH suffix |
#define | BR_PREFIX(suffix) PREFIX suffix |
#define | BR_PREFIXDIR(suffix) BR_PREFIX suffix |
#define | BR_BINDIR(suffix) BINDIR suffix |
#define | BR_SBINDIR(suffix) SBINDIR suffix |
#define | BR_DATADIR(suffix) DATADIR suffix |
#define | BR_LIBDIR(suffix) LIBDIR suffix |
#define | BR_LIBEXECDIR(suffix) LIBEXECDIR suffix |
#define | BR_ETCDIR(suffix) ETCDIR suffix |
#define | BR_SYSCONFDIR(suffix) SYSCONFDIR suffix |
#define | BR_CONFDIR(suffix) CONFDIR suffix |
#define | BR_LOCALEDIR(suffix) LOCALEDIR suffix |
Typedefs | |
typedef char *(* | br_locate_fallback_func )(void *symbol, void *data) |
Functions | |
const char * | br_thread_local_store (char *str) |
char * | br_strcat (const char *str1, const char *str2) |
char * | br_extract_dir (const char *path) |
char * | br_extract_prefix (const char *path) |
void | br_set_locate_fallback_func (br_locate_fallback_func func, void *data) |
#define br_set_locate_fallback_func BR_NAMESPACE(br_set_locate_fallback_func) |
typedef char*(* br_locate_fallback_func)(void *symbol, void *data) |
char* br_extract_dir | ( | const char * | path | ) |
br_extract_dir: path: A path. Returns: A directory name. This string should be freed when no longer needed.
Extracts the directory component of path. Similar to g_dirname() or the dirname commandline application.
Example: br_extract_dir ("/usr/local/foobar"); --> Returns: "/usr/local"
Definition at line 390 of file prefix.c.
00390 : 00391 * br_extract_dir ("/usr/local/foobar"); --> Returns: "/usr/local" 00392 */ 00393 char * 00394 br_extract_dir (const char *path) 00395 { 00396 char *end, *result; 00397 00398 br_return_val_if_fail (path != (char *) NULL, (char *) NULL); 00399 00400 end = strrchr (path, '/'); 00401 if (!end) return strdup ("."); 00402 00403 while (end > path && *end == '/') 00404 end--; 00405 result = br_strndup ((char *) path, end - path + 1); 00406 if (!*result) 00407 { 00408 free (result); return strdup ("/");
char* br_extract_prefix | ( | const char * | path | ) |
br_extract_prefix: path: The full path of an executable or library. Returns: The prefix, or NULL on error. This string should be freed when no longer needed.
Extracts the prefix from path. This function assumes that your executable or library is installed in an LSB-compatible directory structure.
Example: br_extract_prefix ("/usr/bin/gnome-panel"); --> Returns "/usr" br_extract_prefix ("/usr/local/lib/libfoo.so"); --> Returns "/usr/local" br_extract_prefix ("/usr/local/libfoo.so"); --> Returns "/usr"
Definition at line 425 of file prefix.c.
00430 { 00431 char *end, *tmp, *result; 00432 00433 br_return_val_if_fail (path != (char *) NULL, (char *) NULL); 00434 00435 if (!*path) return strdup ("/"); 00436 end = strrchr (path, '/'); 00437 if (!end) return strdup (path); 00438 00439 tmp = br_strndup ((char *) path, end - path); 00440 if (!*tmp) 00441 { 00442 free (tmp); 00443 return strdup ("/"); 00444 } 00445 end = strrchr (tmp, '/'); 00446 if (!end) return tmp; 00447 00448 result = br_strndup (tmp, end - tmp); 00449 free (tmp); 00450 00451 if (!*result) 00452 { 00453 free (result); 00454 result = strdup ("/");
void br_set_locate_fallback_func | ( | br_locate_fallback_func | func, | |
void * | data | |||
) |
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().
Definition at line 467 of file prefix.c.
char* br_strcat | ( | const char * | str1, | |
const char * | str2 | |||
) |
br_strcat: str1: A string. str2: Another string. Returns: A newly-allocated string. This string should be freed when no longer needed.
Concatenate str1 and str2 to a newly allocated string.
Definition at line 339 of file prefix.c.
00344 { 00345 char *result; 00346 size_t len1, len2; 00347 00348 if (!str1) str1 = ""; 00349 if (!str2) str2 = ""; 00350 00351 len1 = strlen (str1); 00352 len2 = strlen (str2); 00353 00354 result = (char *) malloc (len1 + len2 + 1); 00355 memcpy (result, str1, len1); 00356 memcpy (result + len1, str2, len2);
const char* br_thread_local_store | ( | char * | str | ) |