2 * Copyright (c) 1994, Paul Richards.
6 * This software may be used, modified, copied, distributed, and sold, in both
7 * source and binary form provided that the above copyright and these terms
8 * are retained, verbatim, as the first lines of this file. Under no
9 * circumstances is the author responsible for the proper functioning of this
10 * software, nor does the author assume any responsibility for damages
11 * incurred with its use.
19 #include <sys/errno.h>
20 #include <sys/ioctl.h>
21 #include <sys/consio.h>
23 #define VTY_STATUS_LINE 24
24 #define TTY_STATUS_LINE 23
27 prompt_term(char **termp)
31 printf("\nPlease set your TERM variable before running this program.\n");
32 printf("Defaulting to an ANSI compatible terminal - please press RETURN\n");
33 fgets(str, sizeof(str), stdin); /* Just to make it interactive */
34 *termp = (char *)"ansi";
44 term = getenv("TERM");
45 stat = ioctl(STDERR_FILENO, GIO_COLOR, &ColorDisplay);
48 DebugFD = open("sade.debug", O_WRONLY|O_CREAT|O_TRUNC, 0644);
52 DebugFD = open("/dev/null", O_RDWR, 0);
54 if (!OnVTY || (stat < 0)) {
59 if (setenv("TERM", term, 1) < 0)
63 DebugFD = open("/dev/null", O_RDWR, 0);
69 DebugFD = open("/dev/ttyv1", O_WRONLY);
72 i = ioctl(DebugFD, TIOCCONS, (char *)&on);
73 msgDebug("ioctl(%d, TIOCCONS, NULL) = %d (%s)\n",
74 DebugFD, i, !i ? "success" : strerror(errno));
80 if (setenv("TERM", "cons25w", 1) < 0)
86 if (setenv("TERM", "xterm", 1) < 0)
92 if (setenv("TERM", "vt100", 1) < 0)
98 if (ioctl(0, TIOCGWINSZ, &ws) == -1) {
99 msgDebug("Unable to get terminal size - errno %d\n", errno);
102 StatusLine = ws.ws_row ? ws.ws_row - 1: (OnVTY ? VTY_STATUS_LINE : TTY_STATUS_LINE);