diff options
author | 2004-08-08 00:21:55 +0000 | |
---|---|---|
committer | 2004-08-08 00:21:55 +0000 | |
commit | 1cdfc80a2270b33c41aa5ee382d0b11e5564bcd3 (patch) | |
tree | f1997b00571de798c0ecfe34cb0be35506f281a0 | |
parent | do the right math to find out what the average kbytes per transfer is (diff) | |
download | wireguard-openbsd-1cdfc80a2270b33c41aa5ee382d0b11e5564bcd3.tar.xz wireguard-openbsd-1cdfc80a2270b33c41aa5ee382d0b11e5564bcd3.zip |
deprecate the need of specifying -w for setting variables.
setting variables can be done with just name=value now,
like other ctl programs.
update manual, sort options, and fix a few mdoc macros
"go for it" deraadt
-rw-r--r-- | usr.bin/radioctl/radioctl.1 | 21 | ||||
-rw-r--r-- | usr.bin/radioctl/radioctl.c | 26 |
2 files changed, 29 insertions, 18 deletions
diff --git a/usr.bin/radioctl/radioctl.1 b/usr.bin/radioctl/radioctl.1 index 2366a18141d..7ed87e4c029 100644 --- a/usr.bin/radioctl/radioctl.1 +++ b/usr.bin/radioctl/radioctl.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: radioctl.1,v 1.7 2003/06/10 09:12:11 jmc Exp $ +.\" $OpenBSD: radioctl.1,v 1.8 2004/08/08 00:21:55 jaredy Exp $ .\" .\" Copyright (c) 2001 Vladimir Popov .\" All rights reserved. @@ -41,8 +41,7 @@ .Nm radioctl .Op Fl f Ar file .Op Fl n -.Fl w -.Ar name=value +.Ar name Ns Li = Ns Ar value .Sh DESCRIPTION The .Nm @@ -60,15 +59,15 @@ The options are as follows: .Bl -tag -width Ds .It Fl a Print all device variables and their current values. -.It Fl w Ar name=value -Attempt to set the specified variable -.Ar name -to -.Ar value . .It Fl f Ar file Specify an alternative radio tuner device. .It Fl n Suppress printing of the variable name. +.It Ar name Ns Li = Ns Ar value +Attempt to set the specified variable +.Ar name +to +.Ar value . .El .Pp Values may be specified in either absolute or relative forms. @@ -82,10 +81,12 @@ The exact set of controls that can be manipulated depends on the tuner. The general format (in both getting and setting a value) is .Pp -.Va name = value +.Bd -filled -offset indent +.Ar name Ns Li = Ns Ar value +.Ed .Pp The -.Va name +.Ar name indicates what part of the tuner the control affects. .Pp Write only controls: diff --git a/usr.bin/radioctl/radioctl.c b/usr.bin/radioctl/radioctl.c index 1c198eca511..edc827913c3 100644 --- a/usr.bin/radioctl/radioctl.c +++ b/usr.bin/radioctl/radioctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: radioctl.c,v 1.8 2002/01/22 22:09:28 mickey Exp $ */ +/* $OpenBSD: radioctl.c,v 1.9 2004/08/08 00:21:55 jaredy Exp $ */ /* $RuOBSD: radioctl.c,v 1.4 2001/10/20 18:09:10 pva Exp $ */ /* @@ -105,12 +105,12 @@ int main(int argc, char **argv) { struct opt_t opt; + char **avp; char *radiodev = NULL; int rd = -1; int optchar; int show_vars = 0; - int set_param = 0; int silent = 0; int mode = O_RDONLY; @@ -133,8 +133,7 @@ main(int argc, char **argv) silent = 1; break; case 'w': - set_param = 1; - mode = O_RDWR; + /* backwards compatibility */ break; default: usage(); @@ -145,6 +144,16 @@ main(int argc, char **argv) argc -= optind; argv += optind; + /* + * Scan the options for `name=value` so the + * device can be opened in the proper mode. + */ + for (avp = argv; *avp != NULL; avp++) + if (strchr(*avp, '=') != NULL) { + mode = O_RDWR; + break; + } + rd = open(radiodev, mode); if (rd < 0) err(1, "%s open error", radiodev); @@ -152,10 +161,10 @@ main(int argc, char **argv) if (ioctl(rd, RIOCGINFO, &ri) < 0) err(1, "RIOCGINFO"); - if (!argc && show_vars && !set_param) + if (!argc && show_vars) print_vars(silent); else if (argc > 0 && !show_vars) { - if (set_param) { + if (mode == O_RDWR) { for(; argc--; argv++) if (parse_opt(*argv, &opt)) do_ioctls(rd, &opt, silent); @@ -180,8 +189,9 @@ main(int argc, char **argv) void usage(void) { - fprintf(stderr, "usage: %s [-f file] [-n] variable ...\n" - " %s [-f file] [-n] -w variable=value ...\n" + fprintf(stderr, + "usage: %s [-f file] [-n] variable ...\n" + " %s [-f file] [-n] variable=value ...\n" " %s [-f file] [-n] -a\n", __progname, __progname, __progname); exit(1); |