#include <curses.h> /* for bool typedef */
#include <dump_entry.h>
+#include <transform.h>
-MODULE_ID("$Id: tset.c,v 0.41 2000/03/12 00:03:00 tom Exp $")
+MODULE_ID("$Id: tset.c,v 0.47 2000/10/08 01:01:08 tom Exp $")
extern char **environ;
static TTY mode, oldmode;
+static bool isreset = FALSE; /* invoked as reset */
static int terasechar = -1; /* new erase character */
static int intrchar = -1; /* new interrupt character */
-static int isreset; /* invoked as reset */
static int tkillchar = -1; /* new kill character */
static int tlines, tcolumns; /* window size */
const char *porttype; /* Port type, or "" for any. */
const char *type; /* Terminal type to select. */
int conditional; /* Baud rate conditionals bitmask. */
- speed_t speed; /* Baud rate to compare against. */
+ int speed; /* Baud rate to compare against. */
} MAP;
static MAP *cur, *maplist;
{"2400", B2400},
{"4800", B4800},
{"9600", B9600},
+ /* sgttyb may define up to this point */
+#ifdef B19200
{"19200", B19200},
+#endif
+#ifdef B38400
{"38400", B38400},
+#endif
+#ifdef B19200
{"19200", B19200},
+#endif
+#ifdef B38400
{"38400", B38400},
+#endif
#ifdef B19200
{"19200", B19200},
#else
goto map;
if ((ttypath = ttyname(STDERR_FILENO)) != 0) {
- if ((p = strrchr(ttypath, '/')) != 0)
- ++p;
- else
- p = ttypath;
+ p = _nc_basename(ttypath);
#if HAVE_GETTTYNAM
/*
* We have the 4.3BSD library call getttynam(3); that means
}
/* Find the terminfo entry. If it doesn't exist, ask the user. */
while ((rval = setupterm((NCURSES_CONST char *) ttype, STDOUT_FILENO,
- &errret)) != OK) {
+ &errret)) != OK) {
if (errret == 0) {
(void) fprintf(stderr, "tset: unknown terminal type %s\n",
- ttype);
+ ttype);
ttype = 0;
} else {
(void) fprintf(stderr,
- "tset: can't initialize terminal type %s (error %d)\n",
- ttype, errret);
+ "tset: can't initialize terminal type %s (error %d)\n",
+ ttype, errret);
ttype = 0;
}
ttype = askuser(ttype);
mode.c_iflag &= ~(IGNBRK | PARMRK | INPCK | ISTRIP | INLCR | IGNCR
#ifdef IUCLC
- | IUCLC
+ | IUCLC
#endif
#ifdef IXANY
- | IXANY
+ | IXANY
#endif
- | IXOFF);
+ | IXOFF);
mode.c_iflag |= (BRKINT | IGNPAR | ICRNL | IXON
#ifdef IMAXBEL
- | IMAXBEL
+ | IMAXBEL
#endif
);
mode.c_oflag &= ~(0
#ifdef OLCUC
- | OLCUC
+ | OLCUC
#endif
#ifdef OCRNL
- | OCRNL
+ | OCRNL
#endif
#ifdef ONOCR
- | ONOCR
+ | ONOCR
#endif
#ifdef ONLRET
- | ONLRET
+ | ONLRET
#endif
#ifdef OFILL
- | OFILL
+ | OFILL
#endif
#ifdef OFDEL
- | OFDEL
+ | OFDEL
#endif
#ifdef NLDLY
- | NLDLY | CRDLY | TABDLY | BSDLY | VTDLY | FFDLY
+ | NLDLY | CRDLY | TABDLY | BSDLY | VTDLY | FFDLY
#endif
);
mode.c_oflag |= (OPOST
#ifdef ONLCR
- | ONLCR
+ | ONLCR
#endif
);
mode.c_cflag |= (CS8 | CREAD);
mode.c_lflag &= ~(ECHONL | NOFLSH
#ifdef TOSTOP
- | TOSTOP
+ | TOSTOP
#endif
#ifdef ECHOPTR
- | ECHOPRT
+ | ECHOPRT
#endif
#ifdef XCASE
- | XCASE
+ | XCASE
#endif
);
mode.c_lflag |= (ISIG | ICANON | ECHO | ECHOE | ECHOK
#ifdef ECHOCTL
- | ECHOCTL
+ | ECHOCTL
#endif
#ifdef ECHOKE
- | ECHOKE
+ | ECHOKE
#endif
);
#endif
* Returns a "good" value for the erase character. This is loosely based on
* the BSD4.4 logic.
*/
+#ifdef TERMIOS
static int
default_erase(void)
{
return result;
}
+#endif
/*
* Update the values of the erase, interrupt, and kill characters in 'mode'.
/*
* Tell the user if a control key has been changed from the default value.
*/
+#ifdef TERMIOS
static void
report(const char *name, int which, unsigned def)
{
-#ifdef TERMIOS
unsigned older, newer;
char *p;
if (newer == 0177)
(void) fprintf(stderr, "delete.\n");
else if ((p = key_backspace) != 0
- && newer == (unsigned char) p[0]
- && p[1] == '\0')
+ && newer == (unsigned char) p[0]
+ && p[1] == '\0')
(void) fprintf(stderr, "backspace.\n");
else if (newer < 040) {
newer ^= 0100;
(void) fprintf(stderr, "control-%c (^%c).\n", newer, newer);
} else
(void) fprintf(stderr, "%c.\n", newer);
-#endif
}
+#endif
/*
* Convert the obsolete argument forms into something that getopt can handle.
usage(const char *pname)
{
(void) fprintf(stderr,
- "usage: %s [-IQrs] [-] [-e ch] [-i ch] [-k ch] [-m mapping] [terminal]\n", pname);
+ "usage: %s [-IQVrs] [-] [-e ch] [-i ch] [-k ch] [-m mapping] [terminal]\n", pname);
exit(EXIT_FAILURE);
}
const char *p;
const char *ttype;
-#ifdef TERMIOS
- if (tcgetattr(STDERR_FILENO, &mode) < 0)
+ if (GET_TTY(STDERR_FILENO, &mode) < 0)
failed("standard error");
-
oldmode = mode;
+#ifdef TERMIOS
ospeed = cfgetospeed(&mode);
#else
- if (gtty(STDERR_FILENO, &mode) < 0)
- failed("standard error");
-
- oldmode = mode;
ospeed = mode.sg_ospeed;
#endif
- if ((p = strrchr(*argv, '/')) != 0)
- ++p;
- else
- p = *argv;
- if (!CaselessCmp(p, "reset")) {
- isreset = 1;
+ p = _nc_basename(*argv);
+ if (!strcmp(p, PROG_RESET)) {
+ isreset = TRUE;
reset_mode();
}
obsolete(argv);
noinit = noset = quiet = Sflag = sflag = showterm = 0;
- while ((ch = getopt(argc, argv, "a:d:e:Ii:k:m:np:qQSrs")) != EOF) {
+ while ((ch = getopt(argc, argv, "a:d:e:Ii:k:m:np:qQSrsV")) != EOF) {
switch (ch) {
case 'q': /* display term only */
noset = 1;
case 's': /* output TERM set command */
sflag = 1;
break;
+ case 'V':
+ puts(curses_version());
+ return EXIT_SUCCESS;
case '?':
default:
usage(*argv);
* If erase, kill and interrupt characters could have been
* modified and not -Q, display the changes.
*/
+#ifdef TERMIOS
if (!quiet) {
report("Erase", VERASE, CERASE);
report("Kill", VKILL, CINTR);
report("Interrupt", VINTR, CKILL);
}
+#endif
}
if (Sflag)