diff options
author | ache <ache@FreeBSD.org> | 2000-04-27 21:31:23 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2000-04-27 21:31:23 +0000 |
commit | ecbfef142fe07cfdc2340f8798a40ccb16381424 (patch) | |
tree | e87a6bf52c0c5afbf5c65e7dbc73291d1ab484b0 /bin/stty | |
parent | 676117ef4cc0044d29cace8f438915a5fdc4de45 (diff) | |
download | FreeBSD-src-ecbfef142fe07cfdc2340f8798a40ccb16381424.zip FreeBSD-src-ecbfef142fe07cfdc2340f8798a40ccb16381424.tar.gz |
Add ability to manipulate with drain wait time
Diffstat (limited to 'bin/stty')
-rw-r--r-- | bin/stty/extern.h | 6 | ||||
-rw-r--r-- | bin/stty/gfmt.c | 15 | ||||
-rw-r--r-- | bin/stty/key.c | 15 | ||||
-rw-r--r-- | bin/stty/print.c | 6 | ||||
-rw-r--r-- | bin/stty/stty.c | 13 | ||||
-rw-r--r-- | bin/stty/stty.h | 2 |
6 files changed, 42 insertions, 15 deletions
diff --git a/bin/stty/extern.h b/bin/stty/extern.h index 27869f8..47918c0 100644 --- a/bin/stty/extern.h +++ b/bin/stty/extern.h @@ -38,12 +38,12 @@ int c_cchars __P((const void *, const void *)); int c_modes __P((const void *, const void *)); int csearch __P((char ***, struct info *)); void checkredirect __P((void)); -void gprint __P((struct termios *, struct winsize *, int)); -void gread __P((struct termios *, char *)); +void gprint __P((struct termios *, struct winsize *, int, int)); +void gread __P((struct termios *, int *, char *)); int ksearch __P((char ***, struct info *)); int msearch __P((char ***, struct info *)); void optlist __P((void)); -void print __P((struct termios *, struct winsize *, int, enum FMT)); +void print __P((struct termios *, struct winsize *, int, int, enum FMT)); void usage __P((void)); extern struct cchar cchars1[], cchars2[]; diff --git a/bin/stty/gfmt.c b/bin/stty/gfmt.c index b34a117..38ee46f 100644 --- a/bin/stty/gfmt.c +++ b/bin/stty/gfmt.c @@ -59,10 +59,11 @@ gerr(s) } void -gprint(tp, wp, ldisc) +gprint(tp, wp, ldisc, timeout) struct termios *tp; struct winsize *wp; int ldisc; + int timeout; { struct cchar *cp; @@ -71,13 +72,14 @@ gprint(tp, wp, ldisc) (u_long)tp->c_oflag); for (cp = cchars1; cp->name; ++cp) (void)printf("%s=%x:", cp->name, tp->c_cc[cp->sub]); - (void)printf("ispeed=%lu:ospeed=%lu\n", - (u_long)cfgetispeed(tp), (u_long)cfgetospeed(tp)); + (void)printf("ispeed=%lu:ospeed=%lu:drainwait=%d\n", + (u_long)cfgetispeed(tp), (u_long)cfgetospeed(tp), timeout); } void -gread(tp, s) +gread(tp, top, s) struct termios *tp; + int *top; char *s; { struct cchar *cp; @@ -122,6 +124,11 @@ gread(tp, s) tp->c_ospeed = tmp; continue; } + if (CHK("drainwait")) { + (void)sscanf(ep, "%ld", &tmp); + *top = tmp; + continue; + } for (cp = cchars1; cp->name != NULL; ++cp) if (CHK(cp->name)) { if (cp->sub == VMIN || cp->sub == VTIME) diff --git a/bin/stty/key.c b/bin/stty/key.c index ba33a81..9aed9a1 100644 --- a/bin/stty/key.c +++ b/bin/stty/key.c @@ -56,6 +56,7 @@ void f_all __P((struct info *)); void f_cbreak __P((struct info *)); void f_columns __P((struct info *)); void f_dec __P((struct info *)); +void f_drainwait __P((struct info *)); void f_everything __P((struct info *)); void f_extproc __P((struct info *)); void f_ispeed __P((struct info *)); @@ -82,6 +83,7 @@ static struct key { { "columns", f_columns, F_NEEDARG }, { "cooked", f_sane, 0 }, { "dec", f_dec, 0 }, + { "drainwait", f_drainwait, F_NEEDARG }, { "everything", f_everything, 0 }, { "extproc", f_extproc, F_OFFOK }, { "ispeed", f_ispeed, F_NEEDARG }, @@ -140,7 +142,7 @@ void f_all(ip) struct info *ip; { - print(&ip->t, &ip->win, ip->ldisc, BSD); + print(&ip->t, &ip->win, ip->ldisc, ip->timeout, BSD); } void @@ -183,11 +185,20 @@ f_dec(ip) } void +f_drainwait(ip) + struct info *ip; +{ + + ip->timeout = atoi(ip->arg); + ip->tset = 1; +} + +void f_everything(ip) struct info *ip; { - print(&ip->t, &ip->win, ip->ldisc, BSD); + print(&ip->t, &ip->win, ip->ldisc, ip->timeout, BSD); } void diff --git a/bin/stty/print.c b/bin/stty/print.c index a0149c2..6df106d 100644 --- a/bin/stty/print.c +++ b/bin/stty/print.c @@ -55,10 +55,11 @@ static void bput __P((char *)); static char *ccval __P((struct cchar *, int)); void -print(tp, wp, ldisc, fmt) +print(tp, wp, ldisc, timeout, fmt) struct termios *tp; struct winsize *wp; int ldisc; + int timeout; enum FMT fmt; { struct cchar *p; @@ -96,7 +97,8 @@ print(tp, wp, ldisc, fmt) else cnt += printf("speed %d baud;", ispeed); if (fmt >= BSD) - cnt += printf(" %d rows; %d columns;", wp->ws_row, wp->ws_col); + cnt += printf(" %d rows; %d columns; drainwait %d seconds;", + wp->ws_row, wp->ws_col, timeout); if (cnt) (void)printf("\n"); diff --git a/bin/stty/stty.c b/bin/stty/stty.c index 3b59131..b9f0811 100644 --- a/bin/stty/stty.c +++ b/bin/stty/stty.c @@ -103,6 +103,8 @@ args: argc -= optind; err(1, "TIOCGETD"); if (ioctl(i.fd, TIOCGWINSZ, &i.win) < 0) warn("TIOCGWINSZ: %s\n", strerror(errno)); + if (ioctl(i.fd, TIOCGDRAINWAIT, &i.timeout) < 0) + warn("TIOCGDRAINWAIT: %s\n", strerror(errno)); checkredirect(); /* conversion aid */ @@ -113,14 +115,14 @@ args: argc -= optind; /* FALLTHROUGH */ case BSD: case POSIX: - print(&i.t, &i.win, i.ldisc, fmt); + print(&i.t, &i.win, i.ldisc, i.timeout, fmt); break; case GFLAG: - gprint(&i.t, &i.win, i.ldisc); + gprint(&i.t, &i.win, i.ldisc, i.timeout); break; } - for (i.set = i.wset = 0; *argv; ++argv) { + for (i.set = i.wset = i.tset = 0; *argv; ++argv) { if (ksearch(&argv, &i)) continue; @@ -141,8 +143,9 @@ args: argc -= optind; } if (!strncmp(*argv, "gfmt1", sizeof("gfmt1") - 1)) { - gread(&i.t, *argv + sizeof("gfmt1") - 1); + gread(&i.t, &i.timeout, *argv + sizeof("gfmt1") - 1); i.set = 1; + i.tset = 1; continue; } @@ -154,6 +157,8 @@ args: argc -= optind; err(1, "tcsetattr"); if (i.wset && ioctl(i.fd, TIOCSWINSZ, &i.win) < 0) warn("TIOCSWINSZ"); + if (i.tset && ioctl(i.fd, TIOCSDRAINWAIT, &i.timeout) < 0) + warn("TIOCSDRAINWAIT"); exit(0); } diff --git a/bin/stty/stty.h b/bin/stty/stty.h index e122979..6c9ed5e 100644 --- a/bin/stty/stty.h +++ b/bin/stty/stty.h @@ -43,9 +43,11 @@ struct info { int off; /* turn off */ int set; /* need set */ int wset; /* need window set */ + int tset; /* need timeout set */ char *arg; /* argument */ struct termios t; /* terminal info */ struct winsize win; /* window info */ + int timeout; /* drain wait time */ }; struct cchar { |