Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/bin/stty - print the line discipline using the new ioctl
details: https://anonhg.NetBSD.org/src/rev/1ffa1168a748
branches: trunk
changeset: 789906:1ffa1168a748
user: christos <christos%NetBSD.org@localhost>
date: Thu Sep 12 19:47:23 2013 +0000
description:
- print the line discipline using the new ioctl
- print the queue size
diffstat:
bin/stty/extern.h | 4 ++--
bin/stty/key.c | 8 ++++----
bin/stty/print.c | 38 +++++++++++---------------------------
bin/stty/stty.c | 14 +++++++-------
bin/stty/stty.h | 5 +++--
5 files changed, 27 insertions(+), 42 deletions(-)
diffs (200 lines):
diff -r bcb538052b2b -r 1ffa1168a748 bin/stty/extern.h
--- a/bin/stty/extern.h Thu Sep 12 19:46:31 2013 +0000
+++ b/bin/stty/extern.h Thu Sep 12 19:47:23 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.12 2011/08/29 14:51:19 joerg Exp $ */
+/* $NetBSD: extern.h,v 1.13 2013/09/12 19:47:23 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -43,7 +43,7 @@
int ksearch(char ***, struct info *);
int msearch(char ***, struct info *);
void optlist(void);
-void print(struct termios *, struct winsize *, int, enum FMT);
+void print(struct termios *, struct winsize *, int, const char *, enum FMT);
__dead void usage(void);
extern const struct cchar cchars1[], cchars2[];
diff -r bcb538052b2b -r 1ffa1168a748 bin/stty/key.c
--- a/bin/stty/key.c Thu Sep 12 19:46:31 2013 +0000
+++ b/bin/stty/key.c Thu Sep 12 19:47:23 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: key.c,v 1.20 2004/04/01 16:10:03 tsarna Exp $ */
+/* $NetBSD: key.c,v 1.21 2013/09/12 19:47:23 christos Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)key.c 8.4 (Berkeley) 2/20/95";
#else
-__RCSID("$NetBSD: key.c,v 1.20 2004/04/01 16:10:03 tsarna Exp $");
+__RCSID("$NetBSD: key.c,v 1.21 2013/09/12 19:47:23 christos Exp $");
#endif
#endif /* not lint */
@@ -146,7 +146,7 @@
void
f_all(struct info *ip)
{
- print(&ip->t, &ip->win, ip->ldisc, STTY_BSD);
+ print(&ip->t, &ip->win, ip->queue, ip->ldisc, STTY_BSD);
}
void
@@ -185,7 +185,7 @@
void
f_everything(struct info *ip)
{
- print(&ip->t, &ip->win, ip->ldisc, STTY_BSD);
+ print(&ip->t, &ip->win, ip->queue, ip->ldisc, STTY_BSD);
}
void
diff -r bcb538052b2b -r 1ffa1168a748 bin/stty/print.c
--- a/bin/stty/print.c Thu Sep 12 19:46:31 2013 +0000
+++ b/bin/stty/print.c Thu Sep 12 19:47:23 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: print.c,v 1.22 2005/06/26 19:10:49 christos Exp $ */
+/* $NetBSD: print.c,v 1.23 2013/09/12 19:47:23 christos Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94";
#else
-__RCSID("$NetBSD: print.c,v 1.22 2005/06/26 19:10:49 christos Exp $");
+__RCSID("$NetBSD: print.c,v 1.23 2013/09/12 19:47:23 christos Exp $");
#endif
#endif /* not lint */
@@ -52,7 +52,8 @@
static const char *ccval(const struct cchar *, int);
void
-print(struct termios *tp, struct winsize *wp, int ldisc, enum FMT fmt)
+print(struct termios *tp, struct winsize *wp, int queue, const char *ldisc,
+ enum FMT fmt)
{
const struct cchar *p;
long tmp;
@@ -62,29 +63,6 @@
cnt = 0;
- /* Line discipline. */
-#ifdef TTYDISC
- if (ldisc != TTYDISC) {
- switch(ldisc) {
- case TABLDISC:
- cnt += printf("tablet disc; ");
- break;
- case SLIPDISC:
- cnt += printf("slip disc; ");
- break;
- case PPPDISC:
- cnt += printf("ppp disc; ");
- break;
- case STRIPDISC:
- cnt += printf("strip disc; ");
- break;
- default:
- cnt += printf("#%d disc; ", ldisc);
- break;
- }
- }
-#endif
-
/* Line speed. */
ispeed = cfgetispeed(tp);
ospeed = cfgetospeed(tp);
@@ -93,8 +71,14 @@
printf("ispeed %d baud; ospeed %d baud;", ispeed, ospeed);
else
cnt += printf("speed %d baud;", ispeed);
- if (fmt >= STTY_BSD)
+ if (fmt >= STTY_BSD) {
cnt += printf(" %d rows; %d columns;", wp->ws_row, wp->ws_col);
+ if (queue)
+ cnt += printf(" queue = %d;", queue);
+ if (ldisc)
+ cnt += printf(" line = %s;", ldisc);
+ }
+
if (cnt)
(void)printf("\n");
diff -r bcb538052b2b -r 1ffa1168a748 bin/stty/stty.c
--- a/bin/stty/stty.c Thu Sep 12 19:46:31 2013 +0000
+++ b/bin/stty/stty.c Thu Sep 12 19:47:23 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: stty.c,v 1.22 2012/06/20 10:09:43 wiz Exp $ */
+/* $NetBSD: stty.c,v 1.23 2013/09/12 19:47:23 christos Exp $ */
/*-
* Copyright (c) 1989, 1991, 1993, 1994
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)stty.c 8.3 (Berkeley) 4/2/94";
#else
-__RCSID("$NetBSD: stty.c,v 1.22 2012/06/20 10:09:43 wiz Exp $");
+__RCSID("$NetBSD: stty.c,v 1.23 2013/09/12 19:47:23 christos Exp $");
#endif
#endif /* not lint */
@@ -58,8 +58,6 @@
#include "stty.h"
#include "extern.h"
-int main(int, char *[]);
-
int
main(int argc, char *argv[])
{
@@ -99,12 +97,14 @@
args: argc -= optind;
argv += optind;
- if (ioctl(i.fd, TIOCGETD, &i.ldisc) < 0)
- err(1, "TIOCGETD");
+ if (ioctl(i.fd, TIOCGLINED, i.ldisc) < 0)
+ err(1, "TIOCGLINED");
if (tcgetattr(i.fd, &i.t) < 0)
err(1, "tcgetattr");
if (ioctl(i.fd, TIOCGWINSZ, &i.win) < 0)
warn("TIOCGWINSZ");
+ if (ioctl(i.fd, TIOCGQSIZE, &i.queue) < 0)
+ warn("TIOCGQSIZE");
switch(fmt) {
case STTY_NOTSET:
@@ -113,7 +113,7 @@
/* FALLTHROUGH */
case STTY_BSD:
case STTY_POSIX:
- print(&i.t, &i.win, i.ldisc, fmt);
+ print(&i.t, &i.win, i.queue, i.ldisc, fmt);
break;
case STTY_GFLAG:
gprint(&i.t);
diff -r bcb538052b2b -r 1ffa1168a748 bin/stty/stty.h
--- a/bin/stty/stty.h Thu Sep 12 19:46:31 2013 +0000
+++ b/bin/stty/stty.h Thu Sep 12 19:47:23 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: stty.h,v 1.10 2003/08/07 09:05:42 agc Exp $ */
+/* $NetBSD: stty.h,v 1.11 2013/09/12 19:47:23 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -39,7 +39,8 @@
struct info {
int fd; /* file descriptor */
- int ldisc; /* line discipline */
+ linedn_t ldisc; /* line discipline */
+ int queue; /* queue size */
int off; /* turn off */
int set; /* need set */
int wset; /* need window set */
Home |
Main Index |
Thread Index |
Old Index