diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1998-05-02 22:28:08 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1998-05-02 22:28:08 +0000 |
commit | b1eedfc72c92855a1685537ed41365466425b411 (patch) | |
tree | 4c9be03b01de0b059730ba9838ac1104b4797762 /usr.bin | |
parent | bda1863d2f9a5f3b3f6004cff61f8070f2ccd3f4 (diff) |
allow relative values via +/- prefixes
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/mixerctl/mixerctl.1 | 10 | ||||
-rw-r--r-- | usr.bin/mixerctl/mixerctl.c | 47 |
2 files changed, 50 insertions, 7 deletions
diff --git a/usr.bin/mixerctl/mixerctl.1 b/usr.bin/mixerctl/mixerctl.1 index 7ba18b9abaf..fade672e425 100644 --- a/usr.bin/mixerctl/mixerctl.1 +++ b/usr.bin/mixerctl/mixerctl.1 @@ -1,5 +1,6 @@ -.\" $OpenBSD: mixerctl.1,v 1.4 1998/04/30 13:40:00 provos Exp $ +.\" $OpenBSD: mixerctl.1,v 1.5 1998/05/02 22:28:06 millert Exp $ .\" $NetBSD: mixerctl.1,v 1.6 1998/04/27 16:55:23 augustss Exp $ +.\" .\" Copyright (c) 1997 The NetBSD Foundation, Inc. .\" All rights reserved. .\" @@ -73,6 +74,13 @@ flag is specified .Nm attempts to set the specified variables to the given values. .Pp +Values may be specified in either absolute or relative forms. +The relative form is indicated by a prefix of +.Dq + +or +.Dq - +to denote an increase or decrease respectively. +.Pp The .Fl f flag can be used to give an alternative mixer device, the default is diff --git a/usr.bin/mixerctl/mixerctl.c b/usr.bin/mixerctl/mixerctl.c index 3ad33b386ec..fbbb034211d 100644 --- a/usr.bin/mixerctl/mixerctl.c +++ b/usr.bin/mixerctl/mixerctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mixerctl.c,v 1.3 1998/04/30 13:40:01 provos Exp $ */ +/* $OpenBSD: mixerctl.c,v 1.4 1998/05/02 22:28:07 millert Exp $ */ /* $NetBSD: mixerctl.c,v 1.11 1998/04/27 16:55:23 augustss Exp $ */ /* @@ -169,7 +169,7 @@ rdfield(p, q) s = strchr(q, ','); if (s) *s++ = 0; - for(i = 0; i < p->infp->un.s.num_mem; i++) + for (i = 0; i < p->infp->un.s.num_mem; i++) if (strcmp(p->infp->un.s.member[i].label.name, q) == 0) break; if (i < p->infp->un.s.num_mem) { @@ -184,17 +184,52 @@ rdfield(p, q) case AUDIO_MIXER_VALUE: if (m->un.value.num_channels == 1) { if (sscanf(q, "%d", &v) == 1) { - m->un.value.level[0] = v; + switch (*q) { + case '+': + case '-': + m->un.value.level[0] += v; + break; + default: + m->un.value.level[0] = v; + break; + } } else { warnx("Bad number %s", q); return 0; } } else { if (sscanf(q, "%d,%d", &v0, &v1) == 2) { - m->un.value.level[0] = v0; - m->un.value.level[1] = v1; + switch (*q) { + case '+': + case '-': + m->un.value.level[0] += v0; + break; + default: + m->un.value.level[0] = v0; + break; + } + s = strchr(q, ',') + 1; + switch (*s) { + case '+': + case '-': + m->un.value.level[1] += v1; + break; + default: + m->un.value.level[1] = v1; + break; + } } else if (sscanf(q, "%d", &v) == 1) { - m->un.value.level[0] = m->un.value.level[1] = v; + switch (*q) { + case '+': + case '-': + m->un.value.level[0] += v; + m->un.value.level[1] += v; + break; + default: + m->un.value.level[0] = + m->un.value.level[1] = v; + break; + } } else { warnx("Bad numbers %s", q); return 0; |