aboutsummaryrefslogtreecommitdiff
path: root/sbin/comcontrol
diff options
context:
space:
mode:
authorAndrey A. Chernov <ache@FreeBSD.org>1993-12-10 01:08:47 +0000
committerAndrey A. Chernov <ache@FreeBSD.org>1993-12-10 01:08:47 +0000
commitcc4ca2631378a80e8fd4b28797a4515437e25f93 (patch)
tree28edffe2b91afd70bc6f715a429ff28feb124fc2 /sbin/comcontrol
parent31a947eb76477d0f873b00ddb72cc19061d4abfb (diff)
downloadsrc-cc4ca2631378a80e8fd4b28797a4515437e25f93.tar.gz
src-cc4ca2631378a80e8fd4b28797a4515437e25f93.zip
Notes
Diffstat (limited to 'sbin/comcontrol')
-rw-r--r--sbin/comcontrol/comcontrol.c63
1 files changed, 49 insertions, 14 deletions
diff --git a/sbin/comcontrol/comcontrol.c b/sbin/comcontrol/comcontrol.c
index 101d64ff4759..194554a63c52 100644
--- a/sbin/comcontrol/comcontrol.c
+++ b/sbin/comcontrol/comcontrol.c
@@ -31,12 +31,14 @@
#include <sys/types.h>
#include <sys/ioctl.h>
#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
#include <fcntl.h>
void usage(char *progname)
{
- fprintf(stderr, "usage: %s <filename> [[-]bidir]\n", progname);
+ fprintf(stderr, "usage: %s <filename> [[-]bidir] [dtrwait <n>]\n", progname);
exit(1);
}
@@ -44,8 +46,9 @@ int main(int argc, char *argv[])
{
int fd;
int res;
+ int dtrwait;
- if ((argc < 2) || (argc > 3)) usage(argv[0]);
+ if ((argc < 2) || (argc > 5)) usage(argv[0]);
fd = open(argv[1], O_RDONLY|O_NONBLOCK, 0);
if (fd < 0) {
@@ -56,24 +59,56 @@ int main(int argc, char *argv[])
if (argc == 2) {
if (ioctl(fd, TIOCMGBIDIR, &res) < 0) {
- perror("ioctl");
+ perror("TIOCMGBIDIR");
exit(1);
}
if (!res) printf("-");
- printf("bidir\n");
+ printf("bidir ");
+ if (ioctl(fd, TIOCMGDTRWAIT, &dtrwait) < 0) {
+ perror("TIOCMGDTRWAIT");
+ exit(1);
+ }
+ printf("dtrwait %d\n", dtrwait);
} else {
- if (!strcmp(argv[2],"bidir")) {
- res = 1;
- } else if (!strcmp(argv[2],"-bidir")) {
- res = 0;
- } else {
- usage(argv[0]);
+ char *prg = argv[0];
+
+ res = dtrwait = -1;
+ while (argv[2] != NULL) {
+ if (!strcmp(argv[2],"bidir")) {
+ if (res >= 0)
+ usage(prg);
+ res = 1;
+ argv++;
+ } else if (!strcmp(argv[2],"-bidir")) {
+ if (res >= 0)
+ usage(prg);
+ res = 0;
+ argv++;
+ } else if (!strcmp(argv[2],"dtrwait")) {
+ if (dtrwait >= 0)
+ usage(prg);
+ if (argv[3] == NULL || !isdigit(argv[3][0]))
+ usage(prg);
+ dtrwait = atoi(argv[3]);
+ argv += 2;
+ } else {
+ usage(prg);
+ }
+ }
+ if (res >= 0) {
+ if (ioctl(fd, TIOCMSBIDIR, &res) < 0) {
+ perror("TIOCMSBIDIR");
+ exit(1);
+ }
+ }
+ if (dtrwait >= 0) {
+ if (ioctl(fd, TIOCMSDTRWAIT, &dtrwait) < 0) {
+ perror("TIOCMSDTRWAIT");
+ exit(1);
+ }
}
- if (ioctl(fd, TIOCMSBIDIR, &res) < 0) {
- perror("ioctl");
- exit(1);
- }
}
close(fd);
+ exit(0);
}