2eebabbd75
- replace audio(4) backend with sio_open(3) (libsndio) backend update by ajacoutot, new backend from me
69 lines
1.8 KiB
Plaintext
69 lines
1.8 KiB
Plaintext
$OpenBSD: patch-util_c,v 1.6 2008/12/20 08:58:32 jakemsr Exp $
|
|
--- util.c.orig Sun Dec 14 13:35:48 2008
|
|
+++ util.c Sun Dec 14 13:39:45 2008
|
|
@@ -1,5 +1,8 @@
|
|
#include "config.h"
|
|
#include "esd.h"
|
|
+#include <limits.h>
|
|
+#include <pwd.h>
|
|
+#include <stdio.h>
|
|
#include <sys/types.h>
|
|
#include <sys/socket.h>
|
|
#include <stdlib.h>
|
|
@@ -24,36 +27,31 @@ have_ipv6(void) {
|
|
const char*
|
|
esd_get_socket_dirname (void)
|
|
{
|
|
- const char *audiodev = NULL;
|
|
- static char *dirname = NULL;
|
|
+ static char *sockdir = NULL, sockdirbuf[PATH_MAX];
|
|
+ struct passwd *pw;
|
|
|
|
- if (dirname == NULL) {
|
|
- if ((audiodev = getenv("AUDIODEV"))) {
|
|
- char *newdev = strrchr(audiodev, '/');
|
|
- if (newdev != NULL) {
|
|
- audiodev = newdev++;
|
|
- }
|
|
- } else
|
|
- audiodev = "";
|
|
- dirname = malloc(strlen(audiodev) + 40);
|
|
- sprintf (dirname, "/tmp/.esd%s-%i", audiodev, getuid());
|
|
+ if (sockdir != NULL)
|
|
+ return sockdir;
|
|
+ pw = getpwuid(getuid());
|
|
+ if (pw == NULL || pw->pw_dir == NULL) {
|
|
+ fprintf(stderr, "esd: could not find home directory\n");
|
|
+ exit(1);
|
|
}
|
|
-
|
|
- return dirname;
|
|
+ snprintf(sockdirbuf, sizeof(sockdirbuf), "%s/.esd", pw->pw_dir);
|
|
+ endpwent();
|
|
+ sockdir = sockdirbuf;
|
|
+ return sockdir;
|
|
}
|
|
|
|
const char*
|
|
esd_get_socket_name (void)
|
|
{
|
|
- const char *dirname;
|
|
- static char *name = NULL;
|
|
+ static char *sockname = NULL, socknamebuf[PATH_MAX];
|
|
|
|
- if (name == NULL) {
|
|
- dirname = esd_get_socket_dirname();
|
|
- name = malloc(strlen(dirname) + sizeof("/socket"));
|
|
- strcpy(name, dirname);
|
|
- strcat(name, "/socket");
|
|
- }
|
|
-
|
|
- return name;
|
|
+ if (sockname != NULL)
|
|
+ return sockname;
|
|
+ snprintf(socknamebuf, sizeof(socknamebuf), "%s/socket",
|
|
+ esd_get_socket_dirname());
|
|
+ sockname = socknamebuf;
|
|
+ return sockname;
|
|
}
|