diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2015-10-02 09:21:47 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2015-10-02 09:21:47 +0000 |
commit | b7549d84c68bfb7cfbfc1c51e32097c733811e4f (patch) | |
tree | 6b54bbead925c4f314bc88eb6688dba01642910e /lib/libsndio | |
parent | 9e0c2fe2e5cd702c54a81b4d3cdf84182707a9d2 (diff) |
use macros instead of hard-coded strings for unix sockets paths
Diffstat (limited to 'lib/libsndio')
-rw-r--r-- | lib/libsndio/amsg.h | 16 | ||||
-rw-r--r-- | lib/libsndio/aucat.c | 6 |
2 files changed, 16 insertions, 6 deletions
diff --git a/lib/libsndio/amsg.h b/lib/libsndio/amsg.h index d15eaa78272..1a8d6bcabec 100644 --- a/lib/libsndio/amsg.h +++ b/lib/libsndio/amsg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: amsg.h,v 1.7 2015/10/02 09:04:36 ratchov Exp $ */ +/* $OpenBSD: amsg.h,v 1.8 2015/10/02 09:21:46 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -19,10 +19,20 @@ #include <stdint.h> +/* + * unix-domain socket name is: + * + * DIR [ '-' UID ] '/' FILE UNIT + * + * example: "/tmp/aucat-1000/aucat0" + * + */ +#define SOCKPATH_DIR "/tmp/aucat" +#define SOCKPATH_FILE "aucat" + /* - * socket and option names + * server TCP base port number */ -#define AUCAT_PATH "aucat" #define AUCAT_PORT 11025 /* diff --git a/lib/libsndio/aucat.c b/lib/libsndio/aucat.c index 36215f07c84..aa182803a4a 100644 --- a/lib/libsndio/aucat.c +++ b/lib/libsndio/aucat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aucat.c,v 1.64 2015/10/01 06:38:19 ratchov Exp $ */ +/* $OpenBSD: aucat.c,v 1.65 2015/10/02 09:21:46 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -337,7 +337,7 @@ aucat_connect_un(struct aucat *hdl, unsigned int unit) uid = geteuid(); snprintf(ca.sun_path, sizeof(ca.sun_path), - "/tmp/aucat-%u/%s%u", uid, AUCAT_PATH, unit); + SOCKPATH_DIR "-%u/%s%u", uid, SOCKPATH_FILE, unit); ca.sun_family = AF_UNIX; s = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0); if (s < 0) @@ -348,7 +348,7 @@ aucat_connect_un(struct aucat *hdl, unsigned int unit) DPERROR(ca.sun_path); /* try shared server */ snprintf(ca.sun_path, sizeof(ca.sun_path), - "/tmp/aucat/%s%u", AUCAT_PATH, unit); + SOCKPATH_DIR "/%s%u", SOCKPATH_FILE, unit); while (connect(s, (struct sockaddr *)&ca, len) < 0) { if (errno == EINTR) continue; |