From b772564a4eeab6d32ba9b7be9fb9beed1c12c999 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sun, 12 Sep 2004 19:37:04 +0000 Subject: update simple API git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@193 fefdeb5f-60dc-0310-8127-8f9354f1896f --- polyp/util.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'polyp/util.c') 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 #include #include +#include #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; +} -- cgit