From: Daniel Mack Date: Fri, 15 Apr 2011 17:35:25 +0000 (+0200) Subject: util: Implement pa_get_binary_name() for Mac OS X X-Git-Tag: 1.0_branch~626 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7a3b3a376308df191b19b73fe8dbe97659a1061a;p=profile%2Fivi%2Fpulseaudio.git util: Implement pa_get_binary_name() for Mac OS X --- diff --git a/src/pulse/util.c b/src/pulse/util.c index c5cfc8c..48ccf29 100644 --- a/src/pulse/util.c +++ b/src/pulse/util.c @@ -49,6 +49,11 @@ #include #endif +#ifdef OS_IS_DARWIN +#include +#include +#endif + #include #include @@ -221,6 +226,27 @@ char *pa_get_binary_name(char *s, size_t l) { } #endif +#ifdef OS_IS_DARWIN + { + int mib[] = { CTL_KERN, KERN_PROCARGS, getpid(), 0 }; + size_t len, nmib = (sizeof(mib) / sizeof(mib[0])) - 1; + char *buf; + + sysctl(mib, nmib, NULL, &len, NULL, 0); + buf = (char *) pa_xmalloc(len); + + if (sysctl(mib, nmib, buf, &len, NULL, 0) == 0) { + pa_strlcpy(s, basename(buf), l); + pa_xfree(buf); + return s; + } + + pa_xfree(buf); + + /* fall thru */ + } +#endif /* OS_IS_DARWIN */ + errno = ENOENT; return NULL; }