-
Notifications
You must be signed in to change notification settings - Fork 2
/
ckuus6.c
12009 lines (11286 loc) · 390 KB
/
ckuus6.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
#include "ckcsym.h"
#ifndef NOICP
/*
Authors:
Frank da Cruz <[email protected]>,
The Kermit Project, Columbia University, New York City
Jeffrey E Altman <[email protected]>
Secure Endpoints Inc., New York City
Copyright (C) 1985, 2011,
Trustees of Columbia University in the City of New York.
All rights reserved. See the C-Kermit COPYING.TXT file or the
copyright text in the ckcmai.c module for disclaimer and permissions.
*/
/* Includes */
#include "ckcdeb.h"
#include "ckcasc.h"
#include "ckcker.h"
#include "ckuusr.h"
#include "ckcxla.h"
#include "ckcnet.h" /* Network symbols */
#include <signal.h>
#ifndef NOSTAT
#ifdef VMS
/* 2010-03-09 SMS. VAX C needs help to find "sys". It's easier not to try. */
#include <stat.h>
#else /* def VMS */
#include <sys/stat.h>
#endif /* def VMS [else] */
#endif /* NOSTAT */
#ifdef VMS
#ifndef TCPSOCKET
#include <errno.h>
#endif /* TCPSOCKET */
#endif /* VMS */
#ifdef datageneral
#define fgets(stringbuf,max,fd) dg_fgets(stringbuf,max,fd)
#endif /* datageneral */
#ifdef QNX6
#define readblock kreadblock
#endif /* QNX6 */
/* External Kermit Variables, see ckmain.c for description. */
extern xx_strp xxstring;
extern int local, xitsta, binary, parity, escape, flow, cmd_rows, turn,
turnch, duplex, ckxech, seslog, dfloc, cnflg, tlevel, pflag, msgflg, mdmtyp,
zincnt, quiet, repars, techo, network, nzxopts, what, filepeek, recursive;
extern int xaskmore, tt_rows, tt_cols, cmd_cols, g_matchdot, diractive,
xcmdsrc, nscanfile, reliable, nolinks, cmflgs;
#ifdef VMSORUNIX
extern int zgfs_dir, zgfs_link;
#endif /* VMSORUNIX */
#ifdef CK_IFRO
extern int remonly;
#endif /* CK_IFRO */
#ifdef OS2
extern int StartedFromDialer ;
extern int vmode;
extern int k95stdout;
#ifndef NT
#define INCL_NOPM
#define INCL_VIO /* Needed for ckocon.h */
#include <os2.h>
#undef COMMENT
#else
#define APIRET ULONG
#include <windows.h>
#include <tapi.h>
#include "ckntap.h"
#endif /* NT */
#include "ckocon.h"
#endif /* OS2 */
extern long vernum, speed;
extern char *versio, *protv, *ckxv, *ckzv, *fnsv, *connv, *dftty, *cmdv;
extern char *dialv, *loginv, *for_def[], *whil_def[], *xif_def[], *sw_def[];
extern char *foz_def[];
extern char *ckxsys, *ckzsys;
#ifndef OS2
extern char *DIRCMD;
#ifndef UNIX
extern char *DELCMD;
#endif /* UNIX */
#endif /* OS2 */
extern char ttname[], filnam[];
extern CHAR sstate, feol;
extern char *zinptr;
#ifdef UNIX
extern char ** mtchs; /* zxpand() file list */
#endif /* UNIX */
#ifndef NOXFER
extern int oopts, omode, oname, opath; /* O-Packet options */
extern int stdinf, sndsrc, size, rpsiz, urpsiz, fncnv, fnrpath, displa,
stdouf, isguest, pktlog, nfils, keep, maxrps, fblksiz, frecl, frecfm,
atcapr, atdiso, spsizf, spsiz, spsizr, spmax, wslotr, prefixing,
fncact, fnspath, nprotos, g_proto, g_urpsiz, g_spsizf,
g_spsiz, g_spsizr, g_spmax, g_wslotr, g_prefixing, g_fncact, g_fncnv,
g_fnspath, g_fnrpath, xfrxla, g_xfrxla;
extern char *cmarg, *cmarg2;
#ifndef NOMSEND /* Multiple SEND */
extern char *msfiles[];
#endif /* NOMSEND */
extern char fspec[]; /* Most recent filespec */
extern int fspeclen;
#ifdef CK_TMPDIR
extern int f_tmpdir; /* Directory changed temporarily */
extern char savdir[]; /* For saving current directory */
#endif /* CK_TMPDIR */
extern struct keytab protos[]; /* File transfer protocols */
extern struct ck_p ptab[NPROTOS];
#endif /* NOXFER */
#ifdef DCMDBUF /* Declarations from cmd package */
extern char *cmdbuf, *atmbuf; /* Command buffers */
#else
extern char cmdbuf[], atmbuf[]; /* Command buffers */
#endif /* DCMDBUF */
extern int nopush;
#ifndef NOSPL
int askflag = 0; /* ASK-class command active */
int echostars = 0; /* ASKQ should echo asterisks */
extern char **a_ptr[];
extern int a_dim[];
extern char **m_xarg[];
extern int n_xarg[];
extern struct mtab *mactab;
extern int nmac;
extern long ck_alarm;
extern char alrm_date[], alrm_time[];
extern int x_ifnum;
#endif /* NOSPL */
extern int inserver; /* I am IKSD */
extern int backgrd; /* Kermit executing in background */
extern char psave[]; /* For saving & restoring prompt */
extern char *tp; /* Temporary buffer */
int readblock = 4096; /* READ buffer size */
CHAR * readbuf = NULL; /* Pointer to read buffer */
int readsize = 0; /* Number of chars actually read */
int getcmd = 0; /* GET-class command was given */
extern int zchkod, zchkid;
/* C K U U S 6 -- "User Interface" for Unix Kermit (Part 6) */
struct keytab deltab[] = { /* DELETE Command Options */
{ "/all", DEL_ALL, CM_INV },
{ "/after", DEL_AFT, CM_ARG },
{ "/ask", DEL_ASK, 0 },
{ "/before", DEL_BEF, CM_ARG },
{ "/directories", DEL_DIR, 0 },
{ "/dotfiles", DEL_DOT, 0 },
{ "/except", DEL_EXC, CM_ARG },
{ "/heading", DEL_HDG, 0 },
{ "/l", DEL_LIS, CM_INV|CM_ABR },
{ "/larger-than", DEL_LAR, CM_ARG },
{ "/list", DEL_LIS, 0 },
{ "/log", DEL_LIS, CM_INV },
{ "/noask", DEL_NAS, 0 },
{ "/nodotfiles", DEL_NOD, 0 },
{ "/noheading", DEL_NOH, 0 },
{ "/nol", DEL_NOL, CM_INV|CM_ABR },
{ "/nolist", DEL_NOL, 0 },
{ "/nolog", DEL_NOL, CM_INV },
{ "/nopage", DEL_NOP, 0 },
{ "/not-after", DEL_NAF, CM_ARG },
{ "/not-before", DEL_NBF, CM_ARG },
{ "/not-since", DEL_NAF, CM_INV|CM_ARG },
{ "/page", DEL_PAG, 0 },
{ "/quiet", DEL_QUI, CM_INV },
{ "/recursive", DEL_REC, 0 },
{ "/simulate", DEL_SIM, 0 },
{ "/since", DEL_AFT, CM_ARG|CM_INV },
{ "/smaller-than", DEL_SMA, CM_ARG },
{ "/summary", DEL_SUM, 0 },
{ "/tree", DEL_ALL, 0 },
{ "/type", DEL_TYP, CM_ARG },
{ "/verbose", DEL_VRB, CM_INV }
};
int ndeltab = sizeof(deltab)/sizeof(struct keytab);
/* /QUIET-/VERBOSE (/LIST-/NOLIST) (/LOG-/NOLOG) table */
struct keytab qvswtab[] = {
{ "/l", DEL_LIS, CM_INV|CM_ABR },
{ "/list", DEL_LIS, 0 },
{ "/log", DEL_LIS, CM_INV },
{ "/nol", DEL_NOL, CM_INV|CM_ABR },
{ "/nolist", DEL_NOL, 0 },
{ "/nolog", DEL_NOL, CM_INV },
{ "/quiet", DEL_QUI, CM_INV },
{ "/verbose", DEL_VRB, CM_INV }
};
int nqvswtab = sizeof(qvswtab)/sizeof(struct keytab);
static struct keytab renamsw[] = {
{ "/collision", REN_OVW, CM_ARG },
#ifndef NOUNICODE
{ "/convert", REN_XLA, CM_ARG },
#endif /* NOUNICODE */
{ "/fixspaces", REN_SPA, CM_ARG },
{ "/l", DEL_LIS, CM_INV|CM_ABR },
{ "/list", DEL_LIS, 0 },
{ "/log", DEL_LIS, CM_INV },
{ "/lower", REN_LOW, CM_ARG },
{ "/nol", DEL_NOL, CM_INV|CM_ABR },
{ "/nolist", DEL_NOL, 0 },
{ "/nolog", DEL_NOL, CM_INV },
{ "/quiet", DEL_QUI, CM_INV },
{ "/replace", REN_RPL, CM_ARG },
{ "/simulate", DEL_SIM, 0 },
{ "/upper", REN_UPP, CM_ARG },
{ "/verbose", DEL_VRB, CM_INV }
};
static int nrenamsw = sizeof(renamsw)/sizeof(struct keytab);
static struct keytab renamset[] = {
{ "collision", REN_OVW, 0 },
{ "list", DEL_LIS, 0 }
};
static int nrenamset = sizeof(renamset)/sizeof(struct keytab);
/* Args for RENAME /LOWER: and /UPPER: */
static struct keytab r_upper[] = {
{ "all", 1, 0 },
{ "lower", 0, 0 }
};
static struct keytab r_lower[] = {
{ "all", 1, 0 },
{ "upper", 0, 0 }
};
/* Args for RENAME /COLLISION... */
#define RENX_FAIL 0
#define RENX_OVWR 1
#define RENX_SKIP 2
static struct keytab r_collision[] = {
{ "fail", RENX_FAIL, 0 },
{ "overwrite", RENX_OVWR, 0 },
{ "proceed", RENX_SKIP, CM_INV },
{ "skip", RENX_SKIP, 0 }
};
static int nr_collision = sizeof(r_collision)/sizeof(struct keytab);
struct keytab copytab[] = {
{ "/append", 998, 0 },
#ifndef NOSPL
{ "/fromb64", 997, 0 },
#endif /* NOSPL */
{ "/l", DEL_LIS, CM_INV|CM_ABR },
{ "/list", DEL_LIS, 0 },
{ "/log", DEL_LIS, CM_INV },
{ "/nol", DEL_NOL, CM_INV|CM_ABR },
{ "/nolist", DEL_NOL, 0 },
{ "/nolog", DEL_NOL, CM_INV },
{ "/overwrite", 994, CM_ARG },
#ifndef NOXFER
{ "/preserve", 995, 0 },
#endif /* NOXFER */
{ "/quiet", DEL_QUI, CM_INV },
{ "/swap-bytes", 999, 0 },
#ifndef NOSPL
{ "/tob64", 996, 0 },
#endif /* NOSPL */
{ "/verbose", DEL_VRB, CM_INV }
};
int ncopytab = sizeof(copytab)/sizeof(struct keytab);
#define OVW_ALWAYS 0
#define OVW_NEVER 1
#define OVW_OLDER 2
#define OVW_NEWER 3
static struct keytab ovwtab[] = {
{ "always", OVW_ALWAYS, 0 },
{ "never", OVW_NEVER, 0 },
{ "newer", OVW_NEWER, 0 },
{ "older", OVW_OLDER, 0 }
};
static int novwtab = 4;
#ifndef NOXFER
static struct keytab gettab[] = { /* GET options */
{ "/as-name", SND_ASN, CM_ARG },
{ "/binary", SND_BIN, 0 },
#ifdef CALIBRATE
{ "/calibrate", SND_CAL, CM_INV },
#endif /* CALIBRATE */
#ifdef PIPESEND
{ "/command", SND_CMD, CM_PSH },
#endif /* PIPESEND */
{ "/delete", SND_DEL, 0 },
{ "/except", SND_EXC, CM_ARG },
{ "/filenames", SND_NAM, CM_ARG },
#ifdef PIPESEND
{ "/filter", SND_FLT, CM_ARG|CM_PSH },
#endif /* PIPESEND */
#ifdef VMS
{ "/image", SND_IMG, 0 },
{ "/labeled", SND_LBL, 0 },
#else
{ "/image", SND_BIN, CM_INV },
#endif /* VMS */
#ifdef CK_TMPDIR
{ "/move-to", SND_MOV, CM_ARG },
#endif /* CK_TMPDIR */
{ "/pathnames", SND_PTH, CM_ARG },
{ "/pipes", SND_PIP, CM_ARG|CM_PSH },
{ "/quiet", SND_SHH, 0 },
#ifdef CK_RESEND
{ "/recover", SND_RES, 0 },
#endif /* CK_RESEND */
{ "/recursive", SND_REC, 0 },
{ "/rename-to", SND_REN, CM_ARG },
#ifdef COMMENT
{ "/smaller-than", SND_SMA, CM_ARG },
#endif /* COMMENT */
{ "/subdirectories", SND_REC, CM_INV },
{ "/text", SND_TXT, 0 },
{ "/transparent", SND_XPA, 0 }
};
#define NGETTAB sizeof(gettab)/sizeof(struct keytab)
static int ngettab = NGETTAB;
static struct keytab rcvtab[] = { /* RECEIVE options */
{ "/as-name", SND_ASN, CM_ARG },
{ "/binary", SND_BIN, 0 },
#ifdef CALIBRATE
{ "/calibrate", SND_CAL, CM_INV },
#endif /* CALIBRATE */
#ifdef PIPESEND
{ "/command", SND_CMD, CM_PSH },
#endif /* PIPESEND */
{ "/except", SND_EXC, CM_ARG },
{ "/filenames", SND_NAM, CM_ARG },
#ifdef PIPESEND
{ "/filter", SND_FLT, CM_ARG|CM_PSH },
#endif /* PIPESEND */
#ifdef VMS
{ "/image", SND_IMG, 0 },
{ "/labeled", SND_LBL, 0 },
#else
{ "/image", SND_BIN, CM_INV },
#endif /* VMS */
#ifdef CK_TMPDIR
{ "/move-to", SND_MOV, CM_ARG },
#endif /* CK_TMPDIR */
{ "/pathnames", SND_PTH, CM_ARG },
{ "/pipes", SND_PIP, CM_ARG|CM_PSH },
#ifdef CK_XYZ
{ "/protocol", SND_PRO, CM_ARG },
#else
{ "/protocol", SND_PRO, CM_ARG|CM_INV },
#endif /* CK_XYZ */
{ "/quiet", SND_SHH, 0 },
{ "/recursive", SND_REC, 0 },
{ "/rename-to", SND_REN, CM_ARG },
{ "/text", SND_TXT, 0 },
{ "/transparent", SND_XPA, 0 }
};
#define NRCVTAB sizeof(rcvtab)/sizeof(struct keytab)
static int nrcvtab = NRCVTAB;
#endif /* NOXFER */
/* WAIT table */
#define WAIT_FIL 997
#define WAIT_MDM 998
struct keytab waittab[] = {
{ "cd", BM_DCD, CM_INV }, /* (Carrier Detect) */
{ "cts", BM_CTS, CM_INV }, /* (Clear To Send) */
{ "dsr", BM_DSR, CM_INV }, /* (Data Set Ready) */
{ "file", WAIT_FIL, 0 }, /* New category selector keywords */
{ "modem-signals", WAIT_MDM, 0 }, /* ... */
{ "ri", BM_RNG, CM_INV } /* (Ring Indicator) */
};
int nwaittab = (sizeof(waittab) / sizeof(struct keytab));
/* Modem signal table */
struct keytab mstab[] = {
{ "cd", BM_DCD, 0 }, /* Carrier Detect */
{ "cts", BM_CTS, 0 }, /* Clear To Send */
{ "dsr", BM_DSR, 0 }, /* Data Set Ready */
{ "ri", BM_RNG, 0 } /* Ring Indicator */
};
int nms = (sizeof(mstab) / sizeof(struct keytab));
#define WF_MOD 1
#define WF_DEL 2
#define WF_CRE 3
struct keytab wfswi[] = { /* WAIT FILE switches */
{ "creation", WF_CRE, 0 }, /* Wait for file to be created */
{ "deletion", WF_DEL, 0 }, /* Wait for file to be deleted */
{ "modification", WF_MOD, 0 } /* Wait for file to be modified */
};
int nwfswi = (sizeof(wfswi) / sizeof(struct keytab));
#ifndef NOSPL
struct keytab asgtab[] = { /* Assignment operators for "." */
{ "::=", 2, 0 }, /* ASSIGN and EVALUATE */
{ ":=", 1, 0 }, /* ASSIGN */
{ "=", 0, 0 } /* DEFINE */
};
int nasgtab = (sizeof(asgtab) / sizeof(struct keytab));
struct keytab opntab[] = {
#ifndef NOPUSH
{ "!read", OPN_PI_R, CM_INV },
{ "!write", OPN_PI_W, CM_INV },
#endif /* NOPUSH */
{ "append", OPN_FI_A, 0 },
{ "host", OPN_NET, 0 },
#ifdef OS2
{ "line", OPN_SER, CM_INV },
{ "port", OPN_SER, 0 },
#else
{ "line", OPN_SER, 0 },
{ "port", OPN_SER, CM_INV },
#endif /* OS2 */
{ "read", OPN_FI_R, 0 },
{ "write", OPN_FI_W, 0 }
};
int nopn = (sizeof(opntab) / sizeof(struct keytab));
/* IF conditions */
#define XXIFCO 0 /* IF COUNT */
#define XXIFER 1 /* IF ERRORLEVEL */
#define XXIFEX 2 /* IF EXIST */
#define XXIFFA 3 /* IF FAILURE */
#define XXIFSU 4 /* IF SUCCESS */
#define XXIFNO 5 /* IF NOT */
#define XXIFDE 6 /* IF DEFINED */
#define XXIFEQ 7 /* IF EQUAL (strings) */
#define XXIFAE 8 /* IF = (numbers) */
#define XXIFLT 9 /* IF < (numbers) */
#define XXIFGT 10 /* IF > (numbers) */
#define XXIFLL 11 /* IF Lexically Less Than (strings) */
#define XXIFLG 12 /* IF Lexically Greater Than (strings) */
#define XXIFEO 13 /* IF EOF (READ file) */
#define XXIFBG 14 /* IF BACKGROUND */
#define XXIFNU 15 /* IF NUMERIC */
#define XXIFFG 16 /* IF FOREGROUND */
#define XXIFDI 17 /* IF DIRECTORY */
#define XXIFNE 18 /* IF NEWER */
#define XXIFRO 19 /* IF REMOTE-ONLY */
#define XXIFAL 20 /* IF ALARM */
#define XXIFSD 21 /* IF STARTED-FROM-DIALER */
#define XXIFTR 22 /* IF TRUE */
#define XXIFNT 23 /* IF FALSE */
#define XXIFTM 24 /* IF TERMINAL-MACRO */
#define XXIFEM 25 /* IF EMULATION */
#define XXIFOP 26 /* IF OPEN */
#define XXIFLE 27 /* IF <= */
#define XXIFGE 28 /* IF >= */
#define XXIFIP 29 /* IF INPATH */
#define XXIFTA 30 /* IF TAPI */
#define XXIFMA 31 /* IF MATCH */
#define XXIFFL 32 /* IF FLAG */
#define XXIFAB 33 /* IF ABSOLUTE */
#define XXIFAV 34 /* IF AVAILABLE */
#define XXIFAT 35 /* IF ASKTIMEOUT */
#define XXIFRD 36 /* IF READABLE */
#define XXIFWR 37 /* IF WRITEABLE */
#define XXIFAN 38 /* IF ... AND ... */
#define XXIFOR 39 /* IF ... OR ... */
#define XXIFLP 40 /* IF left parenthesis */
#define XXIFRP 41 /* IF right parenthesis */
#define XXIFNQ 42 /* IF != (== "NOT =") */
#define XXIFQU 43 /* IF QUIET */
#define XXIFCK 44 /* IF C-KERMIT */
#define XXIFK9 45 /* IF K-95 */
#define XXIFMS 46 /* IF MS-KERMIT */
#define XXIFWI 47 /* IF WILD */
#define XXIFLO 48 /* IF LOCAL */
#define XXIFCM 49 /* IF COMMAND */
#define XXIFFP 50 /* IF FLOAT */
#define XXIFIK 51 /* IF IKS */
#define XXIFKB 52 /* IF KBHIT */
#define XXIFKG 53 /* IF KERBANG */
#define XXIFVE 54 /* IF VERSION */
#define XXIFDC 55 /* IF DECLARED */
#define XXIFGU 56 /* IF GUI */
#define XXIFLN 57 /* IF LINK */
#define XXIFDB 58 /* IF DEBUG */
struct keytab iftab[] = { /* IF commands */
{ "!", XXIFNO, 0 },
{ "!=", XXIFNQ, 0 },
{ "&&", XXIFAN, 0 },
{ "(", XXIFLP, 0 },
{ ")", XXIFRP, 0 },
{ "<", XXIFLT, 0 },
{ "<=", XXIFLE, 0 },
{ "=", XXIFAE, 0 },
{ "==", XXIFAE, CM_INV },
{ ">", XXIFGT, 0 },
{ ">=", XXIFGE, 0 },
{ "absolute", XXIFAB, 0 },
{ "alarm", XXIFAL, 0 },
{ "and", XXIFAN, 0 },
{ "asktimeout", XXIFAT, 0 },
{ "available", XXIFAV, 0 },
{ "background", XXIFBG, 0 },
{ "c-kermit", XXIFCK, 0 },
{ "command", XXIFCM, 0 },
{ "count", XXIFCO, 0 },
{ "dcl", XXIFDC, CM_INV },
{ "debug", XXIFDB, 0 },
{ "declared", XXIFDC, 0 },
{ "defined", XXIFDE, 0 },
#ifdef CK_TMPDIR
{ "directory", XXIFDI, 0 },
#endif /* CK_TMPDIR */
{ "emulation", XXIFEM, 0 },
#ifdef COMMENT
{ "eof", XXIFEO, 0 },
#endif /* COMMENT */
{ "equal", XXIFEQ, 0 },
{ "error", XXIFFA, CM_INV },
{ "exist", XXIFEX, 0 },
{ "failure", XXIFFA, 0 },
{ "false", XXIFNT, 0 },
{ "flag", XXIFFL, 0 },
#ifdef CKFLOAT
{ "float", XXIFFP, 0 },
#endif /* CKFLOAT */
{ "foreground", XXIFFG, 0 },
#ifdef OS2
{ "gui", XXIFGU, 0 },
#else
{ "gui", XXIFGU, CM_INV },
#endif /* OS2 */
#ifdef IKSD
{ "iksd", XXIFIK, 0 },
#else
{ "iksd", XXIFIK, CM_INV },
#endif /* IKSD */
{ "integer", XXIFNU, CM_INV },
{ "k-95", XXIFK9, 0 },
{ "kbhit", XXIFKB, 0 },
#ifdef UNIX
{ "kerbang", XXIFKG, 0 },
#else
{ "kerbang", XXIFKG, CM_INV },
#endif /* UNIX */
{ "lgt", XXIFLG, 0 },
#ifdef UNIX
{ "link", XXIFLN, 0 },
#endif /* UNIX */
{ "llt", XXIFLL, 0 },
{ "local", XXIFLO, 0 },
{ "match", XXIFMA, 0 },
{ "ms-kermit", XXIFMS, CM_INV },
#ifdef ZFCDAT
{ "newer", XXIFNE, 0 },
#endif /* ZFCDAT */
{ "not", XXIFNO, 0 },
{ "numeric", XXIFNU, 0 },
{ "ok", XXIFSU, CM_INV },
{ "open", XXIFOP, 0 },
{ "or", XXIFOR, 0 },
{ "quiet", XXIFQU, 0 },
{ "readable", XXIFRD, 0 },
{ "remote-only",XXIFRO, 0 },
{ "started-from-dialer",XXIFSD, CM_INV },
{ "success", XXIFSU, 0 },
{ "tapi", XXIFTA, 0 },
#ifdef OS2
{ "terminal-macro", XXIFTM, 0 },
#else
{ "terminal-macro", XXIFTM, CM_INV },
#endif /* OS2 */
{ "true", XXIFTR, 0 },
{ "version", XXIFVE, 0 },
{ "wild", XXIFWI, 0 },
{ "writeable", XXIFWR, 0 },
{ "||", XXIFOR, 0 },
{ "", 0, 0 }
};
int nif = (sizeof(iftab) / sizeof(struct keytab)) - 1;
struct keytab iotab[] = { /* Keywords for IF OPEN */
{ "!read-file", ZRFILE, CM_INV },
{ "!write-file", ZWFILE, CM_INV },
{ "append-file", ZWFILE, CM_INV },
{ "connection", 8888, 0 },
#ifdef CKLOGDIAL
{ "cx-log", 7777, 0 },
#endif /* CKLOGDIAL */
{ "debug-log", ZDFILE, 0 },
{ "error", 9999, 0 },
{ "packet-log", ZPFILE, 0 },
{ "read-file", ZRFILE, 0 },
{ "screen", ZSTDIO, 0 },
{ "session-log", ZSFILE, 0 },
{ "transaction-log", ZTFILE, 0 },
{ "write-file", ZWFILE, 0 }
};
int niot = (sizeof(iotab) / sizeof(struct keytab));
#endif /* NOSPL */
/* Variables and prototypes */
_PROTOTYP(static int doymdir,(int));
_PROTOTYP(static int renameone,(char *,char *,
int,int,int,int,int,int,int,int,int,int,int));
#ifdef NETCONN
extern int nnetdir; /* How many network directories */
#endif /* NETCONN */
#ifdef CK_SECURITY
_PROTOTYP(int ck_krb4_is_installed,(void));
_PROTOTYP(int ck_krb5_is_installed,(void));
_PROTOTYP(int ck_ntlm_is_installed,(void));
_PROTOTYP(int ck_srp_is_installed,(void));
_PROTOTYP(int ck_ssleay_is_installed,(void));
_PROTOTYP(int ck_ssh_is_installed,(void));
_PROTOTYP(int ck_crypt_is_installed,(void));
#else
#define ck_krb4_is_installed() (0)
#define ck_krb5_is_installed() (0)
#define ck_ntlm_is_installed() (0)
#define ck_srp_is_installed() (0)
#define ck_ssleay_is_installed() (0)
#define ck_ssh_is_installed() (0)
#define ck_crypt_is_installed() (0)
#endif /* CK_SECURITY */
#define AV_KRB4 1
#define AV_KRB5 2
#define AV_NTLM 3
#define AV_SRP 4
#define AV_SSL 5
#define AV_CRYPTO 6
#define AV_SSH 7
struct keytab availtab[] = { /* Available authentication types */
{ "crypto", AV_CRYPTO, CM_INV }, /* and encryption */
{ "encryption", AV_CRYPTO, 0 },
{ "k4", AV_KRB4, CM_INV },
{ "k5", AV_KRB5, CM_INV },
{ "kerberos4", AV_KRB4, 0 },
{ "kerberos5", AV_KRB5, 0 },
{ "krb4", AV_KRB4, CM_INV },
{ "krb5", AV_KRB5, CM_INV },
{ "ntlm", AV_NTLM, 0 },
{ "srp", AV_SRP, 0 },
{ "ssh", AV_SSH, 0 },
{ "ssl", AV_SSL, 0 },
{ "tls", AV_SSL, 0 },
{ "", 0, 0 }
};
int availtabn = sizeof(availtab)/sizeof(struct keytab)-1;
#ifndef NODIAL
_PROTOTYP(static int ddcvt, (char *, FILE *, int) );
_PROTOTYP(static int dncvt, (int, int, int, int) );
_PROTOTYP(char * getdname, (void) );
static int partial = 0; /* For partial dial */
static char *dscopy = NULL;
int dialtype = -1;
char *dialnum = (char *)0; /* Remember DIAL number for REDIAL */
int dirline = 0; /* Dial directory line number */
extern char * dialdir[]; /* Dial directory file names */
extern int dialdpy; /* DIAL DISPLAY on/off */
extern int ndialdir; /* How many dial directories */
extern int ntollfree; /* Toll-free call info */
extern int ndialpxx; /* List of PBX exchanges */
extern char *dialtfc[];
char * matchpxx = NULL; /* PBX exchange that matched */
extern int nlocalac; /* Local area-code list */
extern char * diallcac[];
extern int tttapi;
#ifdef CK_TAPI
extern int tapiconv; /* TAPI Conversions */
extern int tapipass; /* TAPI Passthrough */
#endif /* CK_TAPI */
extern int dialatmo;
extern char * dialnpr, * dialsfx;
extern char * dialixp, * dialixs, * dialmac;
extern char * dialldp, * diallds, * dialtfp;
extern char * dialpxi, * dialpxo, * diallac;
extern char * diallcp, * diallcs, * diallcc;
extern char * dialpxx[];
extern int dialcnf; /* DIAL CONFIRMATION */
int dialfld = 0; /* DIAL FORCE-LONG-DISTANCE */
int dialsrt = 1; /* DIAL SORT ON */
int dialrstr = 6; /* DIAL RESTRICTION */
int dialtest = 0; /* DIAL TEST */
int dialcount = 0; /* \v(dialcount) */
extern int dialsta; /* Dial status */
int dialrtr = -1, /* Dial retries */
dialint = 10; /* Dial retry interval */
extern long dialcapas; /* Modem capabilities */
extern int dialcvt; /* DIAL CONVERT-DIRECTORY */
#endif /* NODIAL */
#ifndef NOSPL
#define IFCONDLEN 256
int ifc, /* IF case */
not = 0, /* Flag for IF NOT */
ifargs = 0; /* Count of IF condition words */
char ifcond[IFCONDLEN]; /* IF condition text */
char *ifcp; /* Pointer to IF condition text */
extern int vareval;
#ifdef DCMDBUF
extern int
*ifcmd, *count, *iftest, *intime,
*inpcas, *takerr, *merror, *xquiet, *xvarev;
#else
extern int ifcmd[]; /* Last command was IF */
extern int iftest[]; /* Last IF was true */
extern int count[]; /* For IF COUNT, one for each cmdlvl */
extern int intime[]; /* Ditto for other stackables... */
extern int inpcas[];
extern int takerr[];
extern int merror[];
extern int xquiet[];
extern int xvarev[];
#endif /* DCMDBUF */
#else
extern int takerr[];
#endif /* NOSPL */
#ifdef DCMDBUF
extern char *line; /* Character buffer for anything */
extern char *tmpbuf;
#else
extern char line[], tmpbuf[];
#endif /* DCMDBUF */
extern char *lp; /* Pointer to line buffer */
int cwdf = 0; /* CWD has been done */
/* Flags for ENABLE/DISABLE */
extern int en_cwd, en_cpy, en_del, en_dir, en_fin,
en_get, en_hos, en_ren, en_sen, en_set, en_spa, en_typ, en_who, en_bye,
en_asg, en_que, en_ret, en_mai, en_pri, en_mkd, en_rmd, en_xit, en_ena;
extern FILE *tfile[]; /* File pointers for TAKE command */
extern char *tfnam[]; /* Names of TAKE files */
extern int tfline[]; /* TAKE-file line number */
extern int success; /* Command success/failure flag */
extern int cmdlvl; /* Current position in command stack */
#ifndef NOSPL
extern int maclvl; /* Macro to execute */
extern char *macx[]; /* Index of current macro */
extern char *mrval[]; /* Macro return value */
extern char *macp[]; /* Pointer to macro */
extern int macargc[]; /* ARGC from macro invocation */
#ifdef COMMENT
extern char *m_line[];
#endif /* COMMENT */
extern char *m_arg[MACLEVEL][NARGS]; /* Stack of macro arguments */
extern char *g_var[]; /* Global variables %a, %b, etc */
#ifdef DCMDBUF
extern struct cmdptr *cmdstk; /* The command stack itself */
#else
extern struct cmdptr cmdstk[]; /* The command stack itself */
#endif /* DCMDBUF */
#endif /* NOSPL */
#define xsystem(s) zsyscmd(s)
static int x, y, z = 0;
static char *s, *p;
#ifdef OS2
_PROTOTYP( int os2settitle, (char *, int) );
#endif /* OS2 */
extern struct keytab yesno[], onoff[], fntab[];
extern int nyesno, nfntab;
#ifndef NOSPL
/* Do the ASK, ASKQ, GETOK, and READ commands */
int asktimedout = 0;
#define ASK_PUP 1
#define ASK_TMO 2
#define ASK_GUI 3
#define ASK_QUI 4
#define ASK_DEF 5
#define ASK_ECH 6
static struct keytab asktab[] = {
{ "/default", ASK_DEF, CM_ARG },
{ "/gui", ASK_GUI,
#ifdef KUI
0
#else /* KUI */
CM_INV
#endif /* KUI */
},
{ "/popup", ASK_PUP,
#ifdef OS2
0
#else /* OS2 */
CM_INV
#endif /* OS2 */
},
{ "/quiet", ASK_QUI, 0 },
{ "/timeout", ASK_TMO, CM_ARG },
{ "", 0, 0 }
};
static int nasktab = sizeof(asktab)/sizeof(struct keytab)-1;
static struct keytab askqtab[] = {
{ "/default", ASK_DEF, CM_ARG },
{ "/echo", ASK_ECH, CM_ARG },
{ "/gui", ASK_GUI,
#ifdef KUI
0
#else /* KUI */
CM_INV
#endif /* KUI */
},
{ "/noecho", ASK_QUI, CM_INV },
{ "/popup", ASK_PUP,
#ifdef OS2
0
#else /* OS2 */
CM_INV
#endif /* OS2 */
},
{ "/quiet", ASK_QUI, 0 },
{ "/timeout", ASK_TMO, CM_ARG },
{ "", 0, 0 }
};
static int naskqtab = sizeof(askqtab)/sizeof(struct keytab)-1;
int
doask(cx) int cx; {
extern int asktimer, timelimit;
#ifdef CK_RECALL
extern int on_recall;
#endif /* CK_RECALL */
int echochar = 0;
int popupflg = 0;
int guiflg = 0;
int nomsg = 0;
int mytimer = 0;
#ifdef CK_APC
extern int apcactive, apcstatus;
#endif /* CK_APC */
char dfbuf[1024]; /* Buffer for default answer */
char * dfanswer = NULL; /* Pointer to it */
char vnambuf[VNAML+1]; /* Buffer for variable names */
char *vnp = NULL; /* Pointer to same */
dfbuf[0] = NUL;
vnambuf[0] = NUL;
#ifdef CK_APC
if ( apcactive != APC_INACTIVE && (apcstatus & APC_NOINP) ) {
return(success = 0);
}
#endif /* CK_APC */
mytimer = asktimer; /* Inherit global ASK timer */
echostars = 0; /* For ASKQ */
if (cx == XXASK || cx == XXASKQ) {
struct FDB sw, fl;
int getval;
char c;
if (cx == XXASKQ) /* Don't log ASKQ response */
debok = 0;
cmfdbi(&sw, /* First FDB - command switches */
_CMKEY, /* fcode */
"Variable name or switch",
"", /* default */
"", /* addtl string data */
((cx == XXASK) ? nasktab : naskqtab), /* Table size */
4, /* addtl numeric data 2: 4 = cmswi */
xxstring, /* Processing function */
((cx == XXASK) ? asktab : askqtab), /* Keyword table */
&fl /* Pointer to next FDB */
);
cmfdbi(&fl, /* Anything that doesn't match */
_CMFLD, /* fcode */
"", /* hlpmsg */
"", /* default */
"", /* addtl string data */
0, /* addtl numeric data 1 */
0, /* addtl numeric data 2 */
NULL,
NULL,
NULL
);
while (1) { /* Parse 0 or more switches */
x = cmfdb(&sw); /* Parse something */
if (x < 0)
return(x);
if (cmresult.fcode != _CMKEY) /* Break out if not a switch */
break;
c = cmgbrk();
if ((getval = (c == ':' || c == '=')) && !(cmgkwflgs() & CM_ARG)) {
printf("?This switch does not take an argument\n");
return(-9);
}
if (!getval && (cmgkwflgs() & CM_ARG)) {
printf("?This switch requires an argument\n");
return(-9);
}
switch (cmresult.nresult) {
case ASK_QUI:
nomsg = 1;
if (cx == XXASKQ)
echostars = 0;
break;
case ASK_PUP:
popupflg = 1;
break;
case ASK_GUI:
guiflg = 1;
break;
case ASK_TMO: {
if ((y = cmnum("seconds","1",10,&x,xxstring)) < 0)
return(y);
if (x < 0)
x = 0;
mytimer = x;
break;
}
case ASK_ECH: {
if ((y = cmfld("Character to echo","*",&s,xxstring)) < 0)
return(y);
echochar = *s;
break;
}
case ASK_DEF: {
if ((y = cmfld("Text to supply if reply is empty",
"",&s,xxstring)) < 0)
return(y);
ckstrncpy(dfbuf,s,1024);
dfanswer = dfbuf;
break;
}
default: return(-2);
}
}
/* Have variable name, make copy. */
ckstrncpy(vnambuf,cmresult.sresult,VNAML);
vnp = vnambuf;
if (vnambuf[0] == CMDQ &&
(vnambuf[1] == '%' || vnambuf[1] == '&'))
vnp++;
y = 0;
if (*vnp == '%' || *vnp == '&') {
if ((y = parsevar(vnp,&x,&z)) < 0)
return(y);
}
} else if (cx != XXGOK && cx != XXRDBL) { /* Get variable name */
if ((y = cmfld("Variable name","",&s,NULL)) < 0) {
if (y == -3) {