termcap.c revision 8751
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 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. 12 */ 13 14#include <stdio.h> 15#include <stdlib.h> 16#include <string.h> 17#include <unistd.h> 18#include <stdarg.h> 19#include <fcntl.h> 20#include <sys/ioctl.h> 21#include <machine/console.h> 22 23#include "sysinstall.h" 24 25int 26set_termcap(void) 27{ 28 char *term; 29 int stat; 30 31 OnVTY = OnSerial = FALSE; 32 if (getpid() != 1) 33 DebugFD = open("sysinstall.debug", O_WRONLY|O_CREAT|O_TRUNC, 0644); 34 else 35 RunningAsInit = TRUE; 36 term = getenv("TERM"); 37 stat = ioctl(STDERR_FILENO, GIO_COLOR, &ColorDisplay); 38 if (stat < 0) { 39 if (!term) { 40 if (setenv("TERM", "vt100", 1) < 0) 41 return -1; 42 if (setenv("TERMCAP", termcap_vt100, 1) < 0) 43 return -1; 44 } 45 if (DebugFD == -1) 46 DebugFD = dup(1); 47 OnSerial = TRUE; 48 } 49 else { 50 if (ColorDisplay) { 51 if (!term) { 52 if (setenv("TERM", "cons25", 1) < 0) 53 return -1; 54 if (setenv("TERMCAP", termcap_cons25, 1) < 0) 55 return -1; 56 } 57 } 58 else { 59 if (!term) { 60 if (setenv("TERM", "cons25-m", 1) < 0) 61 return -1; 62 if (setenv("TERMCAP", termcap_cons25_m, 1) < 0) 63 return -1; 64 } 65 } 66 if (DebugFD == -1) { 67 DebugFD = open("/dev/ttyv1", O_WRONLY); 68 ioctl(DebugFD, TIOCCONS, (char *)NULL); 69 } 70 OnVTY = TRUE; 71 } 72 return 0; 73} 74