diff options
Diffstat (limited to 'usr.bin/sndioctl/sndioctl.c')
-rw-r--r-- | usr.bin/sndioctl/sndioctl.c | 54 |
1 files changed, 42 insertions, 12 deletions
diff --git a/usr.bin/sndioctl/sndioctl.c b/usr.bin/sndioctl/sndioctl.c index ca98add3d13..2403f85be9d 100644 --- a/usr.bin/sndioctl/sndioctl.c +++ b/usr.bin/sndioctl/sndioctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sndioctl.c,v 1.13 2020/06/18 05:33:16 ratchov Exp $ */ +/* $OpenBSD: sndioctl.c,v 1.14 2020/06/28 05:17:26 ratchov Exp $ */ /* * Copyright (c) 2014-2020 Alexandre Ratchov <alex@caoua.org> * @@ -103,7 +103,8 @@ cmpdesc(struct sioctl_desc *d1, struct sioctl_desc *d2) if (res != 0) return res; res = d1->node0.unit - d2->node0.unit; - if (d1->type == SIOCTL_VEC || + if (d1->type == SIOCTL_SEL || + d1->type == SIOCTL_VEC || d1->type == SIOCTL_LIST) { if (res != 0) return res; @@ -293,6 +294,7 @@ ismono(struct info *g) return 0; } break; + case SIOCTL_SEL: case SIOCTL_VEC: case SIOCTL_LIST: for (p2 = g; p2 != NULL; p2 = nextpar(p2)) { @@ -341,6 +343,7 @@ print_desc(struct info *p, int mono) case SIOCTL_SW: printf("*"); break; + case SIOCTL_SEL: case SIOCTL_VEC: case SIOCTL_LIST: more = 0; @@ -354,7 +357,8 @@ print_desc(struct info *p, int mono) if (more) printf(","); print_node(&e->desc.node1, mono); - printf(":*"); + if (p->desc.type != SIOCTL_SEL) + printf(":*"); more = 1; } } @@ -390,6 +394,7 @@ print_ent(struct info *e, char *comment) case SIOCTL_NONE: printf("<removed>\n"); break; + case SIOCTL_SEL: case SIOCTL_VEC: case SIOCTL_LIST: print_node(&e->desc.node1, 0); @@ -418,6 +423,7 @@ print_val(struct info *p, int mono) case SIOCTL_SW: print_num(p); break; + case SIOCTL_SEL: case SIOCTL_VEC: case SIOCTL_LIST: more = 0; @@ -617,6 +623,9 @@ dump(void) case SIOCTL_SW: printf("0..%d (%u)", i->desc.maxval, i->curval); break; + case SIOCTL_SEL: + print_node(&i->desc.node1, 0); + break; case SIOCTL_VEC: case SIOCTL_LIST: print_node(&i->desc.node1, 0); @@ -696,6 +705,7 @@ cmd(char *line) npar++; } break; + case SIOCTL_SEL: case SIOCTL_VEC: case SIOCTL_LIST: for (i = g; i != NULL; i = nextpar(i)) { @@ -853,6 +863,7 @@ ondesc(void *arg, struct sioctl_desc *d, int curval) case SIOCTL_SW: case SIOCTL_VEC: case SIOCTL_LIST: + case SIOCTL_SEL: break; default: return; @@ -892,17 +903,36 @@ ondesc(void *arg, struct sioctl_desc *d, int curval) void onctl(void *arg, unsigned addr, unsigned val) { - struct info *i; + struct info *i, *j; - for (i = infolist; i != NULL; i = i->next) { - if (i->ctladdr != addr) - continue; - if (i->curval != val) { - i->curval = val; - if (m_flag) - print_ent(i, "changed"); - } + i = infolist; + for (;;) { + if (i == NULL) + return; + if (i->ctladdr == addr) + break; + i = i->next; } + + if (i->curval == val) { + print_ent(i, "eq"); + return; + } + + if (i->desc.type == SIOCTL_SEL) { + for (j = infolist; j != NULL; j = j->next) { + if (strcmp(i->desc.group, j->desc.group) != 0 || + strcmp(i->desc.node0.name, j->desc.node0.name) != 0 || + strcmp(i->desc.func, j->desc.func) != 0 || + i->desc.node0.unit != j->desc.node0.unit) + continue; + j->curval = (i->ctladdr == j->ctladdr); + } + } else + i->curval = val; + + if (m_flag) + print_ent(i, "changed"); } int |