Merge xxx_openlist() changes from cvs.

This commit is contained in:
Alexandre Ratchov 2020-01-23 12:50:20 +01:00
parent f29da850c6
commit cf2e5f1727
4 changed files with 24 additions and 0 deletions

View File

@ -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;
}

View File

@ -91,7 +91,9 @@ dev_sio_openlist(struct dev *d, unsigned int mode)
{
struct name *n;
struct sio_hdl *hdl;
int idx;
idx = 0;
n = d->path_list;
while (1) {
if (n == NULL)
@ -107,6 +109,7 @@ dev_sio_openlist(struct dev *d, unsigned int mode)
return hdl;
}
n = n->next;
idx++;
}
return NULL;
}

View File

@ -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;
}

View File

@ -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: