termcap.c revision 8302
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 25Boolean ColorDisplay; 26Boolean OnVTY; 27 28int 29set_termcap(void) 30{ 31 char *term; 32 33 OnVTY = OnSerial = FALSE; 34 term = getenv("TERM"); 35 if (term == NULL) { 36 if (ioctl(STDERR_FILENO, GIO_COLOR, &ColorDisplay) < 0) { 37 if (setenv("TERM", "vt100", 1) < 0) 38 return -1; 39 if (setenv("TERMCAP", termcap_vt100, 1) < 0) 40 return -1; 41 DebugFD = dup(1); 42 OnSerial = TRUE; 43 } else if (ColorDisplay) { 44 if (setenv("TERM", "cons25", 1) < 0) 45 return -1; 46 if (setenv("TERMCAP", termcap_cons25, 1) < 0) 47 return -1; 48 DebugFD = open("/dev/ttyv1",O_WRONLY); 49 OnVTY = TRUE; 50 } else { 51 if (setenv("TERM", "cons25-m", 1) < 0) 52 return -1; 53 if (setenv("TERMCAP", termcap_cons25_m, 1) < 0) 54 return -1; 55 DebugFD = open("/dev/ttyv1",O_WRONLY); 56 OnVTY = TRUE; 57 } 58 } 59 else { 60 DebugFD = open("sysinstall.debug", O_WRONLY|O_CREAT|O_TRUNC,0644); 61 } 62 return 0; 63} 64