add port numbers

This commit is contained in:
Alexandre Ratchov 2015-11-25 20:49:09 +01:00
parent d4cea96993
commit c8a50a21ea
2 changed files with 6 additions and 7 deletions

View File

@ -427,18 +427,16 @@ port_exit(void *arg)
struct port *
port_new(char *path, unsigned int mode, int hold)
{
struct port *c, **pc;
struct port *c;
c = xmalloc(sizeof(struct port));
c->path = xstrdup(path);
c->state = PORT_CFG;
c->hold = hold;
c->midi = midi_new(&port_midiops, c, mode);
midi_portnum++;
for (pc = &port_list; *pc != NULL; pc = &(*pc)->next)
; /* nothing */
c->next = NULL;
*pc = c;
c->num = midi_portnum++;
c->next = port_list;
port_list = c;
return c;
}
@ -504,7 +502,7 @@ port_bynum(int num)
struct port *p;
for (p = port_list; p != NULL; p = p->next) {
if (num-- == 0)
if (p->num == num)
return p;
}
return NULL;

View File

@ -87,6 +87,7 @@ struct port {
#define PORT_INIT 1
#define PORT_DRAIN 2
unsigned int state;
unsigned int num; /* port serial number */
char *path; /* hold the port open ? */
int hold;
struct midi *midi;