From 99c93a070ee0c52dd314ce7a8a6ccf9968cc181c Mon Sep 17 00:00:00 2001 From: Micah Cowan Date: Sat, 9 Aug 2008 10:12:43 -0700 Subject: [PATCH] Removed *.dist files. --- src/comm.h.dist | 227 ------- src/kmapdef.c.dist | 144 ---- src/term.h.dist | 252 ------- src/tty.c.dist | 1887 ---------------------------------------------------- 4 files changed, 2510 deletions(-) delete mode 100644 src/comm.h.dist delete mode 100644 src/kmapdef.c.dist delete mode 100644 src/term.h.dist delete mode 100644 src/tty.c.dist diff --git a/src/comm.h.dist b/src/comm.h.dist deleted file mode 100644 index bdc620e..0000000 --- a/src/comm.h.dist +++ /dev/null @@ -1,227 +0,0 @@ -/* - * This file is automagically created from comm.c -- DO NOT EDIT - */ - -struct comm -{ - char *name; - int flags; -#ifdef MULTIUSER - AclBits userbits[ACL_BITS_PER_CMD]; -#endif -}; - -#define ARGS_MASK (3) - -#define ARGS_0 (0) -#define ARGS_1 (1) -#define ARGS_2 (2) -#define ARGS_3 (3) - -#define ARGS_PLUS1 (1<<2) -#define ARGS_PLUS2 (1<<3) -#define ARGS_PLUS3 (1<<4) -#define ARGS_ORMORE (1<<5) - -#define NEED_FORE (1<<6) /* this command needs a fore window */ -#define NEED_DISPLAY (1<<7) /* this command needs a display */ -#define NEED_LAYER (1<<8) /* this command needs a layer */ - -#define ARGS_01 (ARGS_0 | ARGS_PLUS1) -#define ARGS_02 (ARGS_0 | ARGS_PLUS2) -#define ARGS_12 (ARGS_1 | ARGS_PLUS1) -#define ARGS_23 (ARGS_2 | ARGS_PLUS1) -#define ARGS_24 (ARGS_2 | ARGS_PLUS2) -#define ARGS_34 (ARGS_3 | ARGS_PLUS1) -#define ARGS_012 (ARGS_0 | ARGS_PLUS1 | ARGS_PLUS2) -#define ARGS_0123 (ARGS_0 | ARGS_PLUS1 | ARGS_PLUS2 | ARGS_PLUS3) -#define ARGS_123 (ARGS_1 | ARGS_PLUS1 | ARGS_PLUS2) -#define ARGS_124 (ARGS_1 | ARGS_PLUS1 | ARGS_PLUS3) -#define ARGS_1234 (ARGS_1 | ARGS_PLUS1 | ARGS_PLUS2 | ARGS_PLUS3) - -struct action -{ - int nr; - char **args; - int *argl; -}; - -#define RC_ILLEGAL -1 - -#define RC_ACLADD 0 -#define RC_ACLCHG 1 -#define RC_ACLDEL 2 -#define RC_ACLGRP 3 -#define RC_ACLUMASK 4 -#define RC_ACTIVITY 5 -#define RC_ADDACL 6 -#define RC_ALLPARTIAL 7 -#define RC_ALTSCREEN 8 -#define RC_AT 9 -#define RC_ATTRCOLOR 10 -#define RC_AUTODETACH 11 -#define RC_AUTONUKE 12 -#define RC_BACKTICK 13 -#define RC_BCE 14 -#define RC_BELL 15 -#define RC_BELL_MSG 16 -#define RC_BIND 17 -#define RC_BINDKEY 18 -#define RC_BLANKER 19 -#define RC_BLANKERPRG 20 -#define RC_BREAK 21 -#define RC_BREAKTYPE 22 -#define RC_BUFFERFILE 23 -#define RC_C1 24 -#define RC_CAPTION 25 -#define RC_CHACL 26 -#define RC_CHARSET 27 -#define RC_CHDIR 28 -#define RC_CLEAR 29 -#define RC_COLON 30 -#define RC_COMMAND 31 -#define RC_COMPACTHIST 32 -#define RC_CONSOLE 33 -#define RC_COPY 34 -#define RC_CRLF 35 -#define RC_DEBUG 36 -#define RC_DEFAUTONUKE 37 -#define RC_DEFBCE 38 -#define RC_DEFBREAKTYPE 39 -#define RC_DEFC1 40 -#define RC_DEFCHARSET 41 -#define RC_DEFENCODING 42 -#define RC_DEFESCAPE 43 -#define RC_DEFFLOW 44 -#define RC_DEFGR 45 -#define RC_DEFHSTATUS 46 -#define RC_DEFKANJI 47 -#define RC_DEFLOG 48 -#define RC_DEFLOGIN 49 -#define RC_DEFMODE 50 -#define RC_DEFMONITOR 51 -#define RC_DEFNONBLOCK 52 -#define RC_DEFOBUFLIMIT 53 -#define RC_DEFSCROLLBACK 54 -#define RC_DEFSHELL 55 -#define RC_DEFSILENCE 56 -#define RC_DEFSLOWPASTE 57 -#define RC_DEFUTF8 58 -#define RC_DEFWRAP 59 -#define RC_DEFWRITELOCK 60 -#define RC_DETACH 61 -#define RC_DIGRAPH 62 -#define RC_DINFO 63 -#define RC_DISPLAYS 64 -#define RC_DUMPTERMCAP 65 -#define RC_ECHO 66 -#define RC_ENCODING 67 -#define RC_ESCAPE 68 -#define RC_EVAL 69 -#define RC_EXEC 70 -#define RC_FIT 71 -#define RC_FLOW 72 -#define RC_FOCUS 73 -#define RC_GR 74 -#define RC_HARDCOPY 75 -#define RC_HARDCOPY_APPEND 76 -#define RC_HARDCOPYDIR 77 -#define RC_HARDSTATUS 78 -#define RC_HEIGHT 79 -#define RC_HELP 80 -#define RC_HISTORY 81 -#define RC_HSTATUS 82 -#define RC_IDLE 83 -#define RC_IGNORECASE 84 -#define RC_INFO 85 -#define RC_KANJI 86 -#define RC_KILL 87 -#define RC_LASTMSG 88 -#define RC_LICENSE 89 -#define RC_LOCKSCREEN 90 -#define RC_LOG 91 -#define RC_LOGFILE 92 -#define RC_LOGIN 93 -#define RC_LOGTSTAMP 94 -#define RC_MAPDEFAULT 95 -#define RC_MAPNOTNEXT 96 -#define RC_MAPTIMEOUT 97 -#define RC_MARKKEYS 98 -#define RC_MAXWIN 99 -#define RC_META 100 -#define RC_MONITOR 101 -#define RC_MSGMINWAIT 102 -#define RC_MSGWAIT 103 -#define RC_MULTIUSER 104 -#define RC_NETHACK 105 -#define RC_NEXT 106 -#define RC_NONBLOCK 107 -#define RC_NUMBER 108 -#define RC_OBUFLIMIT 109 -#define RC_ONLY 110 -#define RC_OTHER 111 -#define RC_PARTIAL 112 -#define RC_PASSWORD 113 -#define RC_PASTE 114 -#define RC_PASTEFONT 115 -#define RC_POW_BREAK 116 -#define RC_POW_DETACH 117 -#define RC_POW_DETACH_MSG 118 -#define RC_PREV 119 -#define RC_PRINTCMD 120 -#define RC_PROCESS 121 -#define RC_QUIT 122 -#define RC_READBUF 123 -#define RC_READREG 124 -#define RC_REDISPLAY 125 -#define RC_REGISTER 126 -#define RC_REMOVE 127 -#define RC_REMOVEBUF 128 -#define RC_RESET 129 -#define RC_RESIZE 130 -#define RC_SCREEN 131 -#define RC_SCROLLBACK 132 -#define RC_SELECT 133 -#define RC_SESSIONNAME 134 -#define RC_SETENV 135 -#define RC_SETSID 136 -#define RC_SHELL 137 -#define RC_SHELLTITLE 138 -#define RC_SILENCE 139 -#define RC_SILENCEWAIT 140 -#define RC_SLEEP 141 -#define RC_SLOWPASTE 142 -#define RC_SORENDITION 143 -#define RC_SOURCE 144 -#define RC_SPLIT 145 -#define RC_STARTUP_MESSAGE 146 -#define RC_STUFF 147 -#define RC_SU 148 -#define RC_SUSPEND 149 -#define RC_TERM 150 -#define RC_TERMCAP 151 -#define RC_TERMCAPINFO 152 -#define RC_TERMINFO 153 -#define RC_TIME 154 -#define RC_TITLE 155 -#define RC_UMASK 156 -#define RC_UNSETENV 157 -#define RC_UTF8 158 -#define RC_VBELL 159 -#define RC_VBELL_MSG 160 -#define RC_VBELLWAIT 161 -#define RC_VERBOSE 162 -#define RC_VERSION 163 -#define RC_WALL 164 -#define RC_WIDTH 165 -#define RC_WINDOWLIST 166 -#define RC_WINDOWS 167 -#define RC_WRAP 168 -#define RC_WRITEBUF 169 -#define RC_WRITELOCK 170 -#define RC_XOFF 171 -#define RC_XON 172 -#define RC_ZMODEM 173 -#define RC_ZOMBIE 174 - -#define RC_LAST 174 diff --git a/src/kmapdef.c.dist b/src/kmapdef.c.dist deleted file mode 100644 index 71a5b53..0000000 --- a/src/kmapdef.c.dist +++ /dev/null @@ -1,144 +0,0 @@ -/* - * This file is automagically created from term.c -- DO NOT EDIT - */ - -#include "config.h" - -#ifdef MAPKEYS - -char *kmapdef[] = { -"\033[10~", -"\033OP", -"\033OQ", -"\033OR", -"\033OS", -"\033[15~", -"\033[17~", -"\033[18~", -"\033[19~", -"\033[20~", -"\033[21~", -"\033[23~", -"\033[24~", -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -"\033[1~", -0, -"\033[4~", -0, -"\033[6~", -"\033[5~", -"\033[2~", -"\033[3~", -"\033[A", -"\033[B", -"\033[C", -"\033[D", -"0", -"1", -"2", -"3", -"4", -"5", -"6", -"7", -"8", -"9", -"+", -"-", -"*", -"/", -"=", -".", -",", -"\015" -}; - -char *kmapadef[] = { -"\033OA", -"\033OB", -"\033OC", -"\033OD", -"\033Op", -"\033Oq", -"\033Or", -"\033Os", -"\033Ot", -"\033Ou", -"\033Ov", -"\033Ow", -"\033Ox", -"\033Oy", -"\033Ok", -"\033Om", -"\033Oj", -"\033Oo", -"\033OX", -"\033On", -"\033Ol", -"\033OM" -}; - -char *kmapmdef[] = { -"\004", -0, -0, -"\025", -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -"\201", -0, -"\205", -0, -"\006", -"\002", -0, -0, -"\220", -"\216", -"\206", -"\202" -}; - -#endif diff --git a/src/term.h.dist b/src/term.h.dist deleted file mode 100644 index bbe9894..0000000 --- a/src/term.h.dist +++ /dev/null @@ -1,252 +0,0 @@ -/* - * This file is automagically created from term.c -- DO NOT EDIT - */ - -#define T_FLG 0 -#define T_NUM 1 -#define T_STR 2 - -struct term -{ - char *tcname; - int type; -}; - -union tcu -{ - int flg; - int num; - char *str; -}; - -#define d_LI d_tcs[0].num -#define D_LI (D_tcs[0].num) -#define d_CO d_tcs[1].num -#define D_CO (D_tcs[1].num) -#define d_HC d_tcs[2].flg -#define D_HC (D_tcs[2].flg) -#define d_OS d_tcs[3].flg -#define D_OS (D_tcs[3].flg) -#define d_NS d_tcs[4].flg -#define D_NS (D_tcs[4].flg) -#define d_CM d_tcs[5].str -#define D_CM (D_tcs[5].str) -#define d_HO d_tcs[6].str -#define D_HO (D_tcs[6].str) -#define d_CR d_tcs[7].str -#define D_CR (D_tcs[7].str) -#define d_UP d_tcs[8].str -#define D_UP (D_tcs[8].str) -#define d_CUP d_tcs[9].str -#define D_CUP (D_tcs[9].str) -#define d_DO d_tcs[10].str -#define D_DO (D_tcs[10].str) -#define d_CDO d_tcs[11].str -#define D_CDO (D_tcs[11].str) -#define d_BS d_tcs[12].flg -#define D_BS (D_tcs[12].flg) -#define d_BC d_tcs[13].str -#define D_BC (D_tcs[13].str) -#define d_LE d_tcs[14].str -#define D_LE (D_tcs[14].str) -#define d_CLE d_tcs[15].str -#define D_CLE (D_tcs[15].str) -#define d_ND d_tcs[16].str -#define D_ND (D_tcs[16].str) -#define d_CRI d_tcs[17].str -#define D_CRI (D_tcs[17].str) -#define d_CS d_tcs[18].str -#define D_CS (D_tcs[18].str) -#define d_NL d_tcs[19].str -#define D_NL (D_tcs[19].str) -#define d_SF d_tcs[20].str -#define D_SF (D_tcs[20].str) -#define d_SR d_tcs[21].str -#define D_SR (D_tcs[21].str) -#define d_AL d_tcs[22].str -#define D_AL (D_tcs[22].str) -#define d_CAL d_tcs[23].str -#define D_CAL (D_tcs[23].str) -#define d_DL d_tcs[24].str -#define D_DL (D_tcs[24].str) -#define d_CDL d_tcs[25].str -#define D_CDL (D_tcs[25].str) -#define d_IN d_tcs[26].flg -#define D_IN (D_tcs[26].flg) -#define d_IM d_tcs[27].str -#define D_IM (D_tcs[27].str) -#define d_EI d_tcs[28].str -#define D_EI (D_tcs[28].str) -#define d_IC d_tcs[29].str -#define D_IC (D_tcs[29].str) -#define d_CIC d_tcs[30].str -#define D_CIC (D_tcs[30].str) -#define d_DC d_tcs[31].str -#define D_DC (D_tcs[31].str) -#define d_CDC d_tcs[32].str -#define D_CDC (D_tcs[32].str) -#define d_UT d_tcs[33].flg -#define D_UT (D_tcs[33].flg) -#define d_CL d_tcs[34].str -#define D_CL (D_tcs[34].str) -#define d_CD d_tcs[35].str -#define D_CD (D_tcs[35].str) -#define d_CCD d_tcs[36].str -#define D_CCD (D_tcs[36].str) -#define d_CE d_tcs[37].str -#define D_CE (D_tcs[37].str) -#define d_CB d_tcs[38].str -#define D_CB (D_tcs[38].str) -#define d_IS d_tcs[39].str -#define D_IS (D_tcs[39].str) -#define d_TI d_tcs[40].str -#define D_TI (D_tcs[40].str) -#define d_TE d_tcs[41].str -#define D_TE (D_tcs[41].str) -#define d_BL d_tcs[42].str -#define D_BL (D_tcs[42].str) -#define d_VB d_tcs[43].str -#define D_VB (D_tcs[43].str) -#define d_CWS d_tcs[44].str -#define D_CWS (D_tcs[44].str) -#define d_CZ0 d_tcs[45].str -#define D_CZ0 (D_tcs[45].str) -#define d_CZ1 d_tcs[46].str -#define D_CZ1 (D_tcs[46].str) -#define T_ATTR 47 -#define d_MH d_tcs[47].str -#define D_MH (D_tcs[47].str) -#define d_US d_tcs[48].str -#define D_US (D_tcs[48].str) -#define d_MD d_tcs[49].str -#define D_MD (D_tcs[49].str) -#define d_MR d_tcs[50].str -#define D_MR (D_tcs[50].str) -#define d_SO d_tcs[51].str -#define D_SO (D_tcs[51].str) -#define d_MB d_tcs[52].str -#define D_MB (D_tcs[52].str) -#define d_UE d_tcs[53].str -#define D_UE (D_tcs[53].str) -#define d_SE d_tcs[54].str -#define D_SE (D_tcs[54].str) -#define d_ME d_tcs[55].str -#define D_ME (D_tcs[55].str) -#define d_MS d_tcs[56].flg -#define D_MS (D_tcs[56].flg) -#define d_SG d_tcs[57].num -#define D_SG (D_tcs[57].num) -#define d_UG d_tcs[58].num -#define D_UG (D_tcs[58].num) -#define d_SA d_tcs[59].str -#define D_SA (D_tcs[59].str) -#define d_CAF d_tcs[60].str -#define D_CAF (D_tcs[60].str) -#define d_CAB d_tcs[61].str -#define D_CAB (D_tcs[61].str) -#define d_CSF d_tcs[62].str -#define D_CSF (D_tcs[62].str) -#define d_CSB d_tcs[63].str -#define D_CSB (D_tcs[63].str) -#define d_OP d_tcs[64].str -#define D_OP (D_tcs[64].str) -#define d_CCO d_tcs[65].num -#define D_CCO (D_tcs[65].num) -#define d_BE d_tcs[66].flg -#define D_BE (D_tcs[66].flg) -#define d_CAX d_tcs[67].flg -#define D_CAX (D_tcs[67].flg) -#define d_CC8 d_tcs[68].flg -#define D_CC8 (D_tcs[68].flg) -#define d_KS d_tcs[69].str -#define D_KS (D_tcs[69].str) -#define d_KE d_tcs[70].str -#define D_KE (D_tcs[70].str) -#define d_CCS d_tcs[71].str -#define D_CCS (D_tcs[71].str) -#define d_CCE d_tcs[72].str -#define D_CCE (D_tcs[72].str) -#define d_PO d_tcs[73].str -#define D_PO (D_tcs[73].str) -#define d_PF d_tcs[74].str -#define D_PF (D_tcs[74].str) -#define d_HS d_tcs[75].flg -#define D_HS (D_tcs[75].flg) -#define d_WS d_tcs[76].num -#define D_WS (D_tcs[76].num) -#define d_TS d_tcs[77].str -#define D_TS (D_tcs[77].str) -#define d_FS d_tcs[78].str -#define D_FS (D_tcs[78].str) -#define d_DS d_tcs[79].str -#define D_DS (D_tcs[79].str) -#define d_VI d_tcs[80].str -#define D_VI (D_tcs[80].str) -#define d_VS d_tcs[81].str -#define D_VS (D_tcs[81].str) -#define d_VE d_tcs[82].str -#define D_VE (D_tcs[82].str) -#define d_AM d_tcs[83].flg -#define D_AM (D_tcs[83].flg) -#define d_XV d_tcs[84].flg -#define D_XV (D_tcs[84].flg) -#define d_XN d_tcs[85].flg -#define D_XN (D_tcs[85].flg) -#define d_COP d_tcs[86].flg -#define D_COP (D_tcs[86].flg) -#define d_CLP d_tcs[87].flg -#define D_CLP (D_tcs[87].flg) -#define d_CNF d_tcs[88].flg -#define D_CNF (D_tcs[88].flg) -#define d_NX d_tcs[89].flg -#define D_NX (D_tcs[89].flg) -#define d_CAN d_tcs[90].flg -#define D_CAN (D_tcs[90].flg) -#define d_COL d_tcs[91].num -#define D_COL (D_tcs[91].num) -#define d_CKJ d_tcs[92].str -#define D_CKJ (D_tcs[92].str) -#define d_CVR d_tcs[93].str -#define D_CVR (D_tcs[93].str) -#define d_CVN d_tcs[94].str -#define D_CVN (D_tcs[94].str) -#define d_CTF d_tcs[95].flg -#define D_CTF (D_tcs[95].flg) -#define d_CXT d_tcs[96].flg -#define D_CXT (D_tcs[96].flg) -#define d_CG0 d_tcs[97].flg -#define D_CG0 (D_tcs[97].flg) -#define d_CS0 d_tcs[98].str -#define D_CS0 (D_tcs[98].str) -#define d_CE0 d_tcs[99].str -#define D_CE0 (D_tcs[99].str) -#define d_CC0 d_tcs[100].str -#define D_CC0 (D_tcs[100].str) -#define d_AS d_tcs[101].str -#define D_AS (D_tcs[101].str) -#define d_AE d_tcs[102].str -#define D_AE (D_tcs[102].str) -#define d_AC d_tcs[103].str -#define D_AC (D_tcs[103].str) -#define d_EA d_tcs[104].str -#define D_EA (D_tcs[104].str) -#define d_CXC d_tcs[105].str -#define D_CXC (D_tcs[105].str) -#define T_CAPS 106 -#define T_BACKTAB 135 -#define T_NAVIGATE 153 -#define T_NAVIGATE_DELETE 160 -#define T_CURSOR 161 -#define T_KEYPAD 165 -#define T_OCAPS 183 -#define T_ECAPS 196 -#define T_N 196 - -#ifdef MAPKEYS -# define KMAPDEFSTART 106 -# define NKMAPDEF 77 -# define KMAPADEFSTART 161 -# define NKMAPADEF 22 -# define KMAPMDEFSTART 138 -# define NKMAPMDEF 27 -#endif diff --git a/src/tty.c.dist b/src/tty.c.dist deleted file mode 100644 index 688cf62..0000000 --- a/src/tty.c.dist +++ /dev/null @@ -1,1887 +0,0 @@ -/* Copyright (c) 1993-2002 - * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de) - * Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de) - * Copyright (c) 1987 Oliver Laumann - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program (see the file COPYING); if not, write to the - * Free Software Foundation, Inc., - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - * - **************************************************************** - */ - -/* - * NOTICE: tty.c is automatically generated from tty.sh - * Do not change anything here. If you then change tty.sh. - */ - -#include -#include -#include -#ifndef sgi -# include -#endif -#if !defined(sun) || defined(SUNOS3) -# include /* collosions with termios.h */ -#else -# ifndef TIOCEXCL -# include /* needed for TIOCEXCL */ -# endif -#endif -#ifdef __hpux -# include -#endif - -#ifdef ISC -# include -# include -# include -#endif - -#include "config.h" -#ifdef SVR4 -#include /* for I_POP */ -#endif - -#include "screen.h" -#include "extern.h" - -#if !defined(TIOCCONS) && defined(sun) && defined(SVR4) -# include -#endif - -extern struct display *display, *displays; -extern int iflag; -#if (!defined(TIOCCONS) && defined(SRIOCSREDIR)) || defined(linux) -extern struct win *console_window; -static void consredir_readev_fn __P((struct event *, char *)); -#endif - -int separate_sids = 1; - -static void DoSendBreak __P((int, int, int)); -static sigret_t SigAlrmDummy __P(SIGPROTOARG); - - -/* Frank Schulz (fschulz@pyramid.com): - * I have no idea why VSTART is not defined and my fix is probably not - * the cleanest, but it works. - */ -#if !defined(VSTART) && defined(_VSTART) -#define VSTART _VSTART -#endif -#if !defined(VSTOP) && defined(_VSTOP) -#define VSTOP _VSTOP -#endif - -#ifndef O_NOCTTY -# define O_NOCTTY 0 -#endif - -#ifndef TTYVMIN -# define TTYVMIN 1 -#endif -#ifndef TTYVTIME -#define TTYVTIME 0 -#endif - - -static sigret_t -SigAlrmDummy SIGDEFARG -{ - debug("SigAlrmDummy()\n"); - SIGRETURN; -} - -/* - * Carefully open a charcter device. Not used to open display ttys. - * The second parameter is parsed for a few stty style options. - */ - -int -OpenTTY(line, opt) -char *line, *opt; -{ - int f; - struct mode Mode; - sigret_t (*sigalrm)__P(SIGPROTOARG); - - sigalrm = signal(SIGALRM, SigAlrmDummy); - alarm(2); - - /* this open only succeeds, if real uid is allowed */ - if ((f = secopen(line, O_RDWR | O_NONBLOCK | O_NOCTTY, 0)) == -1) - { - if (errno == EINTR) - Msg(0, "Cannot open line '%s' for R/W: open() blocked, aborted.", line); - else - Msg(errno, "Cannot open line '%s' for R/W", line); - alarm(0); - signal(SIGALRM, sigalrm); - return -1; - } - if (!isatty(f)) - { - Msg(0, "'%s' is not a tty", line); - alarm(0); - signal(SIGALRM, sigalrm); - close(f); - return -1; - } -#if defined(I_POP) && defined(POP_TTYMODULES) - debug("OpenTTY I_POP\n"); - while (ioctl(f, I_POP, (char *)0) >= 0) - ; -#endif - /* - * We come here exclusively. This is to stop all kermit and cu type things - * accessing the same tty line. - * Perhaps we should better create a lock in some /usr/spool/locks directory? - */ -#ifdef TIOCEXCL - errno = 0; - if (ioctl(f, TIOCEXCL, (char *) 0) < 0) - Msg(errno, "%s: ioctl TIOCEXCL failed", line); - debug3("%d %d %d\n", getuid(), geteuid(), getpid()); - debug2("%s TIOCEXCL errno %d\n", line, errno); -#endif /* TIOCEXCL */ - /* - * We create a sane tty mode. We do not copy things from the display tty - */ -#if WE_REALLY_WANT_TO_COPY_THE_TTY_MODE - if (display) - { - debug1("OpenTTY: using mode of display for %s\n", line); - Mode = D_NewMode; - } - else -#endif - InitTTY(&Mode, W_TYPE_PLAIN); - - SttyMode(&Mode, opt); -#ifdef DEBUG - DebugTTY(&Mode); -#endif - SetTTY(f, &Mode); - -#if defined(linux) && defined(TIOCMSET) - { - int mcs = 0; - ioctl(f, TIOCMGET, &mcs); - mcs |= TIOCM_RTS; - ioctl(f, TIOCMSET, &mcs); - } -#endif - - brktty(f); - alarm(0); - signal(SIGALRM, sigalrm); - debug2("'%s' CONNECT fd=%d.\n", line, f); - return f; -} - - -/* - * Tty mode handling - */ - -void -InitTTY(m, ttyflag) -struct mode *m; -int ttyflag; -{ - bzero((char *)m, sizeof(*m)); -#ifdef POSIX - /* struct termios tio - * defaults, as seen on SunOS 4.1.3 - */ - debug1("InitTTY: POSIX: termios defaults based on SunOS 4.1.3, but better (%d)\n", ttyflag); -#if defined(BRKINT) - m->tio.c_iflag |= BRKINT; -#endif /* BRKINT */ -#if defined(IGNPAR) - m->tio.c_iflag |= IGNPAR; -#endif /* IGNPAR */ -/* IF{ISTRIP} m->tio.c_iflag |= ISTRIP; may be needed, let's try. jw. */ -#if defined(IXON) - m->tio.c_iflag |= IXON; -#endif /* IXON */ -/* IF{IMAXBEL} m->tio.c_iflag |= IMAXBEL; sorry, this one is ridiculus. jw */ - - if (!ttyflag) /* may not even be good for ptys.. */ - { -#if defined(ICRNL) - m->tio.c_iflag |= ICRNL; -#endif /* ICRNL */ -#if defined(ONLCR) - m->tio.c_oflag |= ONLCR; -#endif /* ONLCR */ -#if defined(TAB3) - m->tio.c_oflag |= TAB3; -#endif /* TAB3 */ -#if defined(OXTABS) - m->tio.c_oflag |= OXTABS; -#endif /* OXTABS */ -/* IF{PARENB} m->tio.c_cflag |= PARENB; nah! jw. */ -#if defined(OPOST) - m->tio.c_oflag |= OPOST; -#endif /* OPOST */ - } - - -/* - * Or-ing the speed into c_cflags is dangerous. - * It breaks on bsdi, where c_ispeed and c_ospeed are extra longs. - * - * IF{B9600} m->tio.c_cflag |= B9600; - * IF{IBSHIFT) && defined(B9600} m->tio.c_cflag |= B9600 << IBSHIFT; - * - * We hope that we have the posix calls to do it right: - * If these are not available you might try the above. - */ -#if defined(B9600) - cfsetospeed(&m->tio, B9600); -#endif /* B9600 */ -#if defined(B9600) - cfsetispeed(&m->tio, B9600); -#endif /* B9600 */ - -#if defined(CS8) - m->tio.c_cflag |= CS8; -#endif /* CS8 */ -#if defined(CREAD) - m->tio.c_cflag |= CREAD; -#endif /* CREAD */ -#if defined(CLOCAL) - m->tio.c_cflag |= CLOCAL; -#endif /* CLOCAL */ - -#if defined(ECHOCTL) - m->tio.c_lflag |= ECHOCTL; -#endif /* ECHOCTL */ -#if defined(ECHOKE) - m->tio.c_lflag |= ECHOKE; -#endif /* ECHOKE */ - - if (!ttyflag) - { -#if defined(ISIG) - m->tio.c_lflag |= ISIG; -#endif /* ISIG */ -#if defined(ICANON) - m->tio.c_lflag |= ICANON; -#endif /* ICANON */ -#if defined(ECHO) - m->tio.c_lflag |= ECHO; -#endif /* ECHO */ - } -#if defined(ECHOE) - m->tio.c_lflag |= ECHOE; -#endif /* ECHOE */ -#if defined(ECHOK) - m->tio.c_lflag |= ECHOK; -#endif /* ECHOK */ -#if defined(IEXTEN) - m->tio.c_lflag |= IEXTEN; -#endif /* IEXTEN */ - -#if defined(VINTR) -#if (VINTR < MAXCC) - m->tio.c_cc[VINTR] = Ctrl('C'); -#endif -#endif /* VINTR */ -#if defined(VQUIT) -#if (VQUIT < MAXCC) - m->tio.c_cc[VQUIT] = Ctrl('\\'); -#endif -#endif /* VQUIT */ -#if defined(VERASE) -#if (VERASE < MAXCC) - m->tio.c_cc[VERASE] = 0x7f; /* DEL */ -#endif -#endif /* VERASE */ -#if defined(VKILL) -#if (VKILL < MAXCC) - m->tio.c_cc[VKILL] = Ctrl('H'); -#endif -#endif /* VKILL */ -#if defined(VEOF) -#if (VEOF < MAXCC) - m->tio.c_cc[VEOF] = Ctrl('D'); -#endif -#endif /* VEOF */ -#if defined(VEOL) -#if (VEOL < MAXCC) - m->tio.c_cc[VEOL] = 0000; -#endif -#endif /* VEOL */ -#if defined(VEOL2) -#if (VEOL2 < MAXCC) - m->tio.c_cc[VEOL2] = 0000; -#endif -#endif /* VEOL2 */ -#if defined(VSWTCH) -#if (VSWTCH < MAXCC) - m->tio.c_cc[VSWTCH] = 0000; -#endif -#endif /* VSWTCH */ -#if defined(VSTART) -#if (VSTART < MAXCC) - m->tio.c_cc[VSTART] = Ctrl('Q'); -#endif -#endif /* VSTART */ -#if defined(VSTOP) -#if (VSTOP < MAXCC) - m->tio.c_cc[VSTOP] = Ctrl('S'); -#endif -#endif /* VSTOP */ -#if defined(VSUSP) -#if (VSUSP < MAXCC) - m->tio.c_cc[VSUSP] = Ctrl('Z'); -#endif -#endif /* VSUSP */ -#if defined(VDSUSP) -#if (VDSUSP < MAXCC) - m->tio.c_cc[VDSUSP] = Ctrl('Y'); -#endif -#endif /* VDSUSP */ -#if defined(VREPRINT) -#if (VREPRINT < MAXCC) - m->tio.c_cc[VREPRINT] = Ctrl('R'); -#endif -#endif /* VREPRINT */ -#if defined(VDISCARD) -#if (VDISCARD < MAXCC) - m->tio.c_cc[VDISCARD] = Ctrl('O'); -#endif -#endif /* VDISCARD */ -#if defined(VWERASE) -#if (VWERASE < MAXCC) - m->tio.c_cc[VWERASE] = Ctrl('W'); -#endif -#endif /* VWERASE */ -#if defined(VLNEXT) -#if (VLNEXT < MAXCC) - m->tio.c_cc[VLNEXT] = Ctrl('V'); -#endif -#endif /* VLNEXT */ -#if defined(VSTATUS) -#if (VSTATUS < MAXCC) - m->tio.c_cc[VSTATUS] = Ctrl('T'); -#endif -#endif /* VSTATUS */ - - if (ttyflag) - { - m->tio.c_cc[VMIN] = TTYVMIN; - m->tio.c_cc[VTIME] = TTYVTIME; - } - -# ifdef HPUX_LTCHARS_HACK - m->m_ltchars.t_suspc = Ctrl('Z'); - m->m_ltchars.t_dsuspc = Ctrl('Y'); - m->m_ltchars.t_rprntc = Ctrl('R'); - m->m_ltchars.t_flushc = Ctrl('O'); - m->m_ltchars.t_werasc = Ctrl('W'); - m->m_ltchars.t_lnextc = Ctrl('V'); -# endif /* HPUX_LTCHARS_HACK */ - -#else /* POSIX */ - -# ifdef TERMIO - debug1("InitTTY: nonPOSIX, struct termio a la Motorola SYSV68 (%d)\n", ttyflag); - /* struct termio tio - * defaults, as seen on Mototola SYSV68: - * input: 7bit, CR->NL, ^S/^Q flow control - * output: POSTprocessing: NL->NL-CR, Tabs to spaces - * control: 9600baud, 8bit CSIZE, enable input - * local: enable signals, erase/kill processing, echo on. - */ -#if defined(ISTRIP) - m->tio.c_iflag |= ISTRIP; -#endif /* ISTRIP */ -#if defined(IXON) - m->tio.c_iflag |= IXON; -#endif /* IXON */ - - if (!ttyflag) /* may not even be good for ptys.. */ - { -#if defined(OPOST) - m->tio.c_oflag |= OPOST; -#endif /* OPOST */ -#if defined(ICRNL) - m->tio.c_iflag |= ICRNL; -#endif /* ICRNL */ -#if defined(ONLCR) - m->tio.c_oflag |= ONLCR; -#endif /* ONLCR */ -#if defined(TAB3) - m->tio.c_oflag |= TAB3; -#endif /* TAB3 */ - } - -#ifdef __bsdi__ - )-: cannot handle BSDI without POSIX -#else -#if defined(B9600) - m->tio.c_cflag = B9600; -#endif /* B9600 */ -#endif -#if defined(CS8) - m->tio.c_cflag |= CS8; -#endif /* CS8 */ -#if defined(CREAD) - m->tio.c_cflag |= CREAD; -#endif /* CREAD */ - - if (!ttyflag) - { -#if defined(ISIG) - m->tio.c_lflag |= ISIG; -#endif /* ISIG */ -#if defined(ICANON) - m->tio.c_lflag |= ICANON; -#endif /* ICANON */ -#if defined(ECHO) - m->tio.c_lflag |= ECHO; -#endif /* ECHO */ - } -#if defined(ECHOE) - m->tio.c_lflag |= ECHOE; -#endif /* ECHOE */ -#if defined(ECHOK) - m->tio.c_lflag |= ECHOK; -#endif /* ECHOK */ - -#if defined(VINTR) -#if (VINTR < MAXCC) - m->tio.c_cc[VINTR] = Ctrl('C'); -#endif -#endif /* VINTR */ -#if defined(VQUIT) -#if (VQUIT < MAXCC) - m->tio.c_cc[VQUIT] = Ctrl('\\'); -#endif -#endif /* VQUIT */ -#if defined(VERASE) -#if (VERASE < MAXCC) - m->tio.c_cc[VERASE] = 0177; /* DEL */ -#endif -#endif /* VERASE */ -#if defined(VKILL) -#if (VKILL < MAXCC) - m->tio.c_cc[VKILL] = Ctrl('H'); -#endif -#endif /* VKILL */ -#if defined(VEOF) -#if (VEOF < MAXCC) - m->tio.c_cc[VEOF] = Ctrl('D'); -#endif -#endif /* VEOF */ -#if defined(VEOL) -#if (VEOL < MAXCC) - m->tio.c_cc[VEOL] = 0377; -#endif -#endif /* VEOL */ -#if defined(VEOL2) -#if (VEOL2 < MAXCC) - m->tio.c_cc[VEOL2] = 0377; -#endif -#endif /* VEOL2 */ -#if defined(VSWTCH) -#if (VSWTCH < MAXCC) - m->tio.c_cc[VSWTCH] = 0000; -#endif -#endif /* VSWTCH */ - - if (ttyflag) - { - m->tio.c_cc[VMIN] = TTYVMIN; - m->tio.c_cc[VTIME] = TTYVTIME; - } - -# else /* TERMIO */ - debug1("InitTTY: BSD: defaults a la SunOS 4.1.3 (%d)\n", ttyflag); - m->m_ttyb.sg_ispeed = B9600; - m->m_ttyb.sg_ospeed = B9600; - m->m_ttyb.sg_erase = 0177; /*DEL */ - m->m_ttyb.sg_kill = Ctrl('H'); - if (!ttyflag) - m->m_ttyb.sg_flags = CRMOD | ECHO -#if defined(ANYP) - | ANYP -#endif /* ANYP */ - ; - else - m->m_ttyb.sg_flags = CBREAK -#if defined(ANYP) - | ANYP -#endif /* ANYP */ - ; - - m->m_tchars.t_intrc = Ctrl('C'); - m->m_tchars.t_quitc = Ctrl('\\'); - m->m_tchars.t_startc = Ctrl('Q'); - m->m_tchars.t_stopc = Ctrl('S'); - m->m_tchars.t_eofc = Ctrl('D'); - m->m_tchars.t_brkc = -1; - - m->m_ltchars.t_suspc = Ctrl('Z'); - m->m_ltchars.t_dsuspc = Ctrl('Y'); - m->m_ltchars.t_rprntc = Ctrl('R'); - m->m_ltchars.t_flushc = Ctrl('O'); - m->m_ltchars.t_werasc = Ctrl('W'); - m->m_ltchars.t_lnextc = Ctrl('V'); - -#if defined(NTTYDISC) - m->m_ldisc = NTTYDISC; -#endif /* NTTYDISC */ - - m->m_lmode = 0 -#if defined(LDECCTQ) - | LDECCTQ -#endif /* LDECCTQ */ -#if defined(LCTLECH) - | LCTLECH -#endif /* LCTLECH */ -#if defined(LPASS8) - | LPASS8 -#endif /* LPASS8 */ -#if defined(LCRTKIL) - | LCRTKIL -#endif /* LCRTKIL */ -#if defined(LCRTERA) - | LCRTERA -#endif /* LCRTERA */ -#if defined(LCRTBS) - | LCRTBS -#endif /* LCRTBS */ - ; -# endif /* TERMIO */ -#endif /* POSIX */ - -#if defined(ENCODINGS) && defined(TIOCKSET) - m->m_jtchars.t_ascii = 'J'; - m->m_jtchars.t_kanji = 'B'; - m->m_knjmode = KM_ASCII | KM_SYSSJIS; -#endif -} - -void -SetTTY(fd, mp) -int fd; -struct mode *mp; -{ - errno = 0; -#ifdef POSIX - tcsetattr(fd, TCSADRAIN, &mp->tio); -# ifdef HPUX_LTCHARS_HACK - ioctl(fd, TIOCSLTC, (char *)&mp->m_ltchars); -# endif -#else -# ifdef TERMIO - ioctl(fd, TCSETAW, (char *)&mp->tio); -# ifdef CYTERMIO - if (mp->tio.c_line == 3) - { - ioctl(fd, LDSETMAPKEY, (char *)&mp->m_mapkey); - ioctl(fd, LDSETMAPSCREEN, (char *)&mp->m_mapscreen); - ioctl(fd, LDSETBACKSPACE, (char *)&mp->m_backspace); - } -# endif -# else - /* ioctl(fd, TIOCSETP, (char *)&mp->m_ttyb); */ - ioctl(fd, TIOCSETC, (char *)&mp->m_tchars); - ioctl(fd, TIOCLSET, (char *)&mp->m_lmode); - ioctl(fd, TIOCSETD, (char *)&mp->m_ldisc); - ioctl(fd, TIOCSETP, (char *)&mp->m_ttyb); - ioctl(fd, TIOCSLTC, (char *)&mp->m_ltchars); /* moved here for apollo. jw */ -# endif -#endif -#if defined(ENCODINGS) && defined(TIOCKSET) - ioctl(fd, TIOCKSETC, &mp->m_jtchars); - ioctl(fd, TIOCKSET, &mp->m_knjmode); -#endif - if (errno) - Msg(errno, "SetTTY (fd %d): ioctl failed", fd); -} - -void -GetTTY(fd, mp) -int fd; -struct mode *mp; -{ - errno = 0; -#ifdef POSIX - tcgetattr(fd, &mp->tio); -# ifdef HPUX_LTCHARS_HACK - ioctl(fd, TIOCGLTC, (char *)&mp->m_ltchars); -# endif -#else -# ifdef TERMIO - ioctl(fd, TCGETA, (char *)&mp->tio); -# ifdef CYTERMIO - if (mp->tio.c_line == 3) - { - ioctl(fd, LDGETMAPKEY, (char *)&mp->m_mapkey); - ioctl(fd, LDGETMAPSCREEN, (char *)&mp->m_mapscreen); - ioctl(fd, LDGETBACKSPACE, (char *)&mp->m_backspace); - } - else - { - mp->m_mapkey = NOMAPKEY; - mp->m_mapscreen = NOMAPSCREEN; - mp->m_backspace = '\b'; - } -# endif -# else - ioctl(fd, TIOCGETP, (char *)&mp->m_ttyb); - ioctl(fd, TIOCGETC, (char *)&mp->m_tchars); - ioctl(fd, TIOCGLTC, (char *)&mp->m_ltchars); - ioctl(fd, TIOCLGET, (char *)&mp->m_lmode); - ioctl(fd, TIOCGETD, (char *)&mp->m_ldisc); -# endif -#endif -#if defined(ENCODINGS) && defined(TIOCKSET) - ioctl(fd, TIOCKGETC, &mp->m_jtchars); - ioctl(fd, TIOCKGET, &mp->m_knjmode); -#endif - if (errno) - Msg(errno, "GetTTY (fd %d): ioctl failed", fd); -} - -/* - * needs interrupt = iflag and flow = d->d_flow - */ -void -SetMode(op, np, flow, interrupt) -struct mode *op, *np; -int flow, interrupt; -{ - *np = *op; - - ASSERT(display); -#if defined(TERMIO) || defined(POSIX) -# ifdef CYTERMIO - np->m_mapkey = NOMAPKEY; - np->m_mapscreen = NOMAPSCREEN; - np->tio.c_line = 0; -# endif -#if defined(ICRNL) - np->tio.c_iflag &= ~ICRNL; -#endif /* ICRNL */ -#if defined(ISTRIP) - np->tio.c_iflag &= ~ISTRIP; -#endif /* ISTRIP */ -#if defined(ONLCR) - np->tio.c_oflag &= ~ONLCR; -#endif /* ONLCR */ - np->tio.c_lflag &= ~(ICANON | ECHO); - /* - * From Andrew Myers (andru@tonic.lcs.mit.edu) - * to avoid ^V^V-Problem on OSF1 - */ -#if defined(IEXTEN) - np->tio.c_lflag &= ~IEXTEN; -#endif /* IEXTEN */ - - /* - * Unfortunately, the master process never will get SIGINT if the real - * terminal is different from the one on which it was originaly started - * (process group membership has not been restored or the new tty could not - * be made controlling again). In my solution, it is the attacher who - * receives SIGINT (because it is always correctly associated with the real - * tty) and forwards it to the master [kill(MasterPid, SIGINT)]. - * Marc Boucher (marc@CAM.ORG) - */ - if (interrupt) - np->tio.c_lflag |= ISIG; - else - np->tio.c_lflag &= ~ISIG; - /* - * careful, careful catche monkey.. - * never set VMIN and VTIME to zero, if you want blocking io. - * - * We may want to do a VMIN > 0, VTIME > 0 read on the ptys too, to - * reduce interrupt frequency. But then we would not know how to - * handle read returning 0. jw. - */ - np->tio.c_cc[VMIN] = 1; - np->tio.c_cc[VTIME] = 0; - if (!interrupt || !flow) - np->tio.c_cc[VINTR] = VDISABLE; - np->tio.c_cc[VQUIT] = VDISABLE; - if (flow == 0) - { -#if defined(VSTART) -#if (VSTART < MAXCC) - np->tio.c_cc[VSTART] = VDISABLE; -#endif -#endif /* VSTART */ -#if defined(VSTOP) -#if (VSTOP < MAXCC) - np->tio.c_cc[VSTOP] = VDISABLE; -#endif -#endif /* VSTOP */ - np->tio.c_iflag &= ~IXON; - } -#if defined(VDISCARD) -#if (VDISCARD < MAXCC) - np->tio.c_cc[VDISCARD] = VDISABLE; -#endif -#endif /* VDISCARD */ -#if defined(VLNEXT) -#if (VLNEXT < MAXCC) - np->tio.c_cc[VLNEXT] = VDISABLE; -#endif -#endif /* VLNEXT */ -#if defined(VSTATUS) -#if (VSTATUS < MAXCC) - np->tio.c_cc[VSTATUS] = VDISABLE; -#endif -#endif /* VSTATUS */ -#if defined(VSUSP) -#if (VSUSP < MAXCC) - np->tio.c_cc[VSUSP] = VDISABLE; -#endif -#endif /* VSUSP */ -#if defined(VERASE) -#if (VERASE < MAXCC) - np->tio.c_cc[VERASE] = VDISABLE; -#endif -#endif /* VERASE */ -#if defined(VKILL) -#if (VKILL < MAXCC) - np->tio.c_cc[VKILL] = VDISABLE; -#endif -#endif /* VKILL */ -# ifdef HPUX_LTCHARS_HACK - np->m_ltchars.t_suspc = VDISABLE; - np->m_ltchars.t_dsuspc = VDISABLE; - np->m_ltchars.t_rprntc = VDISABLE; - np->m_ltchars.t_flushc = VDISABLE; - np->m_ltchars.t_werasc = VDISABLE; - np->m_ltchars.t_lnextc = VDISABLE; -# else /* HPUX_LTCHARS_HACK */ -#if defined(VDSUSP) -#if (VDSUSP < MAXCC) - np->tio.c_cc[VDSUSP] = VDISABLE; -#endif -#endif /* VDSUSP */ -#if defined(VREPRINT) -#if (VREPRINT < MAXCC) - np->tio.c_cc[VREPRINT] = VDISABLE; -#endif -#endif /* VREPRINT */ -#if defined(VWERASE) -#if (VWERASE < MAXCC) - np->tio.c_cc[VWERASE] = VDISABLE; -#endif -#endif /* VWERASE */ -# endif /* HPUX_LTCHARS_HACK */ -#else /* TERMIO || POSIX */ - if (!interrupt || !flow) - np->m_tchars.t_intrc = -1; - np->m_ttyb.sg_flags &= ~(CRMOD | ECHO); - np->m_ttyb.sg_flags |= CBREAK; -# if defined(CYRILL) && defined(CSTYLE) && defined(CS_8BITS) - np->m_ttyb.sg_flags &= ~CSTYLE; - np->m_ttyb.sg_flags |= CS_8BITS; -# endif - np->m_tchars.t_quitc = -1; - if (flow == 0) - { - np->m_tchars.t_startc = -1; - np->m_tchars.t_stopc = -1; - } - np->m_ltchars.t_suspc = -1; - np->m_ltchars.t_dsuspc = -1; - np->m_ltchars.t_flushc = -1; - np->m_ltchars.t_lnextc = -1; -#endif /* defined(TERMIO) || defined(POSIX) */ -} - -/* operates on display */ -void -SetFlow(on) -int on; -{ - ASSERT(display); - if (D_flow == on) - return; -#if defined(TERMIO) || defined(POSIX) - if (on) - { - D_NewMode.tio.c_cc[VINTR] = iflag ? D_OldMode.tio.c_cc[VINTR] : VDISABLE; -#if defined(VSTART) -#if (VSTART < MAXCC) - D_NewMode.tio.c_cc[VSTART] = D_OldMode.tio.c_cc[VSTART]; -#endif -#endif /* VSTART */ -#if defined(VSTOP) -#if (VSTOP < MAXCC) - D_NewMode.tio.c_cc[VSTOP] = D_OldMode.tio.c_cc[VSTOP]; -#endif -#endif /* VSTOP */ - D_NewMode.tio.c_iflag |= D_OldMode.tio.c_iflag & IXON; - } - else - { - D_NewMode.tio.c_cc[VINTR] = VDISABLE; -#if defined(VSTART) -#if (VSTART < MAXCC) - D_NewMode.tio.c_cc[VSTART] = VDISABLE; -#endif -#endif /* VSTART */ -#if defined(VSTOP) -#if (VSTOP < MAXCC) - D_NewMode.tio.c_cc[VSTOP] = VDISABLE; -#endif -#endif /* VSTOP */ - D_NewMode.tio.c_iflag &= ~IXON; - } -# ifdef POSIX - if (tcsetattr(D_userfd, TCSANOW, &D_NewMode.tio)) -# else - if (ioctl(D_userfd, TCSETAW, (char *)&D_NewMode.tio) != 0) -# endif - debug1("SetFlow: ioctl errno %d\n", errno); -#else /* POSIX || TERMIO */ - if (on) - { - D_NewMode.m_tchars.t_intrc = iflag ? D_OldMode.m_tchars.t_intrc : -1; - D_NewMode.m_tchars.t_startc = D_OldMode.m_tchars.t_startc; - D_NewMode.m_tchars.t_stopc = D_OldMode.m_tchars.t_stopc; - } - else - { - D_NewMode.m_tchars.t_intrc = -1; - D_NewMode.m_tchars.t_startc = -1; - D_NewMode.m_tchars.t_stopc = -1; - } - if (ioctl(D_userfd, TIOCSETC, (char *)&D_NewMode.m_tchars) != 0) - debug1("SetFlow: ioctl errno %d\n", errno); -#endif /* POSIX || TERMIO */ - D_flow = on; -} - -/* parse commands from opt and modify m */ -int -SttyMode(m, opt) -struct mode *m; -char *opt; -{ - static const char sep[] = " \t:;,"; - - if (!opt) - return 0; - - while (*opt) - { - while (index(sep, *opt)) opt++; - if (*opt >= '0' && *opt <= '9') - { - if (SetBaud(m, atoi(opt), atoi(opt))) - return -1; - } - else if (!strncmp("cs7", opt, 3)) - { -#if defined(POSIX) || defined(TERMIO) - m->tio.c_cflag &= ~CSIZE; - m->tio.c_cflag |= CS7; -#else - m->m_lmode &= ~LPASS8; -#endif - } - else if (!strncmp("cs8", opt, 3)) - { -#if defined(POSIX) || defined(TERMIO) - m->tio.c_cflag &= ~CSIZE; - m->tio.c_cflag |= CS8; -#else - m->m_lmode |= LPASS8; -#endif - } - else if (!strncmp("istrip", opt, 6)) - { -#if defined(POSIX) || defined(TERMIO) - m->tio.c_iflag |= ISTRIP; -#else - m->m_lmode &= ~LPASS8; -#endif - } - else if (!strncmp("-istrip", opt, 7)) - { -#if defined(POSIX) || defined(TERMIO) - m->tio.c_iflag &= ~ISTRIP; -#else - m->m_lmode |= LPASS8; -#endif - } - else if (!strncmp("ixon", opt, 4)) - { -#if defined(POSIX) || defined(TERMIO) - m->tio.c_iflag |= IXON; -#else - debug("SttyMode: no ixon in old bsd land.\n"); -#endif - } - else if (!strncmp("-ixon", opt, 5)) - { -#if defined(POSIX) || defined(TERMIO) - m->tio.c_iflag &= ~IXON; -#else - debug("SttyMode: no -ixon in old bsd land.\n"); -#endif - } - else if (!strncmp("ixoff", opt, 5)) - { -#if defined(POSIX) || defined(TERMIO) - m->tio.c_iflag |= IXOFF; -#else - m->m_ttyb.sg_flags |= TANDEM; -#endif - } - else if (!strncmp("-ixoff", opt, 6)) - { -#if defined(POSIX) || defined(TERMIO) - m->tio.c_iflag &= ~IXOFF; -#else - m->m_ttyb.sg_flags &= ~TANDEM; -#endif - } - else if (!strncmp("crtscts", opt, 7)) - { -#if (defined(POSIX) || defined(TERMIO)) && defined(CRTSCTS) - m->tio.c_cflag |= CRTSCTS; -#endif - } - else if (!strncmp("-crtscts", opt, 8)) - { -#if (defined(POSIX) || defined(TERMIO)) && defined(CRTSCTS) - m->tio.c_cflag &= ~CRTSCTS; -#endif - } - else - return -1; - while (*opt && !index(sep, *opt)) opt++; - } - return 0; -} - -/* - * Job control handling - * - * Somehow the ultrix session handling is broken, so use - * the bsdish variant. - */ - -/*ARGSUSED*/ -void -brktty(fd) -int fd; -{ -#if defined(POSIX) && !defined(ultrix) - if (separate_sids) - setsid(); /* will break terminal affiliation */ - /* GNU added for Hurd systems 2001-10-10 */ -# if defined(BSD) && defined(TIOCSCTTY) && !defined(__GNU__) - ioctl(fd, TIOCSCTTY, (char *)0); -# endif /* BSD && TIOCSCTTY */ -#else /* POSIX */ -# ifdef SYSV - if (separate_sids) - setpgrp(); /* will break terminal affiliation */ -# else /* SYSV */ -# ifdef BSDJOBS - int devtty; - - if ((devtty = open("/dev/tty", O_RDWR | O_NONBLOCK)) >= 0) - { - if (ioctl(devtty, TIOCNOTTY, (char *)0)) - debug2("brktty: ioctl(devtty=%d, TIOCNOTTY, 0) = %d\n", devtty, errno); - close(devtty); - } -# endif /* BSDJOBS */ -# endif /* SYSV */ -#endif /* POSIX */ -} - -int -fgtty(fd) -int fd; -{ -#ifdef BSDJOBS - int mypid; - - mypid = getpid(); - - /* The next lines should be obsolete. Can anybody check if they - * are really needed on the BSD platforms? - * - * this is to avoid the message: - * fgtty: Not a typewriter (25) - */ -# if defined(__osf__) || (BSD >= 199103) || defined(ISC) - if (separate_sids) - setsid(); /* should be already done */ -# ifdef TIOCSCTTY - ioctl(fd, TIOCSCTTY, (char *)0); -# endif -# endif - -# ifdef POSIX - if (separate_sids) - if (tcsetpgrp(fd, mypid)) - { - debug1("fgtty: tcsetpgrp: %d\n", errno); - return -1; - } -# else /* POSIX */ - if (ioctl(fd, TIOCSPGRP, (char *)&mypid) != 0) - debug1("fgtty: TIOSETPGRP: %d\n", errno); -# ifndef SYSV /* Already done in brktty():setpgrp() */ - if (separate_sids) - if (setpgrp(fd, mypid)) - debug1("fgtty: setpgrp: %d\n", errno); -# endif -# endif /* POSIX */ -#endif /* BSDJOBS */ - return 0; -} - -/* - * The alm boards on our sparc center 1000 have a lousy driver. - * We cannot generate long breaks unless we use the most ugly form - * of ioctls. jw. - */ -#ifdef POSIX -int breaktype = 2; -#else /* POSIX */ -# ifdef TCSBRK -int breaktype = 1; -# else -int breaktype = 0; -# endif -#endif /* POSIX */ - -#if defined(sun) && !defined(SVR4) -# define HAVE_SUPER_TCSENDBREAK -#endif - -/* - * type: - * 0: TIOCSBRK / TIOCCBRK - * 1: TCSBRK - * 2: tcsendbreak() - * n: approximate duration in 1/4 seconds. - */ -static void -DoSendBreak(fd, n, type) -int fd, n, type; -{ - switch (type) - { - case 2: /* tcsendbreak() =============================== */ -#ifdef POSIX -# ifdef HAVE_SUPER_TCSENDBREAK - /* There is one rare case that I have tested, where tcsendbreak works - * really great: this was an alm driver that came with SunOS 4.1.3 - * If you have this one, define the above symbol. - * here we can use the second parameter to specify the duration. - */ - debug2("tcsendbreak(fd=%d, %d)\n", fd, n); - if (tcsendbreak(fd, n) < 0) - Msg(errno, "cannot send BREAK (tcsendbreak)"); -# else - /* - * here we hope, that multiple calls to tcsendbreak() can - * be concatenated to form a long break, as we do not know - * what exact interpretation the second parameter has: - * - * - sunos 4: duration in quarter seconds - * - sunos 5: 0 a short break, nonzero a tcdrain() - * - hpux, irix: ignored - * - mot88: duration in milliseconds - * - aix: duration in milliseconds, but 0 is 25 milliseconds. - */ - debug2("%d * tcsendbreak(fd=%d, 0)\n", n, fd); - { - int i; - - if (!n) - n++; - for (i = 0; i < n; i++) - if (tcsendbreak(fd, 0) < 0) - { - Msg(errno, "cannot send BREAK (tcsendbreak SVR4)"); - return; - } - } -# endif -#else /* POSIX */ - Msg(0, "tcsendbreak() not available, change breaktype"); -#endif /* POSIX */ - break; - - case 1: /* TCSBRK ======================================= */ -#ifdef TCSBRK - if (!n) - n++; - /* - * Here too, we assume that short breaks can be concatenated to - * perform long breaks. But for SOLARIS, this is not true, of course. - */ - debug2("%d * TCSBRK fd=%d\n", n, fd); - { - int i; - - for (i = 0; i < n; i++) - if (ioctl(fd, TCSBRK, (char *)0) < 0) - { - Msg(errno, "Cannot send BREAK (TCSBRK)"); - return; - } - } -#else /* TCSBRK */ - Msg(0, "TCSBRK not available, change breaktype"); -#endif /* TCSBRK */ - break; - - case 0: /* TIOCSBRK / TIOCCBRK ========================== */ -#if defined(TIOCSBRK) && defined(TIOCCBRK) - /* - * This is very rude. Screen actively celebrates the break. - * But it may be the only save way to issue long breaks. - */ - debug("TIOCSBRK TIOCCBRK\n"); - if (ioctl(fd, TIOCSBRK, (char *)0) < 0) - { - Msg(errno, "Can't send BREAK (TIOCSBRK)"); - return; - } - sleep1000(n ? n * 250 : 250); - if (ioctl(fd, TIOCCBRK, (char *)0) < 0) - { - Msg(errno, "BREAK stuck!!! -- HELP! (TIOCCBRK)"); - return; - } -#else /* TIOCSBRK && TIOCCBRK */ - Msg(0, "TIOCSBRK/CBRK not available, change breaktype"); -#endif /* TIOCSBRK && TIOCCBRK */ - break; - - default: /* unknown ========================== */ - Msg(0, "Internal SendBreak error: method %d unknown", type); - } -} - -/* - * Send a break for n * 0.25 seconds. Tty must be PLAIN. - * The longest possible break allowed here is 15 seconds. - */ - -void -SendBreak(wp, n, closeopen) -struct win *wp; -int n, closeopen; -{ - sigret_t (*sigalrm)__P(SIGPROTOARG); - -#ifdef BUILTIN_TELNET - if (wp->w_type == W_TYPE_TELNET) - { - TelBreak(wp); - return; - } -#endif - if (wp->w_type != W_TYPE_PLAIN) - return; - - debug3("break(%d, %d) fd %d\n", n, closeopen, wp->w_ptyfd); - -#ifdef POSIX - (void) tcflush(wp->w_ptyfd, TCIOFLUSH); -#else -# ifdef TIOCFLUSH - (void) ioctl(wp->w_ptyfd, TIOCFLUSH, (char *)0); -# endif /* TIOCFLUSH */ -#endif /* POSIX */ - - if (closeopen) - { - close(wp->w_ptyfd); - sleep1000(n ? n * 250 : 250); - if ((wp->w_ptyfd = OpenTTY(wp->w_tty, wp->w_cmdargs[1])) < 1) - { - Msg(0, "Ouch, cannot reopen line %s, please try harder", wp->w_tty); - return; - } - (void) fcntl(wp->w_ptyfd, F_SETFL, FNBLOCK); - } - else - { - sigalrm = signal(SIGALRM, SigAlrmDummy); - alarm(15); - - DoSendBreak(wp->w_ptyfd, n, breaktype); - - alarm(0); - signal(SIGALRM, sigalrm); - } - debug(" broken.\n"); -} - -/* - * Console grabbing - */ - -#if (!defined(TIOCCONS) && defined(SRIOCSREDIR)) || defined(linux) - -static struct event consredir_ev; -static int consredirfd[2] = {-1, -1}; - -static void -consredir_readev_fn(ev, data) -struct event *ev; -char *data; -{ - char *p, *n, buf[256]; - int l; - - if (!console_window || (l = read(consredirfd[0], buf, sizeof(buf))) <= 0) - { - close(consredirfd[0]); - close(consredirfd[1]); - consredirfd[0] = consredirfd[1] = -1; - evdeq(ev); - return; - } - for (p = n = buf; l > 0; n++, l--) - if (*n == '\n') - { - if (n > p) - WriteString(console_window, p, n - p); - WriteString(console_window, "\r\n", 2); - p = n + 1; - } - if (n > p) - WriteString(console_window, p, n - p); -} - -#endif - -/*ARGSUSED*/ -int -TtyGrabConsole(fd, on, rc_name) -int fd, on; -char *rc_name; -{ -#if defined(TIOCCONS) && !defined(linux) - struct display *d; - int ret = 0; - int sfd = -1; - - if (on < 0) - return 0; /* pty close will ungrab */ - if (on) - { - if (displays == 0) - { - Msg(0, "I need a display"); - return -1; - } - for (d = displays; d; d = d->d_next) - if (strcmp(d->d_usertty, "/dev/console") == 0) - break; - if (d) - { - Msg(0, "too dangerous - screen is running on /dev/console"); - return -1; - } - } - - if (!on) - { - char *slave; - if ((fd = OpenPTY(&slave)) < 0) - { - Msg(errno, "%s: could not open detach pty master", rc_name); - return -1; - } - if ((sfd = open(slave, O_RDWR | O_NOCTTY)) < 0) - { - Msg(errno, "%s: could not open detach pty slave", rc_name); - close(fd); - return -1; - } - } - if (UserContext() == 1) - UserReturn(ioctl(fd, TIOCCONS, (char *)&on)); - ret = UserStatus(); - if (ret) - Msg(errno, "%s: ioctl TIOCCONS failed", rc_name); - if (!on) - { - close(sfd); - close(fd); - } - return ret; - -#else -# if defined(SRIOCSREDIR) || defined(linux) - struct display *d; -# ifdef SRIOCSREDIR - int cfd; -# else - struct mode new1, new2; - char *slave; -# endif - - if (on > 0) - { - if (displays == 0) - { - Msg(0, "I need a display"); - return -1; - } - for (d = displays; d; d = d->d_next) - if (strcmp(d->d_usertty, "/dev/console") == 0) - break; - if (d) - { - Msg(0, "too dangerous - screen is running on /dev/console"); - return -1; - } - } - if (consredirfd[0] >= 0) - { - evdeq(&consredir_ev); - close(consredirfd[0]); - close(consredirfd[1]); - consredirfd[0] = consredirfd[1] = -1; - } - if (on <= 0) - return 0; -# ifdef SRIOCSREDIR - if ((cfd = secopen("/dev/console", O_RDWR|O_NOCTTY, 0)) == -1) - { - Msg(errno, "/dev/console"); - return -1; - } - if (pipe(consredirfd)) - { - Msg(errno, "pipe"); - close(cfd); - consredirfd[0] = consredirfd[1] = -1; - return -1; - } - if (ioctl(cfd, SRIOCSREDIR, consredirfd[1])) - { - Msg(errno, "SRIOCSREDIR ioctl"); - close(cfd); - close(consredirfd[0]); - close(consredirfd[1]); - consredirfd[0] = consredirfd[1] = -1; - return -1; - } - close(cfd); -# else - /* special linux workaround for a too restrictive kernel */ - if ((consredirfd[0] = OpenPTY(&slave)) < 0) - { - Msg(errno, "%s: could not open detach pty master", rc_name); - return -1; - } - if ((consredirfd[1] = open(slave, O_RDWR | O_NOCTTY)) < 0) - { - Msg(errno, "%s: could not open detach pty slave", rc_name); - close(consredirfd[0]); - return -1; - } - InitTTY(&new1, 0); - SetMode(&new1, &new2, 0, 0); - SetTTY(consredirfd[1], &new2); - if (UserContext() == 1) - UserReturn(ioctl(consredirfd[1], TIOCCONS, (char *)&on)); - if (UserStatus()) - { - Msg(errno, "%s: ioctl TIOCCONS failed", rc_name); - close(consredirfd[0]); - close(consredirfd[1]); - return -1; - } -# endif - consredir_ev.fd = consredirfd[0]; - consredir_ev.type = EV_READ; - consredir_ev.handler = consredir_readev_fn; - evenq(&consredir_ev); - return 0; -# else - if (on > 0) - Msg(0, "%s: don't know how to grab the console", rc_name); - return -1; -# endif -#endif -} - -/* - * Read modem control lines of a physical tty and write them to buf - * in a readable format. - * Will not write more than 256 characters to buf. - * Returns buf; - */ -char * -TtyGetModemStatus(fd, buf) -int fd; -char *buf; -{ - char *p = buf; -#ifdef TIOCGSOFTCAR - unsigned int softcar; -#endif -#if defined(TIOCMGET) || defined(TIOCMODG) - unsigned int mflags; -#else -# ifdef MCGETA - /* this is yet another interface, found on hpux. grrr */ - mflag mflags; -#if defined(MDTR) -# define TIOCM_DTR MDTR -#endif /* MDTR */ -#if defined(MRTS) -# define TIOCM_RTS MRTS -#endif /* MRTS */ -#if defined(MDSR) -# define TIOCM_DSR MDSR -#endif /* MDSR */ -#if defined(MDCD) -# define TIOCM_CAR MDCD -#endif /* MDCD */ -#if defined(MRI) -# define TIOCM_RNG MRI -#endif /* MRI */ -#if defined(MCTS) -# define TIOCM_CTS MCTS -#endif /* MCTS */ -# endif -#endif -#if defined(CLOCAL) || defined(CRTSCTS) - struct mode mtio; /* screen.h */ -#endif -#if defined(CRTSCTS) || defined(TIOCM_CTS) - int rtscts; -#endif - int clocal; - -#if defined(CLOCAL) || defined(CRTSCTS) - GetTTY(fd, &mtio); -#endif - clocal = 0; -#ifdef CLOCAL - if (mtio.tio.c_cflag & CLOCAL) - { - clocal = 1; - *p++ = '{'; - } -#endif - -#ifdef TIOCM_CTS -# ifdef CRTSCTS - if (!(mtio.tio.c_cflag & CRTSCTS)) - rtscts = 0; - else -# endif /* CRTSCTS */ - rtscts = 1; -#endif /* TIOCM_CTS */ - -#ifdef TIOCGSOFTCAR - if (ioctl(fd, TIOCGSOFTCAR, (char *)&softcar) < 0) - softcar = 0; -#endif - -#if defined(TIOCMGET) || defined(TIOCMODG) || defined(MCGETA) -# ifdef TIOCMGET - if (ioctl(fd, TIOCMGET, (char *)&mflags) < 0) -# else -# ifdef TIOCMODG - if (ioctl(fd, TIOCMODG, (char *)&mflags) < 0) -# else - if (ioctl(fd, MCGETA, &mflags) < 0) -# endif -# endif - { -#ifdef TIOCGSOFTCAR - sprintf(p, "NO-TTY? %s", softcar ? "(CD)" : "CD"); -#else - sprintf(p, "NO-TTY?"); -#endif - p += strlen(p); - } - else - { - char *s; -# ifdef FANCY_MODEM -# ifdef TIOCM_LE - if (!(mflags & TIOCM_LE)) - for (s = "!LE "; *s; *p++ = *s++); -# endif -# endif /* FANCY_MODEM */ - -# ifdef TIOCM_RTS - s = "!RTS "; if (mflags & TIOCM_RTS) s++; - while (*s) *p++ = *s++; -# endif -# ifdef TIOCM_CTS - s = "!CTS "; - if (!rtscts) - { - *p++ = '('; - s = "!CTS) "; - } - if (mflags & TIOCM_CTS) s++; - while (*s) *p++ = *s++; -# endif - -# ifdef TIOCM_DTR - s = "!DTR "; if (mflags & TIOCM_DTR) s++; - while (*s) *p++ = *s++; -# endif -# ifdef TIOCM_DSR - s = "!DSR "; if (mflags & TIOCM_DSR) s++; - while (*s) *p++ = *s++; -# endif -# if defined(TIOCM_CD) || defined(TIOCM_CAR) - s = "!CD "; -# ifdef TIOCGSOFTCAR - if (softcar) - { - *p++ = '('; - s = "!CD) "; - } -# endif -# ifdef TIOCM_CD - if (mflags & TIOCM_CD) s++; -# else - if (mflags & TIOCM_CAR) s++; -# endif - while (*s) *p++ = *s++; -# endif -# if defined(TIOCM_RI) || defined(TIOCM_RNG) -# ifdef TIOCM_RI - if (mflags & TIOCM_RI) -# else - if (mflags & TIOCM_RNG) -# endif - for (s = "RI "; *s; *p++ = *s++); -# endif -# ifdef FANCY_MODEM -# ifdef TIOCM_ST - s = "!ST "; if (mflags & TIOCM_ST) s++; - while (*s) *p++ = *s++; -# endif -# ifdef TIOCM_SR - s = "!SR "; if (mflags & TIOCM_SR) s++; - while (*s) *p++ = *s++; -# endif -# endif /* FANCY_MODEM */ - if (p > buf && p[-1] == ' ') - p--; - *p = '\0'; - } -#else -# ifdef TIOCGSOFTCAR - sprintf(p, " %s", softcar ? "(CD)", "CD"); - p += strlen(p); -# endif -#endif - if (clocal) - *p++ = '}'; - *p = '\0'; - return buf; -} - -/* - * Old bsd-ish machines may not have any of the baudrate B... symbols. - * We hope to detect them here, so that the btable[] below always has - * many entries. - */ -#ifndef POSIX -# ifndef TERMIO -# if !defined(B9600) && !defined(B2400) && !defined(B1200) && !defined(B300) -#if !defined(B0) -#define B0 0 -#endif /* B0 */ -#if !defined(B50) -#define B50 1 -#endif /* B50 */ -#if !defined(B75) -#define B75 2 -#endif /* B75 */ -#if !defined(B110) -#define B110 3 -#endif /* B110 */ -#if !defined(B134) -#define B134 4 -#endif /* B134 */ -#if !defined(B150) -#define B150 5 -#endif /* B150 */ -#if !defined(B200) -#define B200 6 -#endif /* B200 */ -#if !defined(B300) -#define B300 7 -#endif /* B300 */ -#if !defined(B600) -#define B600 8 -#endif /* B600 */ -#if !defined(B1200) -#define B1200 9 -#endif /* B1200 */ -#if !defined(B1800) -#define B1800 10 -#endif /* B1800 */ -#if !defined(B2400) -#define B2400 11 -#endif /* B2400 */ -#if !defined(B4800) -#define B4800 12 -#endif /* B4800 */ -#if !defined(B9600) -#define B9600 13 -#endif /* B9600 */ -#if !defined(EXTA) -#define EXTA 14 -#endif /* EXTA */ -#if !defined(EXTB) -#define EXTB 15 -#endif /* EXTB */ -# endif -# endif -#endif - -/* - * On hpux, idx and sym will be different. - * Rumor has it that, we need idx in D_dospeed to make tputs - * padding correct. - * Frequently used entries come first. - */ -static struct baud_values btable[] = -{ -#if defined(B9600) - { 13, 9600, B9600 }, -#endif /* B9600 */ -#if defined(B19200) - { 14, 19200, B19200 }, -#endif /* B19200 */ -#if defined(EXTA) - { 14, 19200, EXTA }, -#endif /* EXTA */ -#if defined(B38400) - { 15, 38400, B38400 }, -#endif /* B38400 */ -#if defined(EXTB) - { 15, 38400, EXTB }, -#endif /* EXTB */ -#if defined(B57600) - { 16, 57600, B57600 }, -#endif /* B57600 */ -#if defined(B115200) - { 17, 115200, B115200 }, -#endif /* B115200 */ -#if defined(B230400) - { 18, 230400, B230400 }, -#endif /* B230400 */ -#if defined(B460800) - { 19, 460800, B460800 }, -#endif /* B460800 */ -#if defined(B7200) - { 13, 7200, B7200 }, -#endif /* B7200 */ -#if defined(B4800) - { 12, 4800, B4800 }, -#endif /* B4800 */ -#if defined(B3600) - { 12, 3600, B3600 }, -#endif /* B3600 */ -#if defined(B2400) - { 11, 2400, B2400 }, -#endif /* B2400 */ -#if defined(B1800) - { 10, 1800, B1800 }, -#endif /* B1800 */ -#if defined(B1200) - { 9, 1200, B1200 }, -#endif /* B1200 */ -#if defined(B900) - { 9, 900, B900 }, -#endif /* B900 */ -#if defined(B600) - { 8, 600, B600 }, -#endif /* B600 */ -#if defined(B300) - { 7, 300, B300 }, -#endif /* B300 */ -#if defined(B200) - { 6, 200, B200 }, -#endif /* B200 */ -#if defined(B150) - { 5, 150, B150 }, -#endif /* B150 */ -#if defined(B134) - { 4, 134, B134 }, -#endif /* B134 */ -#if defined(B110) - { 3, 110, B110 }, -#endif /* B110 */ -#if defined(B75) - { 2, 75, B75 }, -#endif /* B75 */ -#if defined(B50) - { 1, 50, B50 }, -#endif /* B50 */ -#if defined(B0) - { 0, 0, B0 }, -#endif /* B0 */ - { -1, -1, -1 } -}; - -/* - * baud may either be a bits-per-second value or a symbolic - * value as returned by cfget?speed() - */ -struct baud_values * -lookup_baud(baud) -int baud; -{ - struct baud_values *p; - - for (p = btable; p->idx >= 0; p++) - if (baud == p->bps || baud == p->sym) - return p; - return NULL; -} - -/* - * change the baud rate in a mode structure. - * ibaud and obaud are given in bit/second, or at your option as - * termio B... symbols as defined in e.g. suns sys/ttydev.h - * -1 means don't change. - */ -int -SetBaud(m, ibaud, obaud) -struct mode *m; -int ibaud, obaud; -{ - struct baud_values *ip, *op; - - if ((!(ip = lookup_baud(ibaud)) && ibaud != -1) || - (!(op = lookup_baud(obaud)) && obaud != -1)) - return -1; - -#ifdef POSIX - if (ip) cfsetispeed(&m->tio, ip->sym); - if (op) cfsetospeed(&m->tio, op->sym); -#else /* POSIX */ -# ifdef TERMIO - if (ip) - { -# ifdef IBSHIFT - m->tio.c_cflag &= ~(CBAUD << IBSHIFT); - m->tio.c_cflag |= (ip->sym & CBAUD) << IBSHIFT; -# else /* IBSHIFT */ - if (ibaud != obaud) - return -1; -# endif /* IBSHIFT */ - } - if (op) - { - m->tio.c_cflag &= ~CBAUD; - m->tio.c_cflag |= op->sym & CBAUD; - } -# else /* TERMIO */ - if (ip) m->m_ttyb.sg_ispeed = ip->idx; - if (op) m->m_ttyb.sg_ospeed = op->idx; -# endif /* TERMIO */ -#endif /* POSIX */ - return 0; -} - -/* - * Write out the mode struct in a readable form - */ - -#ifdef DEBUG -void -DebugTTY(m) -struct mode *m; -{ - int i; - -#ifdef POSIX - debug("struct termios tio:\n"); - debug1("c_iflag = %#x\n", (unsigned int)m->tio.c_iflag); - debug1("c_oflag = %#x\n", (unsigned int)m->tio.c_oflag); - debug1("c_cflag = %#x\n", (unsigned int)m->tio.c_cflag); - debug1("c_lflag = %#x\n", (unsigned int)m->tio.c_lflag); - debug1("cfgetospeed() = %d\n", (int)cfgetospeed(&m->tio)); - debug1("cfgetispeed() = %d\n", (int)cfgetispeed(&m->tio)); - for (i = 0; i < sizeof(m->tio.c_cc)/sizeof(*m->tio.c_cc); i++) - { - debug2("c_cc[%d] = %#x\n", i, m->tio.c_cc[i]); - } -# ifdef HPUX_LTCHARS_HACK - debug1("suspc = %#02x\n", m->m_ltchars.t_suspc); - debug1("dsuspc = %#02x\n", m->m_ltchars.t_dsuspc); - debug1("rprntc = %#02x\n", m->m_ltchars.t_rprntc); - debug1("flushc = %#02x\n", m->m_ltchars.t_flushc); - debug1("werasc = %#02x\n", m->m_ltchars.t_werasc); - debug1("lnextc = %#02x\n", m->m_ltchars.t_lnextc); -# endif /* HPUX_LTCHARS_HACK */ -#else /* POSIX */ -# ifdef TERMIO - debug("struct termio tio:\n"); - debug1("c_iflag = %04o\n", m->tio.c_iflag); - debug1("c_oflag = %04o\n", m->tio.c_oflag); - debug1("c_cflag = %04o\n", m->tio.c_cflag); - debug1("c_lflag = %04o\n", m->tio.c_lflag); - for (i = 0; i < sizeof(m->tio.c_cc)/sizeof(*m->tio.c_cc); i++) - { - debug2("c_cc[%d] = %04o\n", i, m->tio.c_cc[i]); - } -# else /* TERMIO */ - debug1("sg_ispeed = %d\n", m->m_ttyb.sg_ispeed); - debug1("sg_ospeed = %d\n", m->m_ttyb.sg_ospeed); - debug1("sg_erase = %#02x\n", m->m_ttyb.sg_erase); - debug1("sg_kill = %#02x\n", m->m_ttyb.sg_kill); - debug1("sg_flags = %#04x\n", (unsigned short)m->m_ttyb.sg_flags); - debug1("intrc = %#02x\n", m->m_tchars.t_intrc); - debug1("quitc = %#02x\n", m->m_tchars.t_quitc); - debug1("startc = %#02x\n", m->m_tchars.t_startc); - debug1("stopc = %#02x\n", m->m_tchars.t_stopc); - debug1("eofc = %#02x\n", m->m_tchars.t_eofc); - debug1("brkc = %#02x\n", m->m_tchars.t_brkc); - debug1("suspc = %#02x\n", m->m_ltchars.t_suspc); - debug1("dsuspc = %#02x\n", m->m_ltchars.t_dsuspc); - debug1("rprntc = %#02x\n", m->m_ltchars.t_rprntc); - debug1("flushc = %#02x\n", m->m_ltchars.t_flushc); - debug1("werasc = %#02x\n", m->m_ltchars.t_werasc); - debug1("lnextc = %#02x\n", m->m_ltchars.t_lnextc); - debug1("ldisc = %d\n", m->m_ldisc); - debug1("lmode = %#x\n", m->m_lmode); -# endif /* TERMIO */ -#endif /* POSIX */ -} -#endif /* DEBUG */ -- 2.11.4.GIT