diff options
author | Lennart Poettering <lennart@poettering.net> | 2004-09-12 19:37:04 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2004-09-12 19:37:04 +0000 |
commit | b772564a4eeab6d32ba9b7be9fb9beed1c12c999 (patch) | |
tree | f9a00e7c5d253cfdbfdc12edbfb7d31efce168f3 /polyp/util.c | |
parent | f05a4ac806d8d44ab1377ea2069abb1da7ab9d16 (diff) |
update simple API
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@193 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'polyp/util.c')
-rw-r--r-- | polyp/util.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/polyp/util.c b/polyp/util.c index 45e1b605..1dbb8697 100644 --- a/polyp/util.c +++ b/polyp/util.c @@ -39,6 +39,7 @@ #include <sys/time.h> #include <sched.h> #include <sys/resource.h> +#include <limits.h> #include "util.h" #include "xmalloc.h" @@ -322,3 +323,27 @@ int pa_fd_set_cloexec(int fd, int b) { return 0; } + +char *pa_get_binary_name(char *s, size_t l) { + char path[PATH_MAX]; + int i; + assert(s && l); + + /* This works on Linux only */ + + snprintf(path, sizeof(path), "/proc/%u/exe", (unsigned) getpid()); + if ((i = readlink(path, s, l-1)) < 0) + return NULL; + + s[i] = 0; + return s; +} + +char *pa_path_get_filename(const char *p) { + char *fn; + + if ((fn = strrchr(p, '/'))) + return fn+1; + + return (char*) p; +} |