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.
16 #include "sysinstall.h"
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, char **termcapp)
31 const char *term, *termcap;
32 } lookup[] = { { "ansi", termcap_ansi },
33 { "vt100", termcap_vt100 },
34 { "cons25", termcap_cons25 },
35 { "cons25-m", termcap_cons25_m },
36 { "xterm", termcap_xterm },
37 { "cons25w", termcap_cons25w } }; /* must be last */
43 printf("\nThese are the predefined terminal types available to\n");
44 printf("sysinstall when running stand-alone. Please choose the\n");
45 printf("closest match for your particular terminal.\n\n");
46 printf("1 ...................... Standard ANSI terminal.\n");
47 printf("2 ...................... VT100 or compatible terminal.\n");
48 printf("3 ...................... FreeBSD system console (color).\n");
49 printf("4 ...................... FreeBSD system console (monochrome).\n\n");
50 printf("5 ...................... xterm terminal emulator.\n\n");
51 printf("Your choice: (1-5) ");
53 fgets(str, sizeof(str), stdin);
56 *termp = (char *)lookup[i - 1].term;
57 *termcapp = (char *)lookup[i - 1].termcap;
61 printf("\007Invalid choice, please try again.\n\n");
65 printf("\nPlease set your TERM variable before running this program.\n");
66 printf("Defaulting to an ANSI compatible terminal - please press RETURN\n");
67 fgets(str, sizeof(str), stdin); /* Just to make it interactive */
68 *termp = (char *)"ansi";
69 *termcapp = (char *)termcap_ansi;
80 term = getenv("TERM");
81 stat = ioctl(STDERR_FILENO, GIO_COLOR, &ColorDisplay);
85 DebugFD = open("sysinstall.debug", O_WRONLY|O_CREAT|O_TRUNC, 0644);
89 DebugFD = open("/dev/null", O_RDWR, 0);
92 if (!OnVTY || (stat < 0)) {
96 prompt_term(&term, &termcap);
97 if (setenv("TERM", term, 1) < 0)
99 if (setenv("TERMCAP", termcap, 1) < 0)
103 DebugFD = open("/dev/null", O_RDWR, 0);
109 DebugFD = open("/dev/ttyv1", O_WRONLY);
112 i = ioctl(DebugFD, TIOCCONS, (char *)&on);
113 msgDebug("ioctl(%d, TIOCCONS, NULL) = %d (%s)\n",
114 DebugFD, i, !i ? "success" : strerror(errno));
120 if (setenv("TERM", "cons25w", 1) < 0)
122 if (setenv("TERMCAP", termcap_cons25w, 1) < 0)
128 if (setenv("TERM", "xterm", 1) < 0)
130 if (setenv("TERMCAP", termcap_xterm, 1) < 0)
136 if (setenv("TERM", "vt100", 1) < 0)
138 if (setenv("TERMCAP", termcap_vt100, 1) < 0)
144 if (ioctl(0, TIOCGWINSZ, &ws) == -1) {
145 msgDebug("Unable to get terminal size - errno %d\n", errno);
148 StatusLine = ws.ws_row ? ws.ws_row - 1: (OnVTY ? VTY_STATUS_LINE : TTY_STATUS_LINE);