diff --git a/sndiod/miofile.c b/sndiod/miofile.c index 1bf5e5c..ed3a205 100644 --- a/sndiod/miofile.c +++ b/sndiod/miofile.c @@ -52,7 +52,9 @@ port_mio_openlist(struct port *c, unsigned int mode) { struct mio_hdl *hdl; struct name *n; + int idx; + idx = 0; n = c->path_list; while (1) { if (n == NULL) @@ -68,6 +70,7 @@ port_mio_openlist(struct port *c, unsigned int mode) return hdl; } n = n->next; + idx++; } return NULL; } diff --git a/sndiod/siofile.c b/sndiod/siofile.c index 2b19ff7..ba752a7 100644 --- a/sndiod/siofile.c +++ b/sndiod/siofile.c @@ -93,7 +93,9 @@ dev_sio_openlist(struct dev *d, unsigned int mode, struct sioctl_hdl **rctlhdl) struct name *n; struct sio_hdl *hdl; struct sioctl_hdl *ctlhdl; + int idx; + idx = 0; n = d->path_list; while (1) { if (n == NULL) @@ -118,6 +120,7 @@ dev_sio_openlist(struct dev *d, unsigned int mode, struct sioctl_hdl **rctlhdl) return hdl; } n = n->next; + idx++; } return NULL; } diff --git a/sndiod/utils.c b/sndiod/utils.c index bea290b..fce60ce 100644 --- a/sndiod/utils.c +++ b/sndiod/utils.c @@ -215,3 +215,20 @@ namelist_clear(struct name **list) xfree(n); } } + +char * +namelist_byindex(struct name **list, unsigned int idx) +{ + struct name *n; + + n = *list; + while (1) { + if (n == NULL) + return NULL; + if (idx == 0) + break; + n = n->next; + idx--; + } + return n->str; +} diff --git a/sndiod/utils.h b/sndiod/utils.h index ca3e089..531424a 100644 --- a/sndiod/utils.h +++ b/sndiod/utils.h @@ -38,6 +38,7 @@ void xfree(void *); void namelist_add(struct name **, char *); void namelist_clear(struct name **); +char *namelist_byindex(struct name **, unsigned int); /* * Log levels: