diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2009-05-16 09:04:46 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2009-05-16 09:04:46 +0000 |
commit | a906f4b468c0d927c9b71a676b121bce10c0d0e1 (patch) | |
tree | c04ae23d973fae8c7e3d6663e0de16c27d4ebfbb | |
parent | cbac1a9ea0fd1d8a6ed645553cc1da02a6d20283 (diff) |
fix style to make future diffs contain functional changes only
-rw-r--r-- | lib/libsndio/aucat.c | 116 |
1 files changed, 58 insertions, 58 deletions
diff --git a/lib/libsndio/aucat.c b/lib/libsndio/aucat.c index e851a3cec71..5ed3b76857e 100644 --- a/lib/libsndio/aucat.c +++ b/lib/libsndio/aucat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aucat.c,v 1.18 2009/05/16 09:01:56 ratchov Exp $ */ +/* $OpenBSD: aucat.c,v 1.19 2009/05/16 09:04:45 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -71,63 +71,6 @@ static struct sio_ops aucat_ops = { aucat_getvol }; -struct sio_hdl * -sio_open_aucat(char *path, unsigned mode, int nbio) -{ - int s; - struct sio_cap cap; - struct aucat_hdl *hdl; - struct sockaddr_un ca; - socklen_t len = sizeof(struct sockaddr_un); - uid_t uid; - - if (path == NULL) - path = SIO_AUCAT_PATH; - uid = geteuid(); - if (strchr(path, '/') != NULL) - return NULL; - snprintf(ca.sun_path, sizeof(ca.sun_path), - "/tmp/aucat-%u/%s", uid, path); - ca.sun_family = AF_UNIX; - - hdl = malloc(sizeof(struct aucat_hdl)); - if (hdl == NULL) - return NULL; - sio_create(&hdl->sio, &aucat_ops, mode, nbio); - - s = socket(AF_UNIX, SOCK_STREAM, 0); - if (s < 0) - goto bad_free; - while (connect(s, (struct sockaddr *)&ca, len) < 0) { - if (errno == EINTR) - continue; - goto bad_connect; - } - if (fcntl(s, F_SETFD, FD_CLOEXEC) < 0) { - DPERROR("FD_CLOEXEC"); - goto bad_connect; - } - hdl->fd = s; - hdl->rstate = STATE_IDLE; - hdl->rtodo = 0xdeadbeef; - hdl->wstate = STATE_IDLE; - hdl->wtodo = 0xdeadbeef; - hdl->curvol = SIO_MAXVOL; - hdl->reqvol = SIO_MAXVOL; - if (!sio_getcap(&hdl->sio, &cap)) - goto bad_connect; - if (((mode & SIO_PLAY) && cap.confs[0].pchan == 0) || - ((mode & SIO_REC) && cap.confs[0].rchan == 0)) - goto bad_connect; - return (struct sio_hdl *)hdl; - bad_connect: - while (close(s) < 0 && errno == EINTR) - ; /* retry */ - bad_free: - free(hdl); - return NULL; -} - /* * read a message, return 0 if blocked */ @@ -223,6 +166,63 @@ aucat_runmsg(struct aucat_hdl *hdl) return 1; } +struct sio_hdl * +sio_open_aucat(char *path, unsigned mode, int nbio) +{ + int s; + struct sio_cap cap; + struct aucat_hdl *hdl; + struct sockaddr_un ca; + socklen_t len = sizeof(struct sockaddr_un); + uid_t uid; + + if (path == NULL) + path = SIO_AUCAT_PATH; + uid = geteuid(); + if (strchr(path, '/') != NULL) + return NULL; + snprintf(ca.sun_path, sizeof(ca.sun_path), + "/tmp/aucat-%u/%s", uid, path); + ca.sun_family = AF_UNIX; + + hdl = malloc(sizeof(struct aucat_hdl)); + if (hdl == NULL) + return NULL; + sio_create(&hdl->sio, &aucat_ops, mode, nbio); + + s = socket(AF_UNIX, SOCK_STREAM, 0); + if (s < 0) + goto bad_free; + while (connect(s, (struct sockaddr *)&ca, len) < 0) { + if (errno == EINTR) + continue; + goto bad_connect; + } + if (fcntl(s, F_SETFD, FD_CLOEXEC) < 0) { + DPERROR("FD_CLOEXEC"); + goto bad_connect; + } + hdl->fd = s; + hdl->rstate = STATE_IDLE; + hdl->rtodo = 0xdeadbeef; + hdl->wstate = STATE_IDLE; + hdl->wtodo = 0xdeadbeef; + hdl->curvol = SIO_MAXVOL; + hdl->reqvol = SIO_MAXVOL; + if (!sio_getcap(&hdl->sio, &cap)) + goto bad_connect; + if (((mode & SIO_PLAY) && cap.confs[0].pchan == 0) || + ((mode & SIO_REC) && cap.confs[0].rchan == 0)) + goto bad_connect; + return (struct sio_hdl *)hdl; + bad_connect: + while (close(s) < 0 && errno == EINTR) + ; /* retry */ + bad_free: + free(hdl); + return NULL; +} + static void aucat_close(struct sio_hdl *sh) { |