1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
|
/* Copyright (c) 2008, 2009
* Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
* Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
* Micah Cowan (micah@cowan.name)
* Sadrul Habib Chowdhury (sadrul@users.sourceforge.net)
* Copyright (c) 1993-2002, 2003, 2005, 2006, 2007
* 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 3, 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, see
* http://www.gnu.org/licenses/, or contact Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*
****************************************************************
* $Id$ GNU
*/
#include "os.h"
#if defined(__STDC__)
# ifndef __P
# define __P(a) a
# endif
#else
# ifndef __P
# define __P(a) ()
# endif
# define const
#endif
#include "osdef.h"
#include "ansi.h"
#include "sched.h"
#include "acls.h"
#include "comm.h"
#include "layer.h"
#include "term.h"
#ifdef DEBUG
# define STATIC /* a function that the debugger should see */
#else
# define STATIC static
#endif
#ifdef DEBUG
# define DEBUGDIR "/tmp/debug"
# define debugf(a) do {if(dfp){fprintf a;fflush(dfp);}} while (0)
# define debug(x) debugf((dfp,x))
# define debug1(x,a) debugf((dfp,x,a))
# define debug2(x,a,b) debugf((dfp,x,a,b))
# define debug3(x,a,b,c) debugf((dfp,x,a,b,c))
extern FILE *dfp;
#else
# define debugf(a) do {} while (0)
# define debug(x) debugf(x)
# define debug1(x,a) debugf(x)
# define debug2(x,a,b) debugf(x)
# define debug3(x,a,b,c) debugf(x)
#endif
#ifndef DEBUG
# define NOASSERT
#endif
#ifndef NOASSERT
# if defined(__STDC__)
# define ASSERT(lousy_cpp) do {if (!(lousy_cpp)) {if (!dfp) opendebug(0, 1);debug2("ASSERT("#lousy_cpp") failed file %s line %d\n", __FILE__, __LINE__);abort();}} while (0)
# else
# define ASSERT(lousy_cpp) do {if (!(lousy_cpp)) {if (!dfp) opendebug(0, 1);debug2("ASSERT(lousy_cpp) failed file %s line %d\n", __FILE__, __LINE__);abort();}} while (0)
# endif
#else
# define ASSERT(lousy_cpp) do {} while (0)
#endif
/* here comes my own Free: jw. */
#define Free(a) {if ((a) == 0) abort(); else free((void *)(a)); (a)=0;}
#define Ctrl(c) ((c)&037)
#define MAXSTR 768
#define MAXARGS 64
#define MSGWAIT 5
#define MSGMINWAIT 1
#define SILENCEWAIT 30
/*
* if a nasty user really wants to try a history of 3000 lines on all 10
* windows, he will allocate 8 MegaBytes of memory, which is quite enough.
*/
#define MAXHISTHEIGHT 3000
#define DEFAULTHISTHEIGHT 100
#if defined(NAME_MAX) && NAME_MAX < 16
# define DEFAULT_BUFFERFILE "/tmp/screen-xchg"
#else
# define DEFAULT_BUFFERFILE "/tmp/screen-exchange"
#endif
#if defined(hpux) && !(defined(VSUSP) && defined(VDSUSP) && defined(VWERASE) && defined(VLNEXT))
# define HPUX_LTCHARS_HACK
#endif
struct mode
{
#ifdef POSIX
struct termios tio;
# ifdef HPUX_LTCHARS_HACK
struct ltchars m_ltchars;
# endif /* HPUX_LTCHARS_HACK */
#else /* POSIX */
# ifdef TERMIO
struct termio tio;
# ifdef CYTERMIO
int m_mapkey;
int m_mapscreen;
int m_backspace;
# endif
# else /* TERMIO */
struct sgttyb m_ttyb;
struct tchars m_tchars;
struct ltchars m_ltchars;
int m_ldisc;
int m_lmode;
# endif /* TERMIO */
#endif /* POSIX */
#if defined(KANJI) && defined(TIOCKSET)
struct jtchars m_jtchars;
int m_knjmode;
#endif
};
/* #include "logfile.h" */ /* (requires stat.h) struct logfile */
#include "image.h"
#include "canvas.h"
#include "display.h"
#include "window.h"
/*
* Parameters for the Detach() routine
*/
#define D_DETACH 0
#define D_STOP 1
#define D_REMOTE 2
#define D_POWER 3
#define D_REMOTE_POWER 4
#define D_LOCK 5
#define D_HANGUP 6
/*
* Here are the messages the attacher sends to the backend
*/
#define MSG_CREATE 0
#define MSG_ERROR 1
#define MSG_ATTACH 2
#define MSG_CONT 3
#define MSG_DETACH 4
#define MSG_POW_DETACH 5
#define MSG_WINCH 6
#define MSG_HANGUP 7
#define MSG_COMMAND 8
#define MSG_QUERY 9
/*
* versions of struct msg:
* 0: screen version 3.6.6 (version count introduced)
* 1: screen version 4.1.0devel (revisions e3fc19a upto 8147d08)
* A few revisions after 8147d08 incorrectly
* carried version 1, but should have carried 2.
* 2: screen version 4.1.0devel (revisions 8b46d8a upto YYYYYYY)
* 3: screen version 4.2.0 (was incorrectly originally. Patched here)
* 4: screen version 4.2.1 (bumped once again due to changed terminal and login length)
*/
#define MSG_VERSION 2
#define MSG_REVISION (('m'<<24) | ('s'<<16) | ('g'<<8) | MSG_VERSION)
struct msg
{
int protocol_revision; /* reduce harm done by incompatible messages */
int type;
char m_tty[MAXPATHLEN]; /* ttyname */
union
{
struct
{
int lflag;
int aflag;
int flowflag;
int hheight; /* size of scrollback buffer */
int nargs;
char line[MAXPATHLEN];
char dir[MAXPATHLEN];
char screenterm[20]; /* is screen really "screen" ? */
}
create;
struct
{
char auser[MAXLOGINLEN + 1]; /* username */
int apid; /* pid of frontend */
int adaptflag; /* adapt window size? */
int lines, columns; /* display size */
char preselect[20];
int esc; /* his new escape character unless -1 */
int meta_esc; /* his new meta esc character unless -1 */
char envterm[MAXTERMLEN + 1]; /* terminal type */
int encoding; /* encoding of display */
int detachfirst; /* whether to detach remote sessions first */
}
attach;
struct
{
char duser[MAXLOGINLEN + 1]; /* username */
int dpid; /* pid of frontend */
}
detach;
struct
{
char auser[MAXLOGINLEN + 1]; /* username */
int nargs;
char cmd[MAXPATHLEN]; /* command */
int apid; /* pid of frontend */
char preselect[20];
char writeback[MAXPATHLEN]; /* The socket to write the result.
Only used for MSG_QUERY */
}
command;
char message[MAXPATHLEN * 2];
} m;
};
/*
* And the signals the attacher receives from the backend
*/
#define SIG_BYE SIGHUP
#define SIG_POWER_BYE SIGUSR1
#define SIG_LOCK SIGUSR2
#define SIG_STOP SIGTSTP
#ifdef SIGIO
#define SIG_NODEBUG SIGIO /* triggerd by command 'debug off' */
#endif
#define BELL (Ctrl('g'))
#define VBELLWAIT 1 /* No. of seconds a vbell will be displayed */
#define BELL_ON 0 /* No bell has occurred in the window */
#define BELL_FOUND 1 /* A bell has occurred, but user not yet notified */
#define BELL_DONE 2 /* A bell has occured, user has been notified */
#define BELL_VISUAL 3 /* A bell has occured in fore win, notify him visually */
#define MON_OFF 0 /* Monitoring is off in the window */
#define MON_ON 1 /* No activity has occurred in the window */
#define MON_FOUND 2 /* Activity has occured, but user not yet notified */
#define MON_DONE 3 /* Activity has occured, user has been notified */
#define DUMP_TERMCAP 0 /* WriteFile() options */
#define DUMP_HARDCOPY 1
#define DUMP_EXCHANGE 2
#define DUMP_SCROLLBACK 3
#define SILENCE_OFF 0 /* Not checking for silence */
#define SILENCE_ON 1 /* Window being monitored for silence */
#define SILENCE_FOUND 2 /* Window is silent */
#define SILENCE_DONE 3 /* Window is silent and user is notified */
extern char strnomem[];
/*
* line modes used by Input()
*/
#define INP_COOKED 0
#define INP_NOECHO 1
#define INP_RAW 2
#define INP_EVERY 4
#ifdef MULTIUSER
struct acl
{
struct acl *next;
char *name;
};
#endif
/* register list */
#define MAX_PLOP_DEFS 256
struct baud_values
{
int idx; /* the index in the bsd-is padding lookup table */
int bps; /* bits per seconds */
int sym; /* symbol defined in ttydev.h */
};
/*
* windowlist orders
*/
#define WLIST_NUM 0
#define WLIST_MRU 1
#define WLIST_NESTED 2
|