summaryrefslogtreecommitdiff
path: root/usr/src/ucbcmd
diff options
context:
space:
mode:
authorTim Marsland <Tim.Marsland@Sun.COM>2009-04-12 10:48:30 -0700
committerTim Marsland <Tim.Marsland@Sun.COM>2009-04-12 10:48:30 -0700
commitde81e71e031139a0a7f13b7bf64152c3faa76698 (patch)
treee4f1f70082c50c2d6545d118596050ee3e9adad7 /usr/src/ucbcmd
parent73cd555c10e70dac413ae4b40de8450a291750ac (diff)
downloadillumos-joyent-de81e71e031139a0a7f13b7bf64152c3faa76698.tar.gz
6763764 Support for FTDI USB Serial adapters
6798921 usbser mishandles some ioctls 4696628 USB serial needs properties to ignore CD 6821751 Add support for 921600 baud
Diffstat (limited to 'usr/src/ucbcmd')
-rw-r--r--usr/src/ucbcmd/stty/stty.c805
-rw-r--r--usr/src/ucbcmd/stty/sttytable.c44
-rw-r--r--usr/src/ucbcmd/tset/tset.c1054
3 files changed, 946 insertions, 957 deletions
diff --git a/usr/src/ucbcmd/stty/stty.c b/usr/src/ucbcmd/stty/stty.c
index b37bebf6f6..65e79501d8 100644
--- a/usr/src/ucbcmd/stty/stty.c
+++ b/usr/src/ucbcmd/stty/stty.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -19,17 +18,15 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 1995 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-
#include <stdio.h>
#include <ctype.h>
#include <sys/types.h>
@@ -42,8 +39,8 @@ extern char *getenv();
extern void exit();
extern void perror();
-static char *STTY="stty: ";
-static char *USAGE="usage: stty [-agh] [modes]\n";
+static char *STTY = "stty: ";
+static char *USAGE = "usage: stty [-agh] [modes]\n";
static int pitt = 0;
static struct termios cb;
static struct termio ocb; /* for non-streams devices */
@@ -61,17 +58,17 @@ void delay(int, char *s);
void prspeed(char *, int);
void prencode(void);
-#define ioctl_desc 1
-#define output stderr
+#define ioctl_desc 1
+#define output stderr
int
main(int argc, char *argv[])
{
int i;
- char *s_arg, *sttyparse(); /* s_arg: ptr to mode to be set */
+ char *s_arg, *sttyparse(); /* s_arg: ptr to mode to be set */
extern const struct speeds speeds[];
-
+
if (argc == 2) {
/*
* "stty size", "stty speed" and "stty -g" are intended for
@@ -90,42 +87,45 @@ main(int argc, char *argv[])
perror("stty: TIOCGWINSZ");
exit(2);
}
- (void) printf("%d %d\n",winsize.ws_row,winsize.ws_col);
+ (void) printf("%d %d\n",
+ winsize.ws_row, winsize.ws_col);
exit(0);
- }
- else if (strcmp(argv[1], "speed") == 0) {
+ } else if (strcmp(argv[1], "speed") == 0) {
if ((i = open("/dev/tty", 0)) < 0) {
perror("stty: Cannot open /dev/tty");
exit(2);
}
- if((term = get_ttymode(i, &ocb, &cb, &stio, &termiox,
- &winsize)) < 0) {
+ if ((term = get_ttymode(i,
+ &ocb, &cb, &stio, &termiox, &winsize)) < 0) {
perror(STTY);
exit(2);
}
if (term & TERMIOS) {
- for(i=0; speeds[i].string; i++)
- if (cfgetospeed(&cb) == speeds[i].speed) {
- (void) printf("%s\n", speeds[i].string);
- exit(0);
- }
+ for (i = 0; speeds[i].string; i++)
+ if (cfgetospeed(&cb) ==
+ speeds[i].speed) {
+ (void) printf("%s\n",
+ speeds[i].string);
+ exit(0);
+ }
} else {
- for(i=0; speeds[i].string; i++)
- if ((cb.c_cflag&CBAUD) == speeds[i].speed) {
- (void) printf("%s\n", speeds[i].string);
- exit(0);
- }
+ for (i = 0; speeds[i].string; i++)
+ if ((cb.c_cflag&CBAUD) ==
+ speeds[i].speed) {
+ (void) printf("%s\n",
+ speeds[i].string);
+ exit(0);
+ }
}
(void) printf("unknown\n");
exit(1);
- }
- else if (strcmp(argv[1], "-g") == 0) {
+ } else if (strcmp(argv[1], "-g") == 0) {
if ((i = open("/dev/tty", 0)) < 0) {
perror("stty: Cannot open /dev/tty");
exit(2);
}
- if((term = get_ttymode(i, &ocb, &cb, &stio, &termiox,
- &winsize)) < 0) {
+ if ((term = get_ttymode(i,
+ &ocb, &cb, &stio, &termiox, &winsize)) < 0) {
perror(STTY);
exit(2);
}
@@ -134,7 +134,8 @@ main(int argc, char *argv[])
}
}
- if((term = get_ttymode(ioctl_desc, &ocb, &cb, &stio, &termiox, &winsize)) < 0) {
+ if ((term = get_ttymode(ioctl_desc,
+ &ocb, &cb, &stio, &termiox, &winsize)) < 0) {
perror(STTY);
exit(2);
}
@@ -143,16 +144,16 @@ main(int argc, char *argv[])
prmodes(0);
exit(0);
}
- if ((argc ==2) && strcmp(argv[1], "all") ==0) {
+ if ((argc == 2) && strcmp(argv[1], "all") == 0) {
prmodes(1);
exit(0);
}
- if ((argc ==2) && strcmp(argv[1], "everything") ==0) {
+ if ((argc == 2) && strcmp(argv[1], "everything") == 0) {
pramodes(1);
exit(0);
}
if ((argc == 2) && (argv[1][0] == '-') && (argv[1][2] == '\0'))
- switch(argv[1][1]) {
+ switch (argv[1][1]) {
case 'a':
pramodes(0);
exit(0);
@@ -162,13 +163,15 @@ main(int argc, char *argv[])
default:
(void) fprintf(stderr, "%s", USAGE);
exit(2);
- }
- if (s_arg = sttyparse(argc, argv, term, &ocb, &cb, &termiox, &winsize)) {
+ }
+ if (s_arg = sttyparse(argc, argv,
+ term, &ocb, &cb, &termiox, &winsize)) {
(void) fprintf(stderr, "unknown mode: %s\n", s_arg);
exit(2);
}
- if(set_ttymode(ioctl_desc, term, &ocb, &cb, &stio, &termiox, &winsize, &owinsize) == -1) {
+ if (set_ttymode(ioctl_desc,
+ term, &ocb, &cb, &stio, &termiox, &winsize, &owinsize) == -1) {
perror(STTY);
exit(2);
}
@@ -183,21 +186,34 @@ prmodes(int moremodes)
if (!(term & ASYNC)) {
m = stio.imode;
- if (m & IUCLC) (void) fprintf(output, "iuclc ");
- else (void) fprintf(output, "-iuclc ");
+ if (m & IUCLC)
+ (void) fprintf(output, "iuclc ");
+ else
+ (void) fprintf(output, "-iuclc ");
m = stio.omode;
- if (m & OLCUC) (void) fprintf(output, "olcuc ");
- else (void) fprintf(output, "-olcuc ");
- if (m & TAB3) (void) fprintf(output, "tab3 ");
+ if (m & OLCUC)
+ (void) fprintf(output, "olcuc ");
+ else
+ (void) fprintf(output, "-olcuc ");
+ if (m & TAB3)
+ (void) fprintf(output, "tab3 ");
m = stio.lmode;
- if (m & XCASE) (void) fprintf(output, "xcase ");
- else (void) fprintf(output, "-xcase ");
- if (m & STFLUSH) (void) fprintf(output, "stflush ");
- else (void) fprintf(output, "-stflush ");
- if (m & STWRAP) (void)fprintf(output, "stwrap ");
- else (void) fprintf(output, "-stwrap ");
- if (m & STAPPL) (void) fprintf(output, "stappl ");
- else (void) fprintf(output, "-stappl ");
+ if (m & XCASE)
+ (void) fprintf(output, "xcase ");
+ else
+ (void) fprintf(output, "-xcase ");
+ if (m & STFLUSH)
+ (void) fprintf(output, "stflush ");
+ else
+ (void) fprintf(output, "-stflush ");
+ if (m & STWRAP)
+ (void) fprintf(output, "stwrap ");
+ else
+ (void) fprintf(output, "-stwrap ");
+ if (m & STAPPL)
+ (void) fprintf(output, "stappl ");
+ else
+ (void) fprintf(output, "-stappl ");
(void) fprintf(output, "\n");
}
if (term & ASYNC) {
@@ -208,227 +224,242 @@ prmodes(int moremodes)
prspeed("ospeed ", cfgetospeed(&cb));
} else
prspeed("speed ", cfgetospeed(&cb));
- if (m&PARENB) {
- if((m&PAREXT) && (term & TERMIOS)) {
- if (m&PARODD)
- (void) fprintf(output,"markp ");
+ if (m & PARENB) {
+ if ((m & PAREXT) && (term & TERMIOS)) {
+ if (m & PARODD)
+ (void) fprintf(output, "markp ");
else
- (void) fprintf(output,"spacep ");
+ (void) fprintf(output, "spacep ");
} else {
- if (m&PARODD)
- (void) fprintf(output,"oddp ");
+ if (m & PARODD)
+ (void) fprintf(output, "oddp ");
else
- (void) fprintf(output,"evenp ");
+ (void) fprintf(output, "evenp ");
}
} else
- (void) fprintf(output,"-parity ");
- if(((m&PARENB) && !(m&CS7)) || (!(m&PARENB) && !(m&CS8)))
- (void) fprintf(output,"cs%c ",'5'+(m&CSIZE)/CS6);
- if (m&CSTOPB)
- (void) fprintf(output,"cstopb ");
- if (m&HUPCL)
- (void) fprintf(output,"hupcl ");
- if (!(m&CREAD))
- (void) fprintf(output,"-cread ");
- if (m&CLOCAL)
- (void) fprintf(output,"clocal ");
- if (m&LOBLK)
- (void) fprintf(output,"loblk ");
- (void) fprintf(output,"\n");
- if(ocb.c_line != 0)
- (void) fprintf(output,"line = %d; ", ocb.c_line);
- if(term & WINDOW) {
- (void)fprintf(output,"rows = %d; columns = %d;", winsize.ws_row, winsize.ws_col);
- (void)fprintf(output," ypixels = %d; xpixels = %d;\n", winsize.ws_ypixel, winsize.ws_xpixel);
+ (void) fprintf(output, "-parity ");
+ if (((m & PARENB) && !(m & CS7)) ||
+ (!(m & PARENB) && !(m & CS8)))
+ (void) fprintf(output, "cs%c ", '5' + (m & CSIZE)/CS6);
+ if (m & CSTOPB)
+ (void) fprintf(output, "cstopb ");
+ if (m & HUPCL)
+ (void) fprintf(output, "hupcl ");
+ if (!(m & CREAD))
+ (void) fprintf(output, "-cread ");
+ if (m & CLOCAL)
+ (void) fprintf(output, "clocal ");
+ if (m & LOBLK)
+ (void) fprintf(output, "loblk ");
+ (void) fprintf(output, "\n");
+ if (ocb.c_line != 0)
+ (void) fprintf(output, "line = %d; ", ocb.c_line);
+ if (term & WINDOW) {
+ (void) fprintf(output, "rows = %d; columns = %d;",
+ winsize.ws_row, winsize.ws_col);
+ (void) fprintf(output, " ypixels = %d; xpixels = %d;\n",
+ winsize.ws_ypixel, winsize.ws_xpixel);
}
- if((cb.c_lflag&ICANON)== 0)
- (void) fprintf(output,"min = %d; time = %d;\n",
- cb.c_cc[VMIN], cb.c_cc[VTIME]);
+ if ((cb.c_lflag & ICANON) == 0)
+ (void) fprintf(output, "min = %d; time = %d;\n",
+ cb.c_cc[VMIN], cb.c_cc[VTIME]);
if (!moremodes) {
- if(cb.c_cc[VINTR] != CINTR)
+ if (cb.c_cc[VINTR] != CINTR)
pit(cb.c_cc[VINTR], "intr", "; ");
- if(cb.c_cc[VQUIT] != CQUIT)
+ if (cb.c_cc[VQUIT] != CQUIT)
pit(cb.c_cc[VQUIT], "quit", "; ");
- if(cb.c_cc[VERASE] != CERASE)
+ if (cb.c_cc[VERASE] != CERASE)
pit(cb.c_cc[VERASE], "erase", "; ");
- if(cb.c_cc[VKILL] != CKILL)
+ if (cb.c_cc[VKILL] != CKILL)
pit(cb.c_cc[VKILL], "kill", "; ");
- if(cb.c_cc[VEOF] != CEOF)
+ if (cb.c_cc[VEOF] != CEOF)
pit(cb.c_cc[VEOF], "eof", "; ");
- if(cb.c_cc[VEOL] != CNUL)
+ if (cb.c_cc[VEOL] != CNUL)
pit(cb.c_cc[VEOL], "eol", "; ");
- if(cb.c_cc[VEOL2] != CNUL)
+ if (cb.c_cc[VEOL2] != CNUL)
pit(cb.c_cc[VEOL2], "eol2", "; ");
- if(cb.c_cc[VSWTCH] != CSWTCH)
+ if (cb.c_cc[VSWTCH] != CSWTCH)
pit(cb.c_cc[VSWTCH], "swtch", "; ");
- if(term & TERMIOS) {
- if(cb.c_cc[VSTART] != CSTART)
+ if (term & TERMIOS) {
+ if (cb.c_cc[VSTART] != CSTART)
pit(cb.c_cc[VSTART], "start", "; ");
- if(cb.c_cc[VSTOP] != CSTOP)
+ if (cb.c_cc[VSTOP] != CSTOP)
pit(cb.c_cc[VSTOP], "stop", "; ");
- if(cb.c_cc[VSUSP] != CSUSP)
+ if (cb.c_cc[VSUSP] != CSUSP)
pit(cb.c_cc[VSUSP], "susp", "; ");
- if(cb.c_cc[VDSUSP] != CDSUSP)
+ if (cb.c_cc[VDSUSP] != CDSUSP)
pit(cb.c_cc[VDSUSP], "dsusp", "; ");
- if(cb.c_cc[VREPRINT] != CRPRNT)
+ if (cb.c_cc[VREPRINT] != CRPRNT)
pit(cb.c_cc[VREPRINT], "rprnt", "; ");
- if(cb.c_cc[VDISCARD] != CFLUSH)
+ if (cb.c_cc[VDISCARD] != CFLUSH)
pit(cb.c_cc[VDISCARD], "flush", "; ");
- if(cb.c_cc[VWERASE] != CWERASE)
+ if (cb.c_cc[VWERASE] != CWERASE)
pit(cb.c_cc[VWERASE], "werase", "; ");
- if(cb.c_cc[VLNEXT] != CLNEXT)
+ if (cb.c_cc[VLNEXT] != CLNEXT)
pit(cb.c_cc[VLNEXT], "lnext", "; ");
}
}
- if(pitt) (void) fprintf(output,"\n");
+ if (pitt)
+ (void) fprintf(output, "\n");
m = cb.c_iflag;
- if (m&IGNBRK)
- (void) fprintf(output,"ignbrk ");
- else if (!(m&BRKINT))
- (void) fprintf(output,"-brkint ");
- if (!(m&INPCK))
- (void) fprintf(output,"-inpck ");
- else if (!(m&IGNPAR))
- (void) fprintf(output,"-ignpar ");
- if (m&PARMRK)
- (void) fprintf(output,"parmrk ");
- if (!(m&ISTRIP))
- (void) fprintf(output,"-istrip ");
- if (m&INLCR)
- (void) fprintf(output,"inlcr ");
- if (m&IGNCR)
- (void) fprintf(output,"igncr ");
- if (!(m&ICRNL))
- (void) fprintf(output,"-icrnl ");
- if (m&IUCLC)
- (void) fprintf(output,"iuclc ");
- if (!(m&IXON))
- (void) fprintf(output,"-ixon ");
- else if (m&IXANY)
- (void) fprintf(output,"ixany ");
- if (m&IXOFF)
- (void) fprintf(output,"ixoff ");
- if ((term & TERMIOS) && (m&IMAXBEL))
- (void) fprintf(output,"imaxbel ");
+ if (m & IGNBRK)
+ (void) fprintf(output, "ignbrk ");
+ else if (!(m & BRKINT))
+ (void) fprintf(output, "-brkint ");
+ if (!(m & INPCK))
+ (void) fprintf(output, "-inpck ");
+ else if (!(m & IGNPAR))
+ (void) fprintf(output, "-ignpar ");
+ if (m & PARMRK)
+ (void) fprintf(output, "parmrk ");
+ if (!(m & ISTRIP))
+ (void) fprintf(output, "-istrip ");
+ if (m & INLCR)
+ (void) fprintf(output, "inlcr ");
+ if (m & IGNCR)
+ (void) fprintf(output, "igncr ");
+ if (!(m & ICRNL))
+ (void) fprintf(output, "-icrnl ");
+ if (m & IUCLC)
+ (void) fprintf(output, "iuclc ");
+ if (!(m & IXON))
+ (void) fprintf(output, "-ixon ");
+ else if (m & IXANY)
+ (void) fprintf(output, "ixany ");
+ if (m & IXOFF)
+ (void) fprintf(output, "ixoff ");
+ if ((term & TERMIOS) && (m & IMAXBEL))
+ (void) fprintf(output, "imaxbel ");
m = cb.c_oflag;
- if (!(m&OPOST))
- (void) fprintf(output,"-opost ");
+ if (!(m & OPOST))
+ (void) fprintf(output, "-opost ");
else {
- if (m&OLCUC)
- (void) fprintf(output,"olcuc ");
- if (!(m&ONLCR))
- (void) fprintf(output,"-onlcr ");
- if (m&OCRNL)
- (void) fprintf(output,"ocrnl ");
- if (m&ONOCR)
- (void) fprintf(output,"onocr ");
- if (m&ONLRET)
- (void) fprintf(output,"onlret ");
- if (m&OFILL)
- if (m&OFDEL)
- (void) fprintf(output,"del-fill ");
+ if (m & OLCUC)
+ (void) fprintf(output, "olcuc ");
+ if (!(m & ONLCR))
+ (void) fprintf(output, "-onlcr ");
+ if (m & OCRNL)
+ (void) fprintf(output, "ocrnl ");
+ if (m & ONOCR)
+ (void) fprintf(output, "onocr ");
+ if (m & ONLRET)
+ (void) fprintf(output, "onlret ");
+ if (m & OFILL)
+ if (m & OFDEL)
+ (void) fprintf(output, "del-fill ");
+ else
+ (void) fprintf(output, "nul-fill ");
+ delay((m & CRDLY)/CR1, "cr");
+ delay((m & NLDLY)/NL1, "nl");
+ if ((m & TABDLY) == XTABS)
+ (void) fprintf(output, "-tabs ");
else
- (void) fprintf(output,"nul-fill ");
- delay((m&CRDLY)/CR1, "cr");
- delay((m&NLDLY)/NL1, "nl");
- if ((m&TABDLY) == XTABS)
- (void) fprintf(output,"-tabs ");
- else
- delay((m&TABDLY)/TAB1, "tab");
- delay((m&BSDLY)/BS1, "bs");
- delay((m&VTDLY)/VT1, "vt");
- delay((m&FFDLY)/FF1, "ff");
+ delay((m & TABDLY)/TAB1, "tab");
+ delay((m & BSDLY)/BS1, "bs");
+ delay((m & VTDLY)/VT1, "vt");
+ delay((m & FFDLY)/FF1, "ff");
}
- (void) fprintf(output,"\n");
+ (void) fprintf(output, "\n");
m = cb.c_lflag;
- if (!(m&ISIG))
- (void) fprintf(output,"-isig ");
- if (!(m&ICANON))
- (void) fprintf(output,"-icanon ");
- if (m&XCASE)
- (void) fprintf(output,"xcase ");
- if (!(m&ECHO))
- (void) fprintf(output,"-echo ");
- if (m&ECHOE) {
- if (m&ECHOKE)
- (void) fprintf(output,"crt ");
+ if (!(m & ISIG))
+ (void) fprintf(output, "-isig ");
+ if (!(m & ICANON))
+ (void) fprintf(output, "-icanon ");
+ if (m & XCASE)
+ (void) fprintf(output, "xcase ");
+ if (!(m & ECHO))
+ (void) fprintf(output, "-echo ");
+ if (m & ECHOE) {
+ if (m & ECHOKE)
+ (void) fprintf(output, "crt ");
else
- (void) fprintf(output,"echoe -echoke ");
+ (void) fprintf(output, "echoe -echoke ");
} else {
- if (!(m&ECHOPRT))
- (void) fprintf(output,"-echoprt ");
+ if (!(m & ECHOPRT))
+ (void) fprintf(output, "-echoprt ");
}
- if (!(m&ECHOK))
- (void) fprintf(output,"-echok ");
- if (m&ECHONL)
- (void) fprintf(output,"echonl ");
- if (m&NOFLSH)
- (void) fprintf(output,"noflsh ");
- if (m&TOSTOP)
- (void) fprintf(output,"tostop ");
- if (!(m&ECHOCTL))
- (void) fprintf(output,"-echoctl ");
- if (m&DEFECHO)
- (void) fprintf(output,"defecho ");
- if (m&FLUSHO)
- (void) fprintf(output,"flusho ");
- if (m&PENDIN)
- (void) fprintf(output,"pendin ");
- if (m&IEXTEN)
- (void) fprintf(output,"iexten ");
- (void) fprintf(output,"\n");
+ if (!(m & ECHOK))
+ (void) fprintf(output, "-echok ");
+ if (m & ECHONL)
+ (void) fprintf(output, "echonl ");
+ if (m & NOFLSH)
+ (void) fprintf(output, "noflsh ");
+ if (m & TOSTOP)
+ (void) fprintf(output, "tostop ");
+ if (!(m & ECHOCTL))
+ (void) fprintf(output, "-echoctl ");
+ if (m & DEFECHO)
+ (void) fprintf(output, "defecho ");
+ if (m & FLUSHO)
+ (void) fprintf(output, "flusho ");
+ if (m & PENDIN)
+ (void) fprintf(output, "pendin ");
+ if (m & IEXTEN)
+ (void) fprintf(output, "iexten ");
+ (void) fprintf(output, "\n");
}
- if(term & FLOW) {
+ if (term & FLOW) {
m = termiox.x_hflag;
- if(m & RTSXOFF)
- (void) fprintf(output,"rtsxoff ");
- if(m & CTSXON)
- (void) fprintf(output,"ctsxon ");
- if(m & DTRXOFF)
- (void) fprintf(output,"dterxoff ");
- if(m & CDXON)
- (void) fprintf(output,"rlsdxon ");
- if(m & ISXOFF)
- (void) fprintf(output,"isxoff ");
+ if (m & RTSXOFF)
+ (void) fprintf(output, "rtsxoff ");
+ if (m & CTSXON)
+ (void) fprintf(output, "ctsxon ");
+ if (m & DTRXOFF)
+ (void) fprintf(output, "dterxoff ");
+ if (m & CDXON)
+ (void) fprintf(output, "rlsdxon ");
+ if (m & ISXOFF)
+ (void) fprintf(output, "isxoff ");
m = termiox.x_cflag;
- switch(m & XMTCLK)
- {
- case XCIBRG: (void)fprintf(output,"xcibrg ");
- break;
- case XCTSET: (void)fprintf(output,"xctset ");
- break;
- case XCRSET: (void)fprintf(output,"xcrset ");
+ switch (m & XMTCLK) {
+ case XCIBRG:
+ (void) fprintf(output, "xcibrg ");
+ break;
+ case XCTSET:
+ (void) fprintf(output, "xctset ");
+ break;
+ case XCRSET:
+ (void) fprintf(output, "xcrset ");
+ break;
}
-
- switch(m & RCVCLK)
- {
- case RCIBRG: (void)fprintf(output,"rcibrg ");
- break;
- case RCTSET: (void)fprintf(output,"rctset ");
- break;
- case RCRSET: (void)fprintf(output,"rcrset ");
+
+ switch (m & RCVCLK) {
+ case RCIBRG:
+ (void) fprintf(output, "rcibrg ");
+ break;
+ case RCTSET:
+ (void) fprintf(output, "rctset ");
+ break;
+ case RCRSET:
+ (void) fprintf(output, "rcrset ");
+ break;
}
-
- switch(m & TSETCLK)
- {
- case TSETCOFF: (void)fprintf(output,"tsetcoff ");
- break;
- case TSETCRBRG: (void)fprintf(output,"tsetcrc ");
- break;
- case TSETCTBRG: (void)fprintf(output,"tsetcxc ");
+
+ switch (m & TSETCLK) {
+ case TSETCOFF:
+ (void) fprintf(output, "tsetcoff ");
+ break;
+ case TSETCRBRG:
+ (void) fprintf(output, "tsetcrc ");
+ break;
+ case TSETCTBRG:
+ (void) fprintf(output, "tsetcxc ");
+ break;
}
-
- switch(m & RSETCLK)
- {
- case RSETCOFF: (void)fprintf(output,"rsetcoff ");
- break;
- case RSETCRBRG: (void)fprintf(output,"rsetcrc ");
- break;
- case RSETCTBRG: (void)fprintf(output,"rsetcxc ");
+
+ switch (m & RSETCLK) {
+ case RSETCOFF:
+ (void) fprintf(output, "rsetcoff ");
+ break;
+ case RSETCRBRG:
+ (void) fprintf(output, "rsetcrc ");
+ break;
+ case RSETCTBRG:
+ (void) fprintf(output, "rsetcxc ");
}
- (void) fprintf(output,"\n");
+ (void) fprintf(output, "\n");
}
- if(moremodes)
+ if (moremodes)
prachars();
}
@@ -439,23 +470,25 @@ pramodes(int tabform)
int m;
m = cb.c_cflag;
- if(term & ASYNC) {
+ if (term & ASYNC) {
if ((term & TERMIOS) && cfgetispeed(&cb) != 0 &&
cfgetispeed(&cb) != cfgetospeed(&cb)) {
prspeed("ispeed ", cfgetispeed(&cb));
prspeed("ospeed ", cfgetospeed(&cb));
} else
prspeed("speed ", cfgetospeed(&cb));
- if(!(term & TERMIOS))
- (void) fprintf(output,"line = %d; ", ocb.c_line);
- (void) fprintf(output,"\n");
- if(term & WINDOW) {
- (void)fprintf(output,"rows = %d columns = %d; ", winsize.ws_row, winsize.ws_col);
- (void)fprintf(output,"ypixels = %d xpixels = %d\n", winsize.ws_ypixel, winsize.ws_xpixel);
+ if (!(term & TERMIOS))
+ (void) fprintf(output, "line = %d; ", ocb.c_line);
+ (void) fprintf(output, "\n");
+ if (term & WINDOW) {
+ (void) fprintf(output, "rows = %d columns = %d; ",
+ winsize.ws_row, winsize.ws_col);
+ (void) fprintf(output, "ypixels = %d xpixels = %d\n",
+ winsize.ws_ypixel, winsize.ws_xpixel);
}
- if((cb.c_lflag&ICANON)== 0)
- (void) fprintf(output,"min = %d; time = %d;\n", cb.c_cc[VMIN],
- cb.c_cc[VTIME]);
+ if ((cb.c_lflag & ICANON) == 0)
+ (void) fprintf(output, "min = %d; time = %d;\n",
+ cb.c_cc[VMIN], cb.c_cc[VTIME]);
if (!tabform) {
pit(cb.c_cc[VINTR], "intr", "; ");
pit(cb.c_cc[VQUIT], "quit", "; ");
@@ -465,7 +498,7 @@ pramodes(int tabform)
pit(cb.c_cc[VEOL], "eol", "; ");
pit(cb.c_cc[VEOL2], "eol2", "; ");
pit(cb.c_cc[VSWTCH], "swtch", ";\n");
- if(term & TERMIOS) {
+ if (term & TERMIOS) {
pit(cb.c_cc[VSTART], "start", "; ");
pit(cb.c_cc[VSTOP], "stop", "; ");
pit(cb.c_cc[VSUSP], "susp", "; ");
@@ -479,126 +512,138 @@ pramodes(int tabform)
} else
pit((unsigned)stio.tab, "ctab", "\n");
m = cb.c_cflag;
- (void) fprintf(output,"-parenb "+((m&PARENB)!=0));
- (void) fprintf(output,"-parodd "+((m&PARODD)!=0));
- (void) fprintf(output,"cs%c ",'5'+(m&CSIZE)/CS6);
- (void) fprintf(output,"-cstopb "+((m&CSTOPB)!=0));
- (void) fprintf(output,"-hupcl "+((m&HUPCL)!=0));
- (void) fprintf(output,"-cread "+((m&CREAD)!=0));
- (void) fprintf(output,"-clocal "+((m&CLOCAL)!=0));
-
- (void) fprintf(output,"-loblk "+((m&LOBLK)!=0));
- if(term & TERMIOS)
- (void) fprintf(output,"-parext "+((m&PAREXT)!=0));
-
- (void) fprintf(output,"\n");
+ (void) fprintf(output, "-parenb " + ((m & PARENB) != 0));
+ (void) fprintf(output, "-parodd " + ((m & PARODD) != 0));
+ (void) fprintf(output, "cs%c ", '5'+ (m & CSIZE)/CS6);
+ (void) fprintf(output, "-cstopb " + ((m & CSTOPB) != 0));
+ (void) fprintf(output, "-hupcl " + ((m & HUPCL) != 0));
+ (void) fprintf(output, "-cread " + ((m & CREAD) != 0));
+ (void) fprintf(output, "-clocal " + ((m & CLOCAL) != 0));
+
+ (void) fprintf(output, "-loblk " + ((m & LOBLK) != 0));
+ if (term & TERMIOS)
+ (void) fprintf(output, "-parext " + ((m & PAREXT) != 0));
+
+ (void) fprintf(output, "\n");
m = cb.c_iflag;
- (void) fprintf(output,"-ignbrk "+((m&IGNBRK)!=0));
- (void) fprintf(output,"-brkint "+((m&BRKINT)!=0));
- (void) fprintf(output,"-ignpar "+((m&IGNPAR)!=0));
- (void) fprintf(output,"-parmrk "+((m&PARMRK)!=0));
- (void) fprintf(output,"-inpck "+((m&INPCK)!=0));
- (void) fprintf(output,"-istrip "+((m&ISTRIP)!=0));
- (void) fprintf(output,"-inlcr "+((m&INLCR)!=0));
- (void) fprintf(output,"-igncr "+((m&IGNCR)!=0));
- (void) fprintf(output,"-icrnl "+((m&ICRNL)!=0));
- (void) fprintf(output,"-iuclc "+((m&IUCLC)!=0));
- (void) fprintf(output,"\n");
- (void) fprintf(output,"-ixon "+((m&IXON)!=0));
- (void) fprintf(output,"-ixany "+((m&IXANY)!=0));
- (void) fprintf(output,"-ixoff "+((m&IXOFF)!=0));
- if(term & TERMIOS)
- (void) fprintf(output,"-imaxbel "+((m&IMAXBEL)!=0));
- (void) fprintf(output,"\n");
+ (void) fprintf(output, "-ignbrk " + ((m & IGNBRK) != 0));
+ (void) fprintf(output, "-brkint " + ((m & BRKINT) != 0));
+ (void) fprintf(output, "-ignpar " + ((m & IGNPAR) != 0));
+ (void) fprintf(output, "-parmrk " + ((m & PARMRK) != 0));
+ (void) fprintf(output, "-inpck " + ((m & INPCK) != 0));
+ (void) fprintf(output, "-istrip " + ((m & ISTRIP) != 0));
+ (void) fprintf(output, "-inlcr " + ((m & INLCR) != 0));
+ (void) fprintf(output, "-igncr " + ((m & IGNCR) != 0));
+ (void) fprintf(output, "-icrnl " + ((m & ICRNL) != 0));
+ (void) fprintf(output, "-iuclc " + ((m & IUCLC) != 0));
+ (void) fprintf(output, "\n");
+ (void) fprintf(output, "-ixon " + ((m & IXON) != 0));
+ (void) fprintf(output, "-ixany " + ((m & IXANY) != 0));
+ (void) fprintf(output, "-ixoff " + ((m & IXOFF) != 0));
+ if (term & TERMIOS)
+ (void) fprintf(output, "-imaxbel " + ((m & IMAXBEL) != 0));
+ (void) fprintf(output, "\n");
m = cb.c_lflag;
- (void) fprintf(output,"-isig "+((m&ISIG)!=0));
- (void) fprintf(output,"-icanon "+((m&ICANON)!=0));
- (void) fprintf(output,"-xcase "+((m&XCASE)!=0));
- (void) fprintf(output,"-echo "+((m&ECHO)!=0));
- (void) fprintf(output,"-echoe "+((m&ECHOE)!=0));
- (void) fprintf(output,"-echok "+((m&ECHOK)!=0));
- (void) fprintf(output,"-echonl "+((m&ECHONL)!=0));
- (void) fprintf(output,"-noflsh "+((m&NOFLSH)!=0));
- if(term & TERMIOS) {
- (void) fprintf(output,"\n");
- (void) fprintf(output,"-tostop "+((m&TOSTOP)!=0));
- (void) fprintf(output,"-echoctl "+((m&ECHOCTL)!=0));
- (void) fprintf(output,"-echoprt "+((m&ECHOPRT)!=0));
- (void) fprintf(output,"-echoke "+((m&ECHOKE)!=0));
- (void) fprintf(output,"-defecho "+((m&DEFECHO)!=0));
- (void) fprintf(output,"-flusho "+((m&FLUSHO)!=0));
- (void) fprintf(output,"-pendin "+((m&PENDIN)!=0));
- (void) fprintf(output,"-iexten "+((m&IEXTEN)!=0));
+ (void) fprintf(output, "-isig " + ((m & ISIG) != 0));
+ (void) fprintf(output, "-icanon " + ((m & ICANON) != 0));
+ (void) fprintf(output, "-xcase " + ((m & XCASE) != 0));
+ (void) fprintf(output, "-echo " + ((m & ECHO) != 0));
+ (void) fprintf(output, "-echoe " + ((m & ECHOE) != 0));
+ (void) fprintf(output, "-echok " + ((m & ECHOK) != 0));
+ (void) fprintf(output, "-echonl " + ((m & ECHONL) != 0));
+ (void) fprintf(output, "-noflsh " + ((m & NOFLSH) != 0));
+ if (term & TERMIOS) {
+ (void) fprintf(output, "\n");
+ (void) fprintf(output, "-tostop " + ((m & TOSTOP) != 0));
+ (void) fprintf(output, "-echoctl " + ((m & ECHOCTL) != 0));
+ (void) fprintf(output, "-echoprt " + ((m & ECHOPRT) != 0));
+ (void) fprintf(output, "-echoke " + ((m & ECHOKE) != 0));
+ (void) fprintf(output, "-defecho " + ((m & DEFECHO) != 0));
+ (void) fprintf(output, "-flusho " + ((m & FLUSHO) != 0));
+ (void) fprintf(output, "-pendin " + ((m & PENDIN) != 0));
+ (void) fprintf(output, "-iexten " + ((m & IEXTEN) != 0));
}
- if(!(term & ASYNC)) {
- (void) fprintf(output,"-stflush "+((m&STFLUSH)!=0));
- (void) fprintf(output,"-stwrap "+((m&STWRAP)!=0));
- (void) fprintf(output,"-stappl "+((m&STAPPL)!=0));
+ if (!(term & ASYNC)) {
+ (void) fprintf(output, "-stflush " + ((m & STFLUSH) != 0));
+ (void) fprintf(output, "-stwrap " + ((m & STWRAP) != 0));
+ (void) fprintf(output, "-stappl " + ((m & STAPPL) != 0));
}
- (void) fprintf(output,"\n");
+ (void) fprintf(output, "\n");
m = cb.c_oflag;
- (void) fprintf(output,"-opost "+((m&OPOST)!=0));
- (void) fprintf(output,"-olcuc "+((m&OLCUC)!=0));
- (void) fprintf(output,"-onlcr "+((m&ONLCR)!=0));
- (void) fprintf(output,"-ocrnl "+((m&OCRNL)!=0));
- (void) fprintf(output,"-onocr "+((m&ONOCR)!=0));
- (void) fprintf(output,"-onlret "+((m&ONLRET)!=0));
- (void) fprintf(output,"-ofill "+((m&OFILL)!=0));
- (void) fprintf(output,"-ofdel "+((m&OFDEL)!=0));
- delay((m&CRDLY)/CR1, "cr");
- delay((m&NLDLY)/NL1, "nl");
- if ((m&TABDLY) == XTABS)
- (void) fprintf(output,"-tabs ");
+ (void) fprintf(output, "-opost " + ((m & OPOST) != 0));
+ (void) fprintf(output, "-olcuc " + ((m & OLCUC) != 0));
+ (void) fprintf(output, "-onlcr " + ((m & ONLCR) != 0));
+ (void) fprintf(output, "-ocrnl " + ((m & OCRNL) != 0));
+ (void) fprintf(output, "-onocr " + ((m & ONOCR) != 0));
+ (void) fprintf(output, "-onlret " + ((m & ONLRET) != 0));
+ (void) fprintf(output, "-ofill " + ((m & OFILL) != 0));
+ (void) fprintf(output, "-ofdel " + ((m & OFDEL) != 0));
+ delay((m & CRDLY)/CR1, "cr");
+ delay((m & NLDLY)/NL1, "nl");
+ if ((m & TABDLY) == XTABS)
+ (void) fprintf(output, "-tabs ");
else
- delay((m&TABDLY)/TAB1, "tab");
- delay((m&BSDLY)/BS1, "bs");
- delay((m&VTDLY)/VT1, "vt");
- delay((m&FFDLY)/FF1, "ff");
- (void) fprintf(output,"\n");
- if(term & FLOW) {
+ delay((m & TABDLY)/TAB1, "tab");
+ delay((m & BSDLY)/BS1, "bs");
+ delay((m & VTDLY)/VT1, "vt");
+ delay((m & FFDLY)/FF1, "ff");
+ (void) fprintf(output, "\n");
+ if (term & FLOW) {
m = termiox.x_hflag;
- (void) fprintf(output,"-rtsxoff "+((m&RTSXOFF)!=0));
- (void) fprintf(output,"-ctsxon "+((m&CTSXON)!=0));
- (void) fprintf(output,"-dterxoff "+((m&DTRXOFF)!=0));
- (void) fprintf(output,"-rlsdxon "+((m&CDXON)!=0));
- (void) fprintf(output,"-isxoff "+((m&ISXOFF)!=0));
+ (void) fprintf(output, "-rtsxoff " + ((m & RTSXOFF) != 0));
+ (void) fprintf(output, "-ctsxon " + ((m & CTSXON) != 0));
+ (void) fprintf(output, "-dterxoff " + ((m & DTRXOFF) != 0));
+ (void) fprintf(output, "-rlsdxon " + ((m & CDXON) != 0));
+ (void) fprintf(output, "-isxoff " + ((m & ISXOFF) != 0));
m = termiox.x_cflag;
- switch(m & XMTCLK)
- {
- case XCIBRG: (void)fprintf(output,"xcibrg ");
- break;
- case XCTSET: (void)fprintf(output,"xctset ");
- break;
- case XCRSET: (void)fprintf(output,"xcrset ");
+ switch (m & XMTCLK) {
+ case XCIBRG:
+ (void) fprintf(output, "xcibrg ");
+ break;
+ case XCTSET:
+ (void) fprintf(output, "xctset ");
+ break;
+ case XCRSET:
+ (void) fprintf(output, "xcrset ");
+ break;
}
-
- switch(m & RCVCLK)
- {
- case RCIBRG: (void)fprintf(output,"rcibrg ");
- break;
- case RCTSET: (void)fprintf(output,"rctset ");
- break;
- case RCRSET: (void)fprintf(output,"rcrset ");
+
+ switch (m & RCVCLK) {
+ case RCIBRG:
+ (void) fprintf(output, "rcibrg ");
+ break;
+ case RCTSET:
+ (void) fprintf(output, "rctset ");
+ break;
+ case RCRSET:
+ (void) fprintf(output, "rcrset ");
+ break;
}
-
- switch(m & TSETCLK)
- {
- case TSETCOFF: (void)fprintf(output,"tsetcoff ");
- break;
- case TSETCRBRG: (void)fprintf(output,"tsetcrc ");
- break;
- case TSETCTBRG: (void)fprintf(output,"tsetcxc ");
+
+ switch (m & TSETCLK) {
+ case TSETCOFF:
+ (void) fprintf(output, "tsetcoff ");
+ break;
+ case TSETCRBRG:
+ (void) fprintf(output, "tsetcrc ");
+ break;
+ case TSETCTBRG:
+ (void) fprintf(output, "tsetcxc ");
+ break;
}
-
- switch(m & RSETCLK)
- {
- case RSETCOFF: (void)fprintf(output,"rsetcoff ");
- break;
- case RSETCRBRG: (void)fprintf(output,"rsetcrc ");
- break;
- case RSETCTBRG: (void)fprintf(output,"rsetcxc ");
+
+ switch (m & RSETCLK) {
+ case RSETCOFF:
+ (void) fprintf(output, "rsetcoff ");
+ break;
+ case RSETCRBRG:
+ (void) fprintf(output, "rsetcrc ");
+ break;
+ case RSETCTBRG:
+ (void) fprintf(output, "rsetcxc ");
+ break;
}
- (void) fprintf(output,"\n");
+ (void) fprintf(output, "\n");
}
if (tabform)
prachars();
@@ -607,10 +652,10 @@ pramodes(int tabform)
void
prachars(void)
{
- if ((cb.c_lflag&ICANON)==0)
- (void) fprintf(output,"min %d, time %d\n", cb.c_cc[VMIN],
+ if ((cb.c_lflag & ICANON) == 0)
+ (void) fprintf(output, "min %d, time %d\n", cb.c_cc[VMIN],
cb.c_cc[VTIME]);
- (void) fprintf(output,"\
+ (void) fprintf(output, "\
erase kill werase rprnt flush lnext susp intr quit stop eof\
\n");
pcol(cb.c_cc[VERASE], 0);
@@ -625,14 +670,14 @@ erase kill werase rprnt flush lnext susp intr quit stop eof\
pcol(cb.c_cc[VSTOP], cb.c_cc[VSTART]);
if (cb.c_lflag&ICANON)
pcol(cb.c_cc[VEOF], cb.c_cc[VEOL]);
- (void) fprintf(output,"\n");
+ (void) fprintf(output, "\n");
if (cb.c_cc[VEOL2] != 0 || cb.c_cc[VSWTCH] != 0) {
- (void) fprintf(output,"\
+ (void) fprintf(output, "\
eol2 swtch\
\n");
pcol(cb.c_cc[VEOL2], 0);
pcol(cb.c_cc[VSWTCH], 0);
- (void) fprintf(output,"\n");
+ (void) fprintf(output, "\n");
}
}
@@ -649,28 +694,28 @@ pcol(int ch1, int ch2)
if (ch1 == 0)
continue;
if (ch1 & 0200 && !isprint(ch1)) {
- (void) fprintf(output,"M-");
+ (void) fprintf(output, "M-");
nout += 2;
ch1 &= ~ 0200;
}
if (ch1 == 0177) {
- (void) fprintf(output,"^");
+ (void) fprintf(output, "^");
nout++;
ch1 = '?';
} else if (ch1 < ' ') {
- (void) fprintf(output,"^");
+ (void) fprintf(output, "^");
nout++;
ch1 += '@';
}
- (void) fprintf(output,"%c", ch1);
+ (void) fprintf(output, "%c", ch1);
nout++;
if (ch2 != 0) {
- (void) fprintf(output,"/");
+ (void) fprintf(output, "/");
nout++;
}
}
while (nout < 7) {
- (void) fprintf(output," ");
+ (void) fprintf(output, " ");
nout++;
}
}
@@ -681,43 +726,44 @@ pit(unsigned char what, char *itsname, char *sep)
{
pitt++;
- (void) fprintf(output,"%s", itsname);
- if ((term & TERMIOS) && what == _POSIX_VDISABLE || !(term & TERMIOS) && what == 0200) {
- (void) fprintf(output," = <undef>%s", sep);
+ (void) fprintf(output, "%s", itsname);
+ if ((term & TERMIOS) && what == _POSIX_VDISABLE ||
+ !(term & TERMIOS) && what == 0200) {
+ (void) fprintf(output, " = <undef>%s", sep);
return;
}
- (void) fprintf(output," = ");
+ (void) fprintf(output, " = ");
if (what & 0200 && !isprint(what)) {
- (void) fprintf(output,"-");
+ (void) fprintf(output, "-");
what &= ~ 0200;
}
if (what == 0177) {
- (void) fprintf(output,"^?%s", sep);
+ (void) fprintf(output, "^?%s", sep);
return;
} else if (what < ' ') {
- (void) fprintf(output,"^");
+ (void) fprintf(output, "^");
what += '`';
}
- (void) fprintf(output,"%c%s", what, sep);
+ (void) fprintf(output, "%c%s", what, sep);
}
void
delay(int m, char *s)
{
- if(m)
- (void) fprintf(output,"%s%d ", s, m);
+ if (m)
+ (void) fprintf(output, "%s%d ", s, m);
}
long speed[] = {
- 0,50,75,110,134,150,200,300,600,1200,1800,2400,4800,9600,19200,38400,
- 57600,76800,115200,153600,230400,307200,460800
+ 0, 50, 75, 110, 134, 150, 200, 300,
+ 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400,
+ 57600, 76800, 115200, 153600, 230400, 307200, 460800, 921600
};
void
prspeed(char *c, int s)
{
-
- (void) fprintf(output,"%s%d baud; ", c, speed[s]);
+ (void) fprintf(output, "%s%d baud; ", c, speed[s]);
}
/*
@@ -732,14 +778,15 @@ prencode(void)
/* Since the -g option is mostly used for redirecting to a file */
/* We must print to stdout here, not stderr */
- (void) printf("%x:%x:%x:%x:",cb.c_iflag,cb.c_oflag,cb.c_cflag,cb.c_lflag);
+ (void) printf("%x:%x:%x:%x:", cb.c_iflag, cb.c_oflag,
+ cb.c_cflag, cb.c_lflag);
- if(term & TERMIOS)
+ if (term & TERMIOS)
/* last control slot is unused */
last = NCCS - 2;
else
last = NCC - 1;
- for(i = 0; i < last; i++)
+ for (i = 0; i < last; i++)
(void) printf("%x:", cb.c_cc[i]);
(void) printf("%x\n", cb.c_cc[last]);
}
diff --git a/usr/src/ucbcmd/stty/sttytable.c b/usr/src/ucbcmd/stty/sttytable.c
index 9f1539123b..1544f42fb8 100644
--- a/usr/src/ucbcmd/stty/sttytable.c
+++ b/usr/src/ucbcmd/stty/sttytable.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -19,16 +18,15 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 1995 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <stdio.h>
#include <sys/types.h>
@@ -43,7 +41,7 @@ const struct speeds speeds[] = {
"75", B75,
"110", B110,
"134", B134,
- "134.5",B134,
+ "134.5", B134,
"150", B150,
"200", B200,
"300", B300,
@@ -66,6 +64,7 @@ const struct speeds speeds[] = {
"230400", B230400,
"307200", B307200,
"460800", B460800,
+ "921600", B921600,
0,
};
/* Control Modes */
@@ -131,7 +130,7 @@ const struct mds imodes[] = {
"parmrk", PARMRK, 0,
"-parmrk", 0, PARMRK,
"inpck", INPCK, 0,
- "-inpck", 0,INPCK,
+ "-inpck", 0, INPCK,
"istrip", ISTRIP, 0,
"-istrip", 0, ISTRIP,
"inlcr", INLCR, 0,
@@ -255,7 +254,7 @@ const struct mds omodes[] = {
"-nl", ONLCR, (OCRNL|ONLRET),
"nl", 0, ONLCR,
"ocrnl", OCRNL, 0,
- "-ocrnl",0, OCRNL,
+ "-ocrnl", 0, OCRNL,
"onocr", ONOCR, 0,
"-onocr", 0, ONOCR,
"onlret", ONLRET, 0,
@@ -317,18 +316,19 @@ const struct mds hmodes[] = {
};
const struct mds clkmodes[] = {
- "xcibrg", XCIBRG, XMTCLK,
- "xctset", XCTSET, XMTCLK,
- "xcrset", XCRSET, XMTCLK,
- "rcibrg", RCIBRG, RCVCLK,
- "rctset", RCTSET, RCVCLK,
- "rcrset", RCRSET, RCVCLK,
- "tsetcoff", TSETCOFF, TSETCLK,
- "tsetcrc", TSETCRBRG, TSETCLK,
- "tsetcxc", TSETCTBRG, TSETCLK,
- "rsetcoff", RSETCOFF, RSETCLK,
- "rsetcrc", RSETCRBRG, RSETCLK,
- "rsetcxc", RSETCTBRG, RSETCLK,
- "async", XCIBRG|RCIBRG|TSETCOFF|RSETCOFF, XMTCLK|RCVCLK|TSETCLK|RSETCLK,
+ "xcibrg", XCIBRG, XMTCLK,
+ "xctset", XCTSET, XMTCLK,
+ "xcrset", XCRSET, XMTCLK,
+ "rcibrg", RCIBRG, RCVCLK,
+ "rctset", RCTSET, RCVCLK,
+ "rcrset", RCRSET, RCVCLK,
+ "tsetcoff", TSETCOFF, TSETCLK,
+ "tsetcrc", TSETCRBRG, TSETCLK,
+ "tsetcxc", TSETCTBRG, TSETCLK,
+ "rsetcoff", RSETCOFF, RSETCLK,
+ "rsetcrc", RSETCRBRG, RSETCLK,
+ "rsetcxc", RSETCTBRG, RSETCLK,
+ "async",
+ XCIBRG|RCIBRG|TSETCOFF|RSETCOFF, XMTCLK|RCVCLK|TSETCLK|RSETCLK,
0,
};
diff --git a/usr/src/ucbcmd/tset/tset.c b/usr/src/ucbcmd/tset/tset.c
index 8476c4faa1..dcdbcac983 100644
--- a/usr/src/ucbcmd/tset/tset.c
+++ b/usr/src/ucbcmd/tset/tset.c
@@ -1,5 +1,5 @@
/*
- * Copyright 1999 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -13,261 +13,259 @@
* specifies the terms and conditions for redistribution.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
-** TSET -- set terminal modes
-**
-** This program does sophisticated terminal initialization.
-** I recommend that you include it in your .profile or .login
-** file to initialize whatever terminal you are on.
-**
-** There are several features:
-**
-** A special file or sequence (as controlled by the termcap file)
-** is sent to the terminal.
-**
-** Mode bits are set on a per-terminal_type basis (much better
-** than UNIX itself). This allows special delays, automatic
-** tabs, etc.
-**
-** Erase and Kill characters can be set to whatever you want.
-** Default is to change erase to control-H on a terminal which
-** can overstrike, and leave it alone on anything else. Kill
-** is always left alone unless specifically requested. These
-** characters can be represented as "^X" meaning control-X;
-** X is any character.
-**
-** Terminals which are dialups or plugboard types can be aliased
-** to whatever type you may have in your home or office. Thus,
-** if you know that when you dial up you will always be on a
-** TI 733, you can specify that fact to tset. You can represent
-** a type as "?type". This will ask you what type you want it
-** to be -- if you reply with just a newline, it will default
-** to the type given.
-**
-** The current terminal type can be queried.
-**
-** Usage:
-** tset [-] [-EC] [-eC] [-kC] [-iC] [-s] [-h] [-u] [-r]
-** [-m [ident] [test baudrate] :type]
-** [-Q] [-I] [-S] [type]
-**
-** In systems with environments, use:
-** eval `tset -s ...`
-** Actually, this doesn't work in old csh's.
-** Instead, use:
-** tset -s ... > tset.tmp
-** source tset.tmp
-** rm tset.tmp
-** or:
-** set noglob
-** set term=(`tset -S ....`)
-** setenv TERM $term[1]
-** setenv TERMCAP "$term[2]"
-** unset term
-** unset noglob
-**
-** Positional Parameters:
-** type -- the terminal type to force. If this is
-** specified, initialization is for this
-** terminal type.
-**
-** Flags:
-** - -- report terminal type. Whatever type is
-** decided on is reported. If no other flags
-** are stated, the only affect is to write
-** the terminal type on the standard output.
-** -r -- report to user in addition to other flags.
-** -EC -- set the erase character to C on all terminals
-** except those which cannot backspace (e.g.,
-** a TTY 33). C defaults to control-H.
-** -eC -- set the erase character to C on all terminals.
-** C defaults to control-H. If not specified,
-** the erase character is untouched; however, if
-** not specified and the erase character is NULL
-** (zero byte), the erase character is set to CERASE.
-** -kC -- set the kill character to C on all terminals.
-** Default for C is control-U. If not specified,
-** the kill character is untouched; however, if
-** not specified and the kill character is NULL
-** (zero byte), the kill character is set to CKILL.
-** -iC -- set the interrupt character to C on all terminals.
-** Default for C is control-C. If not specified, the
-** interrupt character is untouched; however, if
-** not specified and the interrupt character is NULL
-** (zero byte), the interrupt character is set to
-** control-C.
-** -qC -- reserved for setable quit character.
-** -m -- map the system identified type to some user
-** specified type. The mapping can be baud rate
-** dependent. This replaces the old -d, -p flags.
-** (-d type -> -m dialup:type)
-** (-p type -> -m plug:type)
-** Syntax: -m identifier [test baudrate] :type
-** where: ``identifier'' is terminal type found in
-** /etc/ttys for this port, (abscence of an identifier
-** matches any identifier); ``test'' may be any combination
-** of > = < ! @; ``baudrate'' is as with stty(1);
-** ``type'' is the actual terminal type to use if the
-** mapping condition is met. Multiple maps are scanned
-** in order and the first match prevails.
-** -n -- If the new tty driver from UCB is available, this flag
-** will activate the new options for erase and kill
-** processing. This will be different for printers
-** and crt's. For crts, if the baud rate is < 1200 then
-** erase and kill don't remove characters from the screen.
-** -h -- don't read htmp file. Normally the terminal type
-** is determined by reading the htmp file or the
-** environment (unless some mapping is specified).
-** This forces a read of the ttytype file -- useful
-** when htmp is somehow wrong. (V6 only)
-** -u -- don't update htmp. It seemed like this should
-** be put in. Note that htmp is never actually
-** written if there are no changes, so don't bother
-** bother using this for efficiency reasons alone.
-** -s -- output setenv commands for TERM. This can be
-** used with
-** `tset -s ...`
-** and is to be prefered to:
-** setenv TERM `tset - ...`
-** because -s sets the TERMCAP variable also.
-** -S -- Similar to -s but outputs 2 strings suitable for
-** use in csh .login files as follows:
-** set noglob
-** set term=(`tset -S .....`)
-** setenv TERM $term[1]
-** setenv TERMCAP "$term[2]"
-** unset term
-** unset noglob
-** -Q -- be quiet. don't output 'Erase set to' etc.
-** -I -- don't do terminal initialization (is & if
-** strings).
-** -v -- On virtual terminal systems, don't set up a
-** virtual terminal. Otherwise tset will tell
-** the operating system what kind of terminal you
-** are on (if it is a known terminal) and fix up
-** the output of -s to use virtual terminal sequences.
-**
-** Files:
-** /etc/ttys
-** contains a terminal id -> terminal type
-** mapping; used when any user mapping is specified,
-** or the environment doesn't have TERM set.
-** /etc/termcap
-** a terminal_type -> terminal_capabilities
-** mapping.
-**
-** Return Codes:
-** -1 -- couldn't open termcap.
-** 1 -- bad terminal type, or standard output not tty.
-** 0 -- ok.
-**
-** Defined Constants:
-** DIALUP -- the type code for a dialup port.
-** PLUGBOARD -- the type code for a plugboard port.
-** ARPANET -- the type code for an arpanet port.
-** BACKSPACE -- control-H, the default for -e.
-** CNTL('U') -- control-U, the default for -k.
-** OLDERASE -- the ancient default erase character.
-** FILEDES -- the file descriptor to do the operation
-** on, nominally 1 or 2.
-** STDOUT -- the standard output file descriptor.
-** UIDMASK -- the bit pattern to mask with the getuid()
-** call to get just the user id.
-** GTTYN -- defines file containing generalized ttynames
-** and compiles code to look there.
-**
-** Requires:
-** Routines to handle htmp, ttys, and termcap.
-**
-** Compilation Flags:
-** OLDFLAGS -- must be defined to compile code for any of
-** the -d, -p, or -a flags.
-** OLDDIALUP -- accept the -d flag.
-** OLDPLUGBOARD -- accept the -p flag.
-** OLDARPANET -- accept the -a flag.
-** V6 -- if clear, use environments, not htmp.
-** also use TIOCSETN rather than stty to avoid flushing
-** GTTYN -- if set, compiles code to look at /etc/ttys.
-**
-** Trace Flags:
-** none
-**
-** Diagnostics:
-** Bad flag
-** An incorrect option was specified.
-** Too few args
-** more command line arguments are required.
-** Unexpected arg
-** wrong type of argument was encountered.
-** Cannot open ...
-** The specified file could not be openned.
-** Type ... unknown
-** An unknown terminal type was specified.
-** Cannot update htmp
-** Cannot update htmp file when the standard
-** output is not a terminal.
-** Erase set to ...
-** Telling that the erase character has been
-** set to the specified character.
-** Kill set to ...
-** Ditto for kill
-** Erase is ... Kill is ...
-** Tells that the erase/kill characters were
-** wierd before, but they are being left as-is.
-** Not a terminal
-** Set if FILEDES is not a terminal.
-**
-** Compilation Instructions:
-** cc -n -O tset.c -ltermlib
-** mv a.out tset
-** chown bin tset
-** chmod 4755 tset
-**
-** where 'bin' should be whoever owns the 'htmp' file.
-** If 'htmp' is 666, then tset need not be setuid.
-**
-** For version 6 the compile command should be:
-** cc -n -O -I/usr/include/retrofit tset.c -ltermlib -lretro -lS
-**
-**
-** History:
-** 1/81 -- Added alias checking for mapping identifiers.
-** 7/80 -- '-S' added. '-m' mapping added. TERMCAP string
-** cleaned up.
-** 3/80 -- Changed to use tputs. Prc & flush added.
-** 10/79 -- '-s' option extended to handle TERMCAP
-** variable, set noglob, quote the entry,
-** and know about the Bourne shell. Terminal
-** initialization moved to before any information
-** output so screen clears would not screw you.
-** '-Q' option added.
-** 8/79 -- '-' option alone changed to only output
-** type. '-s' option added. 'VERSION7'
-** changed to 'V6' for compatibility.
-** 12/78 -- modified for eventual migration to VAX/UNIX,
-** so the '-' option is changed to output only
-** the terminal type to STDOUT instead of
-** FILEDES.
-** 9/78 -- '-' and '-p' options added (now fully
-** compatible with ttytype!), and spaces are
-** permitted between the -d and the type.
-** 8/78 -- The sense of -h and -u were reversed, and the
-** -f flag is dropped -- same effect is available
-** by just stating the terminal type.
-** 10/77 -- Written.
-*/
-
-
-#define index strchr
-#define rindex strrchr
-#define curerase modes.c_cc[VERASE]
-#define curkill modes.c_cc[VKILL]
-#define curintr modes.c_cc[VINTR]
-#define olderase oldmodes.c_cc[VERASE]
-#define oldkill oldmodes.c_cc[VKILL]
-#define oldintr oldmodes.c_cc[VINTR]
+ * TSET -- set terminal modes
+ *
+ * This program does sophisticated terminal initialization.
+ * I recommend that you include it in your .profile or .login
+ * file to initialize whatever terminal you are on.
+ *
+ * There are several features:
+ *
+ * A special file or sequence (as controlled by the termcap file)
+ * is sent to the terminal.
+ *
+ * Mode bits are set on a per-terminal_type basis (much better
+ * than UNIX itself). This allows special delays, automatic
+ * tabs, etc.
+ *
+ * Erase and Kill characters can be set to whatever you want.
+ * Default is to change erase to control-H on a terminal which
+ * can overstrike, and leave it alone on anything else. Kill
+ * is always left alone unless specifically requested. These
+ * characters can be represented as "^X" meaning control-X;
+ * X is any character.
+ *
+ * Terminals which are dialups or plugboard types can be aliased
+ * to whatever type you may have in your home or office. Thus,
+ * if you know that when you dial up you will always be on a
+ * TI 733, you can specify that fact to tset. You can represent
+ * a type as "?type". This will ask you what type you want it
+ * to be -- if you reply with just a newline, it will default
+ * to the type given.
+ *
+ * The current terminal type can be queried.
+ *
+ * Usage:
+ * tset [-] [-EC] [-eC] [-kC] [-iC] [-s] [-h] [-u] [-r]
+ * [-m [ident] [test baudrate] :type]
+ * [-Q] [-I] [-S] [type]
+ *
+ * In systems with environments, use:
+ * eval `tset -s ...`
+ * Actually, this doesn't work in old csh's.
+ * Instead, use:
+ * tset -s ... > tset.tmp
+ * source tset.tmp
+ * rm tset.tmp
+ * or:
+ * set noglob
+ * set term=(`tset -S ....`)
+ * setenv TERM $term[1]
+ * setenv TERMCAP "$term[2]"
+ * unset term
+ * unset noglob
+ *
+ * Positional Parameters:
+ * type -- the terminal type to force. If this is
+ * specified, initialization is for this
+ * terminal type.
+ *
+ * Flags:
+ * - -- report terminal type. Whatever type is
+ * decided on is reported. If no other flags
+ * are stated, the only affect is to write
+ * the terminal type on the standard output.
+ * -r -- report to user in addition to other flags.
+ * -EC -- set the erase character to C on all terminals
+ * except those which cannot backspace (e.g.,
+ * a TTY 33). C defaults to control-H.
+ * -eC -- set the erase character to C on all terminals.
+ * C defaults to control-H. If not specified,
+ * the erase character is untouched; however, if
+ * not specified and the erase character is NULL
+ * (zero byte), the erase character is set to CERASE.
+ * -kC -- set the kill character to C on all terminals.
+ * Default for C is control-U. If not specified,
+ * the kill character is untouched; however, if
+ * not specified and the kill character is NULL
+ * (zero byte), the kill character is set to CKILL.
+ * -iC -- set the interrupt character to C on all terminals.
+ * Default for C is control-C. If not specified, the
+ * interrupt character is untouched; however, if
+ * not specified and the interrupt character is NULL
+ * (zero byte), the interrupt character is set to
+ * control-C.
+ * -qC -- reserved for setable quit character.
+ * -m -- map the system identified type to some user
+ * specified type. The mapping can be baud rate
+ * dependent. This replaces the old -d, -p flags.
+ * (-d type -> -m dialup:type)
+ * (-p type -> -m plug:type)
+ * Syntax: -m identifier [test baudrate] :type
+ * where: ``identifier'' is terminal type found in
+ * /etc/ttys for this port, (abscence of an identifier
+ * matches any identifier); ``test'' may be any combination
+ * of > = < ! @; ``baudrate'' is as with stty(1);
+ * ``type'' is the actual terminal type to use if the
+ * mapping condition is met. Multiple maps are scanned
+ * in order and the first match prevails.
+ * -n -- If the new tty driver from UCB is available, this flag
+ * will activate the new options for erase and kill
+ * processing. This will be different for printers
+ * and crt's. For crts, if the baud rate is < 1200 then
+ * erase and kill don't remove characters from the screen.
+ * -h -- don't read htmp file. Normally the terminal type
+ * is determined by reading the htmp file or the
+ * environment (unless some mapping is specified).
+ * This forces a read of the ttytype file -- useful
+ * when htmp is somehow wrong. (V6 only)
+ * -u -- don't update htmp. It seemed like this should
+ * be put in. Note that htmp is never actually
+ * written if there are no changes, so don't bother
+ * bother using this for efficiency reasons alone.
+ * -s -- output setenv commands for TERM. This can be
+ * used with
+ * `tset -s ...`
+ * and is to be prefered to:
+ * setenv TERM `tset - ...`
+ * because -s sets the TERMCAP variable also.
+ * -S -- Similar to -s but outputs 2 strings suitable for
+ * use in csh .login files as follows:
+ * set noglob
+ * set term=(`tset -S .....`)
+ * setenv TERM $term[1]
+ * setenv TERMCAP "$term[2]"
+ * unset term
+ * unset noglob
+ * -Q -- be quiet. don't output 'Erase set to' etc.
+ * -I -- don't do terminal initialization (is & if
+ * strings).
+ * -v -- On virtual terminal systems, don't set up a
+ * virtual terminal. Otherwise tset will tell
+ * the operating system what kind of terminal you
+ * are on (if it is a known terminal) and fix up
+ * the output of -s to use virtual terminal sequences.
+ *
+ * Files:
+ * /etc/ttys
+ * contains a terminal id -> terminal type
+ * mapping; used when any user mapping is specified,
+ * or the environment doesn't have TERM set.
+ * /etc/termcap
+ * a terminal_type -> terminal_capabilities
+ * mapping.
+ *
+ * Return Codes:
+ * -1 -- couldn't open termcap.
+ * 1 -- bad terminal type, or standard output not tty.
+ * 0 -- ok.
+ *
+ * Defined Constants:
+ * DIALUP -- the type code for a dialup port.
+ * PLUGBOARD -- the type code for a plugboard port.
+ * ARPANET -- the type code for an arpanet port.
+ * BACKSPACE -- control-H, the default for -e.
+ * CNTL('U') -- control-U, the default for -k.
+ * OLDERASE -- the ancient default erase character.
+ * FILEDES -- the file descriptor to do the operation
+ * on, nominally 1 or 2.
+ * STDOUT -- the standard output file descriptor.
+ * UIDMASK -- the bit pattern to mask with the getuid()
+ * call to get just the user id.
+ * GTTYN -- defines file containing generalized ttynames
+ * and compiles code to look there.
+ *
+ * Requires:
+ * Routines to handle htmp, ttys, and termcap.
+ *
+ * Compilation Flags:
+ * OLDFLAGS -- must be defined to compile code for any of
+ * the -d, -p, or -a flags.
+ * OLDDIALUP -- accept the -d flag.
+ * OLDPLUGBOARD -- accept the -p flag.
+ * OLDARPANET -- accept the -a flag.
+ * V6 -- if clear, use environments, not htmp.
+ * also use TIOCSETN rather than stty to avoid flushing
+ * GTTYN -- if set, compiles code to look at /etc/ttys.
+ *
+ * Trace Flags:
+ * none
+ *
+ * Diagnostics:
+ * Bad flag
+ * An incorrect option was specified.
+ * Too few args
+ * more command line arguments are required.
+ * Unexpected arg
+ * wrong type of argument was encountered.
+ * Cannot open ...
+ * The specified file could not be openned.
+ * Type ... unknown
+ * An unknown terminal type was specified.
+ * Cannot update htmp
+ * Cannot update htmp file when the standard
+ * output is not a terminal.
+ * Erase set to ...
+ * Telling that the erase character has been
+ * set to the specified character.
+ * Kill set to ...
+ * Ditto for kill
+ * Erase is ... Kill is ...
+ * Tells that the erase/kill characters were
+ * wierd before, but they are being left as-is.
+ * Not a terminal
+ * Set if FILEDES is not a terminal.
+ *
+ * Compilation Instructions:
+ * cc -n -O tset.c -ltermlib
+ * mv a.out tset
+ * chown bin tset
+ * chmod 4755 tset
+ *
+ * where 'bin' should be whoever owns the 'htmp' file.
+ * If 'htmp' is 666, then tset need not be setuid.
+ *
+ * For version 6 the compile command should be:
+ * cc -n -O -I/usr/include/retrofit tset.c -ltermlib -lretro -lS
+ *
+ *
+ * History:
+ * 1/81 -- Added alias checking for mapping identifiers.
+ * 7/80 -- '-S' added. '-m' mapping added. TERMCAP string
+ * cleaned up.
+ * 3/80 -- Changed to use tputs. Prc & flush added.
+ * 10/79 -- '-s' option extended to handle TERMCAP
+ * variable, set noglob, quote the entry,
+ * and know about the Bourne shell. Terminal
+ * initialization moved to before any information
+ * output so screen clears would not screw you.
+ * '-Q' option added.
+ * 8/79 -- '-' option alone changed to only output
+ * type. '-s' option added. 'VERSION7'
+ * changed to 'V6' for compatibility.
+ * 12/78 -- modified for eventual migration to VAX/UNIX,
+ * so the '-' option is changed to output only
+ * the terminal type to STDOUT instead of
+ * FILEDES.
+ * 9/78 -- '-' and '-p' options added (now fully
+ * compatible with ttytype!), and spaces are
+ * permitted between the -d and the type.
+ * 8/78 -- The sense of -h and -u were reversed, and the
+ * -f flag is dropped -- same effect is available
+ * by just stating the terminal type.
+ * 10/77 -- Written.
+ */
+
+
+#define index strchr
+#define rindex strrchr
+#define curerase modes.c_cc[VERASE]
+#define curkill modes.c_cc[VKILL]
+#define curintr modes.c_cc[VINTR]
+#define olderase oldmodes.c_cc[VERASE]
+#define oldkill oldmodes.c_cc[VKILL]
+#define oldintr oldmodes.c_cc[VINTR]
#include <stdio.h>
#include <termio.h>
@@ -313,17 +311,14 @@
#define UIDMASK -1
-#define USAGE "usage: tset [-] [-rsIQS] [-eC] [-kC] [-iC] [-m [ident][test speed]:type] [type]\n"
+#define USAGE "usage: tset [-] [-rsIQS] [-eC] [-kC] " \
+ "[-iC] [-m [ident][test speed]:type] [type]\n"
#define OLDFLAGS
#define DIALUP "dialup"
#define OLDDIALUP "sd"
#define PLUGBOARD "plugboard"
#define OLDPLUGBOARD "sp"
-/*
-#define ARPANET "arpanet"
-#define OLDARPANET "sa"
-*/
#define DEFTYPE "unknown"
@@ -366,7 +361,7 @@ struct
"75", B75, 75,
"110", B110, 110,
"134", B134, 134,
- "134.5",B134, 134,
+ "134.5", B134, 134,
"150", B150, 150,
"200", B200, 200,
"300", B300, 300,
@@ -376,23 +371,24 @@ struct
"2400", B2400, 2400,
"4800", B4800, 4800,
"9600", B9600, 9600,
- "19200",EXTA, 19200,
+ "19200", EXTA, 19200,
"exta", EXTA, 19200,
"extb", EXTB, 38400,
- "57600",B57600, 57600,
- "76800",B76800, 76800,
- "115200",B115200,115200,
- "153600",B153600,153600,
- "230400",B230400,230400,
- "307200",B307200,307200,
- "460800",B460800,460800,
+ "57600", B57600, 57600,
+ "76800", B76800, 76800,
+ "115200", B115200, 115200,
+ "153600", B153600, 153600,
+ "230400", B230400, 230400,
+ "307200", B307200, 307200,
+ "460800", B460800, 460800,
+ "921600", B921600, 921600,
0,
};
signed char Erase_char; /* new erase character */
char Kill_char; /* new kill character */
char Intr_char; /* new interrupt character */
-char Specialerase; /* set => Erase_char only on terminals with backspace */
+char Specialerase; /* set => Erase_char only on terminals with backspace */
char Ttyid = NOTTY; /* terminal identifier */
char *TtyType; /* type of terminal */
@@ -413,7 +409,7 @@ int Ask; /* ask user for termtype */
int DoVirtTerm = YES; /* Set up a virtual terminal */
int PadBaud; /* Min rate of padding needed */
-#define CAPBUFSIZ 1024
+#define CAPBUFSIZ 1024
char Capbuf[CAPBUFSIZ]; /* line from /etc/termcap for this TtyType */
char *Ttycap; /* termcap line from termcap or environ */
@@ -446,7 +442,7 @@ void cat(char *);
void bmove(char *, char *, int);
void makealias(char *);
void wrtermcap(char *);
-void fatal (char *, char *);
+void fatal(char *, char *);
char reset(); /* Routine for checking&resetting chars */
int
@@ -474,20 +470,19 @@ main(int argc, char *argv[])
extern short ospeed;
if ((istermios = ioctl(FILEDES, TCGETS, (char *)&modes)) < 0) {
- if (ioctl(FILEDES, TCGETA, (char *)&mode) < 0)
- {
+ if (ioctl(FILEDES, TCGETA, (char *)&mode) < 0) {
prs("Not a terminal\n");
exit(1);
}
- bmove((char *)&mode, (char *)&oldmode, sizeof mode);
+ bmove((char *)&mode, (char *)&oldmode, sizeof (mode));
modes.c_lflag = oldmodes.c_lflag = mode.c_lflag;
modes.c_oflag = oldmodes.c_oflag = mode.c_oflag;
modes.c_iflag = oldmodes.c_iflag = mode.c_iflag;
modes.c_cflag = oldmodes.c_cflag = mode.c_cflag;
- for(i = 0; i < NCC; i++)
+ for (i = 0; i < NCC; i++)
modes.c_cc[i] = oldmodes.c_cc[i] = mode.c_cc[i];
} else
- bmove((char *)&modes, (char *)&oldmodes, sizeof modes);
+ bmove((char *)&modes, (char *)&oldmodes, sizeof (modes));
ospeed = cfgetospeed(&modes);
(void) signal(SIGINT, setmode);
(void) signal(SIGQUIT, setmode);
@@ -497,8 +492,7 @@ main(int argc, char *argv[])
command++;
else
command = argv[0];
- if (sequal(command, "reset") )
- {
+ if (sequal(command, "reset")) {
/*
* Reset the teletype mode bits to a sensible state.
* Copied from the program by Kurt Shoens & Mark Horton.
@@ -510,7 +504,7 @@ main(int argc, char *argv[])
modes.c_oflag = mode.c_oflag;
modes.c_iflag = mode.c_iflag;
modes.c_cflag = mode.c_cflag;
- for(i = 0; i < NCC; i++)
+ for (i = 0; i < NCC; i++)
modes.c_cc[i] = mode.c_cc[i];
}
curerase = reset(curerase, CERASE);
@@ -523,17 +517,17 @@ main(int argc, char *argv[])
modes.c_iflag &= ~(IGNBRK|PARMRK|INPCK|INLCR|IGNCR|IUCLC|IXOFF);
modes.c_oflag |= (OPOST|ONLCR);
modes.c_oflag &= ~(OLCUC|OCRNL|ONOCR|ONLRET|OFILL|OFDEL|
- NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY);
+ NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY);
modes.c_cflag |= (CS7|CREAD);
modes.c_cflag &= ~(PARODD|CLOCAL);
modes.c_lflag |= (ISIG|ICANON|ECHO|ECHOK);
modes.c_lflag &= ~(XCASE|ECHONL|NOFLSH);
- if (istermios < 0) {
+ if (istermios < 0) {
mode.c_lflag = modes.c_lflag;
mode.c_oflag = modes.c_oflag;
mode.c_iflag = modes.c_iflag;
mode.c_cflag = modes.c_cflag;
- for(i = 0; i < NCC; i++)
+ for (i = 0; i < NCC; i++)
mode.c_cc[i] = modes.c_cc[i];
(void) ioctl(FILEDES, TCSETAW, (char *)&mode);
} else
@@ -541,38 +535,35 @@ main(int argc, char *argv[])
Dash_u = YES;
BeQuiet = YES;
IsReset = YES;
- }
- else if (argc == 2 && sequal(argv[1], "-"))
- {
+ } else if (argc == 2 && sequal(argv[1], "-")) {
RepOnly = YES;
Dash_u = YES;
}
argc--;
/* scan argument list and collect flags */
- while (--argc >= 0)
- {
+ while (--argc >= 0) {
p = *++argv;
- if (*p == '-')
- {
+ if (*p == '-') {
if (*++p == NULL)
Report = YES; /* report current terminal type */
- else while (*p) switch (*p++)
- {
+ else
+ while (*p)
+ switch (*p++) {
- case 'r': /* report to user */
+ case 'r': /* report to user */
Ureport = YES;
continue;
- case 'E': /* special erase: operate on all but TTY33 */
+ case 'E':
+ /* special erase: operate on all but TTY33 */
Specialerase = YES;
/* explicit fall-through to -e case */
- case 'e': /* erase character */
+ case 'e': /* erase character */
if (*p == NULL)
Erase_char = -1;
- else
- {
+ else {
if (*p == '^' && p[1] != NULL)
if (*++p == '?')
Erase_char = '\177';
@@ -584,11 +575,10 @@ main(int argc, char *argv[])
}
continue;
- case 'i': /* interrupt character */
+ case 'i': /* interrupt character */
if (*p == NULL)
Intr_char = CNTL('C');
- else
- {
+ else {
if (*p == '^' && p[1] != NULL)
if (*++p == '?')
Intr_char = '\177';
@@ -600,11 +590,10 @@ main(int argc, char *argv[])
}
continue;
- case 'k': /* kill character */
+ case 'k': /* kill character */
if (*p == NULL)
Kill_char = CNTL('U');
- else
- {
+ else {
if (*p == '^' && p[1] != NULL)
if (*++p == '?')
Kill_char = '\177';
@@ -616,29 +605,28 @@ main(int argc, char *argv[])
}
continue;
-# ifdef OLDFLAGS
-# ifdef OLDDIALUP
- case 'd': /* dialup type */
+#ifdef OLDFLAGS
+#ifdef OLDDIALUP
+ case 'd': /* dialup type */
NewType = DIALUP;
goto mapold;
-# endif
+#endif
-# ifdef OLDPLUGBOARD
- case 'p': /* plugboard type */
+#ifdef OLDPLUGBOARD
+ case 'p': /* plugboard type */
NewType = PLUGBOARD;
goto mapold;
-# endif
+#endif
-# ifdef OLDARPANET
- case 'a': /* arpanet type */
+#ifdef OLDARPANET
+ case 'a': /* arpanet type */
Newtype = ARPANET;
goto mapold;
-# endif
+#endif
mapold: Map->Ident = NewType;
Map->Test = ALL;
- if (*p == NULL)
- {
+ if (*p == NULL) {
p = nextarg(argc--, argv++);
}
Map->Type = p;
@@ -646,20 +634,19 @@ mapold: Map->Ident = NewType;
Mapped = YES;
p = "";
continue;
-# endif
-
- case 'm': /* map identifier to type */
- /* This code is very loose. Almost no
- ** syntax checking is done!! However,
- ** illegal syntax will only produce
- ** weird results.
- */
- if (*p == NULL)
- {
+#endif
+
+ case 'm': /* map identifier to type */
+ /*
+ * This code is very loose. Almost no
+ * syntax checking is done!! However,
+ * illegal syntax will only produce
+ * weird results.
+ */
+ if (*p == NULL) {
p = nextarg(argc--, argv++);
}
- if (isalnum(*p))
- {
+ if (isalnum(*p)) {
Map->Ident = p; /* identifier */
while (isalnum(*p)) p++;
}
@@ -667,8 +654,8 @@ mapold: Map->Ident = NewType;
Map->Ident = "";
Break = NO;
Not = NO;
- while (!Break) switch (*p)
- {
+ while (!Break)
+ switch (*p) {
case NULL:
p = nextarg(argc--, argv++);
continue;
@@ -693,7 +680,7 @@ mapold: Map->Ident = NewType;
Map->Test |= EQ;
*p++ = NULL;
continue;
-
+
case '!': /* invert conditions */
Not = ~Not;
*p++ = NULL;
@@ -703,22 +690,20 @@ mapold: Map->Ident = NewType;
p++;
/* intentional fallthru */
default:
- if (isdigit(*p) || *p == 'e')
- {
- Map->Speed = baudrate(p);
- while (isalnum(*p) || *p == '.')
+ if (isdigit(*p) || *p == 'e') {
+ Map->Speed =
+ baudrate(p);
+ while (isalnum(*p) ||
+ *p == '.')
p++;
- }
- else
+ } else
Break = YES;
continue;
}
- if (Not) /* invert sense of test */
- {
+ if (Not) { /* invert sense of test */
Map->Test = (~(Map->Test))&ALL;
}
- if (*p == NULL)
- {
+ if (*p == NULL) {
p = nextarg(argc--, argv++);
}
Map->Type = p;
@@ -727,61 +712,56 @@ mapold: Map->Ident = NewType;
Mapped = YES;
continue;
- case 'h': /* don't get type from htmp or env */
+ case 'h': /* don't get type from htmp or env */
Dash_h = YES;
continue;
- case 'u': /* don't update htmp */
+ case 'u': /* don't update htmp */
Dash_u = YES;
continue;
- case 's': /* output setenv commands */
+ case 's': /* output setenv commands */
DoSetenv = YES;
CmndLine = YES;
continue;
- case 'S': /* output setenv strings */
+ case 'S': /* output setenv strings */
DoSetenv = YES;
CmndLine = NO;
continue;
- case 'Q': /* be quiet */
+ case 'Q': /* be quiet */
BeQuiet = YES;
continue;
- case 'I': /* no initialization */
+ case 'I': /* no initialization */
NoInit = YES;
continue;
- case 'A': /* Ask user */
+ case 'A': /* Ask user */
Ask = YES;
continue;
-
- case 'v': /* no virtual terminal */
+
+ case 'v': /* no virtual terminal */
DoVirtTerm = NO;
continue;
- default:
+ default:
*p-- = NULL;
fatal("Bad flag -", p);
}
- }
- else
- {
+ } else {
/* terminal type */
DefType = p;
}
}
- if (DefType)
- {
- if (Mapped)
- {
+ if (DefType) {
+ if (Mapped) {
Map->Ident = ""; /* means "map any type" */
Map->Test = ALL; /* at all baud rates */
Map->Type = DefType; /* to the default type */
- }
- else
+ } else
TtyType = DefType;
}
@@ -802,14 +782,12 @@ mapold: Map->Ident = NewType;
Ttyid = ttyname(FILEDES);
/* If still undefined, use DEFTYPE */
- if (TtyType == 0)
- {
+ if (TtyType == 0) {
TtyType = DEFTYPE;
}
/* check for dialup or other mapping */
- if (Mapped)
- {
+ if (Mapped) {
if (!(Alias[0] && isalias(TtyType)))
if (tgetent(Capbuf, TtyType) > 0)
makealias(Capbuf);
@@ -818,15 +796,13 @@ mapold: Map->Ident = NewType;
/* TtyType now contains a pointer to the type of the terminal */
/* If the first character is '?', ask the user */
- if (TtyType[0] == '?')
- {
+ if (TtyType[0] == '?') {
Ask = YES;
TtyType++;
if (TtyType[0] == '\0')
TtyType = DEFTYPE;
}
- if (Ask)
- {
+ if (Ask) {
ask:
prs("TERM = (");
prs(TtyType);
@@ -834,9 +810,8 @@ ask:
flush();
/* read the terminal. If not empty, set type */
- i = read(2, termbuf, sizeof termbuf - 1);
- if (i > 0)
- {
+ i = read(2, termbuf, sizeof (termbuf) - 1);
+ if (i > 0) {
if (termbuf[i - 1] == '\n')
i--;
termbuf[i] = '\0';
@@ -847,32 +822,28 @@ ask:
/* get terminal capabilities */
if (!(Alias[0] && isalias(TtyType))) {
- switch (tgetent(Capbuf, TtyType))
- {
- case -1:
+ switch (tgetent(Capbuf, TtyType)) {
+ case -1:
prs("Cannot find termcap\n");
flush();
exit(-1);
- case 0:
+ case 0:
prs("Type ");
prs(TtyType);
prs(" unknown\n");
flush();
- if (DoSetenv)
- {
+ if (DoSetenv) {
TtyType = DEFTYPE;
Alias[0] = '\0';
goto ask;
- }
- else
+ } else
exit(1);
}
}
Ttycap = Capbuf;
- if (!RepOnly)
- {
+ if (!RepOnly) {
/* determine erase and kill characters */
if (Specialerase && !tgetflag("bs"))
Erase_char = 0;
@@ -892,8 +863,8 @@ ask:
* system set it there. People who want backspace have
* to say tset -e.
*/
- if (Erase_char == 0 && !tgetflag("os") && curerase == OLDERASE)
- {
+ if (Erase_char == 0 && !tgetflag("os") &&
+ curerase == OLDERASE) {
if (tgetflag("bs") || bs_char != 0)
Erase_char = -1;
}
@@ -917,7 +888,7 @@ ask:
/* set modes */
PadBaud = tgetnum("pb"); /* OK if fails */
- for (i=0; speeds[i].string; i++)
+ for (i = 0; speeds[i].string; i++)
if (speeds[i].baudrate == PadBaud) {
PadBaud = speeds[i].speed;
break;
@@ -933,8 +904,7 @@ ask:
modes.c_iflag |= IUCLC;
modes.c_oflag |= OLCUC;
modes.c_cflag |= XCASE;
- }
- else if (tgetflag("LC")) {
+ } else if (tgetflag("LC")) {
modes.c_iflag &= ~IUCLC;
modes.c_oflag &= ~OLCUC;
modes.c_cflag &= ~XCASE;
@@ -964,10 +934,9 @@ ask:
modes.c_lflag &= ~ECHO;
if (tgetflag("pt")) /* print tabs */
modes.c_oflag &= ~TAB3;
-
+
modes.c_lflag |= (ECHOE|ECHOK);
- if (tgetflag("hc"))
- { /** set printer modes **/
+ if (tgetflag("hc")) { /* set printer modes */
modes.c_lflag &= ~ECHOE;
}
@@ -977,10 +946,8 @@ ask:
PC = buf[0];
/* output startup string */
- if (!NoInit)
- {
- if (oldmodes.c_oflag&(TAB3|ONLCR|OCRNL|ONLRET))
- {
+ if (!NoInit) {
+ if (oldmodes.c_oflag&(TAB3|ONLCR|OCRNL|ONLRET)) {
oldmodes.c_oflag &= (TAB3|ONLCR|OCRNL|ONLRET);
setmode(-1);
}
@@ -989,22 +956,19 @@ ask:
flush();
}
bufp = buf;
- if (IsReset && tgetstr("rs", &bufp) != 0 ||
- tgetstr("is", &bufp) != 0)
- {
+ if (IsReset && tgetstr("rs", &bufp) != 0 ||
+ tgetstr("is", &bufp) != 0) {
tputs(buf, 0, prc);
settle = YES;
flush();
}
bufp = buf;
if (IsReset && tgetstr("rf", &bufp) != 0 ||
- tgetstr("if", &bufp) != 0)
- {
+ tgetstr("if", &bufp) != 0) {
cat(buf);
settle = YES;
}
- if (settle)
- {
+ if (settle) {
prc('\r');
if (IsReset)
prc('\n'); /* newline too */
@@ -1019,80 +983,69 @@ ask:
/* (this code is rather heuristic, checking for $SHELL */
/* ending in the 3 characters "csh") */
csh = NO;
- if (DoSetenv)
- {
+ if (DoSetenv) {
char *sh;
- if ((sh = getenv("SHELL")) && (i = strlen(sh)) >= 3)
- {
- if ((csh = sequal(&sh[i-3], "csh")) && CmndLine)
- (void) write(STDOUT, "set noglob;\n", 12);
+ if ((sh = getenv("SHELL")) && (i = strlen(sh)) >= 3) {
+ if ((csh = sequal(&sh[i-3], "csh")) && CmndLine)
+ (void) write(STDOUT,
+ "set noglob;\n", 12);
+ }
+ if (!csh) { /* running Bourne shell */
+ (void) write(STDOUT,
+ "export TERMCAP TERM;\n", 21);
}
- if (!csh)
- /* running Bourne shell */
- (void) write(STDOUT, "export TERMCAP TERM;\n", 21);
}
}
/* report type if appropriate */
- if (DoSetenv || Report || Ureport)
- {
+ if (DoSetenv || Report || Ureport) {
/* if type is the short name, find first alias (if any) */
makealias(Ttycap);
if (sequal(TtyType, Alias[0]) && Alias[1]) {
TtyType = Alias[1];
}
- if (DoSetenv)
- {
- if (csh)
- {
+ if (DoSetenv) {
+ if (csh) {
if (CmndLine)
- (void) write(STDOUT, "setenv TERM ", 12);
+ (void) write(STDOUT,
+ "setenv TERM ", 12);
(void) write(STDOUT, TtyType, strlen(TtyType));
(void) write(STDOUT, " ", 1);
if (CmndLine)
- (void) write(STDOUT, ";\n", 2);
- }
- else
- {
+ (void) write(STDOUT, ";\n", 2);
+ } else {
(void) write(STDOUT, "TERM=", 5);
(void) write(STDOUT, TtyType, strlen(TtyType));
(void) write(STDOUT, ";\n", 2);
}
- }
- else if (Report)
- {
+ } else if (Report) {
(void) write(STDOUT, TtyType, strlen(TtyType));
(void) write(STDOUT, "\n", 1);
}
- if (Ureport)
- {
+ if (Ureport) {
prs("Terminal type is ");
prs(TtyType);
prs("\n");
flush();
}
- if (DoSetenv)
- {
- if (csh)
- {
- if (CmndLine)
- (void) write(STDOUT, "setenv TERMCAP '", 16);
- }
- else
- (void) write(STDOUT, "TERMCAP='", 9);
- wrtermcap(Ttycap);
- if (csh)
- {
+ if (DoSetenv) {
+ if (csh) {
if (CmndLine)
- {
- (void) write(STDOUT, "';\n", 3);
- (void) write(STDOUT, "unset noglob;\n", 14);
+ (void) write(STDOUT,
+ "setenv TERMCAP '", 16);
+ } else
+ (void) write(STDOUT, "TERMCAP='", 9);
+ wrtermcap(Ttycap);
+ if (csh) {
+ if (CmndLine) {
+ (void) write(STDOUT, "';\n", 3);
+ (void) write(STDOUT,
+ "unset noglob;\n", 14);
}
- }
- else
+ } else
(void) write(STDOUT, "';\n", 3);
}
}
@@ -1137,7 +1090,7 @@ settabs(void)
if (set_tab) {
columns = tgetnum("co");
lines = tgetnum("li");
- for (c=0; c<columns; c += 8) {
+ for (c = 0; c < columns; c += 8) {
/* get to that column. */
tg_out = "OOPS"; /* also returned by tgoto */
if (set_column)
@@ -1159,13 +1112,14 @@ settabs(void)
return (0);
}
-void setmode(flag)
-int flag;
-/* flag serves several purposes:
+/*
+ * flag serves several purposes:
* if called as the result of a signal, flag will be > 0.
* if called from terminal init, flag == -1 means reset "oldmode".
* called with flag == 0 at end of normal mode processing.
*/
+void
+setmode(int flag)
{
struct termio *ttymode;
struct termios *ttymodes;
@@ -1176,38 +1130,38 @@ int flag;
if (flag < 0) { /* unconditionally reset oldmode (called from init) */
if (istermios < 0) {
- oldmode.c_lflag = oldmodes.c_lflag;
- oldmode.c_oflag = oldmodes.c_oflag;
- oldmode.c_iflag = oldmodes.c_iflag;
- oldmode.c_cflag = oldmodes.c_cflag;
- for(i = 0; i < NCC; i++)
- oldmode.c_cc[i] = oldmodes.c_cc[i];
- ttymode = &oldmode;
+ oldmode.c_lflag = oldmodes.c_lflag;
+ oldmode.c_oflag = oldmodes.c_oflag;
+ oldmode.c_iflag = oldmodes.c_iflag;
+ oldmode.c_cflag = oldmodes.c_cflag;
+ for (i = 0; i < NCC; i++)
+ oldmode.c_cc[i] = oldmodes.c_cc[i];
+ ttymode = &oldmode;
} else
- ttymodes = &oldmodes;
+ ttymodes = &oldmodes;
} else {
if (istermios < 0) {
- oldmode.c_lflag = oldmodes.c_lflag;
- oldmode.c_oflag = oldmodes.c_oflag;
- oldmode.c_iflag = oldmodes.c_iflag;
- oldmode.c_cflag = oldmodes.c_cflag;
- for(i = 0; i < NCC; i++)
- oldmode.c_cc[i] = oldmodes.c_cc[i];
- mode.c_lflag = modes.c_lflag;
- mode.c_oflag = modes.c_oflag;
- mode.c_iflag = modes.c_iflag;
- mode.c_cflag = modes.c_cflag;
- for(i = 0; i < NCC; i++)
- mode.c_cc[i] = modes.c_cc[i];
- if (!bequal((char *)&mode, (char *)&oldmode, sizeof mode))
+ oldmode.c_lflag = oldmodes.c_lflag;
+ oldmode.c_oflag = oldmodes.c_oflag;
+ oldmode.c_iflag = oldmodes.c_iflag;
+ oldmode.c_cflag = oldmodes.c_cflag;
+ for (i = 0; i < NCC; i++)
+ oldmode.c_cc[i] = oldmodes.c_cc[i];
+ mode.c_lflag = modes.c_lflag;
+ mode.c_oflag = modes.c_oflag;
+ mode.c_iflag = modes.c_iflag;
+ mode.c_cflag = modes.c_cflag;
+ for (i = 0; i < NCC; i++)
+ mode.c_cc[i] = modes.c_cc[i];
+ if (!bequal((char *)&mode, (char *)&oldmode,
+ sizeof (mode)))
ttymode = &mode;
} else if (!bequal((char *)&modes, (char *)&oldmodes,
- sizeof modes))
- ttymodes = &modes;
+ sizeof (modes)))
+ ttymodes = &modes;
}
-
- if (ttymode)
- {
+
+ if (ttymode) {
(void) ioctl(FILEDES, TCSETAW, (char *)ttymode);
} else if (ttymodes) {
(void) ioctl(FILEDES, TCSETSW, (char *)ttymodes);
@@ -1243,10 +1197,8 @@ reportek(char *name, char new, char old, char def)
prs("Backspace\n");
else if (n == 0177)
prs("Delete\n");
- else
- {
- if (n < 040)
- {
+ else {
+ if (n < 040) {
prs("Ctrl-");
n ^= 0100;
}
@@ -1278,10 +1230,8 @@ setdelay(char *cap, struct delay dtab[], tcflag_t bits, tcflag_t *flags)
*flags &= ~bits;
/* scan dtab for first entry with adequate delay */
- for (p = dtab; p->d_delay >= 0; p++)
- {
- if (p->d_delay >= i)
- {
+ for (p = dtab; p->d_delay >= 0; p++) {
+ if (p->d_delay >= i) {
p++;
break;
}
@@ -1306,7 +1256,7 @@ void
prc(char c)
{
OutBuf[OutPtr++] = c;
- if (OutPtr >= sizeof OutBuf)
+ if (OutPtr >= sizeof (OutBuf))
flush();
}
@@ -1326,8 +1276,7 @@ cat(char *file)
char buf[BUFSIZ];
fd = open(file, 0);
- if (fd < 0)
- {
+ if (fd < 0) {
prs("Cannot open ");
prs(file);
prs("\n");
@@ -1367,8 +1316,7 @@ bequal(char *a, char *b, int len) /* must be same thru len chars */
p = a;
q = b;
- while ((*p == *q) && --i > 0)
- {
+ while ((*p == *q) && --i > 0) {
p++; q++;
}
return ((*p == *q) && i >= 0);
@@ -1379,8 +1327,7 @@ sequal(char *a, char *b) /* must be same thru NULL */
{
char *p = a, *q = b;
- while (*p && *q && (*p == *q))
- {
+ while (*p && *q && (*p == *q)) {
p++; q++;
}
return (*p == *q);
@@ -1401,15 +1348,15 @@ makealias(char *buf)
*a++ = NULL;
Alias[i++] = a;
b++;
- }
- else
+ } else
*a++ = *b++;
}
*a = NULL;
Alias[i] = NULL;
-# ifdef DEB
- for(i = 0; Alias[i]; printf("A:%s\n", Alias[i++]));
-# endif
+#ifdef DEB
+ for (i = 0; Alias[i]; printf("A:%s\n", Alias[i++]))
+ ;
+#endif
}
int
@@ -1420,10 +1367,10 @@ isalias(char *ident) /* is ident same as one of the aliases? */
if (*a)
while (*a)
if (sequal(ident, *a))
- return(YES);
+ return (YES);
else
a++;
- return(NO);
+ return (NO);
}
@@ -1444,13 +1391,13 @@ wrtermcap(char *bp)
int space, empty;
/* discard names with blanks */
-/** May not be desireable ? **/
+/* May not be desireable ? */
while (*bp && *bp != ':') {
if (*bp == '|') {
tp = bp+1;
space = NO;
while (*tp && *tp != '|' && *tp != ':') {
- space = (space || WHITE(*tp) );
+ space = (space || WHITE(*tp));
tp++;
}
if (space) {
@@ -1460,15 +1407,15 @@ wrtermcap(char *bp)
}
*p++ = *bp++;
}
-/**/
+/* */
while (*bp) {
switch (*bp) {
case ':': /* discard empty, cancelled or dupl fields */
- tp = bp+1;
+ tp = bp + 1;
empty = YES;
while (*tp && *tp != ':') {
- empty = (empty && WHITE(*tp) );
+ empty = (empty && WHITE(*tp));
tp++;
}
if (empty || cancelled(bp+1)) {
@@ -1514,7 +1461,7 @@ wrtermcap(char *bp)
*p++ = *bp++;
}
*p++ = ':'; /* we skipped the last : with the : lookahead hack */
- (void) write (STDOUT, buf, p-buf);
+ (void) write(STDOUT, buf, p-buf);
}
int
@@ -1522,8 +1469,7 @@ cancelled(char *cap)
{
int i;
- for (i = 0; i < ncap; i++)
- {
+ for (i = 0; i < ncap; i++) {
if (cap[0] == delcap[i][0] && cap[1] == delcap[i][1])
return (YES);
}
@@ -1568,7 +1514,7 @@ baudrate(char *p)
while (i < 7 && (isalnum(*p) || *p == '.'))
buf[i++] = *p++;
buf[i] = NULL;
- for (i=0; speeds[i].string; i++)
+ for (i = 0; speeds[i].string; i++)
if (sequal(speeds[i].string, buf))
return (speeds[i].speed);
return (-1);
@@ -1581,46 +1527,44 @@ char *type;
extern short ospeed;
int match;
-# ifdef DEB
- printf ("spd:%d\n", ospeed);
+#ifdef DEB
+ printf("spd:%d\n", ospeed);
prmap();
-# endif
+#endif
Map = map;
- while (Map->Ident)
- {
- if (*(Map->Ident) == NULL || sequal(Map->Ident, type) || isalias(Map->Ident))
- {
+ while (Map->Ident) {
+ if (*(Map->Ident) == NULL ||
+ sequal(Map->Ident, type) || isalias(Map->Ident)) {
match = NO;
- switch (Map->Test)
- {
- case ANY: /* no test specified */
- case ALL:
- match = YES;
- break;
-
- case GT:
- match = (ospeed > Map->Speed);
- break;
-
- case GE:
- match = (ospeed >= Map->Speed);
- break;
-
- case EQ:
- match = (ospeed == Map->Speed);
- break;
-
- case LE:
- match = (ospeed <= Map->Speed);
- break;
-
- case LT:
- match = (ospeed < Map->Speed);
- break;
-
- case NE:
- match = (ospeed != Map->Speed);
- break;
+ switch (Map->Test) {
+ case ANY: /* no test specified */
+ case ALL:
+ match = YES;
+ break;
+
+ case GT:
+ match = (ospeed > Map->Speed);
+ break;
+
+ case GE:
+ match = (ospeed >= Map->Speed);
+ break;
+
+ case EQ:
+ match = (ospeed == Map->Speed);
+ break;
+
+ case LE:
+ match = (ospeed <= Map->Speed);
+ break;
+
+ case LT:
+ match = (ospeed < Map->Speed);
+ break;
+
+ case NE:
+ match = (ospeed != Map->Speed);
+ break;
}
if (match)
return (Map->Type);
@@ -1631,18 +1575,17 @@ char *type;
return (type);
}
-# ifdef DEB
+#ifdef DEB
prmap()
{
Map = map;
- while (Map->Ident)
- {
- printf ("%s t:%d s:%d %s\n",
- Map->Ident, Map->Test, Map->Speed, Map->Type);
- Map++;
+ while (Map->Ident) {
+ printf("%s t:%d s:%d %s\n",
+ Map->Ident, Map->Test, Map->Speed, Map->Type);
+ Map++;
}
}
-# endif
+#endif
char *
nextarg(argc, argv)
@@ -1650,19 +1593,19 @@ int argc;
char *argv[];
{
if (argc <= 0)
- fatal ("Too few args: ", *argv);
+ fatal("Too few args: ", *argv);
if (*(*++argv) == '-')
- fatal ("Unexpected arg: ", *argv);
+ fatal("Unexpected arg: ", *argv);
return (*argv);
}
void
-fatal (char *mesg, char *obj)
+fatal(char *mesg, char *obj)
{
- prs (mesg);
- prs (obj);
- prc ('\n');
- prs (USAGE);
+ prs(mesg);
+ prs(obj);
+ prc('\n');
+ prs(USAGE);
flush();
exit(1);
}
@@ -1676,8 +1619,7 @@ reset(ch, def)
char ch;
int def;
{
-
if (ch == 0 || (ch&0377) == 0377)
- return def;
- return ch;
+ return (def);
+ return (ch);
}