summaryrefslogtreecommitdiffstats
path: root/sbin/comcontrol
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>2000-05-01 12:14:30 +0000
committerache <ache@FreeBSD.org>2000-05-01 12:14:30 +0000
commitfd776bd6a962dc53c287071dcc755263f80b2cf8 (patch)
tree5c2fd49bcdc2a5d57c478253d33b53608d1c057b /sbin/comcontrol
parent8d4e0e3a58a63b0f20d0ed0c7deda786a620aeb6 (diff)
downloadFreeBSD-src-fd776bd6a962dc53c287071dcc755263f80b2cf8.zip
FreeBSD-src-fd776bd6a962dc53c287071dcc755263f80b2cf8.tar.gz
Print options only supported by device, back out printing options separately
Pointed-by: bde
Diffstat (limited to 'sbin/comcontrol')
-rw-r--r--sbin/comcontrol/comcontrol.810
-rw-r--r--sbin/comcontrol/comcontrol.c56
2 files changed, 25 insertions, 41 deletions
diff --git a/sbin/comcontrol/comcontrol.8 b/sbin/comcontrol/comcontrol.8
index 84ef5b5..7e5d1ad 100644
--- a/sbin/comcontrol/comcontrol.8
+++ b/sbin/comcontrol/comcontrol.8
@@ -7,9 +7,9 @@
.Nd control an special tty device.
.Sh SYNOPSIS
.Nm comcontrol
-.Ar special_device | -
-.Op dtrwait Op number
-.Op drainwait Op number
+.Ar special_device | Fl
+.Op dtrwait Ar number
+.Op drainwait Ar number
.Sh DESCRIPTION
.Nm Comcontrol
is used to examine and modify some of the special characteristics
@@ -22,8 +22,6 @@ Only the superuser can change the settings.
.Pp
The following options are available:
.Bl -tag -width indent
-.It Cm dtrwait
-Print current DTR wait time.
.It Cm dtrwait Ar number
Set the time to wait after dropping DTR
to the given number.
@@ -31,8 +29,6 @@ The units are hundredths of a second.
The default is 300 hundredths, i.e., 3 seconds.
This option needed mainly to set proper recover time after
modem reset.
-.It Cm drainwait
-Print current output drain timeout.
.It Cm drainwait Ar number
Set the time to wait for output drain
to the given number.
diff --git a/sbin/comcontrol/comcontrol.c b/sbin/comcontrol/comcontrol.c
index 7de2225..ad77b98 100644
--- a/sbin/comcontrol/comcontrol.c
+++ b/sbin/comcontrol/comcontrol.c
@@ -33,6 +33,7 @@ static const char rcsid[] =
#include <ctype.h>
#include <err.h>
+#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
@@ -44,7 +45,7 @@ static void
usage()
{
fprintf(stderr,
- "usage: comcontrol <filename|-> [dtrwait [<n>]] [drainwait [<n>]]\n");
+ "usage: comcontrol <filename>|- [dtrwait <n>] [drainwait <n>]\n");
exit(1);
}
@@ -53,9 +54,8 @@ main(int argc, char *argv[])
{
int fd;
int res = 0;
+ int print_dtrwait = 1, print_drainwait = 1;
int dtrwait = -1, drainwait = -1;
- int temp;
- int output = 0;
if (argc < 2)
usage();
@@ -69,50 +69,40 @@ main(int argc, char *argv[])
return 1;
}
}
-
if (argc == 2) {
if (ioctl(fd, TIOCMGDTRWAIT, &dtrwait) < 0) {
- res = 1;
- warn("TIOCMGDTRWAIT");
+ print_dtrwait = 0;
+ if (errno != ENOTTY) {
+ res = 1;
+ warn("TIOCMGDTRWAIT");
+ }
}
if (ioctl(fd, TIOCGDRAINWAIT, &drainwait) < 0) {
- res = 1;
- warn("TIOCGDRAINWAIT");
+ print_drainwait = 0;
+ if (errno != ENOTTY) {
+ res = 1;
+ warn("TIOCGDRAINWAIT");
+ }
}
- printf("dtrwait %d drainwait %d ", dtrwait, drainwait);
- output = 1;
+ if (print_dtrwait)
+ printf("dtrwait %d ", dtrwait);
+ if (print_drainwait)
+ printf("drainwait %d ", drainwait);
+ printf("\n");
} else {
while (argv[2] != NULL) {
if (!strcmp(argv[2],"dtrwait")) {
- if (argv[3] == NULL || !isdigit(argv[3][0])) {
- if (ioctl(fd, TIOCMGDTRWAIT, &temp) < 0) {
- res = 1;
- temp = -1;
- warn("TIOCMGDTRWAIT");
- }
- printf("dtrwait %d ", temp);
- output = 1;
- argv++;
- continue;
- }
if (dtrwait >= 0)
usage();
+ if (argv[3] == NULL || !isdigit(argv[3][0]))
+ usage();
dtrwait = atoi(argv[3]);
argv += 2;
} else if (!strcmp(argv[2],"drainwait")) {
- if (argv[3] == NULL || !isdigit(argv[3][0])) {
- if (ioctl(fd, TIOCGDRAINWAIT, &temp) < 0) {
- res = 1;
- temp = -1;
- warn("TIOCGDRAINWAIT");
- }
- printf("drainwait %d ", temp);
- argv++;
- output = 1;
- continue;
- }
if (drainwait >= 0)
usage();
+ if (argv[3] == NULL || !isdigit(argv[3][0]))
+ usage();
drainwait = atoi(argv[3]);
argv += 2;
} else
@@ -133,7 +123,5 @@ main(int argc, char *argv[])
}
close(fd);
- if (output)
- printf("\n");
return res;
}
OpenPOWER on IntegriCloud