static char rcsid[] = "@(#)$Id: init.c,v 1.5 2006/04/09 07:37:37 hurtta Exp $"; /****************************************************************************** * The Elm (ME+) Mail System - $Revision: 1.5 $ $State: Exp $ * * Modified by: Kari Hurtta * (was hurtta+elm@ozone.FMI.FI) ****************************************************************************** * Most of code copied from src/init.c. It have following copyright: * * The Elm Mail System * * Copyright (c) 1988-1992 USENET Community Trust * Copyright (c) 1986,1987 Dave Taylor *****************************************************************************/ #include "def_screen.h" DEBUG_VAR(Debug,__FILE__,"screen"); #include #ifndef ANSI_C extern int errno; /* system error number on failure */ #endif #ifdef TERMIOS # include typedef struct termios term_buff; #else # ifdef TERMIO # include # define tcgetattr(fd,buf) ioctl((fd),TCGETA,(buf)) typedef struct termio term_buff; # else # include typedef struct { struct sgttyb sgttyb; struct tchars tchars; #ifdef TIOCLGET struct ltchars ltchars; #endif } term_buff; static int tcgetattr P_((int,term_buff *)); /* Prototype */ # endif #endif char backspace, /* the current backspace char */ kill_line, /* the current kill-line char */ word_erase, /* the current word-erase char */ interrupt_char, /* the current interrupt char */ reprint_char, /* the current reprint-line char */ eof_char; /* the current end-of-file char */ char VQUIT_char, /* the current quit char */ VSUSP_char; /* the current suspend char */ void get_term_chars(fd) int fd; { /** This routine sucks out the special terminal characters ERASE and KILL for use in the input routine. The meaning of the characters are (dare I say it?) fairly obvious... **/ term_buff term_buffer; if (tcgetattr(fd,&term_buffer) == -1) { int err = errno; DPRINT(Debug,3, (&Debug, "Error: %s encountered on ioctl call (get_term_chars, fd=%d)\n", error_description(err), fd)); /* set to defaults for terminal driver */ backspace = BACKSPACE; kill_line = ctrl('U'); word_erase = ctrl('W'); interrupt_char = 0177; /* DEL */ reprint_char = ctrl('R'); eof_char = ctrl('D'); VQUIT_char = 034; /* Ctrl \ */ VSUSP_char = ctrl('Z'); } else { #if defined(TERMIO) || defined(TERMIOS) backspace = term_buffer.c_cc[VERASE]; kill_line = term_buffer.c_cc[VKILL]; #if defined(TERMIOS) && defined(VWERASE) word_erase = term_buffer.c_cc[VWERASE]; #else word_erase = ctrl('W'); #endif interrupt_char = term_buffer.c_cc[VINTR]; #if defined(TERMIOS) && defined(VREPRINT) reprint_char = term_buffer.c_cc[VREPRINT]; #else reprint_char = ctrl('R'); #endif eof_char = term_buffer.c_cc[VEOF]; #else backspace = term_buffer.sgttyb.sg_erase; kill_line = term_buffer.sgttyb.sg_kill; #ifdef TIOCLGET word_erase = term_buffer.ltchars.t_werasc; reprint_char = term_buffer.ltchars.t_rprntc; #else word_erase = ctrl('W'); reprint_char = ctrl('R'); #endif interrupt_char = term_buffer.tchars.t_intrc; eof_char = term_buffer.tchars.t_eofc; #endif #if defined(TERMIOS) VQUIT_char = term_buffer.c_cc[VQUIT]; VSUSP_char = term_buffer.c_cc[VSUSP]; #else VQUIT_char = 034; /* Ctrl \ */ VSUSP_char = ctrl('Z'); #endif } DPRINT(Debug,4, (&Debug,"get_term_chars(%d): \n\ backspace %3d\n\ kill_line %3d\n\ word_erase %3d\n\ interrupt_char %3d\n\ reprint_char %3d\n\ eof_char %3d\n\ ", fd, backspace, kill_line, word_erase, interrupt_char, reprint_char, eof_char)); } #if !defined(TERMIO) && !defined(TERMIOS) static int tcgetattr(fd, buf) int fd; term_buff *buf; { if (ioctl(fd, TIOCGETP, &buf->sgttyb) < 0) return(-1); if (ioctl(fd, TIOCGETC, &buf->tchars) < 0) return(-1); #ifdef TIOCLGET if (ioctl(fd, TIOCLGET, &buf->ltchars) < 0) return(-1); #endif return(0); } #endif /* * Local Variables: * mode:c * c-basic-offset:4 * buffer-file-coding-system: iso-8859-1 * End: */