#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
#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
#define Free(a) {if ((a) == 0) abort(); else free((void *)(a)); (a)=0;}
#define Ctrl(c) ((c)&037)
#define MAXSTR 256
#define MAXARGS 64
#define MSGWAIT 5
#define MSGMINWAIT 1
#define SILENCEWAIT 30
#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
#else
# ifdef TERMIO
struct termio tio;
# ifdef CYTERMIO
int m_mapkey;
int m_mapscreen;
int m_backspace;
# endif
# else
struct sgttyb m_ttyb;
struct tchars m_tchars;
struct ltchars m_ltchars;
int m_ldisc;
int m_lmode;
# endif
#endif
#if defined(KANJI) && defined(TIOCKSET)
struct jtchars m_jtchars;
int m_knjmode;
#endif
};
#include "image.h"
#include "display.h"
#include "window.h"
#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
#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_VERSION 0
#define MSG_REVISION (('m'<<24) | ('s'<<16) | ('g'<<8) | MSG_VERSION)
struct msg
{
int protocol_revision;
int type;
char m_tty[MAXPATHLEN];
union
{
struct
{
int lflag;
int aflag;
int flowflag;
int hheight;
int nargs;
char line[MAXPATHLEN];
char dir[MAXPATHLEN];
char screenterm[20];
}
create;
struct
{
char auser[20 + 1];
int apid;
int adaptflag;
int lines, columns;
char preselect[20];
int esc;
int meta_esc;
char envterm[20 + 1];
int encoding;
}
attach;
struct
{
char duser[20 + 1];
int dpid;
}
detach;
struct
{
char auser[20 + 1];
int nargs;
char cmd[MAXPATHLEN];
int apid;
char preselect[20];
}
command;
char message[MAXPATHLEN * 2];
} m;
};
#define SIG_BYE SIGHUP
#define SIG_POWER_BYE SIGUSR1
#define SIG_LOCK SIGUSR2
#define SIG_STOP SIGTSTP
#ifdef SIGIO
#define SIG_NODEBUG SIGIO
#endif
#define BELL (Ctrl('g'))
#define VBELLWAIT 1
#define BELL_ON 0
#define BELL_FOUND 1
#define BELL_DONE 2
#define BELL_VISUAL 3
#define MON_OFF 0
#define MON_ON 1
#define MON_FOUND 2
#define MON_DONE 3
#define DUMP_TERMCAP 0
#define DUMP_HARDCOPY 1
#define DUMP_EXCHANGE 2
#define DUMP_SCROLLBACK 3
#define SILENCE_OFF 0
#define SILENCE_ON 1
extern char strnomem[];
#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
#define MAX_PLOP_DEFS 256
struct baud_values
{
int idx;
int bps;
int sym;
};
#define WLIST_NUM 0
#define WLIST_MRU 1