-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathckocon.c
3864 lines (3525 loc) · 121 KB
/
ckocon.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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#ifdef NT
char *connv = "Win32 CONNECT command 8.0.232, 20 Oct 2003";
#else /* NT */
char *connv = "OS/2 CONNECT command 8.0.232, 20 Oct 2003";
#endif /* NT */
/* C K O C O N -- Kermit CONNECT command for OS/2 and Windows */
/*
Authors: Frank da Cruz <fdc@columbia.edu>,
Kermit Project, Columbia University, New York City.
Jeffrey E Altman <jaltman@secure-endpoints.com>
Secure Endpoints Inc., New York City
Copyright (C) 1985, 2004,
Trustees of Columbia University in the City of New York.
All rights reserved.
Originally adapted to OS/2 by Chris Adie of Edinburgh University, Scotland
(C.Adie@edinburgh.ac.uk), 1988, from the UNIX Kermit CONNECT module by Frank
da Cruz, Columbia University. VT102 terminal emulation originally by Chris
Adie, 1988 ("If the code looks a bit funny sometimes, it's because it was
machine translated to C.") (From what??)
Adapted to c-Kermit 5A by Kai Uwe Rommel (rommel@informatik.tu-muenchen.de),
1992-93 (present address: rommel@ars.muc.de).
Many changes by Frank da Cruz (fdc@columbia.edu): numerous bug fixes (tabs,
cursor/attributes save/restore, scrolling, keypad modes, etc), new SET
TERMINAL commands, TCP/IP TELNET support, printer support, character-set
support, APC escape sequence handling, print/dump screen, complete rewrite
of character attribute handling & screen reversal and rollback, addition of
VT220 and ANSI emulations, keyboard verbs, Compose key, Hebrew features,
Cyrillic features, context-sensitive popup screens, cosmetic improvements,
commentary, etc: 1992-present. (Hopefully much of the funny-looking code
looks less funny now.)
Massive improvements by Jeffrey Altman <jaltman@secure-endpoints.com>:
changes to keyboard handling, mouse support, ...: 1993 to present.
(191) new connect mode screen handling, scrollback, ...
(192) Win32 support, many new emulations, new keyboard scan codes, ... */
/*
* =============================#includes=====================================
*/
#include "ckcdeb.h" /* Typedefs, debug formats, etc */
#include "ckcker.h" /* Kermit definitions */
#include "ckcasc.h" /* ASCII character symbols */
#include "ckcxla.h" /* Character set translation */
#include "ckcnet.h" /* Network support */
#include "ckuusr.h" /* For terminal type definitions, etc. */
#include <ctype.h> /* Character types */
#include <io.h> /* File io function declarations */
#include <process.h> /* Process-control function declarations */
#include <stdlib.h> /* Standard library declarations */
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <signal.h>
#ifdef NT
#include <windows.h>
#include <tapi.h>
#include "ckntap.h"
#include "cknwin.h"
#ifdef KUI
#include "kui/ikui.h"
#endif /* KUI */
#else /* NT */
#ifdef OS2MOUSE
#define INCL_MOU
#endif /* OS2MOUSE */
#define INCL_WIN
#define INCL_VIO
#define INCL_ERRORS
#define INCL_DOSPROCESS
#define INCL_DOSSEMAPHORES
#define INCL_DOSDEVIOCTL
#define INCL_WINCLIPBOARD
#define INCL_DOSDATETIME
#include <os2.h>
#undef COMMENT /* COMMENT is defined in os2.h */
#endif /* NT */
#include "ckowin.h"
#include "ckcuni.h"
#include "ckocon.h" /* definitions common to console routines */
#include "ckokey.h"
#ifdef CK_NETBIOS
#include "ckonbi.h"
extern UCHAR NetBiosRemote[] ;
#endif /* CK_NETBIOS */
/*
*
* =============================externals=====================================
*/
extern CHAR (*xls[MAXTCSETS+1][MAXFCSETS+1])(CHAR); /* Character set xlate */
extern CHAR (*xlr[MAXTCSETS+1][MAXFCSETS+1])(CHAR); /* functions. */
extern int language; /* Current language. */
extern struct langinfo langs[]; /* Language info. */
extern struct csinfo fcsinfo[]; /* File character set info */
extern int tcsr, tcsl; /* Terminal character sets, remote & local. */
extern int tcs_transp;
extern struct _vtG G[4]; /* G0->G3 character sets */
extern int tnlm, tn_nlm; /* Terminal newline mode, ditto for TELNET */
extern int me_binary, u_binary; /* Telnet binary modes */
extern int tt_crd; /* Carriage-return display mode */
extern int tt_lfd; /* Line-feed display mode */
extern int tt_bell; /* How to handle incoming Ctrl-G characters */
extern long speed, vernum;
extern int local, escape, duplex, parity, flow, seslog, ttyfd,
cmdmsk, cmask, sosi, xitsta, debses, mdmtyp, carrier, what;
extern int cflg, cnflg, stayflg, tt_escape;
extern int network, nettype, ttnproto;
extern int tt_status[VNUM] ;
extern int quiet, tn_exit, exitonclose;
extern int SysInited;
#ifndef NOSPL
extern struct mtab *mactab; /* Main macro table */
extern int nmac; /* Number of macros */
#endif /* NOSPL */
extern KEY *keymap;
extern MACRO *macrotab;
extern char ttname[];
extern char *versio, *ckxsys;
#ifdef COMMENT
extern HAB hab ;
#endif /* COMMENT */
extern enum markmodes markmodeflag[VNUM] ;
/*
* =============================variables==============================
*/
/*
These are RGB bits for the fore- and background colors in the PC's video
adapter, 3 bits for each color. These default values can be changed by the
SET TERMINAL COLOR command (in ckuus7.c) or by CSI3x;4xm escape sequences
from the host.
*/
extern unsigned char colorhelp;
extern unsigned char colorcmd;
int scrninitialized[VNUM] = {0,0,0} ;
bool scrollflag[VNUM] = {0,0,0}, flipscrnflag[VNUM] = {0,0,0};
extern bool scrollstatus[] ;
bool viewonly = FALSE ; /* View only terminal mode */
int updmode = TTU_FAST ; /* Fast/Smooth scrolling */
int priority = XYP_REG ;
int tn_bold = 0; /* TELNET negotiation bold */
int esc_exit = 0; /* Escape back = exit */
char * esc_msg;
long waittime; /* Timeout on CTS during CONNECT */
#define INTERVAL 100L
char termessage[MAXTERMCOL];
#ifdef CK_APC
extern int apcactive; /* Application Program Command (APC) */
#endif /* CK_APC */
#ifdef IKSD
extern int inserver;
#endif /* IKSD */
#ifdef KUI
int gui_dialog = 1;
#else
int gui_dialog = 0;
#endif /* KUI */
char * keydefptr = NULL;
int keymac = 0;
int keymacx = -1 ;
int pmask = 0377 ;
extern videobuffer vscrn[];
ascreen /* For saving screens: */
vt100screen, /* terminal screen */
commandscreen ; /* OS/2 screen */
extern unsigned char /* Video attribute bytes */
attribute, /* Current video attribute byte */
savedattribute, /* Saved video attribute byte */
defaultattribute; /* Default video attribute byte */
int wherex[VNUM]={1,1,1}; /* Screen column, 1-based */
int wherey[VNUM]={1,1,1}; /* Screen row, 1-based */
int ConnectMode ;
int quitnow, hangnow, outshift, tcs, langsv;
#ifdef NT
char answerback[81] = "K-95\r"; /* Default answerback */
#else /* NT */
char answerback[81] = "K-95 for OS/2\r";/* Default answerback */
#endif /* NT */
char useranswerbk[60] = "" ; /* User answerback extension */
int safeanswerbk = TRUE ; /* Require Kermit Product Prefix */
char usertext[(MAXTERMCOL) + 1]; /* Status line and its parts */
char statusline[MAXTERMCOL + 1];
char exittext[(20) + 1];
#define HLPTXTLEN 41
char helptext[HLPTXTLEN];
char filetext[(20) + 1];
#define HSTNAMLEN 41
char hostname[HSTNAMLEN];
#ifdef NT
CK_CURSORINFO crsr_command={88,0,8,1};
#else
CK_CURSORINFO crsr_command={-88,0,8,1};
#endif /* NT */
extern bool cursoron[VNUM] = {TRUE,TRUE,TRUE}; /* For speed, turn off when busy */
extern bool cursorena[VNUM] = {TRUE,TRUE,TRUE}; /* Cursor enabled / disabled */
extern bool printon; /* Printer is on */
extern bool xprint; /* Controller print in progress */
extern bool aprint; /* Auto print in progress */
extern bool uprint; /* User/transparent print in progress */
extern bool keylock;
extern bool deccolm; /* 80/132-column mode */
extern bool decscnm; /* Normal/reverse screen mode */
extern struct _vtG G[4]; /* Graphic Set definitions */
/*
Terminal parameters that can also be set externally by SET commands.
Formerly they were declared and initialized here, and had different
names, as shown in the comments. Now they are declared and
initialized in ckuus7.c. - fdc
*/
bool tt_hebrew = 0; /* Keyboard is in Hebrew mode */
/* SET TERMINAL values ... */
extern struct tt_info_rec tt_info[] ; /* Indexed by terminal type */
extern int max_tt; /* Highest terminal type */
extern int tt_arrow; /* Arrow-key mode */
extern int tt_keypad; /* Keypad mode */
extern int tt_wrap; /* Autowrap */
extern int tt_type; /* Terminal type */
extern int tt_type_mode; /* Terminal type */
extern int tt_cursor; /* Cursor type */
extern int tt_answer; /* Answerback enabled/disabled */
extern int tt_scrsize[]; /* Scrollback buffer size */
extern int tt_roll[]; /* Scrollback style */
extern int tt_rows[]; /* Screen rows */
extern int tt_cols[]; /* Screen columns */
extern int tt_cols_usr;
extern int tt_szchng[VNUM];
extern int cmd_rows; /* Screen rows */
extern int cmd_cols; /* Screen columns */
extern int tt_ctstmo; /* CTS timeout */
extern int tt_pacing; /* Output-pacing */
extern int tt_updmode; /* Terminal Screen Update Mode */
extern bool escapestatus[VNUM] ; /* are we in ESCAPE mode? */
/* extern int tt_idlesnd_tmo; /* Idle Send Timeout, disabled */
extern char * tt_idlesnd_str; /* Idle Send String, none */
extern int tt_idlelimit; /* Auto-exit Connect when idle */
extern int tt_idleact;
extern int tt_timelimit;
static time_t keypress_t=0; /* Time of last keypress */
static time_t idlesnd_t=0; /* Time of last idle send */
int escstate ;
USHORT marginbot; /* Bottom of same, 1-based */
int tt_async = 0; /* asynchronous connect mode? */
int col_init = 0, row_init = 0;
/*
For pushing back input characters,
e.g. converting 8-bit controls to 7-bit escape sequences.
*/
int f_pushed = 0, c_pushed = 0, f_popped = 0;
unsigned char sgrcols[8] = {0, 4, 2, 6, 1, 5, 3, 7};
/* Function prototypes */
#ifndef NOSETKEY
/* Key names */
char *keyname(unsigned long); /* Names of keys, by scan code */
extern vik_rec vik;
#endif /* NOSETKEY */
/* Thread stuff... */
#define THRDSTKSIZ 131072 /* Needed for Mouse Thread */
extern TID tidRdComWrtScr,
tidConKbdHandler,
tidTermScrnUpd;
extern BYTE vmode ;
int
oskipesc = 0, /* Esc seq recognizer for keys... */
os2_outesc = ES_NORMAL;
#ifndef NOLOCAL
#ifndef NT
#define CK_BORDER /* Allow border colors */
#endif /* NT */
int cmd_border = -1;
void
setborder() {
#ifdef CK_BORDER
extern HVIO VioHandle ;
extern unsigned char borderattribute ;
VIOOVERSCAN vo; /* Set border (overscan) color */
vo.cb = sizeof(vo); /* for terminal emulation window */
vo.type = 1;
vo.color = borderattribute ;
VioSetState((PVOID) &vo, VioHandle );
#endif /* CK_BORDER */
}
void
saveborder() { /* Save command-screen border */
#ifdef CK_BORDER
extern HVIO VioHandle ;
VIOOVERSCAN vo;
vo.cb = sizeof(vo);
vo.type = 1;
VioGetState((PVOID) &vo, VioHandle);
cmd_border = vo.color;
#endif /* CK_BORDER */
}
void
restoreborder() {
#ifdef CK_BORDER
extern HVIO VioHandle ;
VIOOVERSCAN vo; /* Restore command-screen border */
if (cmd_border < 0) /* None saved. */
return;
vo.cb = sizeof(vo);
vo.type = 1;
vo.color = cmd_border;
cmd_border = 0;
VioSetState((PVOID) &vo, VioHandle);
#endif /* CK_BORDER */
}
/* Save current status of screen */
void
SaveTermMode(int wherex, int wherey) {
debug(F101,"x_save wherex","",wherex);
debug(F101,"x_save wherey","",wherey);
#ifndef KUI
if (GetMode( &vt100screen.mi ))
return;
#endif /* KUI */
vt100screen.ox = wherex;
vt100screen.oy = wherey;
vt100screen.att = attribute;
vt100screen.scrncpy ; /* not used for terminal mode */
}
/* Restore a saved screen */
void
RestoreTermMode(void) {
extern int tt_modechg;
int omode = vmode ;
#ifndef KUI
if ( tt_modechg == TVC_ENA )
SetMode( &vt100screen.mi ) ;
else if ( tt_modechg == TVC_W95 ) {
CK_VIDEOMODEINFO wmi = vt100screen.mi ;
wmi.col = 80 ;
SetMode( &wmi ) ;
}
#endif /* KUI */
vmode = VTERM ;
VscrnIsDirty(omode);
VscrnForceFullUpdate();
VscrnIsDirty(VTERM);
}
/* Save current status of command screen */
void
SaveCmdMode(int wherex, int wherey) {
debug(F101,"x_save wherex","",wherex);
debug(F101,"x_save wherey","",wherey);
#ifndef KUI
if (GetMode( &commandscreen.mi ))
return;
commandscreen.mi.row = (commandscreen.mi.row > MAXSCRNROW ?
MAXSCRNROW : commandscreen.mi.row) ;
commandscreen.mi.col = (commandscreen.mi.col > MAXSCRNCOL ?
MAXSCRNCOL : commandscreen.mi.col);
#ifdef NT
commandscreen.mi.sbcol = commandscreen.mi.col;
commandscreen.mi.sbrow = commandscreen.mi.row;
#endif /* NT */
#endif /* KUI */
commandscreen.ox = wherex;
commandscreen.oy = wherey;
commandscreen.att = colorcmd;
}
/* Restore a saved command screen */
void
RestoreCmdMode() {
extern int tt_modechg;
int omode = vmode ;
#ifndef KUI
if ( tt_modechg == TVC_ENA )
SetMode( &commandscreen.mi ) ;
else if ( tt_modechg == TVC_W95 ) {
CK_VIDEOMODEINFO wmi = commandscreen.mi ;
wmi.col = 80 ;
SetMode( &wmi ) ;
}
#endif /* KUI */
#ifdef COMMENT
colorcmd = commandscreen.att;
wherey[VTERM] = commandscreen.oy;
wherex[VTERM] = commandscreen.ox;
#endif /* COMMENT */
debug(F101,"x_rest wherex","",commandscreen.ox);
debug(F101,"x_rest wherey","",commandscreen.oy);
SetCurPos( commandscreen.oy-1, commandscreen.ox-1 ) ;
/* lgotoxy no longer moves */
/* the physical cursor */
vmode = VCMD ;
VscrnIsDirty(omode);
VscrnForceFullUpdate();
VscrnIsDirty(VCMD);
}
#endif /* NOLOCAL */
void /* Push from CONNECT mode to OS/2 */
os2push() { /* not just for CONNECT mode anymore */
#ifndef NOPUSH
#ifndef KUI
CK_VIDEOMODEINFO mi;
#endif /* KUI */
int connectmode = IsConnectMode() ;
extern int nopush;
if ( nopush )
{
bleep( BP_WARN ) ;
return;
}
#ifndef KUI
if (GetMode(&mi))
return;
#endif /* KUI */
if ( connectmode ) {
SaveTermMode(wherex[VTERM],wherey[VTERM]) ;
concooked();
#ifdef NT
setint();
#endif
}
RequestScreenMutex(SEM_INDEFINITE_WAIT);
clearcmdscreen();
if ( connectmode ) {
restorecursormode();
puts("Enter EXIT to return to Kermit-95 Connect Mode.");
}
else
puts("Enter EXIT to return to Kermit-95 Command Mode.");
zshcmd("");
if ( connectmode ) {
conraw();
connoi();
#ifndef KUI
SetMode(&mi);
#endif /* KUI */
setborder(); /* Put back CONNECT screen border */
setcursormode();
RestoreTermMode();
}
ReleaseScreenMutex();
if ( connectmode ) {
cursoron[VTERM] = FALSE ; /* Force update just in case */
VscrnIsDirty(VTERM);
}
else
VscrnIsDirty(VCMD);
#endif /* NOPUSH */
}
/*---------------------------------------------------------------------------*/
/* bleep */
/*---------------------------------------------------------------------------*/
int beepfreq = DEF_BEEP_FREQ ; /* Beep Frequency */
int beeptime = DEF_BEEP_TIME ; /* Beep Duration */
void
bleep(short int type) {
debug(F101,"bleep","",type);
#ifdef IKSD
if ( inserver ) {
if ( ttyfd != -1 )
printf("%c",BEL);
return;
}
#endif /* IKSD */
#ifndef IKSDONLY
switch(tt_bell) { /* Follows TERMINAL BELL setting. */
case XYB_AUD | XYB_BEEP: /* AUDIBLE - BEEP */
switch (type) {
#ifndef NT
case BP_NOTE:
DosBeep( WinQuerySysValue(HWND_DESKTOP,SV_NOTEFREQ),
WinQuerySysValue(HWND_DESKTOP,SV_NOTEDURATION));
break;
case BP_WARN:
DosBeep( WinQuerySysValue(HWND_DESKTOP,SV_WARNINGFREQ),
WinQuerySysValue(HWND_DESKTOP,SV_WARNINGDURATION));
break;
case BP_FAIL:
DosBeep( WinQuerySysValue(HWND_DESKTOP,SV_ERRORFREQ),
WinQuerySysValue(HWND_DESKTOP,SV_ERRORDURATION));
break;
case BP_BEL:
DosBeep(beepfreq,beeptime);
break;
default:
DosBeep(DEF_BEEP_FREQ,DEF_BEEP_TIME);
#else /* NT */
case BP_BEL:
Beep(beepfreq,beeptime);
break;
default:
Beep(DEF_BEEP_FREQ,DEF_BEEP_TIME ) ;
#endif /* NT */
}
return;
case XYB_AUD | XYB_SYS: /* AUDIBLE - SYSTEM-SOUNDS */
switch (type) {
#ifndef NT
case BP_NOTE:
WinAlarm(HWND_DESKTOP, WA_NOTE);
break;
case BP_WARN:
WinAlarm(HWND_DESKTOP, WA_WARNING);
break;
case BP_FAIL:
case BP_BEL:
default:
WinAlarm(HWND_DESKTOP, WA_ERROR);
break;
#ifdef COMMENT
case BP_BEL:
DosBeep(beepfreq,beeptime);
break;
default:
DosBeep(DEF_BEEP_FREQ,DEF_BEEP_TIME);
#endif /* COMMENT */
#else /* NT */
case BP_NOTE:
MessageBeep( MB_ICONQUESTION );
break;
case BP_WARN:
MessageBeep( MB_ICONASTERISK );
break;
case BP_FAIL:
case BP_BEL:
default:
MessageBeep( MB_ICONEXCLAMATION );
break;
#ifdef COMMENT
case BP_BEL:
Beep(beepfreq,beeptime);
break;
default:
MessageBeep(0xFFFFFFFF); /* Standard Beep */
#endif /* COMMENT */
#endif /* NT */
}
return;
case XYB_VIS: /* VISIBLE */
if ( IsConnectMode() ) { /* in terminal mode */
if ( flipscrnflag[VTERM] ) /* Flash the screen */
flipscrnflag[VTERM] = FALSE ;
else
flipscrnflag[VTERM] = TRUE ;
VscrnForceFullUpdate();
VscrnIsDirty(VTERM);
msleep(250); /* for 250 msec */
if ( flipscrnflag[VTERM] ) /* Flash the screen */
flipscrnflag[VTERM] = FALSE ;
else
flipscrnflag[VTERM] = TRUE ;
VscrnForceFullUpdate();
VscrnIsDirty(VTERM);
}
else { /* in command mode */
if ( flipscrnflag[VCMD] ) /* Flash the screen */
flipscrnflag[VCMD] = FALSE ;
else
flipscrnflag[VCMD] = TRUE ;
/* reversescreen(VTERM); */ /* Flash the screen */
VscrnForceFullUpdate();
VscrnIsDirty(VCMD);
msleep(250); /* for 250 msec */
if ( flipscrnflag[VCMD] ) /* Flash the screen */
flipscrnflag[VCMD] = FALSE ;
else
flipscrnflag[VCMD] = TRUE ;
/* reversescreen(VTERM); */ /* Flash the screen */
VscrnForceFullUpdate();
VscrnIsDirty(VCMD);
}
return;
default: /* NONE or other */
return;
}
#endif /* IKSDONLY */
}
#ifndef NOLOCAL
/* */
/* getcmdcolor */
/* */
void
getcmdcolor(void)
{
#ifndef KUI
viocell cell ;
USHORT x,y ;
USHORT length = 1;
GetCurPos( &x, &y ) ;
ReadCellStr( &cell, &length, x, y ) ;
colorcmd = cell.a ;
#endif /* KUI */
}
/*---------------------------------------------------------------------------*/
/* clearcmdscreen */
/*---------------------------------------------------------------------------*/
void
clearcmdscreen(void) {
viocell cell ;
ttgcwsz();
cell.c = ' ' ;
cell.a = colorcmd ;
WrtNCell(cell, cmd_cols * (cmd_rows+1), 0, 0);
SetCurPos( 0, 0 ) ;
}
/*---------------------------------------------------------------------------*/
/* clearscrollback */
/*---------------------------------------------------------------------------*/
void
clearscrollback( BYTE vmode ) {
ULONG bufsize = VscrnGetBufferSize(vmode) ;
VscrnSetBufferSize( vmode, 256 ) ;
VscrnSetBufferSize( vmode, bufsize ) ;
scrollstatus[vmode] = FALSE ;
scrollflag[vmode] = FALSE ;
cursoron[vmode] = FALSE ;
cleartermscreen(vmode) ;
}
/*---------------------------------------------------------------------------*/
/* cleartermscreen */
/*---------------------------------------------------------------------------*/
void
cleartermscreen( BYTE vmode ) {
int x,y ;
videoline * line ;
for ( y = 0 ; y < VscrnGetHeight(vmode) ; y++ ) {
line = VscrnGetLineFromTop(vmode,y) ;
line->width = VscrnGetWidth(vmode) ;
line->vt_line_attr = VT_LINE_ATTR_NORMAL ;
for ( x = 0 ; x < MAXTERMCOL ; x++ ) {
line->cells[x].c = ' ' ;
line->cells[x].a = vmode == VTERM ? attribute : colorcmd ;
line->vt_char_attrs[x] = VT_CHAR_ATTR_NORMAL ;
}
}
lgotoxy(vmode,1, 1);
if ( IsConnectMode() || vmode != VTERM )
VscrnIsDirty(vmode);
else {
vt100screen.ox = vt100screen.oy = 1 ;
}
}
/* POPUPHELP -- Give help message for connect. */
static int helpcol, helprow;
static int helpwidth;
videopopup *
helpstart(int w, int h, int gui) { /* Start help window */
videopopup * pPopup = malloc(sizeof(videopopup)) ;
if (pPopup == NULL)
return(NULL);
#ifdef KUI
if ( gui ) {
helpcol = 0;
helprow = -1;
pPopup->width = w;
pPopup->height = h;
pPopup->gui = 1;
} else
#endif /* KUI */
{
helpcol = helprow = 0 ;
pPopup->a = colorhelp ;
pPopup->width = w + 4 ; /* 2 for border, plus 2 for padding */
pPopup->height = h + 2 ; /* 2 for border */
pPopup->c[helprow][helpcol++] = 201; /* IBM upper left box corner double */
pPopup->gui = 0;
for ( helpcol ; helpcol < pPopup->width-1 ; helpcol++ )
pPopup->c[helprow][helpcol] = 205 ;
/* Center box bar horizontal double */
pPopup->c[helprow][helpcol] = 187; /* Upper right box corner double */
}
return pPopup ;
}
void
helpline(videopopup *pPopup, char *s) { /* Add line to popup help */
int l;
l = strlen(s); /* Length of this line */
helprow++;
helpcol=0;
#ifdef KUI
if ( pPopup->gui ) {
/* Add the string */
for ( helpcol ; helpcol < l && helpcol < pPopup->width; helpcol++ )
pPopup->c[helprow][helpcol] = s[helpcol] ;
/* Pad with NUL */
for ( helpcol ; helpcol < pPopup->width ; helpcol++ )
pPopup->c[helprow][helpcol] = NUL;
} else
#endif /* KUI */
{
pPopup->c[helprow][helpcol++] = 186; /* IBM center bar vertical double */
/* Add the string */
for ( helpcol ; helpcol <= l && helpcol < (pPopup->width-2); helpcol++ )
pPopup->c[helprow][helpcol] = s[helpcol-1] ;
/* Pad with spaces */
for ( helpcol ; helpcol < pPopup->width-1 ; helpcol++ )
pPopup->c[helprow][helpcol] = SP;
pPopup->c[helprow][helpcol++] = 186; /* IBM center bar vertical double */
}
}
void
helpend(videopopup * pPopup) { /* End of popup help box */
helprow++;
helpcol=0;
#ifdef KUI
if ( !pPopup->gui )
#endif /* KUI */
{
pPopup->c[helprow][helpcol++] = 200; /* IBM lower left box corner double */
for ( helpcol ; helpcol < pPopup->width-1 ; helpcol++ )
pPopup->c[helprow][helpcol] = 205; /* Center box bar horizontal double */
pPopup->c[helprow][helpcol++] = 188; /* Lower right box corner double */
}
}
int
popuperror(int mode, char * msg ) {
videopopup * pPopup = NULL ;
int c=0;
con_event evt ;
extern int holdscreen;
save_status_line(); /* Save current status line */
strcpy(usertext, " ERROR: Press (almost) any key to continue.");
exittext[0] = helptext[0] = hostname[0] = NUL;
pPopup = helpstart(strlen(msg), 1, gui_dialog);
helpline( pPopup, msg ) ;
helpend(pPopup); /* Write bottom of help panel */
#ifdef KUI
if ( pPopup->gui ) {
c = gui_videopopup_dialog(pPopup, 0);
} else
#endif /* KUI */
{
#ifdef OS2ONLY
VscrnSetPopup( mode, pPopup ) ;
/* wait until user presses a key */
evt = congev(mode,0);
while ( evt.type != key && evt.type != kverb) {
if ( evt.type != error )
bleep( BP_WARN ) ;
evt = congev(mode,0);
}
if ( evt.type == kverb )
c = F_KVERB | evt.kverb.id ;
else {
c = 0 ;
}
VscrnResetPopup(mode) ; /* This frees the Popup structure */
#else /* OS2ONLY */
;
#endif /* OS2ONLY */
}
restore_status_line();
return (c);
}
int
popupdemo(int mode, int secsleft ) {
videopopup * pPopup = NULL ;
char buf[80];
extern unsigned char colorhelp ;
int color_sav;
color_sav = colorhelp;
colorhelp = 0xE9;
sprintf(buf," Time remaining in this session: %2d:%02d",secsleft/60, secsleft%60);
pPopup = helpstart(57, (ttyfd == -1 || ttyfd == -2) ? 5 : 7, gui_dialog);
helpline( pPopup, " This is a trial copy of Kermit 95 to be evaluated for" ) ;
helpline( pPopup, " for possible purchase. It is fully functional and does" );
helpline( pPopup, " not expire, but sessions are limited to 15 minutes." );
helpline( pPopup, " To register, contact the distributor of this package or" );
helpline( pPopup, " visit http://www.columbia.edu/kermit/k95.html." );
if ( ttyfd != -1 && ttyfd != -2 ) {
helpline( pPopup, " " );
helpline( pPopup, buf );
}
helpend(pPopup); /* Write bottom of help panel */
bleep(BP_WARN);
#ifdef KUI
if ( pPopup->gui )
gui_videopopup_dialog(pPopup, 6);
else
#endif /* KUI */
{
VscrnSetPopup( mode, pPopup ) ;
sleep(6);
VscrnResetPopup(mode) ; /* This frees the Popup structure */
}
colorhelp = color_sav;
return(0);
}
int
popup_readtext(int mode, char * preface, char * prmpt, char * buffer, int buflen, int timo ) {
videopopup * pPopup = NULL ;
con_event evt ;
char inputline[256];
char prompt[1024];
int input_width,popup_width,i,j,len=0;
CHAR x1, * p, * q;
int lines;
int resp_line;
if ( prmpt ) {
ckstrncpy(prompt,prmpt,1024);
}
else
strcpy(prompt,"Enter text:");
if ( !buffer || buflen <= 0 )
return(-1);
i = 0;
lines=1;
if ( preface ) {
lines += 2;
p = q = preface;
while ( *p ) {
if ( *p == LF ) {
lines++;
if ( p - q > i )
i = p - q;
q = p;
}
p++;
}
if ( q == preface )
i = p - q;
}
p = q = prompt;
while ( *p ) {
if ( *p == LF ) {
lines++;
if ( p - q > i )
i = p - q;
q = p;
}
p++;
}
if ( q == prompt )
i = p - q;
j = VscrnGetWidth(mode);
popup_width = (i > j - 10 || buflen > j - 10) ? j - 10 :
(buflen > i) ? buflen : i;
input_width = (buflen <= popup_width ? buflen : popup_width)-1;
save_status_line(); /* Save current status line */
strcpy(usertext, " Enter text followed by Enter to continue");
exittext[0] = helptext[0] = hostname[0] = NUL;
pPopup = helpstart(popup_width, lines+1, 0);
if ( preface ) {
char * cp_preface = NULL;
makestr(&cp_preface, preface);
p = q = cp_preface;
while ( *p ) {
if ( *p == LF ) {
*p = '\0';
if ( *(p-1) == CR )
*(p-1) = '\0';
helpline( pPopup, q );
q = p+1;
}
p++;
}
helpline( pPopup, q );
helpline( pPopup, "" );
free(cp_preface);
}
p = q = prompt;
while ( *p ) {
if ( *p == LF ) {
*p = '\0';
if ( *(p-1) == CR )
*(p-1) = '\0';
helpline( pPopup, q );
q = p+1;
}
p++;
}
helpline( pPopup, q );
resp_line = helprow;
sprintf(inputline,"[%*s]",input_width," ");
helpline(pPopup,inputline);
helpend(pPopup); /* Write bottom of help panel */
VscrnSetPopup( mode, pPopup );
buffer[0] = '\0';
len = 0;
do {
VscrnIsDirty(vmode); /* status line needs to be updated */
evt = congev(vmode,timo > 0 ? timo : -1) ;
switch (evt.type) {
case key:
#ifdef COMMENT
x1 = mapkey(evt.key.scancode); /* Get value from keymap */
#else
x1 = evt.key.scancode ;
#endif
break;
#ifndef NOKVERBS
case kverb:
x1 = evt.kverb.id | F_KVERB;
switch ( evt.kverb.id & ~F_KVERB ) {