Deleted Added
full compact
termcap.c (22757) termcap.c (27798)
1/*
2 * Copyright (c) 1994, Paul Richards.
3 *
4 * All rights reserved.
5 *
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

--- 7 unchanged lines hidden (view full) ---

16#include <fcntl.h>
17#include <sys/errno.h>
18#include <sys/ioctl.h>
19#include <machine/console.h>
20
21#define VTY_STATUS_LINE 24
22#define TTY_STATUS_LINE 23
23
1/*
2 * Copyright (c) 1994, Paul Richards.
3 *
4 * All rights reserved.
5 *
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

--- 7 unchanged lines hidden (view full) ---

16#include <fcntl.h>
17#include <sys/errno.h>
18#include <sys/ioctl.h>
19#include <machine/console.h>
20
21#define VTY_STATUS_LINE 24
22#define TTY_STATUS_LINE 23
23
24static void
25prompt_term(char **termp, char **termcapp)
26{
27 char str[80];
28 static struct {
29 const char *term, *termcap;
30 } lookup[] = { { "ansi", termcap_ansi },
31 { "vt100", termcap_vt100 },
32 { "cons25", termcap_cons25 },
33 { "cons25-m", termcap_cons25_m } };
34
35 if (RunningAsInit) {
36 while (1) {
37 int i;
38
39 printf("\nThese are the predefined terminal types available to\n");
40 printf("sysinstall when running stand-alone. Please choose the\n");
41 printf("closest match for your particular terminal.\n\n");
42 printf("1 ...................... Standard ANSI terminal.\n");
43 printf("2 ...................... VT100 or compatible terminal.\n");
44 printf("3 ...................... FreeBSD system console (color).\n");
45 printf("4 ...................... FreeBSD system console (monochrome).\n\n");
46 printf("Your choice: (1-4) ");
47 fflush(stdout);
48 fgets(str, 80, stdin);
49 i = str[0] - '0';
50 if (i > 0 && i < 5) {
51 *termp = (char *)lookup[i - 1].term;
52 *termcapp = (char *)lookup[i - 1].termcap;
53 break;
54 }
55 else
56 printf("\007Invalid choice, please try again.\n\n");
57 }
58 }
59 else {
60 printf("\nPlease set your TERM variable before running this program.\n");
61 printf("Defaulting to an ANSI compatible terminal - please press RETURN\n");
62 fgets(str, 80, stdin); /* Just to make it interactive */
63 *termp = (char *)"ansi";
64 *termcapp = (char *)termcap_ansi;
65 }
66}
67
24int
25set_termcap(void)
26{
27 char *term;
28 int stat;
29 struct ttysize ts;
30
31 term = getenv("TERM");
32 stat = ioctl(STDERR_FILENO, GIO_COLOR, &ColorDisplay);
33
68int
69set_termcap(void)
70{
71 char *term;
72 int stat;
73 struct ttysize ts;
74
75 term = getenv("TERM");
76 stat = ioctl(STDERR_FILENO, GIO_COLOR, &ColorDisplay);
77
34 if (getpid() != 1) {
78 if (!RunningAsInit) {
35 if (getenv("SYSINSTALL_DEBUG"))
36 DebugFD = open("sysinstall.debug", O_WRONLY|O_CREAT|O_TRUNC, 0644);
37 else
38 DebugFD = -1;
39 if (DebugFD < 0)
40 DebugFD = open("/dev/null", O_RDWR, 0);
41 }
42
43 if (!OnVTY || (stat < 0)) {
44 if (!term) {
79 if (getenv("SYSINSTALL_DEBUG"))
80 DebugFD = open("sysinstall.debug", O_WRONLY|O_CREAT|O_TRUNC, 0644);
81 else
82 DebugFD = -1;
83 if (DebugFD < 0)
84 DebugFD = open("/dev/null", O_RDWR, 0);
85 }
86
87 if (!OnVTY || (stat < 0)) {
88 if (!term) {
45 if (setenv("TERM", "vt100", 1) < 0)
89 char *term, *termcap;
90
91 prompt_term(&term, &termcap);
92 if (setenv("TERM", term, 1) < 0)
46 return -1;
93 return -1;
47 if (setenv("TERMCAP", termcap_vt100, 1) < 0)
94 if (setenv("TERMCAP", termcap, 1) < 0)
48 return -1;
49 }
50 if (DebugFD == -1)
51 DebugFD = dup(1);
52 }
53 else {
54 int i, on;
55

--- 30 unchanged lines hidden ---
95 return -1;
96 }
97 if (DebugFD == -1)
98 DebugFD = dup(1);
99 }
100 else {
101 int i, on;
102

--- 30 unchanged lines hidden ---