diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2010-07-06 01:12:46 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2010-07-06 01:12:46 +0000 |
commit | 62c59396ae4ebfd4eff1915ca3fd61801cd9422b (patch) | |
tree | 0ea7288eb421fe1614095e3c6e8e8c02ea49d0b8 /lib | |
parent | 68d47837d6755abb9ef7ca19da55f024330f5495 (diff) |
Handle all streams the same way because there's no actual
difference between audio files and client connections. Clean up
the way command line options are handled and clarify this in the
manual page: stream parameters (-Ccehjmrtvx) must precede stream
definitions (-ios) and per-device parameters (-abz) and stream
definitions (-ios) must precede device definitions (-f). Since
there's no ``server'' and ``non-server'' modes anymore, make the
-l option just detach the process.
ok and help from jakemsr and jmc
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libsndio/mio_thru.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/lib/libsndio/mio_thru.c b/lib/libsndio/mio_thru.c index 67763ad9000..7ce4853dd7b 100644 --- a/lib/libsndio/mio_thru.c +++ b/lib/libsndio/mio_thru.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mio_thru.c,v 1.8 2010/04/24 06:15:54 ratchov Exp $ */ +/* $OpenBSD: mio_thru.c,v 1.9 2010/07/06 01:12:45 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -55,6 +55,7 @@ struct mio_hdl * thru_open(const char *str, char *sock, unsigned mode, int nbio) { extern char *__progname; + char unit[4], *sep, *opt; struct amsg msg; int s, n, todo; unsigned char *data; @@ -63,11 +64,24 @@ thru_open(const char *str, char *sock, unsigned mode, int nbio) socklen_t len = sizeof(struct sockaddr_un); uid_t uid; + sep = strchr(str, '.'); + if (sep == NULL) { + opt = "default"; + strlcpy(unit, str, sizeof(unit)); + } else { + opt = sep + 1; + if (sep - str >= sizeof(unit)) { + DPRINTF("thru_open: %s: too long\n", str); + return NULL; + } + strlcpy(unit, str, opt - str); + } + DPRINTF("thru_open: trying %s -> %s.%s\n", str, unit, opt); uid = geteuid(); if (strchr(str, '/') != NULL) return NULL; snprintf(ca.sun_path, sizeof(ca.sun_path), - "/tmp/aucat-%u/%s%s", uid, sock, str); + "/tmp/aucat-%u/%s%s", uid, sock, unit); ca.sun_family = AF_UNIX; hdl = malloc(sizeof(struct thru_hdl)); @@ -84,7 +98,7 @@ thru_open(const char *str, char *sock, unsigned mode, int nbio) DPERROR("thru_open: connect"); /* try shared server */ snprintf(ca.sun_path, sizeof(ca.sun_path), - "/tmp/aucat/%s%s", sock, str); + "/tmp/aucat/%s%s", sock, unit); while (connect(s, (struct sockaddr *)&ca, len) < 0) { if (errno == EINTR) continue; @@ -110,7 +124,7 @@ thru_open(const char *str, char *sock, unsigned mode, int nbio) msg.u.hello.proto |= AMSG_MIDIIN; if (mode & MIO_OUT) msg.u.hello.proto |= AMSG_MIDIOUT; - strlcpy(msg.u.hello.opt, "default", sizeof(msg.u.hello.opt)); + strlcpy(msg.u.hello.opt, opt, sizeof(msg.u.hello.opt)); strlcpy(msg.u.hello.who, __progname, sizeof(msg.u.hello.who)); n = write(s, &msg, sizeof(struct amsg)); if (n < 0) { |