From 298f5ad9040c0b93ccd39f1e110caab2684070a4 Mon Sep 17 00:00:00 2001 From: Alexandre Ratchov Date: Wed, 23 May 2012 19:25:12 +0000 Subject: Make the "default" string a valid device name that has the same effect as NULL has. This will (hopefully) simplify ports where the user passes the device string. --- lib/libsndio/mio.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lib/libsndio/mio.c') diff --git a/lib/libsndio/mio.c b/lib/libsndio/mio.c index e359adcb615..8dc0823a930 100644 --- a/lib/libsndio/mio.c +++ b/lib/libsndio/mio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mio.c,v 1.14 2012/04/11 06:05:43 ratchov Exp $ */ +/* $OpenBSD: mio.c,v 1.15 2012/05/23 19:25:11 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov * @@ -34,6 +34,7 @@ struct mio_hdl * mio_open(const char *str, unsigned int mode, int nbio) { + static char portany[] = MIO_PORTANY; struct mio_hdl *hdl; const char *p; @@ -42,9 +43,14 @@ mio_open(const char *str, unsigned int mode, int nbio) #endif if ((mode & (MIO_OUT | MIO_IN)) == 0) return NULL; - if (str == NULL && !issetugid()) + if (str == NULL) /* backward compat */ + str = portany; + if (strcmp(str, portany) == 0 && !issetugid()) { str = getenv("MIDIDEVICE"); - if (str == NULL) { + if (str == NULL) + str = portany; + } + if (strcmp(str, portany) == 0) { hdl = mio_aucat_open("/0", mode, nbio, 1); if (hdl != NULL) return hdl; -- cgit v1.2.3