-
Notifications
You must be signed in to change notification settings - Fork 0
/
ckoadm.c
297 lines (280 loc) · 7.12 KB
/
ckoadm.c
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
/* C K O A D M . C -- ADM-3A Emulation */
/*
Author: Jeffrey Altman <[email protected]>,
Secure Endpoints Inc., New York City.
Copyright (C) 1985, 2004, Trustees of Columbia University in the City of New
York.
*/
#include "ckcdeb.h"
#ifndef NOTERM
#ifdef NT
#include <windows.h>
#else /* NT */
#include <os2.h>
#undef COMMENT
#endif /* NT */
#include "ckcker.h"
#include "ckcasc.h"
#include "ckuusr.h"
#include "ckcuni.h"
#include "ckocon.h"
#include "ckoadm.h"
#ifdef NETCONN
#ifdef TCPSOCKET
#include "ckcnet.h"
extern int network, nettype, ttnproto, u_binary;
#endif /* TCPSOCKET */
#endif /* NETCONN */
extern bool keyclick ;
extern int cursorena[], keylock, duplex, duplex_sav, screenon ;
extern int printon, aprint, uprint, xprint, cprint, seslog ;
extern int insertmode, tnlm ;
extern int escstate, debses, decscnm, tt_cursor ;
extern int tt_type, tt_type_mode, tt_max, tt_answer, tt_status[VNUM], tt_szchng[] ;
extern int tt_cols[], tt_rows[], tt_wrap ;
extern int wherex[], wherey[], margintop, marginbot ;
extern int marginbell, marginbellcol ;
extern char answerback[], htab[] ;
extern struct tt_info_rec tt_info[] ;
extern vtattrib attrib ;
extern unsigned char attribute;
extern int ttpush;
extern int autoscroll, protect ;
extern struct _vtG G[];
extern struct _vtG *GL, *GR;
int
adminc(void)
{
extern int pmask, cmask;
extern int tt_utf8;
int ch;
loop:
ch = ttinc(0);
if ( ch < 0 )
return ch;
if ( seslog )
logchar(ch);
/* Handle the UTF8 conversion if we are in that mode */
if ( tt_utf8 ) {
USHORT * ucs2 = NULL;
int rc = utf8_to_ucs2( (CHAR)(ch & 0xFF), &ucs2 );
if ( rc > 0 )
goto loop;
else if ( rc < 0 )
ch = 0xfffd;
else
ch = *ucs2;
}
if ( !xprint ) {
#ifndef NOXFER
autodown(ch);
#endif /* NOXFER */
autoexitchk(ch);
}
ch = ch & pmask & cmask;
debugses(ch);
if (printon && (is_xprint() || is_uprint()))
prtchar(ch);
return ch;
}
void
admctrl( int ch )
{
int i,j;
if ( !xprint ) {
switch ( ch ) {
case SOH:
case STX:
case ETX:
case EOT:
debug(F111,"ADM-3A","unused Ctrl",ch);
break;
case ENQ: /* Answerback Message */
if ( debses )
break;
sendcharsduplex(answerback,strlen(answerback), FALSE) ;
break;
case ACK:
debug(F111,"ADM-3A","unused Ctrl",ch);
break;
case BEL:
if ( debses )
break;
bleep(BP_BEL);
break;
case BS:
/* Cursor Left */
if ( debses )
break;
cursorleft(0) ;
break;
case HT:
debug(F111,"ADM-3A","unused Ctrl",ch);
break;
case LF:
/* Linefeed */
if ( debses )
break;
wrtch((CHAR)LF);
break;
case VT:
if ( debses )
break;
cursorup(0);
break;
case FF:
if ( debses )
break;
cursorright(0);
break;
case CR:
if ( debses )
break;
wrtch((char) CR);
break;
case SO: /* lock keyboard */
if ( debses )
break;
keylock = TRUE;
break;
case SI: /* unlock keyboard */
if ( debses )
break;
keylock = FALSE;
break;
case DLE:
case DC1:
case DC2:
case DC3:
case DC4:
case NAK:
case SYN:
case ETB:
case CAN:
debug(F111,"ADM-3A","unused Ctrl",ch);
break;
case ESC:
debug(F111,"ADM-3A","ESC",ch);
if ( debses )
break;
escstate = ES_GOTESC;
break;
case XEM:
debug(F111,"ADM-3A","unused Ctrl",ch);
break;
case SUB: /* Clear Screen */
if ( debses )
break;
cleartermscreen(VTERM);
break;
case XFS:
case XGS:
debug(F111,"ADM-3A","unused Ctrl",ch);
break;
case XRS: /* Home cursor */
if ( debses )
break;
lgotoxy(VTERM,1,1);
break;
case US:
default:
debug(F111,"ADM-3A","unused Ctrl",ch);
}
} /* !xprint */
else {
switch ( ch ) {
default:
break; /* There are no print commands */
}
}
}
void
admascii( int ch )
{
int i,j,k,n,x,y,z;
vtattrib attr ;
viocell blankvcell;
if (printon && (is_xprint() || is_uprint()))
prtchar(ch);
if ( escstate == ES_GOTESC )/* Process character as part of an escstate sequence */
{
escstate = ES_ESCSEQ ;
switch ( ch ) {
case '=': {
/* Absolute cursor position */
int col, line ;
line = adminc();
#ifdef NETCONN
#ifdef TCPSOCKET
if ( network && IS_TELNET() && !TELOPT_U(TELOPT_BINARY) && line == CR ) {
/* Handle TELNET CR-NUL or CR-LF if necessary */
int dummy = ttinc(0);
debug(F111,"ADM-3A","Addr cursor in page found CR",dummy);
if ( dummy != NUL )
ttpush = dummy;
}
#endif /* TCPSOCKET */
#endif /* NETCONN */
col = adminc();
#ifdef COMMENT
/* Is this really necessary? Who cares if the next character is a NUL now that */
/* we know that the sequence is complete? */
#ifdef NETCONN
#ifdef TCPSOCKET
if ( network && IS_TELNET() && !TELOPT_U(TELOPT_BINARY) && col == CR ) {
/* Handle TELNET CR-NUL or CR-LF if necessary */
int dummy = ttinc(0);
debug(F111,"ADM-3A","Addr cursor in page found CR",dummy);
if ( dummy != NUL )
ttpush = dummy;
}
#endif /* TCPSOCKET */
#endif /* NETCONN */
#endif /* COMMENT */
if ( debses )
break;
lgotoxy(VTERM,(col-SP)+1,(line-SP)+1);
break;
}
case 'T': /* ADM 5 - clear to end of line with SP */
debug(F110,"ADM-5","Clear to End of Line with SP",0);
if ( debses )
break;
clrtoeoln( VTERM, SP );
break;
case 'Y': /* ADM 5 - clear to end of page with SP */
debug(F110,"ADM-5","Clear to Screen of Line with SP",0);
if ( debses )
break;
clreoscr_escape( VTERM, SP );
break;
case '(': /* ADM 5 - restore standard intensity */
debug(F110,"ADM-5","Restore Standard Intensity",0);
if ( debses )
break;
break;
case ')': /* ADM 5 - set reduced intensity */
debug(F110,"ADM-5","Set Reduced Intensity",0);
if ( debses )
break;
break;
case 'G': /* ADM 5 - toggle reverse intensity */
debug(F110,"ADM-5","Toggle Reverse Intensity",0);
if ( debses )
break;
break;
default:
debug(F111,"ADM-3A","unknown ESC sequence",ch);
}
escstate = ES_NORMAL ;
}
else { /* Handle as a normal character */
if ( ch < SP )
admctrl(ch) ;
else if ( !debses && ch != DEL ) {
wrtch(ch);
}
}
VscrnIsDirty(VTERM) ;
}
#endif /* NOTERM */