00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "os.h"
00026
00027 #if defined(__STDC__)
00028 # ifndef __P
00029 # define __P(a) a
00030 # endif
00031 #else
00032 # ifndef __P
00033 # define __P(a) ()
00034 # endif
00035 # define const
00036 #endif
00037
00038 #include "osdef.h"
00039
00040 #include "ansi.h"
00041 #include "sched.h"
00042 #include "acls.h"
00043 #include "comm.h"
00044 #include "layer.h"
00045 #include "term.h"
00046
00047
00048 #ifdef DEBUG
00049 # define STATIC
00050 #else
00051 # define STATIC static
00052 #endif
00053
00054 #ifdef DEBUG
00055 # define DEBUGDIR "/tmp/debug"
00056 # define debugf(a) do {if(dfp){fprintf a;fflush(dfp);}} while (0)
00057 # define debug(x) debugf((dfp,x))
00058 # define debug1(x,a) debugf((dfp,x,a))
00059 # define debug2(x,a,b) debugf((dfp,x,a,b))
00060 # define debug3(x,a,b,c) debugf((dfp,x,a,b,c))
00061 extern FILE *dfp;
00062 #else
00063 # define debugf(a) do {} while (0)
00064 # define debug(x) debugf(x)
00065 # define debug1(x,a) debugf(x)
00066 # define debug2(x,a,b) debugf(x)
00067 # define debug3(x,a,b,c) debugf(x)
00068 #endif
00069
00070 #ifndef DEBUG
00071 # define NOASSERT
00072 #endif
00073
00074 #ifndef NOASSERT
00075 # if defined(__STDC__)
00076 # 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)
00077 # else
00078 # 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)
00079 # endif
00080 #else
00081 # define ASSERT(lousy_cpp) do {} while (0)
00082 #endif
00083
00084
00085 #define Free(a) {if ((a) == 0) abort(); else free((void *)(a)); (a)=0;}
00086
00087 #define Ctrl(c) ((c)&037)
00088
00089 #define MAXSTR 256
00090 #define MAXARGS 64
00091 #define MSGWAIT 5
00092 #define MSGMINWAIT 1
00093 #define SILENCEWAIT 30
00094
00095
00096
00097
00098
00099 #define MAXHISTHEIGHT 3000
00100 #define DEFAULTHISTHEIGHT 100
00101 #if defined(NAME_MAX) && NAME_MAX < 16
00102 # define DEFAULT_BUFFERFILE "/tmp/screen-xchg"
00103 #else
00104 # define DEFAULT_BUFFERFILE "/tmp/screen-exchange"
00105 #endif
00106
00107
00108 #if defined(hpux) && !(defined(VSUSP) && defined(VDSUSP) && defined(VWERASE) && defined(VLNEXT))
00109 # define HPUX_LTCHARS_HACK
00110 #endif
00111
00112 struct mode
00113 {
00114 #ifdef POSIX
00115 struct termios tio;
00116 # ifdef HPUX_LTCHARS_HACK
00117 struct ltchars m_ltchars;
00118 # endif
00119 #else
00120 # ifdef TERMIO
00121 struct termio tio;
00122 # ifdef CYTERMIO
00123 int m_mapkey;
00124 int m_mapscreen;
00125 int m_backspace;
00126 # endif
00127 # else
00128 struct sgttyb m_ttyb;
00129 struct tchars m_tchars;
00130 struct ltchars m_ltchars;
00131 int m_ldisc;
00132 int m_lmode;
00133 # endif
00134 #endif
00135 #if defined(KANJI) && defined(TIOCKSET)
00136 struct jtchars m_jtchars;
00137 int m_knjmode;
00138 #endif
00139 };
00140
00141
00142
00143 #include "image.h"
00144 #include "display.h"
00145 #include "window.h"
00146
00147
00148
00149
00150 #define D_DETACH 0
00151 #define D_STOP 1
00152 #define D_REMOTE 2
00153 #define D_POWER 3
00154 #define D_REMOTE_POWER 4
00155 #define D_LOCK 5
00156 #define D_HANGUP 6
00157
00158
00159
00160
00161 #define MSG_CREATE 0
00162 #define MSG_ERROR 1
00163 #define MSG_ATTACH 2
00164 #define MSG_CONT 3
00165 #define MSG_DETACH 4
00166 #define MSG_POW_DETACH 5
00167 #define MSG_WINCH 6
00168 #define MSG_HANGUP 7
00169 #define MSG_COMMAND 8
00170
00171
00172
00173
00174
00175 #define MSG_VERSION 0
00176 #define MSG_REVISION (('m'<<24) | ('s'<<16) | ('g'<<8) | MSG_VERSION)
00177 struct msg
00178 {
00179 int protocol_revision;
00180 int type;
00181 char m_tty[MAXPATHLEN];
00182 union
00183 {
00184 struct
00185 {
00186 int lflag;
00187 int aflag;
00188 int flowflag;
00189 int hheight;
00190 int nargs;
00191 char line[MAXPATHLEN];
00192 char dir[MAXPATHLEN];
00193 char screenterm[20];
00194 }
00195 create;
00196 struct
00197 {
00198 char auser[20 + 1];
00199 int apid;
00200 int adaptflag;
00201 int lines, columns;
00202 char preselect[20];
00203 int esc;
00204 int meta_esc;
00205 char envterm[20 + 1];
00206 int encoding;
00207 }
00208 attach;
00209 struct
00210 {
00211 char duser[20 + 1];
00212 int dpid;
00213 }
00214 detach;
00215 struct
00216 {
00217 char auser[20 + 1];
00218 int nargs;
00219 char cmd[MAXPATHLEN];
00220 int apid;
00221 char preselect[20];
00222 }
00223 command;
00224 char message[MAXPATHLEN * 2];
00225 } m;
00226 };
00227
00228
00229
00230
00231 #define SIG_BYE SIGHUP
00232 #define SIG_POWER_BYE SIGUSR1
00233 #define SIG_LOCK SIGUSR2
00234 #define SIG_STOP SIGTSTP
00235 #ifdef SIGIO
00236 #define SIG_NODEBUG SIGIO
00237 #endif
00238
00239
00240 #define BELL (Ctrl('g'))
00241 #define VBELLWAIT 1
00242
00243 #define BELL_ON 0
00244 #define BELL_FOUND 1
00245 #define BELL_DONE 2
00246
00247 #define BELL_VISUAL 3
00248
00249 #define MON_OFF 0
00250 #define MON_ON 1
00251 #define MON_FOUND 2
00252 #define MON_DONE 3
00253
00254 #define DUMP_TERMCAP 0
00255 #define DUMP_HARDCOPY 1
00256 #define DUMP_EXCHANGE 2
00257 #define DUMP_SCROLLBACK 3
00258
00259 #define SILENCE_OFF 0
00260 #define SILENCE_ON 1
00261
00262 extern char strnomem[];
00263
00264
00265
00266
00267 #define INP_COOKED 0
00268 #define INP_NOECHO 1
00269 #define INP_RAW 2
00270 #define INP_EVERY 4
00271
00272
00273 #ifdef MULTIUSER
00274 struct acl
00275 {
00276 struct acl *next;
00277 char *name;
00278 };
00279 #endif
00280
00281
00282 #define MAX_PLOP_DEFS 256
00283
00284 struct baud_values
00285 {
00286 int idx;
00287 int bps;
00288 int sym;
00289 };
00290
00291
00292
00293
00294 #define WLIST_NUM 0
00295 #define WLIST_MRU 1