From cc4ca2631378a80e8fd4b28797a4515437e25f93 Mon Sep 17 00:00:00 2001 From: "Andrey A. Chernov" Date: Fri, 10 Dec 1993 01:08:47 +0000 Subject: Add 'dtrwait ' option to comcontrol to handle TIOCM[SG]DTRWAIT ioctl. --- sbin/i386/comcontrol/comcontrol.c | 63 ++++++++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 14 deletions(-) (limited to 'sbin/i386') diff --git a/sbin/i386/comcontrol/comcontrol.c b/sbin/i386/comcontrol/comcontrol.c index 101d64ff4759..194554a63c52 100644 --- a/sbin/i386/comcontrol/comcontrol.c +++ b/sbin/i386/comcontrol/comcontrol.c @@ -31,12 +31,14 @@ #include #include #include +#include +#include #include void usage(char *progname) { - fprintf(stderr, "usage: %s [[-]bidir]\n", progname); + fprintf(stderr, "usage: %s [[-]bidir] [dtrwait ]\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); } -- cgit v1.2.3