File: ckuus5.c

package info (click to toggle)
ckermit 305~alpha02-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 11,228 kB
  • sloc: ansic: 256,830; makefile: 5,103; sh: 66
file content (12695 lines) | stat: -rw-r--r-- 399,030 bytes parent folder | download
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
9387
9388
9389
9390
9391
9392
9393
9394
9395
9396
9397
9398
9399
9400
9401
9402
9403
9404
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481
9482
9483
9484
9485
9486
9487
9488
9489
9490
9491
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504
9505
9506
9507
9508
9509
9510
9511
9512
9513
9514
9515
9516
9517
9518
9519
9520
9521
9522
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
9545
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
9556
9557
9558
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592
9593
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637
9638
9639
9640
9641
9642
9643
9644
9645
9646
9647
9648
9649
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663
9664
9665
9666
9667
9668
9669
9670
9671
9672
9673
9674
9675
9676
9677
9678
9679
9680
9681
9682
9683
9684
9685
9686
9687
9688
9689
9690
9691
9692
9693
9694
9695
9696
9697
9698
9699
9700
9701
9702
9703
9704
9705
9706
9707
9708
9709
9710
9711
9712
9713
9714
9715
9716
9717
9718
9719
9720
9721
9722
9723
9724
9725
9726
9727
9728
9729
9730
9731
9732
9733
9734
9735
9736
9737
9738
9739
9740
9741
9742
9743
9744
9745
9746
9747
9748
9749
9750
9751
9752
9753
9754
9755
9756
9757
9758
9759
9760
9761
9762
9763
9764
9765
9766
9767
9768
9769
9770
9771
9772
9773
9774
9775
9776
9777
9778
9779
9780
9781
9782
9783
9784
9785
9786
9787
9788
9789
9790
9791
9792
9793
9794
9795
9796
9797
9798
9799
9800
9801
9802
9803
9804
9805
9806
9807
9808
9809
9810
9811
9812
9813
9814
9815
9816
9817
9818
9819
9820
9821
9822
9823
9824
9825
9826
9827
9828
9829
9830
9831
9832
9833
9834
9835
9836
9837
9838
9839
9840
9841
9842
9843
9844
9845
9846
9847
9848
9849
9850
9851
9852
9853
9854
9855
9856
9857
9858
9859
9860
9861
9862
9863
9864
9865
9866
9867
9868
9869
9870
9871
9872
9873
9874
9875
9876
9877
9878
9879
9880
9881
9882
9883
9884
9885
9886
9887
9888
9889
9890
9891
9892
9893
9894
9895
9896
9897
9898
9899
9900
9901
9902
9903
9904
9905
9906
9907
9908
9909
9910
9911
9912
9913
9914
9915
9916
9917
9918
9919
9920
9921
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933
9934
9935
9936
9937
9938
9939
9940
9941
9942
9943
9944
9945
9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973
9974
9975
9976
9977
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
9996
9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115
10116
10117
10118
10119
10120
10121
10122
10123
10124
10125
10126
10127
10128
10129
10130
10131
10132
10133
10134
10135
10136
10137
10138
10139
10140
10141
10142
10143
10144
10145
10146
10147
10148
10149
10150
10151
10152
10153
10154
10155
10156
10157
10158
10159
10160
10161
10162
10163
10164
10165
10166
10167
10168
10169
10170
10171
10172
10173
10174
10175
10176
10177
10178
10179
10180
10181
10182
10183
10184
10185
10186
10187
10188
10189
10190
10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
10201
10202
10203
10204
10205
10206
10207
10208
10209
10210
10211
10212
10213
10214
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235
10236
10237
10238
10239
10240
10241
10242
10243
10244
10245
10246
10247
10248
10249
10250
10251
10252
10253
10254
10255
10256
10257
10258
10259
10260
10261
10262
10263
10264
10265
10266
10267
10268
10269
10270
10271
10272
10273
10274
10275
10276
10277
10278
10279
10280
10281
10282
10283
10284
10285
10286
10287
10288
10289
10290
10291
10292
10293
10294
10295
10296
10297
10298
10299
10300
10301
10302
10303
10304
10305
10306
10307
10308
10309
10310
10311
10312
10313
10314
10315
10316
10317
10318
10319
10320
10321
10322
10323
10324
10325
10326
10327
10328
10329
10330
10331
10332
10333
10334
10335
10336
10337
10338
10339
10340
10341
10342
10343
10344
10345
10346
10347
10348
10349
10350
10351
10352
10353
10354
10355
10356
10357
10358
10359
10360
10361
10362
10363
10364
10365
10366
10367
10368
10369
10370
10371
10372
10373
10374
10375
10376
10377
10378
10379
10380
10381
10382
10383
10384
10385
10386
10387
10388
10389
10390
10391
10392
10393
10394
10395
10396
10397
10398
10399
10400
10401
10402
10403
10404
10405
10406
10407
10408
10409
10410
10411
10412
10413
10414
10415
10416
10417
10418
10419
10420
10421
10422
10423
10424
10425
10426
10427
10428
10429
10430
10431
10432
10433
10434
10435
10436
10437
10438
10439
10440
10441
10442
10443
10444
10445
10446
10447
10448
10449
10450
10451
10452
10453
10454
10455
10456
10457
10458
10459
10460
10461
10462
10463
10464
10465
10466
10467
10468
10469
10470
10471
10472
10473
10474
10475
10476
10477
10478
10479
10480
10481
10482
10483
10484
10485
10486
10487
10488
10489
10490
10491
10492
10493
10494
10495
10496
10497
10498
10499
10500
10501
10502
10503
10504
10505
10506
10507
10508
10509
10510
10511
10512
10513
10514
10515
10516
10517
10518
10519
10520
10521
10522
10523
10524
10525
10526
10527
10528
10529
10530
10531
10532
10533
10534
10535
10536
10537
10538
10539
10540
10541
10542
10543
10544
10545
10546
10547
10548
10549
10550
10551
10552
10553
10554
10555
10556
10557
10558
10559
10560
10561
10562
10563
10564
10565
10566
10567
10568
10569
10570
10571
10572
10573
10574
10575
10576
10577
10578
10579
10580
10581
10582
10583
10584
10585
10586
10587
10588
10589
10590
10591
10592
10593
10594
10595
10596
10597
10598
10599
10600
10601
10602
10603
10604
10605
10606
10607
10608
10609
10610
10611
10612
10613
10614
10615
10616
10617
10618
10619
10620
10621
10622
10623
10624
10625
10626
10627
10628
10629
10630
10631
10632
10633
10634
10635
10636
10637
10638
10639
10640
10641
10642
10643
10644
10645
10646
10647
10648
10649
10650
10651
10652
10653
10654
10655
10656
10657
10658
10659
10660
10661
10662
10663
10664
10665
10666
10667
10668
10669
10670
10671
10672
10673
10674
10675
10676
10677
10678
10679
10680
10681
10682
10683
10684
10685
10686
10687
10688
10689
10690
10691
10692
10693
10694
10695
10696
10697
10698
10699
10700
10701
10702
10703
10704
10705
10706
10707
10708
10709
10710
10711
10712
10713
10714
10715
10716
10717
10718
10719
10720
10721
10722
10723
10724
10725
10726
10727
10728
10729
10730
10731
10732
10733
10734
10735
10736
10737
10738
10739
10740
10741
10742
10743
10744
10745
10746
10747
10748
10749
10750
10751
10752
10753
10754
10755
10756
10757
10758
10759
10760
10761
10762
10763
10764
10765
10766
10767
10768
10769
10770
10771
10772
10773
10774
10775
10776
10777
10778
10779
10780
10781
10782
10783
10784
10785
10786
10787
10788
10789
10790
10791
10792
10793
10794
10795
10796
10797
10798
10799
10800
10801
10802
10803
10804
10805
10806
10807
10808
10809
10810
10811
10812
10813
10814
10815
10816
10817
10818
10819
10820
10821
10822
10823
10824
10825
10826
10827
10828
10829
10830
10831
10832
10833
10834
10835
10836
10837
10838
10839
10840
10841
10842
10843
10844
10845
10846
10847
10848
10849
10850
10851
10852
10853
10854
10855
10856
10857
10858
10859
10860
10861
10862
10863
10864
10865
10866
10867
10868
10869
10870
10871
10872
10873
10874
10875
10876
10877
10878
10879
10880
10881
10882
10883
10884
10885
10886
10887
10888
10889
10890
10891
10892
10893
10894
10895
10896
10897
10898
10899
10900
10901
10902
10903
10904
10905
10906
10907
10908
10909
10910
10911
10912
10913
10914
10915
10916
10917
10918
10919
10920
10921
10922
10923
10924
10925
10926
10927
10928
10929
10930
10931
10932
10933
10934
10935
10936
10937
10938
10939
10940
10941
10942
10943
10944
10945
10946
10947
10948
10949
10950
10951
10952
10953
10954
10955
10956
10957
10958
10959
10960
10961
10962
10963
10964
10965
10966
10967
10968
10969
10970
10971
10972
10973
10974
10975
10976
10977
10978
10979
10980
10981
10982
10983
10984
10985
10986
10987
10988
10989
10990
10991
10992
10993
10994
10995
10996
10997
10998
10999
11000
11001
11002
11003
11004
11005
11006
11007
11008
11009
11010
11011
11012
11013
11014
11015
11016
11017
11018
11019
11020
11021
11022
11023
11024
11025
11026
11027
11028
11029
11030
11031
11032
11033
11034
11035
11036
11037
11038
11039
11040
11041
11042
11043
11044
11045
11046
11047
11048
11049
11050
11051
11052
11053
11054
11055
11056
11057
11058
11059
11060
11061
11062
11063
11064
11065
11066
11067
11068
11069
11070
11071
11072
11073
11074
11075
11076
11077
11078
11079
11080
11081
11082
11083
11084
11085
11086
11087
11088
11089
11090
11091
11092
11093
11094
11095
11096
11097
11098
11099
11100
11101
11102
11103
11104
11105
11106
11107
11108
11109
11110
11111
11112
11113
11114
11115
11116
11117
11118
11119
11120
11121
11122
11123
11124
11125
11126
11127
11128
11129
11130
11131
11132
11133
11134
11135
11136
11137
11138
11139
11140
11141
11142
11143
11144
11145
11146
11147
11148
11149
11150
11151
11152
11153
11154
11155
11156
11157
11158
11159
11160
11161
11162
11163
11164
11165
11166
11167
11168
11169
11170
11171
11172
11173
11174
11175
11176
11177
11178
11179
11180
11181
11182
11183
11184
11185
11186
11187
11188
11189
11190
11191
11192
11193
11194
11195
11196
11197
11198
11199
11200
11201
11202
11203
11204
11205
11206
11207
11208
11209
11210
11211
11212
11213
11214
11215
11216
11217
11218
11219
11220
11221
11222
11223
11224
11225
11226
11227
11228
11229
11230
11231
11232
11233
11234
11235
11236
11237
11238
11239
11240
11241
11242
11243
11244
11245
11246
11247
11248
11249
11250
11251
11252
11253
11254
11255
11256
11257
11258
11259
11260
11261
11262
11263
11264
11265
11266
11267
11268
11269
11270
11271
11272
11273
11274
11275
11276
11277
11278
11279
11280
11281
11282
11283
11284
11285
11286
11287
11288
11289
11290
11291
11292
11293
11294
11295
11296
11297
11298
11299
11300
11301
11302
11303
11304
11305
11306
11307
11308
11309
11310
11311
11312
11313
11314
11315
11316
11317
11318
11319
11320
11321
11322
11323
11324
11325
11326
11327
11328
11329
11330
11331
11332
11333
11334
11335
11336
11337
11338
11339
11340
11341
11342
11343
11344
11345
11346
11347
11348
11349
11350
11351
11352
11353
11354
11355
11356
11357
11358
11359
11360
11361
11362
11363
11364
11365
11366
11367
11368
11369
11370
11371
11372
11373
11374
11375
11376
11377
11378
11379
11380
11381
11382
11383
11384
11385
11386
11387
11388
11389
11390
11391
11392
11393
11394
11395
11396
11397
11398
11399
11400
11401
11402
11403
11404
11405
11406
11407
11408
11409
11410
11411
11412
11413
11414
11415
11416
11417
11418
11419
11420
11421
11422
11423
11424
11425
11426
11427
11428
11429
11430
11431
11432
11433
11434
11435
11436
11437
11438
11439
11440
11441
11442
11443
11444
11445
11446
11447
11448
11449
11450
11451
11452
11453
11454
11455
11456
11457
11458
11459
11460
11461
11462
11463
11464
11465
11466
11467
11468
11469
11470
11471
11472
11473
11474
11475
11476
11477
11478
11479
11480
11481
11482
11483
11484
11485
11486
11487
11488
11489
11490
11491
11492
11493
11494
11495
11496
11497
11498
11499
11500
11501
11502
11503
11504
11505
11506
11507
11508
11509
11510
11511
11512
11513
11514
11515
11516
11517
11518
11519
11520
11521
11522
11523
11524
11525
11526
11527
11528
11529
11530
11531
11532
11533
11534
11535
11536
11537
11538
11539
11540
11541
11542
11543
11544
11545
11546
11547
11548
11549
11550
11551
11552
11553
11554
11555
11556
11557
11558
11559
11560
11561
11562
11563
11564
11565
11566
11567
11568
11569
11570
11571
11572
11573
11574
11575
11576
11577
11578
11579
11580
11581
11582
11583
11584
11585
11586
11587
11588
11589
11590
11591
11592
11593
11594
11595
11596
11597
11598
11599
11600
11601
11602
11603
11604
11605
11606
11607
11608
11609
11610
11611
11612
11613
11614
11615
11616
11617
11618
11619
11620
11621
11622
11623
11624
11625
11626
11627
11628
11629
11630
11631
11632
11633
11634
11635
11636
11637
11638
11639
11640
11641
11642
11643
11644
11645
11646
11647
11648
11649
11650
11651
11652
11653
11654
11655
11656
11657
11658
11659
11660
11661
11662
11663
11664
11665
11666
11667
11668
11669
11670
11671
11672
11673
11674
11675
11676
11677
11678
11679
11680
11681
11682
11683
11684
11685
11686
11687
11688
11689
11690
11691
11692
11693
11694
11695
11696
11697
11698
11699
11700
11701
11702
11703
11704
11705
11706
11707
11708
11709
11710
11711
11712
11713
11714
11715
11716
11717
11718
11719
11720
11721
11722
11723
11724
11725
11726
11727
11728
11729
11730
11731
11732
11733
11734
11735
11736
11737
11738
11739
11740
11741
11742
11743
11744
11745
11746
11747
11748
11749
11750
11751
11752
11753
11754
11755
11756
11757
11758
11759
11760
11761
11762
11763
11764
11765
11766
11767
11768
11769
11770
11771
11772
11773
11774
11775
11776
11777
11778
11779
11780
11781
11782
11783
11784
11785
11786
11787
11788
11789
11790
11791
11792
11793
11794
11795
11796
11797
11798
11799
11800
11801
11802
11803
11804
11805
11806
11807
11808
11809
11810
11811
11812
11813
11814
11815
11816
11817
11818
11819
11820
11821
11822
11823
11824
11825
11826
11827
11828
11829
11830
11831
11832
11833
11834
11835
11836
11837
11838
11839
11840
11841
11842
11843
11844
11845
11846
11847
11848
11849
11850
11851
11852
11853
11854
11855
11856
11857
11858
11859
11860
11861
11862
11863
11864
11865
11866
11867
11868
11869
11870
11871
11872
11873
11874
11875
11876
11877
11878
11879
11880
11881
11882
11883
11884
11885
11886
11887
11888
11889
11890
11891
11892
11893
11894
11895
11896
11897
11898
11899
11900
11901
11902
11903
11904
11905
11906
11907
11908
11909
11910
11911
11912
11913
11914
11915
11916
11917
11918
11919
11920
11921
11922
11923
11924
11925
11926
11927
11928
11929
11930
11931
11932
11933
11934
11935
11936
11937
11938
11939
11940
11941
11942
11943
11944
11945
11946
11947
11948
11949
11950
11951
11952
11953
11954
11955
11956
11957
11958
11959
11960
11961
11962
11963
11964
11965
11966
11967
11968
11969
11970
11971
11972
11973
11974
11975
11976
11977
11978
11979
11980
11981
11982
11983
11984
11985
11986
11987
11988
11989
11990
11991
11992
11993
11994
11995
11996
11997
11998
11999
12000
12001
12002
12003
12004
12005
12006
12007
12008
12009
12010
12011
12012
12013
12014
12015
12016
12017
12018
12019
12020
12021
12022
12023
12024
12025
12026
12027
12028
12029
12030
12031
12032
12033
12034
12035
12036
12037
12038
12039
12040
12041
12042
12043
12044
12045
12046
12047
12048
12049
12050
12051
12052
12053
12054
12055
12056
12057
12058
12059
12060
12061
12062
12063
12064
12065
12066
12067
12068
12069
12070
12071
12072
12073
12074
12075
12076
12077
12078
12079
12080
12081
12082
12083
12084
12085
12086
12087
12088
12089
12090
12091
12092
12093
12094
12095
12096
12097
12098
12099
12100
12101
12102
12103
12104
12105
12106
12107
12108
12109
12110
12111
12112
12113
12114
12115
12116
12117
12118
12119
12120
12121
12122
12123
12124
12125
12126
12127
12128
12129
12130
12131
12132
12133
12134
12135
12136
12137
12138
12139
12140
12141
12142
12143
12144
12145
12146
12147
12148
12149
12150
12151
12152
12153
12154
12155
12156
12157
12158
12159
12160
12161
12162
12163
12164
12165
12166
12167
12168
12169
12170
12171
12172
12173
12174
12175
12176
12177
12178
12179
12180
12181
12182
12183
12184
12185
12186
12187
12188
12189
12190
12191
12192
12193
12194
12195
12196
12197
12198
12199
12200
12201
12202
12203
12204
12205
12206
12207
12208
12209
12210
12211
12212
12213
12214
12215
12216
12217
12218
12219
12220
12221
12222
12223
12224
12225
12226
12227
12228
12229
12230
12231
12232
12233
12234
12235
12236
12237
12238
12239
12240
12241
12242
12243
12244
12245
12246
12247
12248
12249
12250
12251
12252
12253
12254
12255
12256
12257
12258
12259
12260
12261
12262
12263
12264
12265
12266
12267
12268
12269
12270
12271
12272
12273
12274
12275
12276
12277
12278
12279
12280
12281
12282
12283
12284
12285
12286
12287
12288
12289
12290
12291
12292
12293
12294
12295
12296
12297
12298
12299
12300
12301
12302
12303
12304
12305
12306
12307
12308
12309
12310
12311
12312
12313
12314
12315
12316
12317
12318
12319
12320
12321
12322
12323
12324
12325
12326
12327
12328
12329
12330
12331
12332
12333
12334
12335
12336
12337
12338
12339
12340
12341
12342
12343
12344
12345
12346
12347
12348
12349
12350
12351
12352
12353
12354
12355
12356
12357
12358
12359
12360
12361
12362
12363
12364
12365
12366
12367
12368
12369
12370
12371
12372
12373
12374
12375
12376
12377
12378
12379
12380
12381
12382
12383
12384
12385
12386
12387
12388
12389
12390
12391
12392
12393
12394
12395
12396
12397
12398
12399
12400
12401
12402
12403
12404
12405
12406
12407
12408
12409
12410
12411
12412
12413
12414
12415
12416
12417
12418
12419
12420
12421
12422
12423
12424
12425
12426
12427
12428
12429
12430
12431
12432
12433
12434
12435
12436
12437
12438
12439
12440
12441
12442
12443
12444
12445
12446
12447
12448
12449
12450
12451
12452
12453
12454
12455
12456
12457
12458
12459
12460
12461
12462
12463
12464
12465
12466
12467
12468
12469
12470
12471
12472
12473
12474
12475
12476
12477
12478
12479
12480
12481
12482
12483
12484
12485
12486
12487
12488
12489
12490
12491
12492
12493
12494
12495
12496
12497
12498
12499
12500
12501
12502
12503
12504
12505
12506
12507
12508
12509
12510
12511
12512
12513
12514
12515
12516
12517
12518
12519
12520
12521
12522
12523
12524
12525
12526
12527
12528
12529
12530
12531
12532
12533
12534
12535
12536
12537
12538
12539
12540
12541
12542
12543
12544
12545
12546
12547
12548
12549
12550
12551
12552
12553
12554
12555
12556
12557
12558
12559
12560
12561
12562
12563
12564
12565
12566
12567
12568
12569
12570
12571
12572
12573
12574
12575
12576
12577
12578
12579
12580
12581
12582
12583
12584
12585
12586
12587
12588
12589
12590
12591
12592
12593
12594
12595
12596
12597
12598
12599
12600
12601
12602
12603
12604
12605
12606
12607
12608
12609
12610
12611
12612
12613
12614
12615
12616
12617
12618
12619
12620
12621
12622
12623
12624
12625
12626
12627
12628
12629
12630
12631
12632
12633
12634
12635
12636
12637
12638
12639
12640
12641
12642
12643
12644
12645
12646
12647
12648
12649
12650
12651
12652
12653
12654
12655
12656
12657
12658
12659
12660
12661
12662
12663
12664
12665
12666
12667
12668
12669
12670
12671
12672
12673
12674
12675
12676
12677
12678
12679
12680
12681
12682
12683
12684
12685
12686
12687
12688
12689
12690
12691
12692
12693
12694
12695
#include "ckcsym.h"

int xcmdsrc = 0;

#ifdef NOICP
int cmdsrc() { return(0); }
#endif /* NOICP */

/*  C K U U S 5 --  "User Interface" for C-Kermit, part 5  */

/*
  Authors:
    Frank da Cruz <fdc@columbia.edu>,
      The Kermit Project, New York City
    Jeffrey E Altman <jaltman@secure-endpoints.com>
      Secure Endpoints Inc., New York City

  Copyright (C) 1985, 2017,
    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"

#ifdef DCMDBUF
char *line;                             /* Character buffer for anything */
char *tmpbuf;
#else
char line[LINBUFSIZ+1];
char tmpbuf[TMPBUFSIZ+1];               /* Temporary buffer */
#endif /* DCMDBUF */
char lasttakeline[TMPBUFSIZ+1];        /* Last TAKE-file line */

#ifndef NOICP

#include "ckcnet.h"
#ifndef NOCSETS
#include "ckcxla.h"
#endif /* NOCSETS */
#ifdef MAC
#include "ckmasm.h"
#endif /* MAC */
#ifdef CK_SSL
#include "ck_ssl.h"
#endif /* CK_SSL */

extern char * ck_cryear;       /* (ckcmai.c) Latest C-Kermit copyright year */

#ifdef OS2
#include "ckoetc.h"
#ifndef NT
#define INCL_NOPM
#define INCL_VIO /* Needed for ckocon.h */
#include <os2.h>
#undef COMMENT
#else /* NT */
#include <windows.h>
#define TAPI_CURRENT_VERSION 0x00010004
#include <tapi.h>
#include <mcx.h>
#include "ckntap.h"
#define APIRET ULONG
extern int DialerHandle;
extern int StartedFromDialer;
#endif /* NT */
#include "ckocon.h"
#include "ckokey.h"
#ifdef KUI
#include "ikui.h"
#endif /* KUI */
#ifdef putchar
#undef putchar
#endif /* putchar */
#define putchar(x) conoc(x)
extern int cursor_save ;
extern bool cursorena[] ;
#endif /* OS2 */

/* 2010-03-09 SMS.  VAX C V3.1-051 needs <stat.h> for off_t. */
#ifdef VMS
#include <stat.h>
#endif /* def VMS */

/* For formatted screens, "more?" prompting, etc. */

#ifdef FT18
#define isxdigit(c) isdigit(c)
#endif /* FT18 */

#ifdef STRATUS                          /* Stratus Computer, Inc.  VOS */
#ifdef putchar
#undef putchar
#endif /* putchar */
#define putchar(x) conoc(x)
#ifdef getchar
#undef getchar
#endif /* getchar */
#define getchar(x) coninc(0)
#endif /* STRATUS */

/* External variables */

extern int carrier, cdtimo, local, quiet, backgrd, bgset, sosi, xsuspend,
  binary, escape, xargs, flow, cmdmsk, duplex, ckxech, seslog, what,
  inserver, diractive, tlevel, cwdf, nfuncs, msgflg, remappd, hints, mdmtyp,
  zincnt, cmask, rcflag, success, xitsta, pflag, tnlm, tn_nlm, xitwarn,
  debses, xaskmore, parity, saveask, wasclosed, whyclosed, cdactive,
  rcdactive, keepallchars, cmd_err;

#ifdef LOCUS
extern int locus, autolocus;
#endif /* LOCUS */

#ifndef NOMSEND
extern int addlist;
#endif /* NOMSEND */

#ifdef CK_SPEED
extern int prefixing;
#endif /* CK_SPEED */

extern int g_matchdot;

#ifdef RECURSIVE
extern int recursive;
#endif /* RECURSIVE */
extern int xfiletype;

#ifdef IKSDCONF
extern char * iksdconf;
extern int iksdcf;
#endif /* IKSDCONF */

#ifdef CK_RECALL
extern int on_recall;
#endif /* CK_RECALL */

extern int ngetpath, exitonclose;
extern char * getpath[];
extern CHAR * epktmsg;

extern char * snd_move;
extern char * snd_rename;
extern char * rcv_move;
extern char * rcv_rename;
extern char * g_snd_move;
extern char * g_snd_rename;
extern char * g_rcv_move;
extern char * g_rcv_rename;

extern char * nm[];

#ifdef CK_UTSNAME
extern char unm_mch[];
extern char unm_mod[];
extern char unm_nam[];
extern char unm_rel[];
extern char unm_ver[];
#endif /* CK_UTSNAME */

#ifndef NOPUSH
#ifndef NOFRILLS
extern char editor[];
extern char editfile[];
extern char editopts[];
#ifdef BROWSER
extern char browser[];
extern char browsopts[];
extern char browsurl[];
#endif /* BROWSER */
#endif /*  NOFRILLS */
#endif /* NOPUSH */

#ifndef NOFRILLS
#ifndef NORENAME
_PROTOTYP(VOID shorename, (void));
#endif	/* NORENAME */
#endif	/* NOFRILLS */

#ifndef NOSERVER
extern char * x_user, * x_passwd, * x_acct;
#endif /* NOSERVER */

#ifdef CKLOGDIAL
extern int dialog;
extern char diafil[];
#endif /* CKLOGDIAL */

#ifdef CKROOT
extern int ckrooterr;
#endif /* CKROOT */

#ifndef NOSPL
extern int cfilef, xxdot, vareval;
extern char cmdfil[];

struct localvar * localhead[CMDSTKL];
struct localvar * localtail = NULL;
struct localvar * localnext = NULL;

_PROTOTYP( VOID shosexp, (void) );
_PROTOTYP( static VOID shoinput, (void) );
_PROTOTYP( static char gettok,   (void) );
_PROTOTYP( static VOID factor,   (void) );
_PROTOTYP( static VOID term,     (void) );
_PROTOTYP( static VOID termp,    (void) );
_PROTOTYP( static VOID exprp,    (void) );
_PROTOTYP( static VOID expr,     (void) );
_PROTOTYP( static VOID simple,   (void) );
_PROTOTYP( static VOID simpler,  (void) );
_PROTOTYP( static VOID simplest, (void) );
_PROTOTYP( static CK_OFF_T xparse,   (void) );
#endif /* NOSPL */
#ifndef NOSHOW
_PROTOTYP( int sho_iks, (void) );
#endif /* NOSHOW */

#ifdef MAC
char * ckprompt = "Mac-Kermit>";        /* Default prompt for Macintosh */
char * ikprompt = "IKSD>";
#else  /* Not MAC */
#ifdef NOSPL
#ifdef OS2
char * ckprompt = "K-95> ";             /* Default prompt for Win32 */
char * ikprompt = "IKSD> ";
#else
char * ckprompt = "C-Kermit>";
char * ikprompt = "IKSD>";
#endif /* NT */
#else  /* NOSPL */
#ifdef OS2
/* Default prompt for OS/2 and Win32 */
/* fdc 2013-12-06 - C-Kermit 9.0 and later is just "C-Kermit" */
#ifdef NT
#ifdef COMMENT
char * ckprompt = "[\\freplace(\\flongpath(\\v(dir)),/,\\\\)] K-95> ";
#else
char * ckprompt = "[\\freplace(\\flongpath(\\v(dir)),/,\\\\)] C-Kermit> ";
#endif /* COMMENT */
char * ikprompt = "[\\freplace(\\flongpath(\\v(dir)),/,\\\\)] IKSD> ";
#else  /* NT */
#ifdef COMMENT
char * ckprompt = "[\\freplace(\\v(dir),/,\\\\)] K-95> ";
#else
char * ckprompt = "[\\freplace(\\v(dir),/,\\\\)] C-Kermit> ";
#endif /* COMMENT */
char * ikprompt = "[\\freplace(\\v(dir),/,\\\\)] IKSD> ";
#endif /* NT */
#else  /* OS2 */
#ifdef VMS
char * ckprompt = "\\v(dir) C-Kermit>"; /* Default prompt VMS */
char * ikprompt = "\\v(dir) IKSD>";
#else
#ifdef UNIX
/* Note: parens, not brackets, because of ISO646 */
/* Collapse long paths using ~ notation if in home directory tree */
char * ckprompt = "(\\freplace(\\v(dir),\\fpathname(\\v(home)),~/)) C-Kermit>";
char * ikprompt = "(\\freplace(\\v(dir),\\fpathname(\\v(home)),~/)) IKSD>";
#else
/* Default prompt for other platforms */
char * ckprompt = "(\\v(dir)) C-Kermit>"; /* Default prompt for others */
char * ikprompt = "(\\v(dir)) IKSD>";
#endif /* UNIX */
#endif /* VMS */
#endif /* NT */
#endif /* NOSPL */
#endif /* MAC */

#ifndef CCHMAXPATH
#define CCHMAXPATH 257
#endif /* CCHMAXPATH */
char inidir[CCHMAXPATH] = { NUL, NUL }; /* Directory INI file executed from */

#ifdef TNCODE
extern int tn_b_nlm;                    /* TELNET BINARY newline mode */
#endif /* TNCODE */

#ifndef NOKVERBS
extern struct keytab kverbs[];          /* Table of \Kverbs */
extern int nkverbs;                     /* Number of \Kverbs */
#endif /* NOKVERBS */

#ifndef NOPUSH
extern int nopush;
#endif /* NOPUSH */

#ifdef CK_RECALL
extern int cm_recall;
#endif /* CK_RECALL */

extern char *ccntab[];

/* Printer stuff */

extern char *printername;
extern int printpipe;
#ifdef BPRINT
extern int printbidi, pportparity, pportflow;
extern long pportspeed;
#endif /* BPRINT */

#ifdef OS2
_PROTOTYP (int os2getcp, (void) );
_PROTOTYP (int os2getcplist, (int *, int) );
#ifdef OS2MOUSE
extern int tt_mouse;
#endif /* OS2MOUSE */
extern int tt_update, tt_updmode, updmode, tt_utf8;
#ifndef IKSDONLY
extern int tt_status[];
#endif /* IKSDONLY */
#ifdef PCFONTS
extern struct keytab term_font[];
#else
#ifdef KUI
extern struct keytab * term_font;
#endif /* KUI */
#endif /* PCFONTS */
extern int ntermfont, tt_font, tt_font_size;
extern unsigned char colornormal, colorunderline, colorstatus,
    colorhelp, colorselect, colorborder, colorgraphic, colordebug,
    colorreverse, colorcmd, coloritalic;
extern int priority;
extern struct keytab prtytab[];
extern int nprty;
char * cmdmac = NULL;
#endif /* OS2 */

#ifdef VMS
_PROTOTYP (int zkermini, (char *, int, char *) );
#endif /* VMS */

extern long vernum;
extern int inecho, insilence, inbufsize, nvars, inintr;
extern char *protv, *fnsv, *cmdv, *userv, *ckxv, *ckzv, *ckzsys, *xlav,
 *cknetv, *clcmds;
#ifdef OS2
extern char *ckyv;
#endif /* OS2 */
#ifdef CK_AUTHENTICATION
extern char * ckathv;
#endif /* CK_AUTHENTICATION */
#ifdef CK_SSL
extern char * cksslv;
#endif /* CK_SSL */
#ifdef CK_ENCRYPTION
#ifndef CRYPT_DLL
extern char * ckcrpv;
#endif /* CRYPT_DLL */
#endif /* CK_ENCRYPTION */

#ifdef SSHBUILTIN
extern char *cksshv;
#ifdef SFTP_BUILTIN
extern char *cksftpv;
#endif /* SFTP_BUILTIN */
#endif /* SSHBUILTIN */

#ifdef TNCODE
extern char *cktelv;
#endif /* TNCODE */
#ifndef NOFTP
#ifndef SYSFTP
extern char * ckftpv;
#endif /* SYSFTP */
#endif /* NOFTP */

extern int srvidl;

#ifdef OS2
extern char *ckonetv;
extern int interm;
#ifdef CK_NETBIOS
extern char *ckonbiv;
#endif /* CK_NETBIOS */
#ifdef OS2MOUSE
extern char *ckomouv;
#endif /* OS2MOUSE */
#endif /* OS2 */

#ifndef NOLOCAL
extern char *connv;
#endif /* NOLOCAL */
#ifndef NODIAL
extern char *dialv;
#endif /* NODIAL */
#ifndef NOSCRIPT
extern char *loginv;
extern int secho;
#endif /* NOSCRIPT */

#ifndef NODIAL
extern int nmdm, dirline;
extern struct keytab mdmtab[];
#endif /* NODIAL */

extern int network, nettype, ttnproto;

#ifdef OS2
#ifndef NOTERM
/* SET TERMINAL items... */
extern int tt_type, tt_arrow, tt_keypad, tt_wrap, tt_answer, tt_scrsize[];
extern int tt_bell, tt_roll[], tt_ctstmo, tt_cursor, tt_pacing, tt_type_mode;
extern char answerback[];
extern struct tt_info_rec tt_info[];    /* Indexed by terminal type */
extern int max_tt;
#endif /* NOTERM */
#endif /* OS2 */

_PROTOTYP( VOID shotrm, (void) );
_PROTOTYP( int shofea, (void) );

#ifdef OS2
extern int tt_rows[], tt_cols[];
#else /* OS2 */
extern int tt_rows, tt_cols;
#endif /* OS2 */
extern int cmd_rows, cmd_cols;

#ifdef CK_TMPDIR
extern int f_tmpdir;                    /* Directory changed temporarily */
extern char savdir[];                   /* Temporary directory */
#endif /* CK_TMPDIR */

#ifndef NOLOCAL
extern int tt_crd, tt_lfd, tt_escape;
#endif /* NOLOCAL */

#ifndef NOCSETS
extern int language, nfilc, tcsr, tcsl, tcs_transp, fcharset;
extern struct keytab fcstab[];
extern struct csinfo fcsinfo[];
#ifndef MAC
extern struct keytab ttcstab[];
#endif /* MAC */
#endif /* NOCSETS */

extern long speed;

#ifndef NOXMIT
extern int xmitf, xmitl, xmitp, xmitx, xmits, xmitw, xmitt;
extern char xmitbuf[];
#endif /* NOXMIT */

extern char **xargv, *versio, *ckxsys, *dftty, *lp;

#ifdef DCMDBUF
extern char *cmdbuf, *atmbuf;           /* Command buffers */
#ifndef NOSPL
extern char *savbuf;                    /* Command buffers */
#endif /* NOSPL */
#else
extern char cmdbuf[], atmbuf[];         /* Command buffers */
#ifndef NOSPL
extern char savbuf[];                   /* Command buffers */
#endif /* NOSPL */
#endif /* DCMDBUF */

extern char toktab[], ttname[], psave[];
extern CHAR sstate, feol;
extern int cmflgs, techo, repars, ncmd;
extern struct keytab cmdtab[];

#ifndef NOSETKEY
KEY *keymap;
#ifndef OS2
#define mapkey(x) keymap[x]
#endif /* OS2 */
MACRO *macrotab;
_PROTOTYP( VOID shostrdef, (CHAR *) );
#endif /* NOSETKEY */

extern int cmdlvl;

#ifndef NOSPL
extern struct mtab *mactab;
extern struct keytab mackey[];
extern struct keytab vartab[], fnctab[], iftab[];
extern int maclvl, nmac, mecho, fndiags, fnerror, fnsuccess, nif;
#endif /* NOSPL */

FILE *tfile[MAXTAKE];                   /* TAKE file stack */
char *tfnam[MAXTAKE];                   /* Name of TAKE file */
int tfline[MAXTAKE];                    /* Current line number */
int tfblockstart[MAXTAKE];              /* Current block-start line */

int topcmd = -1;                        /* cmdtab index of current command */
int havetoken = 0;
extern int dblquo;                      /* Doublequoting enabled */

#ifdef DCMDBUF                          /* Initialization filespec */
char *kermrc = NULL;
#else
char kermrcb[KERMRCL];
char *kermrc = kermrcb;
#endif /* DCMDBUF */

int noherald = 0;
int cm_retry = 1;                       /* Command retry enabled */
xx_strp xxstring = zzstring;

#ifndef NOXFER
extern int displa, bye_active, protocol, pktlog, remfile, rempipe, unkcs,
  keep, lf_opts, fncnv, pktpaus, autodl, xfrcan, xfrchr, xfrnum, srvtim,
  srvdis, query, retrans, streamed, reliable, crunched, timeouts,
  fnrpath, autopath, rpackets, spackets, epktrcvd, srvping;

#ifdef CK_AUTODL
extern int inautodl, cmdadl;
#endif /* CK_AUTODL */

#ifndef NOSERVER
extern int en_asg, en_cwd, en_cpy, en_del, en_dir, en_fin, en_bye, en_ret,
  en_get, en_hos, en_que, en_ren, en_sen, en_set, en_spa, en_typ, en_who,
  en_mai, en_pri, en_mkd, en_rmd, en_xit, en_ena;
#endif /* NOSERVER */

extern int atcapr,
  atenci, atenco, atdati, atdato, atleni, atleno, atblki, atblko,
  attypi, attypo, atsidi, atsido, atsysi, atsyso, atdisi, atdiso;

#ifdef STRATUS
extern int atfrmi, atfrmo, atcrei, atcreo, atacti, atacto;
#endif /* STRATUS */

#ifdef CK_PERMS
extern int atlpri, atlpro, atgpri, atgpro;
#endif /* CK_PERMS */

#ifdef CK_LOGIN
extern char * anonfile;                 /* Anonymous login init file */
extern char * anonroot;                 /* Anonymous file-system root */
extern char * userfile;                 /* Forbidden user file */
extern int isguest;                     /* Flag for anonymous user */
#endif /* CK_LOGIN */
#endif /* NOXFER */

#ifdef DCMDBUF
int *xquiet = NULL;
int *xvarev = NULL;
#else
int xquiet[CMDSTKL];
int xvarev[CMDSTKL];
#endif /* DCMDBUF */

char * prstring[CMDSTKL];

#ifndef NOSPL

extern long ck_alarm;
extern char alrm_date[], alrm_time[];

/* Local declarations */

static int nulcmd = 0;                  /* Flag for next cmd to be ignored */

/* Definitions for predefined macros */

/* First, the single-line macros, installed with addmac()... */

/* IBM-LINEMODE macro */
char *m_ibm = "set parity mark, set dupl half, set handsh xon, set flow none";

/* FATAL macro */
char *m_fat = "if def \\%1 echo \\%1, if not = \\v(local) 0 hangup, stop 1";

#ifdef CK_SPEED
#ifdef IRIX65
char *m_fast = "set win 30, set rec pack 4000, set prefix cautious";
#else
#ifdef IRIX
/* Because of bug in telnet server */
char *m_fast = "set window 30, set rec pack 4000, set send pack 4000,\
 set pref cautious";
#else
#ifdef pdp11
char *m_fast = "set win 3, set rec pack 1024, set prefix cautious";
#else
#ifdef BIGBUFOK
char *m_fast = "set win 30, set rec pack 4000, set prefix cautious";
#else
char *m_fast = "set win 4, set rec pack 2200, set prefix cautious";
#endif /* BIGBUFOK */
#endif /* IRIX */
#endif /* IRIX65 */
#endif /* pdp11 */
#ifdef pdp11
char *m_cautious = "set win 2, set rec pack 512, set prefixing cautious";
#else
char *m_cautious = "set win 4, set rec pack 1000, set prefixing cautious";
#endif /* pdp11 */
char *m_robust = "set win 1, set rec pack 90, set prefixing all, \
set reliable off, set clearchannel off, set send timeout 20 fixed";
#else
#ifdef BIGBUFOK
#ifdef IRIX65
char *m_fast = "set win 30, set rec pack 4000";
#else
#ifdef IRIX
char *m_fast = "set win 30, set rec pack 4000, set send pack 4000";
#else
char *m_fast = "set win 30, set rec pack 4000";
#endif /* IRIX */
#endif /* IRIX65 */
#else /* Not BIGBUFOK */
char *m_fast = "set win 4, set rec pack 2200";
#endif /* BIGBUFOK */
char *m_cautious = "set win 4, set rec pack 1000";
char *m_robust = "set win 1, set rec pack 90, set reliable off,\
 set send timeout 20 fixed";
#endif /* CK_SPEED */

#ifdef VMS
char *m_purge = "run purge \\%*";
#endif /* VMS */

#ifdef OS2
char *m_manual = "browse \\v(exedir)docs/manual/kermit95.htm";
#endif /* OS2 */

/* Now the multiline macros, defined with addmmac()... */

/*
  Kermit's scripting language is so much more powerful than C that it was
  about a thousand time easier to implement FOR, WHILE, IF, and SWITCH
  commands as internal Kermit macros.  This was done in 1996 for C-Kermit 6.0.

  The following definitions, down to #ifdef COMMENT, are from C-Kermit
  9.0.304 Dev.22, April 2017, where the command parser was changed to not
  evaluate macro arguments on the DO command line, but to defer evaluation
  until after the arguments had been separated and counted.  This change
  required subtle modifications to the internal macro templates.

  IMPORTANT: Internal macros must have names that start with '_', followed
  by three letters, e.g. _whi for WHILE.  The definitions below are just
  templates for some other code that constructs the actual menu to be
  executed by filling in the \%x variables.  The generated macros have names
  like _whil2, _whil3, etc, where the trailing number is the execution stack
  level.  The reason for the strict naming convention is so internal macros
  can be parsed differently than regular ones.  See
  ckuusr.c:isinternalmacro(), which determines the type of macro.
*/

/*
 The WHILE macro:
 \%1 = Loop condition
 \%2 = Loop body
*/
char *whil_def[] = { "_assign _whi\\v(cmdlevel) {_getargs,",
":_..inc,\\fcontents(\\%1),\\fcontents(\\%2),goto _..inc,:_..bot,_putargs},",
"_define break goto _..bot, _define continue goto _..inc,",
"do _whi\\v(cmdlevel),_assign _whi\\v(cmdlevel)",
""};

/*  
 FOR macro for \%i-style loop variables (see dofor()...)
 \%1 = Loop variable
 \%2 = Initial value (can be an expression)
 \%3 = Loop exit value
 \%4 = Loop increment
 \%5 = > or <
 \%6 = Loop body
*/
char *for_def[] = { "_assign _for\\v(cmdlevel) { _getargs,",
"define \\\\\\%1 \\feval(\\%2),:_..top,if \\%5 \\\\\\%1 \\%3 goto _..bot,",
"\\fcontents(\\%6),:_..inc,incr \\\\\\%1 \\%4,goto _..top,:_..bot,_putargs},",
"define break goto _..bot, define continue goto _..inc,",
"do _for\\v(cmdlevel) \\\\%1 \\%2 \\%3 \\%4 { \\%5 },_assign _for\\v(cmdlevel)",
""};

/*
  FOR macro when the loop variable is itself a macro, with same arguments
  but slightly different quoting.
*/
char *foz_def[] = { "_assign _for\\v(cmdlevel) { _getargs,",
"def \\%1 \\feval(\\%2),:_..top,if \\%5 \\%1 \\%3 goto _..bot,",
"\\fcontents(\\%6),:_..inc,incr \\%1 \\%4,goto _..top,:_..bot,_putargs},",
"def break goto _..bot, def continue goto _..inc,",
"do _for\\v(cmdlevel) \\%1 \\%2 \\%3 \\%4 { \\%5 },_assign _for\\v(cmdlevel)",
""};

/*
 SWITCH macro
 \%1 = Switch variable
 \%2 = Switch body
*/
char *sw_def[] = { "_assign _sw_\\v(cmdlevel) {_getargs,",
"_forward {\\fcontents(\\%1)},\\fcontents(\\%2),:default,:_..bot,_putargs},_def break goto _..bot,",
"do _sw_\\v(cmdlevel),_assign _sw_\\v(cmdlevel)",
""};

/*
  IF macro
  /%1 = Commands to execute (IF part and ELSE part if any)
*/
char *xif_def[] = {
"_assign _if_\\v(cmdlevel) {_getargs,\\fcontents(\\%1),_putargs},",
"do _if_\\v(cmdlevel),_assign _if\\v(cmdlevel)",
""};

#ifdef COMMENT
/* Internal macro definitions for C-Kermit 6.0 through 9.0.302 */

char *for_def[] = { "_assign _for\\v(cmdlevel) { _getargs,",
"def \\\\\\%1 \\feval(\\%2),:_..top,if \\%5 \\\\\\%1 \\%3 goto _..bot,",
"\\%6,:_..inc,incr \\\\\\%1 \\%4,goto _..top,:_..bot,_putargs},",
"def break goto _..bot, def continue goto _..inc,",
"do _for\\v(cmdlevel) \\%1 \\%2 \\%3 \\%4 { \\%5 },_assign _for\\v(cmdlevel)",
""};

char *foz_def[] = { "_assign _for\\v(cmdlevel) { _getargs,",
"def \\%1 \\feval(\\%2),:_..top,if \\%5 \\%1 \\%3 goto _..bot,",
"\\%6,:_..inc,incr \\%1 \\%4,goto _..top,:_..bot,_putargs},",
"def break goto _..bot, def continue goto _..inc,",
"do _for\\v(cmdlevel) \\%1 \\%2 \\%3 \\%4 { \\%5 },_assign _for\\v(cmdlevel)",
""};

/* SWITCH macro */
char *sw_def[] = { "_assign _sw_\\v(cmdlevel) {_getargs,",
"_forward {\\%1},\\%2,:default,:_..bot,_putargs},_def break goto _..bot,",
"do _sw_\\v(cmdlevel),_assign _sw_\\v(cmdlevel)",
""};

/* XIF macro */
char *xif_def[] = {
"_assign _if\\v(cmdlevel) {_getargs,\\%1,_putargs},",
"do _if\\v(cmdlevel),_assign _if\\v(cmdlevel)",
""};

#endif  /* COMMENT */

/*
  Variables declared here for use by other ckuus*.c modules.
  Space is allocated here to save room in ckuusr.c.
*/
#ifdef DCMDBUF
struct cmdptr *cmdstk;
int
  *ifcmd  = NULL,
  *count  = NULL,
  *iftest = NULL,
  *intime = NULL,
  *inpcas = NULL,
  *takerr = NULL,
  *merror = NULL;
#else
struct cmdptr cmdstk[CMDSTKL];
int ifcmd[CMDSTKL], count[CMDSTKL], iftest[CMDSTKL], intime[CMDSTKL],
  inpcas[CMDSTKL], takerr[CMDSTKL], merror[CMDSTKL];
#endif /* DCMDBUF */

/* Macro stack */

#ifdef COMMENT
char *topline = NULL;                   /* Program invocation arg line */
char *m_line[MACLEVEL] = { NULL, NULL }; /* Stack of macro invocation lines */
#endif /* COMMENT */

char **m_xarg[MACLEVEL];                /* Pointers to arg vector arrays */
int n_xarg[MACLEVEL];                   /* Sizes of arg vector arrays */
char *m_arg[MACLEVEL][NARGS];           /* Args of each level */
int macargc[MACLEVEL];                  /* Argc of each level */
char *macp[MACLEVEL];                   /* Current position in each macro */
char *macx[MACLEVEL];                   /* Beginning of each macro def */
char *mrval[MACLEVEL];                  /* RETURN value at each level */
int lastcmd[MACLEVEL];                  /* Last command at each level */
int topargc = 0;                        /* Argc at top level */
char **topxarg = NULL;                  /* Argv at top level */
char *toparg[MAXARGLIST+2];

/* Global Variables */

char *g_var[GVARS+1];                   /* Global \%a..z pointers */
extern char varnam[];                   /* \%x variable name buffer */

/* Arrays -- Dimension must be 'z' - ARRAYBASE + 1 */
/* Note: a_link[x] < 0 means no link; >= 0 is a link */

char **a_ptr[32];                       /* Array pointers, for arrays a-z */
int a_dim[32];                          /* Dimensions for each array */
int a_link[32];                         /* Link (index of linked-to-array) */

char **aa_ptr[CMDSTKL][32];             /* Array stack for automatic arrays */
int aa_dim[CMDSTKL][32];                /* Dimensions for each array */

/* INPUT command buffers and variables */

char * inpbuf = NULL;                   /* Buffer for INPUT and REINPUT */
extern char * inpbp;                    /* Global/static pointer to it  */
char inchar[2] = { NUL, NUL };          /* Last character that was INPUT */
int  incount = 0;                       /* INPUT character count */
extern int instatus;                    /* INPUT status */
static char * i_text[] = {              /* INPUT status text */
    "success", "timeout", "interrupted", "internal error", "i/o error"
};

char lblbuf[LBLSIZ];                    /* Buffer for labels */

#else  /* NOSPL */

int takerr[MAXTAKE];
#endif /* NOSPL */

static char *prevdir = NULL;

int pacing = 0;                         /* OUTPUT pacing */

char *tp;                               /* Temporary buffer pointer */

int timelimit = 0, asktimer = 0;        /* Timers for time-limited commands */

#ifdef CK_APC                           /* Application Program Command (APC) */
int apcactive = APC_INACTIVE;
int apcstatus = APC_OFF;                /* OFF by default everywhere */
#ifdef DCMDBUF
char *apcbuf;
#else
char apcbuf[APCBUFLEN];
#endif /* DCMDBUF */
#endif /* CK_APC */

extern char pktfil[],
#ifdef DEBUG
  debfil[],
#endif /* DEBUG */
#ifdef TLOG
  trafil[],
#endif /* TLOG */
  sesfil[];

#ifndef NOFRILLS
extern int rmailf, rprintf;             /* REMOTE MAIL & PRINT items */
extern char optbuf[];
#endif /* NOFRILLS */

extern int noinit;			/* Flat to skip init file */

#ifndef NOSPL
static struct keytab kcdtab[] = {	/* Symbolic directory names */
#ifdef NT
    { "appdata",  VN_APPDATA,   0 },
    { "common",   VN_COMMON,    0 },
    { "desktop",  VN_DESKTOP,   0 },
#endif /* NT */
    { "download", VN_DLDIR,     0 },
#ifdef OS2ORUNIX
    { "exedir",   VN_EXEDIR,    0 },
#endif /* OS2ORUNIX */
    { "home",     VN_HOME,      0 },
    { "inidir",   VN_INI,       0 },
#ifdef UNIX
    { "lockdir",  VN_LCKDIR,    0 },
#endif /* UNIX */
#ifdef NT
    { "my_documents",VN_PERSONAL,  0 },
    { "personal", VN_PERSONAL,  CM_INV },
#endif /* NT */
    { "startup",  VN_STAR,      0 },
    { "textdir",  VN_TXTDIR,    0 },
    { "tmpdir",   VN_TEMP,      0 }
};
static int nkcdtab = (sizeof(kcdtab) / sizeof(struct keytab));
#endif /* NOSPL */

#ifndef NOSPL
_PROTOTYP( VOID freelocal, (int) );
_PROTOTYP( static CK_OFF_T expon, (CK_OFF_T, CK_OFF_T) );
_PROTOTYP( static CK_OFF_T gcd, (CK_OFF_T, CK_OFF_T) );
_PROTOTYP( static CK_OFF_T fact, (CK_OFF_T) );

int                     /* Initialize macro data structures. */
macini() {              /* Allocate mactab and preset the first element. */
    int i;
    if (!(mactab = (struct mtab *) malloc(sizeof(struct mtab) * MAC_MAX)))
      return(-1);
    mactab[0].kwd = NULL;
    mactab[0].mval = NULL;
    mactab[0].flgs = 0;
    for (i = 0; i < MACLEVEL; i++)
      localhead[i] = NULL;
    return(0);
}
#endif /* NOSPL */

/*  C M D S R C  --  Returns current command source  */

/*  0 = top level, 1 = file, 2 = macro, -1 = error (shouldn't happen) */

/*
  As of 19 Aug 2000 this routine is obsolete.  The scalar global variable
  xcmdsrc can be checked instead to save the overhead of a function call.
*/
int
cmdsrc() {
#ifdef COMMENT
    return(xcmdsrc);
#else
#ifndef NOSPL
    if (cmdlvl == 0)
      return(0);
    else if (cmdstk[cmdlvl].src == CMD_MD)
      return(2);
    else if (cmdstk[cmdlvl].src == CMD_TF)
      return(1);
    else
      return(-1);
#else
    if (tlevel < 0)
      return(0);
    else
      return(1);
#endif /* NOSPL */
#endif /* COMMENT */
}

/*  C M D I N I  --  Initialize the interactive command parser  */

static int cmdinited = 0;               /* Command parser initialized */
extern int cmdint;                      /* Interrupts are allowed */
#ifdef CK_AUTODL
int cmdadl = 1;                         /* Autodownload */
#else
int cmdadl = 0;
#endif /* CK_AUTODL */

char * k_info_dir = NULL;               /* Where to find text files */
#ifdef UNIX
static char * txtdir[] = {
    "/usr/local/doc/",                  /* Linux, SunOS, ... */
    "/usr/share/lib/",                  /* HP-UX 10.xx... */
    "/usr/share/doc/",                  /* Other possibilities... */
    "/usr/local/lib/",                  /* NOTE: Each of these is tried */
    "/usr/local/share/",                /* as is, and also with a kermit */
    "/usr/local/share/doc/",            /* subdirectory. */
    "/usr/local/share/lib/",
    "/opt/kermit/",                     /* Solaris */
    "/opt/kermit/doc/",
    "/opt/",
    "/usr/doc/",
    "/doc/",
    ""
};
#endif /* UNIX */

/*
  lookup() cache to speed up script execution.

  This is a static cache.  Items are stored in decreasing frequency of
  reference based on statistics from a range of scripts.  This gives
  better performance than a dynamic cache, which would require a lot more
  code and also would require system-dependent elements including system
  calls (e.g. to get subsecond times for entry aging).
*/
#ifdef USE_LUCACHE                      /* Set in ckuusr.h */
#define LUCACHE 32                      /* Change this to reduce cache size */
int lusize = 0;
char * lucmd[LUCACHE];
int luval[LUCACHE];
int luidx[LUCACHE];
struct keytab * lutab[LUCACHE];
#endif /* USE_LUCACHE */

static VOID
luinit() {                              /* Initialize lookup() cache */
    int x, y;

#ifdef USE_LUCACHE
    x = lookup(cmdtab,"if",ncmd,&y);
    lucmd[lusize] = "if";
    luval[lusize] = x;
    luidx[lusize] = y;
    lutab[lusize] = cmdtab;
    if (++lusize > LUCACHE) return;

    x = lookup(iftab,"not",nif,&y);
    lucmd[lusize] = "not";
    luval[lusize] = x;
    luidx[lusize] = y;
    lutab[lusize] = iftab;
    if (++lusize > LUCACHE) return;

    x = lookup(vartab,"cmdlevel",nvars,&y);
    lucmd[lusize] = "cmdlevel";
    luval[lusize] = x;
    luidx[lusize] = y;
    lutab[lusize] = vartab;
    if (++lusize > LUCACHE) return;

    x = lookup(cmdtab,"goto",ncmd,&y);
    lucmd[lusize] = "goto";
    luval[lusize] = x;
    luidx[lusize] = y;
    lutab[lusize] = cmdtab;
    if (++lusize > LUCACHE) return;

    x = lookup(iftab,">",nif,&y);
    lucmd[lusize] = ">";
    luval[lusize] = x;
    luidx[lusize] = y;
    lutab[lusize] = iftab;
    if (++lusize > LUCACHE) return;

    x = lookup(cmdtab,"incr",ncmd,&y);
    lucmd[lusize] = "incr";
    luval[lusize] = x;
    luidx[lusize] = y;
    lutab[lusize] = cmdtab;
    if (++lusize > LUCACHE) return;

    x = lookup(cmdtab,"def",ncmd,&y);
    lucmd[lusize] = "def";
    luval[lusize] = x;
    luidx[lusize] = y;
    lutab[lusize] = cmdtab;
    if (++lusize > LUCACHE) return;

    x = lookup(cmdtab,"_assign",ncmd,&y);
    lucmd[lusize] = "_assign";
    luval[lusize] = x;
    luidx[lusize] = y;
    lutab[lusize] = cmdtab;
    if (++lusize > LUCACHE) return;

    x = lookup(cmdtab,"echo",ncmd,&y);
    lucmd[lusize] = "echo";
    luval[lusize] = x;
    luidx[lusize] = y;
    lutab[lusize] = cmdtab;
    if (++lusize > LUCACHE) return;

    x = lookup(fnctab,"eval",nfuncs,&y);
    lucmd[lusize] = "eval";
    luval[lusize] = x;
    luidx[lusize] = y;
    lutab[lusize] = fnctab;
    if (++lusize > LUCACHE) return;

    x = lookup(fnctab,"lit",nfuncs,&y);
    lucmd[lusize] = "lit";
    luval[lusize] = x;
    luidx[lusize] = y;
    lutab[lusize] = fnctab;
    if (++lusize > LUCACHE) return;

    x = lookup(cmdtab,"do",ncmd,&y);
    lucmd[lusize] = "do";
    luval[lusize] = x;
    luidx[lusize] = y;
    lutab[lusize] = cmdtab;
    if (++lusize > LUCACHE) return;

    x = lookup(cmdtab,"_getargs",ncmd,&y);
    lucmd[lusize] = "_getargs";
    luval[lusize] = x;
    luidx[lusize] = y;
    lutab[lusize] = cmdtab;
    if (++lusize > LUCACHE) return;

    x = lookup(iftab,"<",nif,&y);
    lucmd[lusize] = "<";
    luval[lusize] = x;
    luidx[lusize] = y;
    lutab[lusize] = iftab;
    if (++lusize > LUCACHE) return;

    x = lookup(cmdtab,"_putargs",ncmd,&y);
    lucmd[lusize] = "_putargs";
    luval[lusize] = x;
    luidx[lusize] = y;
    lutab[lusize] = cmdtab;
    if (++lusize > LUCACHE) return;

    x = lookup(cmdtab,"asg",ncmd,&y);
    lucmd[lusize] = "asg";
    luval[lusize] = x;
    luidx[lusize] = y;
    lutab[lusize] = cmdtab;
    if (++lusize > LUCACHE) return;

    x = lookup(cmdtab,"else",ncmd,&y);
    lucmd[lusize] = "else";
    luval[lusize] = x;
    luidx[lusize] = y;
    lutab[lusize] = cmdtab;
#endif /* USE_LUCACHE */
}

VOID
cmdini() {
    int i = 0, x = 0, y = 0, z = 0, skip = 0;
    char * p;
#ifdef TTSPDLIST
    long * ss = NULL;
    extern int nspd;
    extern struct keytab * spdtab;
#endif /* TTSPDLIST */

#ifndef NOSPL
/*
  On stack to allow recursion!
*/
    char vnambuf[VNAML];                /* Buffer for variable names */
#endif /* NOSPL */

    if (cmdinited)                      /* Already initialized */
      return;                           /* Don't do it again */

    for (i = 0; i < CMDSTKL; i++)       /* Prompt strings for each */
      prstring[i] = NULL;               /* command level */

#ifndef NOCSETS
    p = getenv("K_CHARSET");            /* Set default file character set */
    if (p) {                            /* from environment */
        x = lookup(fcstab,p,nfilc,&y);
        if (x > -1)
          fcharset = x;
    }
#endif /* NOCSETS */

    p = getenv("K_INFO_DIRECTORY");     /* Find Kermit info directory */
    if (p && *p && strlen(p) <= CKMAXPATH)
      makestr(&k_info_dir,p);
    if (!k_info_dir) {
        p = getenv("K_INFO_DIR");
        if (p && *p && strlen(p) <= CKMAXPATH)
          makestr(&k_info_dir,p);
    }
#ifdef UNIX
    if (k_info_dir) {                   /* Look for Kermit docs directory */
        if (zchki(k_info_dir) == -2) {
            char xbuf[CKMAXPATH+32], *s = "";
            if (ckrchar(k_info_dir) != '/')
              s = "/";
            ckmakmsg(xbuf,CKMAXPATH+32,k_info_dir,s,"ckubwr.txt",NULL);
            if (zchki(xbuf) < 0)
              makestr(&k_info_dir,NULL);
        }
    }
    if (!k_info_dir) {
        char xbuf[CKMAXPATH+32];
        int i;
        for (i = 0; *(txtdir[i]); i++) {
            ckmakmsg(xbuf,CKMAXPATH+32,txtdir[i],"ckubwr.txt",NULL,NULL);
            if (zchki(xbuf) > 0) {
                makestr(&k_info_dir,txtdir[i]);
                debug(F110,"k_info_dir 1",k_info_dir,0);
                break;
            }
            ckmakmsg(xbuf,CKMAXPATH+32,
                     txtdir[i],"kermit/","ckubwr.txt",NULL);
            if (zchki(xbuf) > 0) {
                ckmakmsg(xbuf,CKMAXPATH+32,txtdir[i],"kermit/",NULL,NULL);
                makestr(&k_info_dir,xbuf);
                debug(F110,"k_info_dir 2",k_info_dir,0);
                break;
            }
            ckmakmsg(xbuf,CKMAXPATH+32,
                     txtdir[i],"ckermit/","ckubwr.txt",NULL);
            if (zchki(xbuf) > 0) {
                ckmakmsg(xbuf,CKMAXPATH+32,txtdir[i],"ckermit/",NULL,NULL);
                makestr(&k_info_dir,xbuf);
                debug(F110,"k_info_dir 3",k_info_dir,0);
                break;
            }
        }
        if (k_info_dir) {               /* Make sure it ends with "/" */
            if (ckrchar(k_info_dir) != '/') {
                char xbuf[CKMAXPATH+32];
                ckmakmsg(xbuf,CKMAXPATH+32,k_info_dir,"/",NULL,NULL);
                makestr(&k_info_dir,xbuf);
            }
        }
    }
#else
#ifdef OS2
    {
        char xdir[CKMAXPATH+8], *s = "";
        extern char startupdir[];
        xdir[0] = NUL;
        if (ckrchar(startupdir) != '/')
          s = "/";
        if (strlen(s) + strlen(startupdir) + 5 < CKMAXPATH + 8 )
          ckmakmsg(xdir,CKMAXPATH+8,s,startupdir,"DOC/",NULL);
        makestr(&k_info_dir,xdir);
    }
#endif /* OS2 */
#endif /* UNIX */

#ifdef TTSPDLIST
    if (!spdtab && (ss = ttspdlist())) { /* Get speed list if necessary */
        int j, k, m = 0, n;             /* Create sorted keyword table */
        char buf[16];
        char * p;
        if ((spdtab =
             (struct keytab *) malloc(sizeof(struct keytab) * ss[0]))) {
            for (i = 1; i <= ss[0]; i++) { /* ss[0] = number of elements */
                if (ss[i] < 1L) break;     /* Shouldn't happen */
                buf[0] = NUL;              /* Make string */
                sprintf(buf,"%ld",ss[i]);  /* SAFE */
                if (ss[i] == 8880L)
                  ckstrncpy(buf,"75/1200",sizeof(buf));
                if (ss[i] == 134L)
                  ckstrncat(buf,".5",16);
                n = strlen(buf);
                if ((n > 0) && (p = (char *)malloc(n+1))) {
                    if (m > 0) {        /* Have at least one in list */
                        for (j = 0;     /* Find slot */
                             j < m && strcmp(buf,spdtab[j].kwd) > 0;
                             j++
                             )
                          ;
                        if (j < m) {    /* Must insert */
                            for (k = m-1; k >= j; k--) { /* Move others down */
                                spdtab[k+1].kwd = spdtab[k].kwd;
                                spdtab[k+1].flgs = spdtab[k].flgs;
                                spdtab[k+1].kwval = spdtab[k].kwval;
                            }
                        }
                    } else              /* First one */
                      j = 0;
                    ckstrncpy(p,buf,n+1); /* Add new speed */
                    spdtab[j].kwd = p;
                    spdtab[j].flgs = 0;
                    spdtab[j].kwval = (int) ss[i] / 10;
                    m++;                /* Count this one */
                }
            }
        }
        nspd = m;
    }
#endif /* TTSPDLIST */

#ifndef NOSPL
    /* Allocate INPUT command buffer */
    if (!inpbuf) {
        if (!(inpbuf = (char *) malloc(INPBUFSIZ+8)))
          fatal("cmdini: no memory for INPUT buffer");
    }
    for (x = 0; x < INPBUFSIZ; x++)     /* Initialize it */
      inpbuf[x] = NUL;
    inpbp = inpbuf;                     /* Initialize pointer */
    inbufsize = INPBUFSIZ;              /* and size. */
#endif /* NOSPL */

#ifdef DCMDBUF
    if (cmsetup() < 0) fatal("Can't allocate command buffers!");

#ifndef NOSPL
    /* Allocate command stack allowing command parser to call itself */

    if (!(cmdstk = (struct cmdptr *) malloc(sizeof(struct cmdptr)*CMDSTKL)))
      fatal("cmdini: no memory for cmdstk");
    if (!(ifcmd = (int *) malloc(sizeof(int)*CMDSTKL)))
      fatal("cmdini: no memory for ifcmd");
    if (!(count = (int *) malloc(sizeof(int)*CMDSTKL)))
      fatal("cmdini: no memory for count");
    if (!(iftest = (int *) malloc(sizeof(int)*CMDSTKL)))
      fatal("cmdini: no memory for iftest");
    if (!(intime = (int *) malloc(sizeof(int)*CMDSTKL)))
      fatal("cmdini: no memory for intime");
    if (!(inpcas = (int *) malloc(sizeof(int)*CMDSTKL)))
      fatal("cmdini: no memory for inpcas");
    if (!(takerr = (int *) malloc(sizeof(int)*CMDSTKL)))
      fatal("cmdini: no memory for takerr");
    if (!(merror = (int *) malloc(sizeof(int)*CMDSTKL)))
      fatal("cmdini: no memory for merror");
    if (!(xquiet = (int *) malloc(sizeof(int)*CMDSTKL)))
      fatal("cmdini: no memory for xquiet");
    if (!(xvarev = (int *) malloc(sizeof(int)*CMDSTKL)))
      fatal("cmdini: no memory for xvarev");
    if (!kermrc)
      if (!(kermrc = (char *) malloc(KERMRCL+1)))
        fatal("cmdini: no memory for kermrc");
#ifdef CK_APC
/* Application Program Command buffer */
    if (!(apcbuf = malloc(APCBUFLEN + 1)))
        fatal("cmdini: no memory for apcbuf");
#endif /* CK_APC */
#endif /* NOSPL */

/* line[] and tmpbuf[] are the two string buffers used by the command parser */

    if (!(line = malloc(LINBUFSIZ + 1)))
        fatal("cmdini: no memory for line");
    if (!(tmpbuf = malloc(LINBUFSIZ + 1)))
        fatal("cmdini: no memory for tmpbuf");
#endif /* DCMDBUF */

#ifndef NOSPL
#ifdef CK_MINPUT
    {                                   /* Initialize MINPUT pointers */
        int i;
        extern char *ms[];
        for (i = 0; i < MINPMAX; i++)
          ms[i] = NULL;
    }
#endif /* CK_MINPUT */

    if (macini() < 0)                   /* Allocate macro buffers */
      fatal("Can't allocate macro buffers!");

    ifcmd[0] = 0;                       /* Command-level related variables. */
    iftest[0] = 0;                      /* Initialize variables at top level */
    count[0] = 0;                       /* of stack... */
    intime[0] = 0;
    inpcas[0] = 0;
    takerr[0] = 0;
    merror[0] = 0;
    xquiet[0] = quiet;
    xvarev[0] = vareval;
#endif /* NOSPL */

#ifndef NOSPL
    cmdlvl = 0;                         /* Initialize the command stack */
    xcmdsrc = CMD_KB;
    cmdstk[cmdlvl].src = CMD_KB;        /* Source is console */
    cmdstk[cmdlvl].lvl = 0;             /* Level is 0 */
    cmdstk[cmdlvl].ccflgs = 0;          /* No flags */
#endif /* NOSPL */

    tlevel = -1;                        /* Take file level = keyboard */
    for (i = 0; i < MAXTAKE; i++)       /* Initialize command file names */
      tfnam[i] = NULL;

    cmsetp(ckprompt);                   /* Set up C-Kermit's prompt */
                                        /* Can't set IKSD prompt here since */
                                        /* we do not yet know if we are IKSD */
#ifndef NOSPL

    initmac();                          /* Initialize macro table */

/* Predefine built-in one-line macros */

    addmac("ibm-linemode",m_ibm);       /* IBM-LINEMODE */
    addmac("fatal",m_fat);              /* FATAL macro */
    y = addmac("fast",m_fast);          /* FAST macro */
    addmac("cautious",m_cautious);      /* CAUTIOUS macro */
    addmac("robust",m_robust);          /* ROBUST macro */
#ifdef OS2
    addmac("manual",m_manual);          /* MANUAL macro */
#endif /* OS2 */
#ifdef VMS
    addmac("purge",m_purge);            /* PURGE macro */
#endif /* VMS */

/*
  Predefine built-in multiline macros; these are top-level commands
  that are implemented internally as macros.  NOTE: When adding a new
  one of these, remember to update the END and RETURN commands to
  account for it, or else END and RETURN from within it won't work right.
*/
    x = addmmac("_forx",for_def);       /* FOR macro */
    if (x > -1) mactab[x].flgs = CM_INV;
    x = addmmac("_forz",foz_def);       /* Other FOR macro */
    if (x > -1) mactab[x].flgs = CM_INV;
    x = addmmac("_xif",xif_def);        /* XIF macro */
    if (x > -1) mactab[x].flgs = CM_INV;
    x = addmmac("_while",whil_def);     /* WHILE macro */
    if (x > -1) mactab[x].flgs = CM_INV;
    x = addmmac("_switx",sw_def);       /* SWITCH macro */
    if (x > -1) mactab[x].flgs = CM_INV;

/* Fill in command-line argument vector */

    sprintf(vnambuf,"\\&@[%d]",xargs);  /* SAFE */
    if (inserver) {                     /* But hidden in IKSD */
        y = -1;
        xargs = 0;
    } else
      y = arraynam(vnambuf,&x,&z);      /* goes in array \&@[] */

    tmpbuf[0] = NUL;
    if (y > -1) {
        int j = -1;
        int yy = 0;
        dclarray((char)x,z);            /* Declare the array */
#ifndef NOTAKEARGS
        /* Macro argument vector */
        sprintf(vnambuf,"\\&_[%d]",z);  /* SAFE */
        yy = arraynam(vnambuf,&x,&z);   /* goes in array \&_[] */
        if (yy > -1)                    /* Name is OK */
          dclarray((char)x,z);          /* Declare the array */
#endif /* NOTAKEARGS */
        skip = 0;
        for (i = 0; i < xargs; i++) {   /* Fill the arrays */
            sprintf(vnambuf,"\\&@[%d]",i); /* SAFE */
            addmac(vnambuf,xargv[i]);
            if (cfilef && i == 0)
              continue;
#ifdef KERBANG
            if (skip) {
                j = 0;
                skip = 0;
                continue;
            }
#endif /* KERBANG */
            if (j < 0 &&                /* Assign items after "=" or "--"*/
                (!strcmp(xargv[i],"=") || !strcmp(xargv[i],"--"))
                ) {
                j = 0;                  /* to \%1..\%9 */
#ifdef KERBANG
            } else if (j < 0 &&
                       (!strcmp(xargv[i],"+") ||
                        !strncmp(xargv[i],"+ ",2) ||
                        !strncmp(xargv[i],"+\t",2))
                        ) {
                skip = 1;
                continue;
#endif /* KERBANG */
            } else if (j > -1) {
                j++;
                if (j <= 9) {
                    vnambuf[0] = '\\';
                    vnambuf[1] = '%';
                    vnambuf[2] = (char)(j+'0');
                    vnambuf[3] = NUL;
                    addmac(vnambuf,xargv[i]);
                }
                if (yy > -1) {
                    char c, * p;
                    int flag = 0;
                    p = xargv[i];
                    makestr(&(toparg[j]),p);
                    while ((c = *p++)) { if (c == SP) { flag++; break; } }
                    if (flag)
                      ckstrncat(tmpbuf,"\"",TMPBUFSIZ);
                    ckstrncat(tmpbuf,xargv[i],TMPBUFSIZ);
                    if (flag)
                      ckstrncat(tmpbuf,"\"",TMPBUFSIZ);
                    ckstrncat(tmpbuf," ",TMPBUFSIZ);
                }
            }
        }
        if (cfilef) {
            addmac("\\%0",cmdfil);
            if (yy > -1)
              makestr(&(toparg[0]),cmdfil);
        } else {
            addmac("\\%0",xargv[0]);
            if (yy > -1)
              makestr(&(toparg[0]),xargv[0]);
        }
        if (yy > -1) {
            topargc = (j < 0) ? 1 : j + 1;
            topxarg = toparg;
#ifdef COMMENT
            /* This needs work */
            if (!cfilef)
              makestr(&topline,tmpbuf);
#endif /* COMMENT */
        } else {
            topargc = 0;
            topxarg = NULL;
        }
        a_dim[0] = topargc - 1;
        a_ptr[0] = topxarg;
	debug(F111,"a_dim[0]","A",a_dim[0]);
    }
    *vnambuf = NUL;
#endif /* NOSPL */

    luinit();                           /* Initialize lookup() cache */

/* Get our home directory now.  This needed in lots of places. */

    cmdinited = 1;
}

#ifdef NT
_PROTOTYP(char * GetAppData,(int));
#endif /* NT */

VOID
doinit() {
#ifdef CKROOT
extern int ckrooterr;
#endif /* CKROOT */
    int x = 0, ok = 0;
#ifdef OS2
    char * ptr = 0;
#endif /* OS2 */

    if (!cmdinited)
      cmdini();

#ifdef MAC
    return;                             /* Mac Kermit has no init file */

#else /* !MAC */

/* If skipping init file ('-Y' on Kermit command line), return now. */

    if (noinit) {
        kermrc[0] = '\0';
        inidir[0] = '\0';
/*
  But returning from here results in inidir[] never being set to anything.
  Instead it should be set to wherever the init file *would* have been
  executed from.  So this bit of code should be removed, and then we should
  sprinkle "if (noinit)" tests throughout the following code until we have
  set inidir[], and then return without actually taking the init file.
*/
        return;
    }

#ifdef OS2
/*
  The -y init file must be fully specified or in the current directory.
  KERMRC is looked for via INIT, DPATH and PATH in that order.  Finally, our
  own executable file path is taken and the .EXE suffix is replaced by .INI
  and this is tried as the initialization file.
*/
#ifdef CK_LOGIN
    debug(F101,"doinit inserver","",inserver);
    debug(F101,"doinit isguest","",isguest);
    debug(F110,"doinit anonfile",anonfile,0);

    if (isguest && anonfile) {
      ckstrncpy(line, anonfile, LINBUFSIZ+1);
    } else
#endif /* CK_LOGIN */
      if (rcflag) {
          ckstrncpy(line,kermrc,LINBUFSIZ+1);
#ifdef CK_LOGIN
      } else if (inserver) {
          char * appdata = NULL;
#ifdef NT
          appdata = GetAppData(1);
          if ( appdata ) {
              ckmakmsg(line,LINBUFSIZ+1,appdata,
                        "Kermit 95/k95.ini",NULL,NULL);
              if ( zchki(line) < 0 )
                  line[0] = '\0';
          }
          if (line[0] == 0) {
              appdata = GetAppData(0);
              if ( appdata ) {
                  ckmakmsg(line,LINBUFSIZ+1,appdata,
                            "Kermit 95/k95.ini",NULL,NULL);
                  if ( zchki(line) < 0 )
                      line[0] = '\0';
              }
          }
#endif /* NT */
          if (line[0] == 0) {
              appdata = zhome();
              if ( appdata ) {
                  ckmakmsg(line,LINBUFSIZ+1,appdata,
#ifdef NT
                          "k95.ini",
#else /* NT */
                          "k2.ini",
#endif /* NT */
                           NULL,NULL);
                  if ( zchki(line) < 0 )
                      line[0] = '\0';
              }
          }
          debug(F110,"doinit inserver inifile",line,0);
#endif /* CK_LOGIN */
    } else {
        char * env = 0;
#ifdef NT
        env = getenv("K95.KSC");
#else
        env = getenv("K2.KSC");
#endif /* NT */
        if (!env) {
#ifdef NT
            env = getenv("K95.INI");
#else
            env = getenv("K2.INI");
#endif /* NT */
        }
        if (!env)
          env = getenv("CKERMIT.INI");
        if (!env)
          env = getenv("CKERMIT_INI");
        line[0] = '\0';

        debug(F110,"doinit env",env,0);
        if (env)
          ckstrncpy(line,env,LINBUFSIZ+1);

#ifdef NT
        if (line[0] == 0) {
            env = GetAppData(1);
            if ( env ) {
                ckmakmsg(line,LINBUFSIZ+1,env,"Kermit 95/k95.ini",NULL,NULL);
                if ( zchki(line) < 0 )
                    line[0] = '\0';
            }
        }
        if (line[0] == 0) {
            env = GetAppData(0);
            if ( env ) {
                ckmakmsg(line,LINBUFSIZ+1,env,"Kermit 95/k95.ini",NULL,NULL);
                if ( zchki(line) < 0 )
                    line[0] = '\0';
            }
        }
#endif /* NT */

        if (line[0] == 0) {
            env = zhome();
            if ( env ) {
                ckmakmsg(line,LINBUFSIZ+1,env,
#ifdef NT
                          "k95.ini",
#else /* NT */
                          "k2.ini",
#endif /* NT */
                          NULL,NULL);
                if ( zchki(line) < 0 )
                    line[0] = '\0';
            }
        }

        if (line[0] == 0)
          _searchenv(kermrc,"INIT",line);
        if (line[0] == 0)
          _searchenv(kermrc,"DPATH",line);
        if (line[0] == 0)
          _searchenv(kermrc,"PATH",line);
        if (line[0] == 0) {
            char *pgmptr = GetLoadPath();
            if (pgmptr && strlen(pgmptr) < LINBUFSIZ-8) {
                lp = strrchr(pgmptr, '\\');
                if (lp) {
                    strncpy(line, pgmptr, lp - pgmptr);
#ifdef NT
                    strcpy(line + (lp - pgmptr), "/k95.ini");
#else /* NT */
                    strcpy(line + (lp - pgmptr), "/k2.ini");
#endif /* NT */
                } else {
                    lp = strrchr(pgmptr, '.');
                    if (lp) {
                        strncpy(line, pgmptr, lp - pgmptr);
                        strcpy(line + (lp - pgmptr), ".ini");
                    }
                }
            }
        }
    }

#ifdef CKROOT
    if (!zinroot(line)) {
        debug(F110,"doinit setroot violation",line,0);
        return;
    }
#endif /* CKROOT */

    debug(F110,"doinit fopen()",line,0);
    if ((tfile[0] = fopen(line,"r")) != NULL) {
        ok = 1;
        tlevel = 0;
        tfline[tlevel] = 0;
        tfblockstart[tlevel] = 1;
        if (tfnam[tlevel] = malloc(strlen(line)+1))
          strcpy(tfnam[tlevel],line);   /* safe */
#ifndef NOSPL
        cmdlvl++;
        xcmdsrc = CMD_TF;
        cmdstk[cmdlvl].src = CMD_TF;
        cmdstk[cmdlvl].lvl = tlevel;
        cmdstk[cmdlvl].ccflgs = 0;
        ifcmd[cmdlvl] = 0;
        iftest[cmdlvl] = 0;
        count[cmdlvl] =  count[cmdlvl-1]; /* Inherit from previous level */
        intime[cmdlvl] = intime[cmdlvl-1];
        inpcas[cmdlvl] = inpcas[cmdlvl-1];
        takerr[cmdlvl] = takerr[cmdlvl-1];
        merror[cmdlvl] = merror[cmdlvl-1];
        xquiet[cmdlvl] = quiet;
        xvarev[cmdlvl] = vareval;
#endif /* NOSPL */
        debug(F110,"doinit init file",line,0);
    } else {
        debug(F100,"doinit no init file","",0);
    }
    ckstrncpy(kermrc,line,KERMRCL);
    for (ptr = kermrc; *ptr; ptr++)     /* Convert backslashes to slashes */
       if (*ptr == '\\')
         *ptr = '/';
#else /* not OS2 */
    lp = line;
    lp[0] = '\0';
    debug(F101,"doinit rcflag","",rcflag);
#ifdef GEMDOS
    zkermini(line, rcflag, kermrc);
#else
#ifdef VMS
    {
	int x;
	x = zkermini(line,LINBUFSIZ,kermrc);
	debug(F111,"CUSTOM zkermini",line,x);
	if (x == 0)
	  line[0] = NUL;
    }
#else /* not VMS */
#ifdef CK_LOGIN
    debug(F101,"doinit isguest","",isguest);
    if (isguest)
      ckstrncpy(lp, anonfile ? anonfile : kermrc, LINBUFSIZ);
    else
#endif /* CK_LOGIN */
      if (rcflag) {                     /* If init file name from cmd line */
          ckstrncpy(lp,kermrc,LINBUFSIZ); /* use it, */
      } else {                          /* otherwise... */
#ifdef CK_INI_A                         /* If we've a system-wide init file */
          /* And it takes precedence over the user's... */
          ckstrncpy(lp,CK_SYSINI,KERMRCL); /* Use it */
          if (zchki(lp) < 0) {          /* (if it exists...) */
#endif /* CK_INI_A */
              char * homdir;
              char * env = 0;
              line[0] = NUL;

              /* Add support for environment variable */
              env = getenv("CKERMIT.INI");
              if (!env)
                env = getenv("CKERMIT_INI");
              if (env)
                ckstrncpy(lp,env,KERMRCL);

              if (lp[0] == 0) {
                  homdir = zhome();
                  if (homdir) {         /* Home directory for init file. */
                      ckstrncpy(lp,homdir,KERMRCL);
#ifdef STRATUS
                      ckstrncat(lp,">",KERMRCL);/* VOS dirsep */
#else
                      if (lp[0] == '/') ckstrncat(lp,"/",KERMRCL);
#endif /* STRATUS */
                  }
                  ckstrncat(lp,kermrc,KERMRCL);/* Append default file name */
              }
#ifdef CK_INI_A
          }
#endif /* CK_INI_A */
#ifdef CK_INI_B                         /* System-wide init defined? */
          /* But user's ini file takes precedence */
          if (zchki(lp) < 0)            /* If user doesn't have her own, */
            ckstrncpy(lp,CK_SYSINI,KERMRCL); /* use system-wide one. */
#endif /* CK_INI_B */
      }
#endif /* VMS */
#endif /* GEMDOS */

#ifdef AMIGA
    reqoff();                           /* Disable requestors */
#endif /* AMIGA */

#ifdef USE_CUSTOM
    /* If no init file was found, execute the customization file */
    debug(F111,"CUSTOM 1",line,rcflag);
    if ((!line[0] || zchki(line) < 0) && !rcflag) {
	int x;
#ifdef OS2
	x = ckmakestr(line,LINBUFSIZ,GetAppData(1),"/","K95CUSTOM.INI",NULL);
	debug(F111,"CUSTOM 2",line,x);
	if (zchki(line) < 0) {
	    x = ckmakestr(line,LINBUFSIZ,GetAppData(0),"/","K95USER.INI",NULL);
	    debug(F111,"CUSTOM 3",line,x);
	}
#else  /* OS2 */
	x = ckstrncpy(line,zhome(),LINBUFSIZ);
#ifndef VMS
	/* VMS zhome() returns "SYS$LOGIN:" */
	if (line[x-1] != DIRSEP) {
	    line[x++] = DIRSEP;
	    line[x] = NUL;
	}
#endif /* VMS */
	x = ckstrncat(line,MYCUSTOM,LINBUFSIZ);
	debug(F111,"CUSTOM 4",line,x);
#endif /* OS2 */
    }
    debug(F110,"CUSTOM 5",line,0);
#endif /* USE_CUSTOM */

#ifdef CKROOT
    if (!zinroot(line)) {
        debug(F110,"doinit setroot violation",line,0);
        return;
    }
#endif /* CKROOT */

    debug(F110,"doinit ini file is",line,0);
    if ((tfile[0] = fopen(line,"r")) != NULL) { /* Try to open init file. */
        ok = 1;
        tlevel = 0;
        tfline[tlevel] = 0;
        tfblockstart[tlevel] = 1;
        if ((tfnam[tlevel] = malloc(strlen(line)+1)))
          strcpy(tfnam[tlevel],line);   /* safe */

        ckstrncpy(kermrc,line,KERMRCL);

#ifndef NOSPL
        cmdlvl++;
        ifcmd[cmdlvl] = 0;
        iftest[cmdlvl] = 0;
        count[cmdlvl] =  count[cmdlvl-1]; /* Inherit from previous level */
        intime[cmdlvl] = intime[cmdlvl-1];
        inpcas[cmdlvl] = inpcas[cmdlvl-1];
        takerr[cmdlvl] = takerr[cmdlvl-1];
        merror[cmdlvl] = merror[cmdlvl-1];
        xquiet[cmdlvl] = quiet;
        xvarev[cmdlvl] = vareval;
        debug(F101,"doinit open ok","",cmdlvl);
        xcmdsrc = CMD_TF;
        cmdstk[cmdlvl].src = CMD_TF;
        cmdstk[cmdlvl].lvl = tlevel;
        cmdstk[cmdlvl].ccflgs = 0;
#endif /* NOSPL */
    } else if (rcflag) {
        /* Print an error message only if a specific file was asked for. */
        printf("?%s - %s\n", ck_errstr(), line);
    }

#ifdef datageneral
/* If CKERMIT.INI not found in home directory, look in searchlist */
    if (/* homdir && */ (tlevel < 0)) {
        ckstrncpy(lp,kermrc,LINBUFSIZ);
        if ((tfile[0] = fopen(line,"r")) != NULL) {
            ok = 1;
            tlevel = 0;
            tfline[tlevel] = 0;
            tfblockstart[tlevel] = 1;
            if (tfnam[tlevel] = malloc(strlen(line)+1))
              strcpy(tfnam[tlevel],line); /* safe */
#ifndef NOSPL
            cmdlvl++;
            xcmdsrc = CMD_TF;
            cmdstk[cmdlvl].src = CMD_TF;
            cmdstk[cmdlvl].lvl = tlevel;
            cmdstk[cmdlvl].ccflgs = 0;
            ifcmd[cmdlvl] = 0;
            iftest[cmdlvl] = 0;
            count[cmdlvl] =  count[cmdlvl-1]; /* Inherit from previous level */
            intime[cmdlvl] = intime[cmdlvl-1];
            inpcas[cmdlvl] = inpcas[cmdlvl-1];
            takerr[cmdlvl] = takerr[cmdlvl-1];
            merror[cmdlvl] = merror[cmdlvl-1];
            xquiet[cmdlvl] = quiet;
	    xvarev[cmdlvl] = vareval;
#endif /* NOSPL */
        }
    }
#endif /* datageneral */

#ifdef AMIGA                            /* Amiga... */
    reqpop();                           /* Restore requestors */
#endif /* AMIGA */
#endif /* OS2 */
#endif /* MAC */

    /* Assign value to inidir */

    if (!ok) {
        inidir[0] = NUL;
    } else {
        ckstrncpy(inidir, kermrc, CCHMAXPATH);
        x = strlen(inidir);
        if (x > 0) {
            int i;
            for (i = x - 1; i > 0; i-- ) {
                if (ISDIRSEP(inidir[i])) {
                    inidir[i+1] = NUL;
                    break;
                }
            }
        }
#ifdef NT
        GetShortPathName(inidir,inidir,CCHMAXPATH);
#endif /* NT */
    }
}

VOID
doiksdinit() {
#ifdef CK_SSL
    /* IKSD doesn't request client certs */
    ssl_verify_flag = SSL_VERIFY_NONE;
#endif /* CK_SSL */

    if (!cmdinited)
      cmdini();

#ifdef IKSDCONF
#ifdef OS2
    line[0] = '\0';
    _searchenv(iksdconf,"INIT",line);
    if (line[0] == 0)
      _searchenv(iksdconf,"DPATH",line);
    if (line[0] == 0)
      _searchenv(iksdconf,"PATH",line);
    if (line[0] == 0) {
        char *pgmptr = GetLoadPath();
        if (pgmptr && strlen(pgmptr) < LINBUFSIZ-8) {
            lp = strrchr(pgmptr, '\\');
            if (lp) {
                strncpy(line, pgmptr, lp - pgmptr);
                strcpy(line + (lp - pgmptr), "\\");
                strcpy(line + (lp - pgmptr + 1), iksdconf);
            } else {
                lp = strrchr(pgmptr, '.');
                if (lp) {
                    strncpy(line, pgmptr, lp - pgmptr);
                    strcpy(line + (lp - pgmptr), ".ksc");
                }
            }
        }
    }
    debug(F110,"doiksdinit() line",line,0);
    tfile[0] = fopen(line,"r");
#else /* OS2 */
    tfile[0] = fopen(iksdconf,"r");
#endif /* OS2 */
    if (tfile[0] != NULL) {
        tlevel = 0;
        tfline[tlevel] = 0;
        tfblockstart[tlevel] = 1;
#ifdef OS2
        if (tfnam[tlevel] = malloc(strlen(line)+1))
          strcpy(tfnam[tlevel],line);
#else /* OS2 */
        if ((tfnam[tlevel] = malloc(strlen(iksdconf)+1)))
          strcpy(tfnam[tlevel],iksdconf);
#endif /* OS2 */
#ifndef NOSPL
        cmdlvl++;
        xcmdsrc = CMD_TF;
        cmdstk[cmdlvl].src = CMD_TF;
        cmdstk[cmdlvl].lvl = tlevel;
        cmdstk[cmdlvl].ccflgs = 0;
        ifcmd[cmdlvl]  = 0;
        iftest[cmdlvl] = 0;
        count[cmdlvl]  = count[cmdlvl-1]; /* Inherit from previous level */
        intime[cmdlvl] = intime[cmdlvl-1];
        inpcas[cmdlvl] = inpcas[cmdlvl-1];
        takerr[cmdlvl] = takerr[cmdlvl-1];
        merror[cmdlvl] = merror[cmdlvl-1];
        xquiet[cmdlvl] = quiet;
	xvarev[cmdlvl] = vareval;
#endif /* NOSPL */
        debug(F110,"doiksdinit file ok",tfnam[tlevel],0);
    } else {
        debug(F110,"doiksdinit open failed",tfnam[tlevel],0);
    }
#endif /* IKSDCONF */
}

#ifndef NOSPL
/*
  G E T N C M

  Get next command from current macro definition.  Command is copied
  into string pointed to by argument s, max length n.   Returns:
   0 if a string was copied;
  -1 if there was no string to copy.
*/
int
getncm(s,n) char *s; int n; {
    int y = 0;				/* Character counter */
    int quote = 0;
    int kp = 0;				/* Brace up-down counter */
    int pp = 0;				/* Parenthesis up-down counter */
#ifndef NODQMACRO
    int dq = 0;				/* Doublequote counter */
#endif /* NODQMACRO */
    char *s2;                           /* Copy of destination pointer */

    s2 = s;                             /* Initialize string pointers */
    *s = NUL;                           /* and destination buffer */

    /* debug(F010,"getncm entry",macp[maclvl],0); */

    for (y = 0;                         /* Loop for n bytes max */
         macp[maclvl] && *macp[maclvl] && y < n;
         y++, s++, macp[maclvl]++) {

        *s = *macp[maclvl];             /* Get next char from macro def */

#ifndef COMMENT
/*
  This is to allow quoting of parentheses, commas, etc, in function
  arguments, but it breaks just about everything else.  DON'T REMOVE THIS
  COMMENT!  (Otherwise you'll wind up adding the same code again and breaking
  everything again.)  <-- The preceding warning should be obsolete since the
  statements below have been fixed, but in case of fire, remove the "n" from
  the <#>ifndef above.  NEW WARNING: code added 12 Apr 2002 to exempt the
  opening brace in \{nnn} from being treated as a quoted brace.
*/
        if (!quote && *s == CMDQ) {
            quote = 1;
            continue;
        }
        if (quote) {
	    int notquote = 0;
            quote = 0;
	    if (*s == '{') {		/* Check for \{nnn} (8.0.203) */
		char c, * p;
		p = macp[maclvl] + 1;
		while ((c = *p++)) {
		    if (isdigit(c))
		      continue;
		    else if (c == '}') {
			notquote++;
			break;
		    } else {
			break;
		    }
		}
	    }
	    if (notquote == 0)
	      continue;
        }
#endif /* COMMENT */

/*
  Allow braces around macro definition to prevent commas from being turned to
  end-of-lines and also treat any commas within parens as text so that
  multiple-argument functions won't cause the command to break prematurely.
  19 Oct 2001: Similar treatment was added for doublequotes, so

     define foo { echo "one, two, three" }

  would work as expected.  This doesn't seem to have broken anything but
  if something comes up later, rebuild with NODQMACRO defined.
*/
        if (*s == '{') kp++;            /* Count braces */
        if (*s == '}' && kp > 0) kp--;
        if (*s == '(') pp++;            /* Count parentheses. */
        if (*s == ')' && pp > 0) pp--;
#ifndef NODQMACRO
#ifndef COMMENT
	/* Too many false positives */
	/* No, not really -- this is indeed the best we can do */
	/* Reverted to this method Sun May 11 18:43:45 2003 */
	if (*s == '"') dq = 1 - dq;     /* Account for doublequotes */
#else  /* Fri Apr  4 13:21:29 2003 */
	/* The code below breaks the SWITCH statement */
	/* There is no way to make this work -- it would require */
	/* building in all the knowledge of command parser. */
        if (dblquo && (*s == '"')) {    /* Have doublequote */
            if (dq == 1) {		/* Close quote only if... */
                if ((*(macp[maclvl]+1) == SP) || /* followed by space or... */
		    (!*(macp[maclvl]+1)) ||      /* at end or ... */
		    /* Next char is command separator... */
		    /* Sun May 11 17:24:12 2003 */
		    (kp < 1 && pp < 1 && (*(macp[maclvl]+1) == ','))
		    )		     
                  dq = 0;		/* Close the quote */
            } else if (dq == 0) {
                /* Open quote only if at beginning or preceded by space */
                if (s > s2) {
                    if (*(s-1) == SP)
                      dq = 1;
                } else if (s == s2) {
                      dq = 1;
                }
            }
        }
#endif /* COMMENT */
#endif /* NODQMACRO */
        if (*s == ',' && pp <= 0 && kp <= 0
#ifndef NODQMACRO
            && dq == 0
#endif /* NODQMACRO */
            ) {
            macp[maclvl]++;             /* Comma not in {} or () */
            /* debug(F110,"next cmd",s,0); */
            kp = pp = 0;                /* so we have the next command */
            break;
        }
    }                                   /* Reached end. */
#ifdef COMMENT
    /* DON'T DO THIS - IT BREAKS EVERYTHING */
    *s = NUL;
#endif /* COMMENT */
    if (*s2 == NUL) {                   /* If nothing was copied, */
        /* debug(F100,"getncm eom","",0); */
        popclvl();                      /* pop command level. */
        return(-1);
    } else {                            /* otherwise, tack CR onto end */
        *s++ = CR;
        *s = '\0';
        /* debug(F110,"getncm OK",s,0); */
        if (mecho && pflag)             /* If MACRO ECHO ON, echo the cmd */
          printf("%s\n",s2);
    }
    return(0);
}

/*  D O M A C  --  Define and then execute a macro */

int
domac(name, def, flags) char *name, *def; int flags; {
    int x, m;
#ifndef NOLOCAL
#ifdef OS2
    extern int term_io;
    int term_io_sav = term_io;
    term_io = 0;                        /* Disable Terminal Emulator I/O */
#endif /* OS2 */
#endif /* NOLOCAL */
    m = maclvl;                         /* Current macro stack level */
    x = addmac(name, def);              /* Define a new macro */
    if (x > -1) {                       /* If successful, */
        dodo(x,NULL,flags);             /* start it (increments maclvl). */
        while (maclvl > m) {            /* Keep going till done with it, */
            debug(F101,"domac loop maclvl 1","",maclvl);
            sstate = (CHAR) parser(1);  /* parsing & executing each command, */
            debug(F101,"domac loop maclvl 2","",maclvl);
            if (sstate) proto();        /* including protocol commands. */
        }
        debug(F101,"domac loop exit maclvl","",maclvl);
    }
#ifndef NOLOCAL
#ifdef OS2
    term_io = term_io_sav;
#endif /* OS2 */
#endif /* NOLOCAL */
    return(success);
}
#endif /* NOSPL */

/*
  G E T N C T

  Get next command from TAKE (command) file.

  Call with:
   s     Pointer to buffer to read into
   n     Length of buffer
   f     File descriptor of file to read from
   flag  0 == keep line terminator on and allow continuation
         1 == discard line terminator and don't allow continuation

  Call with flag == 0 to read a command from a TAKE file;
  Call with flag != 0 to read a line from a dialing or network directory.

  In both cases, trailing comments and/or trailing whitespace is/are stripped.
  If flag == 0, continued lines are combined into one line.  A continued line
  is one that ends in hypen, or any line in a "block", which starts with "{"
  at the end of a line and ends with a matching "}" at the beginning of a
  subsequent line; blocks may be nested.

  Returns:
   0 if a string was copied,
  -1 on EOF,
  -2 on malloc failure
  -3 if line is not properly terminated
  -4 if (possibly continued) line is too long.
*/
static int lpxlen = 0;

int
getnct(s,n,f,flag) char *s; int n; FILE *f; int flag; {
    int i = 0, len = 0, buflen = 0;
    char c = NUL, cc = NUL, ccl = NUL, ccx = NUL, *s2 = NULL;
    char *lp = NULL, *lpx = NULL, *lp2 = NULL, *lp3 = NULL, *lastcomma = NULL;
    char * prev = NULL;
    int bc = 0;                         /* Block counter */
    int firstread = 1;

    s2 = s;                             /* Remember original pointer */
    prev = s2;				/* Here too */
    buflen = n;                         /* Remember original buffer length */

    if (n < 0)
      return(-2);

    /* Allocate a line buffer only if we don't have one that's big enough */

    debug(F111,"getnct",ckitoa(lpxlen),n);

    if (lpx && (n > lpxlen)) {          /* Have one already */
        debug(F101,"getnct new buffer","",lpxlen);
        free(lpx);                      /* But it's not big enough */
        lpx = NULL;                     /* Free current one */
        lpxlen = 0;
    }
    if (!lpx) {                         /* Get new one */
        if (!(lpx = (char *) malloc(n))) {
            debug(F101,"getnct malloc failure","",0);
            printf("?Memory allocation failure [getnct:%d]\n",n);
            return(-2);
        }
        lpxlen = n;
    }
    lp2 = lpx;
#ifdef KLUDGE
    /* NOTE: No longer used as of 14 Aug 2000 */
    lp2++;
#endif /* KLUDGE */

    while (1) {                         /* Loop to read lines from file */
        debug(F101,"getnct while (1)","",n);
        if (fgets(lp2,n,f) == NULL) {   /* Read a line into lp2 */
            debug(F110,"getnct EOF",s2,0); /* EOF */
            free(lpx);                  /* Free temporary storage */
            lpx = NULL;
            *s = NUL;                   /* Make destination be empty */
            return(-1);                 /* Return failure code */
        }
        if (firstread) {               /* Beginning of a block or statement */
            tfblockstart[tlevel] = tfline[tlevel];
            firstread = 0;
        }
#ifndef NODIAL
        if (flag)                       /* Count this line */
          dirline++;
        else
#endif /* NODIAL */
          tfline[tlevel]++;
        len = strlen(lp2) - 1;          /* Position of line terminator */
        if (len == 0 && lp2[0] != '\n') { /* Last line in file has one char */
            lp2[++len] = '\n';          /* that is not a newline */
            lp2[len] = NUL;
        }
        debug(F010,"getnct",lp2,0);
        if (len < 0)
          len = 0;
        if (techo && pflag) {            /* If TAKE ECHO ON, */
            if (flag) {
                printf("%3d. %s",             /* echo it this line. */
#ifndef NODIAL
                    flag ? dirline :
#endif /* NODIAL */
                    tfline[tlevel],
                    lp2
                    );
            } else {
                printf("%3d. %3d. %s",             /* echo it this line. */
                    tfline[tlevel],
                    tfblockstart[tlevel],
                    lp2
                    );
            }
        }
        lp3 = lp2;                      /* Working pointer */
        i = len;                        /* Get first nonwhitespace character */
        while (i > 0 && (*lp3 == SP || *lp3 == HT)) {
            i--;
            lp3++;
        }
        if (i == 0 && bc > 0)           /* Blank line in {...} block */
          continue;

        /* Isolate, remove, and check terminator */

        c = lp2[len];                   /* Value of line terminator */
        /* debug(F101,"getnct terminator","",c); */
        if (c < LF || c > CR) {         /* It's not a terminator */
            /* debug(F111,"getnct bad line",lp2,c); */
            if (feof(f) && len > 0 && len < n) {
                /* Kludge Alert... */
                if (!quiet)
                  printf("WARNING: Last line of %s lacks terminator\n",
                         s2 == cmdbuf ? "command file" : "directory file");
                c = lp2[++len] = '\n';  /* No big deal - supply one. */
            } else {                    /* Something's wrong, fail. */
                free(lpx);
                lpx = NULL;
                return(-3);
            }
        }
        /* Trim trailing whitespace */

        for (i = len - 1; i > -1 && lp2[i] <= SP; i--) /* Trim */
          ;
        /* debug(F101,"getnct i","",i); */
        lp2[i+1] = NUL;                 /* Terminate the string */
        /* debug(F110,"getnct lp2",lp2,0); */
        lp = lp2;                       /* Make a working pointer */

        /* Remove trailing or full-line comment */

        while ((cc = *lp)) {
            if (cc == ';' || cc == '#') { /* Comment introducer? */
                if (lp == lp2) {        /* First char on line */
                    *lp = NUL;
                    break;
                } else if (*(lp - 1) == SP || *(lp - 1) == HT) {
                    lp--;
                    *lp = NUL;  /* Or preceded by whitespace */
                    break;
                }
            }
            lp++;
        }
        if (lp > lp2)
          lp--;                         /* Back up over the NUL */

        /* Now trim any space that preceded the comment */

        while ((*lp == SP || *lp == HT) && lp >= lp2) {
            *lp = NUL;
            if (lp <= lp2)
              break;
            lp--;
        }
        /* debug(F110,"getnct comment trimmed",lp2,0); */

        len = strlen(lp2);              /* Length after trimming */

        if (n - len < 2) {              /* Check remaining space */
            debug(F111,"getnct command too long",s2,buflen);
            printf("?Line too long, maximum length: %d.\n",buflen);
            free(lpx);
            return(-4);
        }
        ccl = (len > 0) ? lp2[len-1] : 0;     /* Last character in line */
        ccx = (len > 1) ? lp2[len-2] : 0;     /* Penultimate char in line */

#ifdef COMMENT
        /* Line containing only whitespace and ,- */
        if ((len > 1) && (lp3 == lp2+len-2) && (ccl == '-') && (ccx == ','))
          continue;
#endif /* COMMENT */

#ifdef KLUDGE
/*
  If it is a command and it begins with a token (like ! or .) that is not
  followed by a space, insert a space now; otherwise cmkey() can get mighty
  confused.
*/
        if (s == s2 && !flag) {
            char *p = toktab;
            while (*p) {
                if (*p == *lp3 && *(p+1) != SP) {
                    debug(F110,"getnct token",p,0);
                    *lp3-- = SP;
                    *lp3 = *p;
                    if (lp3 < lp2) {
                        lp2--;
                        len++;
                    }
                    break;
                } else
                  p++;
            }
        }
#endif /* KLUDGE */
        lp = lp2;

        while ((*s++ = *lp++))          /* Copy result to target buffer */
          n--;                          /* accounting for length */
        s--;                            /* Back up over the NUL */

        /* Check whether this line is continued */

        if (flag)                       /* No line continuation when flag=1 */
          break;                        /* So break out of read-lines loop */

#ifdef COMMENT
        debug(F000,"getnct first char","",*lp3);
        debug(F000,"getnct last char","",ccl);
        debug(F000,"getnct next-to-last char","",ccx);
#endif /* COMMENT */

        if (bc > 0 && *lp3 == '}') {    /* First char on line is '}' */
            bc--;			/* Decrement block counter */
        }

        if (bc == 0 &&                  /* Line is continued if bc > 0 */
#ifdef COMMENT
            /* Not supported as of C-Kermit 6.0 */
            ccl != CMDQ &&              /* or line ends with CMDQ */
#endif /* COMMENT */
            ccl != '-'  &&              /* or line ends with dash */
            ccl != '{') {               /* or line ends with opening brace */
            break;                      /* None of those, we're done. */
        }
        if (ccl == '-' || ccl == '{')   /* Continuation character */
          if (ccx == CMDQ)              /* But it's quoted */
            break;                      /* so ignore it */

        if (ccl == '{') {               /* Last char on line is '{'? */
            bc++;                       /* Count the block opener. */
        } else if (ccl == '-') {        /* Explicit continue? */
            char c, * ss;
            int state = 0, nn;
            s--;                        /* Yes, back up over terminators */
            n++;                        /* and over continuation character */
            nn = n;                     /* Save current count */
            ss = s;                     /* and pointer */
            s--;                        /* Back up over dash */
            n++;
            while (state < 2 && s >= prev) { /* Check for "{,-" */
                n++;
                c = *s--;
                if (c <= SP)
                  continue;
                if (c != ',' && c != '{')
                  break;
                switch (state) {
                  case 0:               /* Looking for comma */
                    if (c == ',')
                      state = 1;
                    break;
                  case 1:               /* Looking for left brace */
                    if (c == '{') {
                        state = 2;
                        s += 2;
                        *s = NUL;
                        bc++;
                    }
                    break;
                }
            }
            if (state != 2) { s = ss; n = nn; }
            *s = NUL;
        } else {                        /* None of those but (bc > 0) */
            lastcomma = s;
            *s++ = ',';                 /* and insert a comma */
            n--;
        }
#ifdef COMMENT
        debug(F101,"getnct bc","",bc);
        debug(F100,"getnct continued","",0);
#endif /* COMMENT */

        *s = NUL;
        prev = s;

    } /* read-lines while loop */

    if (lastcomma)
      *lastcomma = SP;
    if (!flag)                          /* Tack line terminator back on */
      *s++ = c;
    *s++ = NUL;                         /* Terminate the string */
    untab(s2);                          /* Done, convert tabs to spaces */
#ifdef DEBUG
    if (!flag) {
        debug(F010,"CMD(F)",s2,0);
    }
#endif /* DEBUG */
    {
        int i = 0; char *s = s2; char prev = '\0'; char c = '\0';
        while (*s) {   /* Save beginning of this command for error messages */
            c = *s++;
            if (c == '\n' || c == '\r') c = SP;
            if (c == SP && prev == SP) /* Squeeze spaces */
              continue;
            lasttakeline[i++] = c;
            prev = c;
            if (i > TMPBUFSIZ-5) {
                lasttakeline[i++] = '.';
                lasttakeline[i++] = '.';
                lasttakeline[i++] = '.';
                lasttakeline[i++] = NUL;
                break;
            }
        }
        i = (int)strlen((char *)lasttakeline) - 1;
        while (i > 0 && lasttakeline[i] == SP) { /* Trim treailing spaces */
            lasttakeline[i] = NUL;
            i--;
        }    }
    free(lpx);                          /* Free temporary storage */
    return(0);                          /* Return success */
}

VOID
shostack() {                            /* Dump the command stack */
    int i;
    char *p;
#ifndef NOSPL
    for (i = cmdlvl; i > 0; i--) {
        if (cmdstk[i].src == CMD_TF) {
            p = tfnam[cmdstk[i].lvl];
            if (zfnqfp(p,TMPBUFSIZ,tmpbuf))
              p = tmpbuf;
            printf(" %2d. File  : %s (line %d)\n",
                   i,
                   p,
                   tfline[cmdstk[i].lvl]
                   );
        } else if (cmdstk[i].src == CMD_MD) {
            char * m;
            m = m_arg[cmdstk[i].lvl][0]; /* Name of this macro */
            if (i > 0) {                 /* Special handling for 2-level */
                char *s;                 /* built-in macros... */
                s = m_arg[cmdstk[i-1].lvl][0]; /* Name next level up */
                if (s && cmdstk[i-1].src == CMD_MD) {
                    if (!strcmp(s,"_forx"))
                      m = "FOR";
                    else if (!strcmp(s,"_xif"))
                      m = "XIF";
                    else if (!strcmp(s,"_while"))
                      m = "WHILE";
                    else if (!strcmp(s,"_switx"))
                      m = "SWITCH";
                }
            }
            printf(" %2d. Macro : %s\n",i,m);
        } else if (cmdstk[i].src == CMD_KB) {
            printf(" %2d. Prompt:\n",i);
        } else {
            printf(" %2d. ERROR : Command source unknown\n",i);
        }
    }
#else
    for (i = tlevel; i > -1; i--) {
        p = tfnam[i];
        if (zfnqfp(p,TMPBUFSIZ,tmpbuf))
          p = tmpbuf;
        printf(" %2d. File  : %s (line %d)\n",
               i,
               p,
               tfline[i]
               );
    }
#endif /* NOSPL */
    if (i == 0)
      printf(" %2d. Prompt: (top level)\n",0);
}

/* For command error messages - avoid dumping out the contents of some */
/* some huge FOR loop if it contains a syntax error. */

static char *
cmddisplay(s, cx) char * s; int cx; {
    static char buf[80];
    if ((int)strlen(s) > 70) {
	sprintf(buf,"%.64s...",s);	/* SAFE */
	s = buf;
    }
    return(s);
}

static VOID
cmderr() {
    if (xcmdsrc > 0) {
	switch (cmd_err) {		/* SET COMMAND ERROR-DISPLAY */
	  case 0:
	    break;
	  case 1:
	  case 2:
	    if (tlevel > -1) {
#ifndef NOSPL
		if (xcmdsrc == 2)
		  printf(
"In macro or block defined in file: %s starting about line %d\n",
			 tfnam[tlevel] ? tfnam[tlevel] : "", tfline[tlevel]
			 );
		else
#endif /* NOSPL */
		  printf("File: %s, Line: %d\n",
			 tfnam[tlevel] ? tfnam[tlevel] : "", tfline[tlevel]
			 );
	    }
#ifndef NOSPL
	    if (cmd_err == 2) {
		if (cmdstk[cmdlvl].src == CMD_MD) { /* Executing a macro? */
		    int m;
		    m = cmdstk[cmdlvl].lvl;
		    if (mlook(mactab,m_arg[m][0],nmac) >= 0)
		      printf("Macro name: %s\n", m_arg[m][0]);
		}
	    }
#endif /* NOSPL */
	    break;

	  case 3:
	    printf("Command stack:\n");
	    shostack();			    
	}
    }
}

/*  P A R S E R  --  Top-level interactive command parser.  */

/*
  Call with:
    m = 0 for normal behavior: keep parsing and executing commands
          until an action command is parsed, then return with a
          Kermit start-state as the value of this function.
    m = 1 to parse only one command, can also be used to call parser()
          recursively.
    m = 2 to read but do not execute one command.
  In all cases, parser() returns:
    0     if no Kermit protocol action required
    > 0   with a Kermit protocol start-state.
    < 0   upon error.
*/
int
parser(m) int m; {
    int tfcode, xx, yy, zz;             /* Workers */
    int is_tn = 0;
    int cdlost = 0;

#ifndef NOSPL
    int inlevel;                        /* Level we were called at */
    extern int askflag, echostars;
#endif /* NOSPL */
    char *cbp;                          /* Command buffer pointer */
#ifdef MAC
    extern char *lfiles;                /* Fake extern cast */
#endif /* MAC */
    extern int interrupted;
#ifndef NOXFER
    extern int sndcmd, getcmd, fatalio, clearrq;
#endif /* NOXFER */

#ifdef AMIGA
    reqres();                           /* Restore AmigaDOS requestors */
#endif /* AMIGA */

#ifdef OS2
    if (cursor_save > -1) {             /* Restore cursor if it was */
        cursorena[VCMD] = cursor_save;  /* turned off during file transfer */
        cursor_save = -1;
    }
#endif /* OS2 */

#ifdef IKSDB
    if (ikdbopen) slotstate(what,"COMMAND PROMPT","",""); /* IKSD database */
#endif /* IKSDB */

    is_tn = (local && network && IS_TELNET()) ||
      (!local && sstelnet);

    if (!xcmdsrc)                       /* If at top (interactive) level ... */
      concb((char)escape);              /* put console in 'cbreak' mode. */

#ifdef CK_TMPDIR
/* If we were cd'd temporarily to another device or directory ... */
    if (f_tmpdir) {
        int x;
        x = zchdir((char *) savdir);    /* ... restore previous directory */
        f_tmpdir = 0;                   /* and remember we did it. */
        debug(F111,"parser tmpdir restoring",savdir,x);
    }
#endif /* CK_TMPDIR */

#ifndef NOSPL
    inlevel = cmdlvl;           /* Current macro level */
#ifdef DEBUG
    if (deblog) {
        debug(F101,"&parser entry maclvl","",maclvl);
        debug(F101,"&parser entry inlevel","",inlevel);
        debug(F101,"&parser entry tlevel","",tlevel);
        debug(F101,"&parser entry cmdlvl","",cmdlvl);
        debug(F101,"&parser entry m","",m);
    }
#endif /* DEBUG */
#endif /* NOSPL */

#ifndef NOXFER
    ftreset();                          /* Reset global file settings */
#endif /* NOXFER */
/*
  sstate becomes nonzero when a command has been parsed that requires some
  action from the protocol module.  Any non-protocol actions, such as local
  directory listing or terminal emulation, are invoked directly from below.
*/
    sstate = 0;                         /* Start with no start state. */

#ifndef NOXFER
#ifndef NOSPL
    query = 0;                          /* QUERY not active */
#endif /* NOSPL */
#ifndef NOHINTS
    if (!success) {
        if (local && !network && carrier != CAR_OFF) {
            int x;                      /* Serial connection */
            x = ttgmdm();               /* with carrier checking */
            if (x > -1) {
                if (!(x & BM_DCD)) {
                    cdlost = 1;
                    fatalio = 1;
                }
            }
        }
    }
#ifdef DEBUG
    if (deblog) {
        debug(F101,"parser top what","",what);
        debug(F101,"parser top interrupted","",interrupted);
        debug(F101,"parser top cdlost","",cdlost);
        debug(F101,"parser top sndcmd","",sndcmd);
        debug(F101,"parser top getcmd","",getcmd);
    }
#endif /* DEBUG */
    if (cdlost && !interrupted && (sndcmd || getcmd)) {
        printf("?Connection broken (carrier signal lost)\n");
    }
    if (sndcmd && protocol == PROTO_K &&
	!success && hints && !interrupted && !fatalio && !xcmdsrc) {
        int x = 0, n = 0;
        printf("\n*************************\n");
        printf("SEND-class command failed.\n");
        printf(" Packets sent: %d\n", spackets);
        printf(" Retransmissions: %d\n",retrans);
        printf(" Timeouts: %d\n", timeouts);
        printf(" Damaged packets: %d\n", crunched);
        if (epktrcvd) {
            printf(" Transfer canceled by receiver.\n");
            printf(" Receiver's message: \"%s\"\n",(char *)epktmsg);
            n++;
        } else {
            if (epktmsg) if (*epktmsg) {
                printf(" Fatal Kermit Protocol Error: %s\n",epktmsg);
                n++;
            }
        }
        if (local && !network && carrier != CAR_OFF) {
            int xx;                     /* Serial connection */
            xx = ttgmdm();              /* with carrier checking */
            if (xx > -1) {
                if (!(xx & BM_DCD))
                  cdlost = 1;
            }
        }

#ifdef UNIX
        if (errno != 0)
#endif /* UNIX */
          {
              printf(" Most recent local OS error: \"%s\"\n",ck_errstr());
              n++;
          }
        printf(
   "\nHINTS... If the preceding error message%s not explain the failure:\n",
               (n > 1) ? "s do" : " does"
               );
#ifndef NOLOCAL
        if (local) {
            if (rpackets == 0) {
                printf(" . Did you start a Kermit receiver on the far end?\n");
            } else {
                printf(
                " . Try changing the remote Kermit's FLOW-CONTROL setting.\n");
                if (!network && mdmtyp > 0)
                  if ((3 * crunched) > spackets)
                    printf(
                " . Try placing a new call to get a cleaner connection.\n");
            }
        } else if (rpackets > 0) {
            if (flow == FLO_NONE)
             printf(" . Give me a SET FLOW XON/XOFF command and try again.\n");
            else
             printf(" . Give me a SET FLOW NONE command and try again.\n");
        }
        x++;
#endif /* NOLOCAL */

        if ((3 * timeouts) > spackets)
          printf(" . Adjust the timeout method (see HELP SET SEND).\n");
        if ((3 * retrans) > spackets)
          printf(" . Increase the retry limit (see HELP SET RETRY).\n");

#ifdef CK_SPEED
        if (prefixing != PX_ALL && rpackets > 2) {
            printf(" . Try it again with: SET PREFIXING ALL\n");
            x++;
        }
#endif /* CK_SPEED */
#ifdef STREAMING
        if (streamed) {
            printf(" . Try it again with: SET STREAMING OFF\n");
            x++;
        } else if (reliable) {
            printf(" . Try it again with: SET RELIABLE OFF\n");
            x++;
        }
#endif /* STREAMING */

#ifdef CK_SPEED
        if (clearrq > 0 && prefixing == PX_NON) {
            printf(" . Try it again with: SET CLEAR-CHANNEL OFF\n");
            x++;
        }
#endif /* CK_SPEED */
        if (!parity) {
            printf(" . Try it again with: SET PARITY SPACE\n");
            x++;
        }
        printf(" . %sive a ROBUST command and try again.\n",
               (x > 0) ? "As a last resort, g" : "G"
               );
        printf("Also:\n");
        printf(" . Be sure the source file has read permission.\n");
        printf(" . Be sure the target directory has write permission.\n");
/*
        if the file was 2G or larger make sure other Kermit supports LFs...
*/
        printf(" . Be sure the target disk has sufficient space.\n");
        printf("(Use SET HINTS OFF to suppress hints.)\n");
        printf("*************************\n\n");
    }
    debug(F101,"topcmd","",topcmd);
    if (getcmd && protocol == PROTO_K &&
	!success && hints && !interrupted && !fatalio && !xcmdsrc) {
        int x = 0;
        extern int urpsiz, wslotr;
        printf("\n*************************\n");
        printf("RECEIVE- or GET-class command failed.\n");
        printf(" Packets received: %d\n", rpackets);
        printf(" Damaged packets: %d\n", crunched);
        printf(" Timeouts: %d\n", timeouts);
        if (rpackets > 0)
          printf(" Packet length: %d\n", urpsiz);
        if (epktrcvd) {
            printf(" Transfer canceled by sender.\n");
            printf(" Sender's message: \"%s\"\n",(char *)epktmsg);
            if (ckindex("not found",(char *)epktmsg,0,0,0) ||
                ckindex("no such",(char *)epktmsg,0,0,0)) {
                printf(" Did you spell the filename right?\n");
                printf(" Is the other Kermit CD'd to the right directory?\n");
            }
        }
#ifdef UNIX
        if (errno != 0)
#endif /* UNIX */
        {
             (VOID) ckstrncpy(tmpbuf,ck_errstr(),TMPBUFSIZ);
             printf(" Most recent local error: \"%s\"\n",tmpbuf);
        }
#ifdef COMMENT
        printf(
   "\nHINTS... If the preceding error message%s not explain the failure:\n",
               epktrcvd ? "s do" : " does"
               );
#ifndef NOLOCAL
        if (local) {
            if (topcmd == XXGET)
              printf(" . Did you start a Kermit SERVER on the far end?\n");
            if (rpackets == 0) {
                if (topcmd != XXGET)
                  printf(" . Did you start a Kermit SENDer on the far end?\n");
            } else {
                printf(
                " . Choose a different FLOW-CONTROL setting and try again.\n");
            }
        } else if (topcmd == XXGET)
          printf(" . Is the other Kermit in (or does it have) SERVER mode?\n");
        if (rpackets > 0 && urpsiz > 90)
          printf(" . Try smaller packets (SET RECEIVE PACKET-LENGTH).\n");
        if (rpackets > 0 && wslotr > 1 && !streamed)
          printf(" . Try a smaller window size (SET WINDOW).\n");
        if (!local && rpackets > 0) {
            if (flow == FLO_NONE)
             printf(" . Give me a SET FLOW XON/XOFF command and try again.\n");
            else
             printf(" . Give me a SET FLOW NONE command and try again.\n");
        }
        x++;
#endif /* NOLOCAL */
#ifdef STREAMING
        if (streamed) {
            printf(" . Try it again with: SET STREAMING OFF\n");
            x++;
        } else if (reliable && local) {
            printf(" . Try it again with: SET RELIABLE OFF\n");
            x++;
        } else
#endif /* STREAMING */
        if (!parity) {
            printf(" . Try it again with: SET PARITY SPACE\n");
            x++;
        }
        printf((x > 0) ?
               " . As a last resort, give a ROBUST command and try again.\n" :
               " . Give a ROBUST command and try again.\n"
               );
#endif  /* COMMENT */
        printf("Also:\n");
        printf(" . Be sure the target directory has write permission.\n");
        printf(" . Be sure the target disk has sufficient space.\n");
        printf(" . Try telling the %s to SET PREFIXING ALL.\n",
               topcmd == XXGET ? "server" : "sender"
               );
        printf(" . Try giving a ROBUST command to the %s.\n",
               topcmd == XXGET ? "server" : "sender"
               );
        printf("(Use SET HINTS OFF to suppress hints.)\n");
        printf("*************************\n\n");
    }
#endif /* NOHINTS */
    getcmd = 0;
    sndcmd = 0;
    interrupted = 0;
#endif /* NOXFER */

    while (sstate == 0) {               /* Parse cmds until action requested */
        debug(F100,"parse top","",0);
	what = W_COMMAND;		/* Now we're parsing commands. */
	rcdactive = 0;			/* REMOTE CD not active */
	keepallchars = 0;		/* MINPUT not active */

#ifdef OS2
        if (apcactive == APC_INACTIVE)
          WaitCommandModeSem(-1);
#endif /* OS2 */
#ifdef IKS_OPTION
        if ((local &&
             !xcmdsrc &&
             is_tn &&
             TELOPT_ME(TELOPT_KERMIT) &&
             TELOPT_SB(TELOPT_KERMIT).kermit.me_start) ||
            (!local &&
             !cmdadl &&
             TELOPT_ME(TELOPT_KERMIT) &&
             TELOPT_SB(TELOPT_KERMIT).kermit.me_start)
            ) {
            tn_siks(KERMIT_STOP);
        }
#endif /* IKS_OPTION */

#ifndef NOXFER
        if (autopath) {
            fnrpath = PATH_AUTO;
            autopath = 0;
        }
        remfile = 0;                    /* Clear these in case REMOTE */
        remappd = 0;                    /* command was interrupted... */
        rempipe = 0;
        makestr(&snd_move,g_snd_move);  /* Restore these */
        makestr(&rcv_move,g_rcv_move);
        makestr(&snd_rename,g_snd_rename);
        makestr(&rcv_rename,g_rcv_rename);
#endif /* NOXFER */

    /* Take requested action if there was an error in the previous command */

        setint();
        debug(F101,"parser tlevel","",tlevel);
        debug(F101,"parser cmd_rows","",cmd_rows);

#ifndef NOLOCAL
        debug(F101,"parser wasclosed","",wasclosed);
        if (wasclosed) {                /* If connection was just closed */
#ifndef NOSPL
            int k;
            k = mlook(mactab,"on_close",nmac); /* Look up "on_close" */
            if (k >= 0) {               /* If found, */
                /* printf("ON_CLOSE CMD LOOP\n"); */
                dodo(k,ckitoa(whyclosed),0); /* Set it up */
            }
#endif /* NOSPL */
            whyclosed = WC_REMO;
            wasclosed = 0;
        }
#endif /* NOLOCAL */

#ifndef NOSPL
        xxdot = 0;                      /* Clear this... */

        debug(F101,"parser success","",success);
        if (success == 0) {
            if (cmdstk[cmdlvl].src == CMD_TF && takerr[cmdlvl]) {
                printf("Command file terminated by error.\n");
                popclvl();
                if (cmdlvl == 0) return(0);
            }
            if (cmdstk[cmdlvl].src == CMD_MD && merror[cmdlvl]) {
                printf("Command error: macro terminated.\n");
                popclvl();
                if (m && (cmdlvl < inlevel))
                  return((int) sstate);
            }
        }
        nulcmd = (m == 2);
        debug(F101,"parser nulcmd","",nulcmd);
#else
        if (success == 0 && tlevel > -1 && takerr[tlevel]) {
            printf("Command file terminated by error.\n");
            popclvl();
            cmini(ckxech);              /* Clear the cmd buffer. */
            if (tlevel < 0)             /* Just popped out of cmd files? */
              return(0);                /* End of init file or whatever. */
        }
#endif /* NOSPL */

#ifdef MAC
        /* Check for TAKE initiated by menu. */
        if ((tlevel == -1) && lfiles)
            startlfile();
#endif /* MAC */

        /* If in TAKE file, check for EOF */
#ifndef NOSPL
#ifdef MAC
        if
#else
        while
#endif /* MAC */
          ((cmdstk[cmdlvl].src == CMD_TF)  /* If end of take file */
               && (tlevel > -1)
               && feof(tfile[tlevel])) {
            popclvl();                  /* pop command level */
            cmini(ckxech);              /* and clear the cmd buffer. */
            if (cmdlvl == 0) {          /* Just popped out of all cmd files? */
                return(0);              /* End of init file or whatever. */
            }
        }
#ifdef MAC
        miniparser(1);
        if (sstate == 'a') {            /* if cmd-. cancel */
            debug(F100, "parser: cancel take due to sstate", "", sstate);
            sstate = '\0';
            dostop();
            return(0);                  /* End of init file or whatever. */
        }
#endif /*  MAC */

#else /* NOSPL */
        if ((tlevel > -1) && feof(tfile[tlevel])) { /* If end of take */
            popclvl();                  /* Pop up one level. */
            cmini(ckxech);              /* and clear the cmd buffer. */
            if (tlevel < 0)             /* Just popped out of cmd files? */
              return(0);                /* End of init file or whatever. */
        }
#endif /* NOSPL */


#ifndef NOSPL
        debug(F101,"parser cmdlvl","",cmdlvl);
        debug(F101,"parser cmdsrc","",cmdstk[cmdlvl].src);

        if (cmdstk[cmdlvl].src == CMD_MD) { /* Executing a macro? */
            debug(F100,"parser macro","",0);
            maclvl = cmdstk[cmdlvl].lvl; /* Get current level */
            debug(F101,"parser maclvl","",maclvl);
            cbp = cmdbuf;               /* Copy next cmd to command buffer. */
            *cbp = NUL;
            if (*savbuf) {              /* In case then-part of 'if' command */
                ckstrncpy(cbp,savbuf,CMDBL); /* was saved, restore it. */
                *savbuf = '\0';
            } else {                    /* Else get next cmd from macro def */
                if (getncm(cbp,CMDBL) < 0) {
#ifdef DEBUG
                    if (deblog) {
                        debug(F101,"parser end of macro m","",m);
                        debug(F101,"parser end of macro cmdlvl","",cmdlvl);
                        debug(F101,"parser end of macro inlevel","",inlevel);
                    }
#endif /* DEBUG */
                    if (m && (cmdlvl < inlevel))
                      return((int) sstate);
                    else /* if (!m) */ continue;
                }
            }
            debug(F010,"CMD(M)",cmdbuf,0);

        } else if (cmdstk[cmdlvl].src == CMD_TF)
#else
          if (tlevel > -1)
#endif /* NOSPL */
          {
#ifndef NOSPL
            debug(F111,"parser savbuf",savbuf,tlevel);
            if (*savbuf) {              /* In case THEN-part of IF command */
                ckstrncpy(cmdbuf,savbuf,CMDBL); /* was saved, restore it. */
                *savbuf = '\0';
            } else
#endif /* NOSPL */

              /* Get next line from TAKE file */

              if ((tfcode = getnct(cmdbuf,CMDBL,tfile[tlevel],0)) < 0) {
                  debug(F111,"parser tfcode",tfile[tlevel],tfcode);
                  if (tfcode < -1) {    /* Error */
                      printf("?Error in TAKE command file: %s\n",
                             (tfcode == -2) ? "Memory allocation failure" :
                             "Line too long or contains NUL characters"
                             );
                      dostop();
                  }
                  continue;             /* -1 means EOF */
              }

        /* If interactive, get next command from user. */

        } else {                        /* User types it in. */
            if (pflag) prompt(xxstring);
            cmini(ckxech);
        }

    /* Now we know where next command is coming from. Parse and execute it. */

        repars = 1;                     /* 1 = command needs parsing */
#ifndef NOXFER
        displa = 0;                     /* Assume no file transfer display */
#endif /* NOXFER */

        while (repars) {                /* Parse this cmd until entered. */

            debug(F101,"parser top of while loop","",0);
	    xaskmore = saveask;		/* Restore global more-prompting */
	    diractive = 0;		/* DIR command not active */
	    cdactive = 0;		/* CD command not active */
#ifndef NOSPL
	    askflag = 0;		/* ASK command not active */
	    echostars = 0;		/* Nor ASKQ */
	    debok = 1;			/* Undisable debugging */
#endif /* NOSPL */

#ifdef RECURSIVE
            /* In case of "send /recursive ./?<Ctrl-U>" etc */
            recursive = 0;              /* This is never sticky */
#endif /* RECURSIVE */
            xfiletype = -1;             /* Reset this between each command */
#ifndef NOMSEND
            addlist = 0;
#endif /* NOMSEND */
#ifdef CK_RECALL
            on_recall = 1;
#endif /* CK_RECALL */
            /* This might have been changed by a switch */
            if (g_matchdot > -1) {
                matchdot = g_matchdot;
                g_matchdot = -1;
            }
            cmres();                    /* Reset buffer pointers. */

#ifdef OS2
#ifdef COMMENT
            /* we check to see if a macro is waiting to be executed */
            /* if so, we call domac on it */
            if (cmdmac) {
                ckstrncpy(cmdbuf, cmdmac, CMDBL);
                free(cmdmac);
                cmdmac = NULL;
            }
#endif /* COMMENT */
#endif /* OS2 */
#ifndef NOXFER
            bye_active = 0;
#endif /* NOXFER */
            havetoken = 0;
            xx = cmkey2(cmdtab,ncmd,"Command","",toktab,xxstring,1);
            debug(F101,"top-level cmkey2","",xx);
            if (xx == -5) {
                yy = chktok(toktab);
                debug(F101,"top-level cmkey token","",yy);
#ifndef COMMENT
                /* Either way makes absolutely no difference */
                debug(F110,"NO UNGWORD",atmbuf,0);
                /* ungword(); */
#else
                debug(F110,"TOKEN UNGWORD",atmbuf,0);
                ungword();
#endif /* COMMENT */
                switch (yy) {
                  case '#': xx = XXCOM; break; /* Comment */
                  case ';': xx = XXCOM; break; /* Comment */
#ifndef NOSPL
                  case '.': xx = XXDEF; xxdot = 1; break; /* Assignment */
                  case ':': xx = XXLBL; break; /* GOTO label */
#endif /* NOSPL */

#ifndef NOPUSH
#ifdef CK_REDIR
                  case '<':
#endif /* CK_REDIR */
                  case '@':
                  case '!':
                    if (nopush) {
                        char *s; int x;
                        if ((x = cmtxt("Text to be ignored","",&s,NULL)) < 0)
                          return(x);
                        success = 0;
                        xx = XXCOM;
                    } else {
                        switch(yy) {
#ifdef CK_REDIR
                          case '<': xx = XXFUN; break; /* REDIRECT */
#endif /* CK_REDIR */
                          case '@':
                          case '!': xx = XXSHE; break; /* Shell escape */
                        }
                    }
                    break;
#endif /* NOPUSH */
#ifdef CK_RECALL
                  case '^': xx = XXREDO;  break;
#endif /* CK_RECALL */
#ifndef NOSPL
                  case '{': xx = XXMACRO; break;
                  case '(': xx = XXSEXP;  break;
#endif /* NOSPL */

                  default:
                    if (!quiet && !cmd_err) {
                        printf("\n?Not a valid command or token - \"%s\"\n",
			       cmddisplay((char *)cmdbuf,xx)
			       );
			/* cmderr(); */ newerrmsg("");
                    }
                    xx = -2;
                }
                havetoken = 1;
                debug(F101,"HAVE TOKEN","",xx);
            }
            if (xx > -1) {
                topcmd = xx;            /* Top-level command index */
#ifndef NOSPL
                if (maclvl > -1)
                  lastcmd[maclvl] = xx;
#endif /* NOSPL */
                debug(F101,"topcmd","",topcmd);
                debug(F101,"cmflgs","",cmflgs);
            }

#ifndef NOSPL
            /* Special handling for IF..ELSE */

            debug(F101,"cmdlvl","",cmdlvl);
            debug(F101,"ifcmd[cmdlvl]","",ifcmd[cmdlvl]);

            if (ifcmd[cmdlvl])          /* Count stmts after IF */
              ifcmd[cmdlvl]++;
            if (ifcmd[cmdlvl] > 2 && xx != XXELS && xx != XXCOM)
              ifcmd[cmdlvl] = 0;

            /* Execute the command and take action based on return code. */

            if (nulcmd) {               /* Ignoring this command? */
                xx = XXCOM;             /* Make this command a comment. */
            }
            fnsuccess = 1;              /* For catching \function() errors */
#endif /* NOSPL */

            debug(F101,"calling docmd()","",xx);
            zz = docmd(xx);             /* Parse rest of command & execute. */

#ifndef NOSPL
	    {				/* For \v(lastcommand) */
		extern char * prevcmd;
		/* The exception list kind of a hack but let's try it... */
		if (ckstrcmp(cmdbuf,"_getarg",7,0) &&
		    ckstrcmp(cmdbuf,"if ",3,0) &&
		    ckstrcmp(cmdbuf,"xif ",4,0) &&
		    ckstrcmp(cmdbuf,"do _if",6,0) &&
		    ckstrcmp(cmdbuf,"_assign _if",11,0))
		  ckstrncpy(prevcmd,cmdbuf,CMDBL);
	    }
#endif	/* NOSPL */

#ifndef NOSPL
            if (fnerror && !fnsuccess)
              success = 0;
#endif /* NOSPL */
            debug(F101,"docmd returns","",zz);
            /* debug(F011,"cmdbuf",cmdbuf,30); */
            /* debug(F011,"atmbuf",atmbuf,30); */
#ifdef MAC
            if (tlevel > -1) {
                if (sstate == 'a') {    /* if cmd-. cancel */
                    debug(F110, "parser: cancel take, sstate:", "a", 0);
                    sstate = '\0';
                    dostop();
                    return(0);          /* End of init file or whatever. */
                }
            }
#endif /* MAC */

            switch (zz) {
              case -4:                  /* EOF (e.g. on redirected stdin) */
                doexit(GOOD_EXIT,xitsta); /* ...exit successfully */
              case -1:                  /* Reparse needed */
                repars = 1;             /* Just set reparse flag and... */
                continue;
#ifdef OS2
              case -7:                  /* They typed a disk letter */
                if (!zchdir((char *)cmdbuf)) {
                    perror((char *)cmdbuf);
                    success = 0;
                } else success = 1;
                repars = 0;
                continue;

#endif /* OS2 */
/*
  Changed 2013-12-06 fdc: Previously the failing command was echoed only in
  the -6 and -9 cases.  This made it difficult to know exactly which command
  had failed when a macro or command file was being executed and the failing
  command had already issued its own error message and returned -9.  Now we
  include -9 in the caselist for this code, but we echo the failing command
  only if Kermit is not at top level.  So now, even though the error message
  is imprecise about *where* the failing command was, at least it shows the
  failing command.
*/
	      case -9:			/* Bad, error message already done */
              case -6:                  /* Invalid command given w/no args */
              case -2:			/* Invalid command given w/args */
		if (zz == -2 || zz == -6 || (zz == -9 && cmdlvl > 0)) {
		    int x = 0;
		    char * eol = "";
		    x = strlen(cmdbuf);	/* Avoid blank line */
#ifdef COMMENT
		    if (x > 0) {
			if (cmdbuf[x-1] != LF)
			  eol = "\n";
			printf("?Invalid: %s%s",
			       cmddisplay(cmdbuf,xx),eol
			       );
		    } else
		      printf("?Invalid\n");
#else
                    if (x > 0)
                      newerrmsg("Syntax error");
#endif  /* COMMENT */
		}
		success = 0;
		debug(F110,"top-level cmkey failed",cmdbuf,0);
		/* If in background w/ commands coming stdin, terminate */
		if (pflag == 0 && tlevel < 0)
		  fatal("Kermit command error in background execution");
/*
  Command retry feature, edit 190.  If we're at interactive prompting level,
  reprompt the user with as much of the command as didn't fail.
*/
#ifdef CK_RECALL
		if (cm_retry && !xcmdsrc) { /* If at top level */
		    int len;
		    char *p, *s;
		    len = strlen(cmdbuf); /* Length of command buffer */
		    p = malloc(len + 1);  /* Allocate space for copy */
		    if (p) {              /* If we got the space copy */
			strcpy(p,cmdbuf); /* the command buffer (SAFE). */
			/* Chop off final field, the one that failed. */
			s = p + len - 1;          /* Point to end */
			while (*s == SP && s > p) /* Trim blanks */
			  s--;
			while (*s != SP && s > p) /* Trim last field */
			  s--;
			if (s > p)        /* Keep the space */
			  s++;            /* after last good field */
			if (s >= p)       /* Cut off remainder */
			  *s = NUL;
			cmini(ckxech);    /* Reinitialize the parser */
			ckstrncpy(cmdbuf,p,CMDBL); /* Copy result back */
			free(p);          /* Free temporary storage */
			p = NULL;
			prompt(xxstring); /* Reprint the prompt */
			printf("%s",cmdbuf); /* Reprint partial command */
			repars = 1;          /* Force reparse */
			continue;
		    }
		} else
#endif /* CK_RECALL */
                  /* cmderr(); */ newerrmsg("");

		cmini(ckxech);		/* (fall thru) */

	      case -3:			/* Empty command OK at top level */
		repars = 0;		/* Don't need to reparse. */
		continue;		/* Go back and get another command. */

	      default:			/* Command was successful. */
#ifndef NOSPL
		debug(F101,"parser preparing to continue","",maclvl);
#endif /* NOSPL */
		debug(F101,"parser success","",success);
		repars = 0;		/* Don't need to reparse. */
		continue;		/* Go back and get another command. */
	    }
        }
#ifndef NOSPL
        debug(F101,"parser breaks out of while loop","",maclvl);
        if (m && (cmdlvl < inlevel))  return((int) sstate);
#endif /* NOSPL */
    }

/* Got an action command, return start state. */

    return((int) sstate);
}

#ifndef NOSPL
/*
  OUTPUT command.
  Buffering and pacing added by L.I. Kirby, 5A(189), June 1993.
*/
#define OBSIZE 80                       /* Size of local character buffer */

static int obn;                         /* Buffer offset (high water mark) */
static char obuf[OBSIZE+1];             /* OUTPUT buffer. */
static char *obp;                       /* Pointer to output buffer. */
_PROTOTYP( static int oboc, (char) );
_PROTOTYP( static int xxout, (char *, int) );

static int
#ifdef CK_ANSIC
xxout(char *obuf, int obsize)
#else
xxout(obuf, obsize) char *obuf; int obsize;
#endif /* CK_ANSIC */
/* xxout */ {                           /* OUTPUT command's output function */
    int i, rc;

    debug(F101,"xxout obsize","",obsize);
    debug(F101,"xxout pacing","",pacing);
    debug(F111,"xxout string",obuf,strlen(obuf));

    rc = 0;                             /* Initial return code. */
    if (!obuf || (obsize <= 0))         /* Nothing to output. */
      goto xxout_x;                     /* Return successfully */

    rc = -1;                              /* Now assume failure */
    if (pacing == 0) {                    /* Is pacing enabled? */
        if ((local ?                      /* No, write entire string at once */
             ttol((CHAR *)obuf, obsize) : /* to communications device */
             conxo(obsize, obuf))         /* or to console */
            != obsize)
          goto xxout_x;
    } else {
        for (i = 0; i < obsize; i++) {  /* Write individual chars */
            if ((local ? ttoc(obuf[i]) : conoc(obuf[i])) < 0)
              goto xxout_x;
            msleep(pacing);
        }
    }
    if (duplex) {
#ifdef OS2
        if (inecho && local) {
#ifndef NOLOCAL
            for (i = 0; i < obsize; i++) { /* Write to emulator */
                scriptwrtbuf((USHORT)obuf[i]); /* which also logs session */
            }
#endif /* NOLOCAL */
            conxo(obsize,obuf);
        } else if (seslog) {            /* or log session here */
            logstr((char *) obuf, obsize);
        }
#else /* OS2 */
        if (seslog) {
            logstr((char *) obuf, obsize);
        }
        if (inecho && local) {
            conxo(obsize,obuf);
        }
#endif /* OS2 */
    }
    rc = 0;                             /* Success */
  xxout_x:
    obn = 0;                            /* Reset count */
    obp = obuf;                         /* and pointers */
    return(rc);                         /* return our return code */
}

#ifdef COMMENT
/*
  Macros for OUTPUT command execution, to make it go faster.
*/
#define obfls() ((xxout(obuf,obn)<0)?-1:0)
#define oboc(c) ((*obp++=(char)(c)),*obp=0,(((++obn)>=OBSIZE)?obfls():0))

#else /* The macros cause some compilers to generate bad code. */

static int
#ifdef CK_ANSIC
oboc(char c)
#else
oboc(c) char c;
#endif /* CK_ANSIC */
/* oboc */ {                            /* OUTPUT command's output function */

    *obp++ = c;                         /* Deposit character */
    *obp = NUL;                         /* Flush buffer if it's now full */

    return(((++obn) >= OBSIZE) ? xxout(obuf,obn) : 0);
}
#endif /* COMMENT */

/*  Routines for handling local variables -- also see popclvl().  */

VOID
freelocal(m) int m; {                   /* Free local variables */
    struct localvar * v, * tv;          /* at macro level m... */
    debug(F101,"freelocal level","",m);
    if (m < 0) return;
    v = localhead[m];                   /* List head for level m */
    while (v) {
        if (v->lv_name)                 /* Variable name */
          free(v->lv_name);
        if (v->lv_value)                /* Value */
          free(v->lv_value);
        tv = v;                         /* Save pointer to this node */
        v = v->lv_next;                 /* Get next one */
        if (tv)                         /* Free this one */
          free((char *)tv);
    }
    localhead[m] = (struct localvar *) NULL; /* Done, set list head to NULL */
}

#define MAXLOCALVAR 64

/* Return a pointer to the definition of a user-defined variable */

static char *
vardef(s,isarray,x1,x2) char * s; int * isarray, * x1, * x2; {
    char * p;
    char c;
    *isarray = 0;
    if (!s) return(NULL);
    if (!*s) return(NULL);
    p = s;
    if (*s == CMDQ) {
        p++;
        if (!*p)
          return(NULL);
        if ((c = *p) == '%') {          /* Scalar variable. */
            c = *++p;                   /* Get ID character. */
            p = "";                     /* Assume definition is empty */
            if (!c)
              return(NULL);
            if (c >= '0' && c <= '9') { /* Digit for macro arg */
                if (maclvl < 0)         /* Digit variables are global */
                  return(g_var[c]);     /* if no macro is active */
                else                    /* otherwise */
                  return(m_arg[maclvl][c - '0']); /* they're on the stack */
            } else if (isalpha(c)) {
                if (isupper(c)) c -= ('a'-'A');
                return(g_var[c]);           /* Letter for global variable */
            } else
              return(NULL);
        } else if (c == '&') {          /* Array reference. */
            int x, vbi, d;
            x = arraynam(p,&vbi,&d);    /* Get name and subscript */
            if (x > -1 || d == -17) {
                *isarray = 1;
                *x1 = vbi;
                *x2 = (d == -17) ? 0 : d;
            }
            if (x < 0)
              return(NULL);
            if (chkarray(vbi,d) >= 0) {	/* Array is declared? */
                vbi -= ARRAYBASE;       /* Convert name to index */
                if (a_dim[vbi] >= d) {  /* If subscript in range */
                    char **ap;
                    ap = a_ptr[vbi];
                    return((ap) ? ap[d] : NULL);
                }
            }
        }
        return(NULL);
    } else {
        int k;
        k = mxlook(mactab,s,nmac);
        return((k > -1) ? mactab[k].mval : NULL);
    }
}


int
addlocal(p) char * p; {
    int x, z, isarray = 0;
    char * s;
    struct localvar * v, *prev = (struct localvar *)NULL;
    extern int tra_asg; int tra_tmp;

    tra_tmp = tra_asg;

    s = vardef(p,&isarray,&x,&z);       /* Get definition of variable */
    if (isarray) {                      /* Arrays are handled specially */
        pusharray(x,z);
        return(0);
    }
    if (!s) s = "";
    if ((v = localhead[cmdlvl])) {      /* Already have some at this level? */
        while (v) {                     /* Find end of list */
            prev = v;
            v = v->lv_next;
        }
    }
    v = (struct localvar *) malloc(sizeof(struct localvar));
    if (!v) {
        printf("?Failure to allocate storage for local variables");
        return(-9);
    }
    if (!localhead[cmdlvl])             /* If first, set list head */
      localhead[cmdlvl] = v;
    else                                /* Otherwise link previous to this */
      prev->lv_next = v;
    prev = v;                           /* And make this previous */
    v->lv_next = (struct localvar *) NULL; /* No next yet */

    if (!(v->lv_name = (char *) malloc((int) strlen(p) + 1)))
      return(-1);
    strcpy(v->lv_name, p);              /* Copy name into new node (SAFE) */

    if (*s) {
        if (!(v->lv_value = (char *) malloc((int) strlen(s) + 1)))
          return(-1);
        strcpy(v->lv_value, s);         /* Copy value into new node (SAFE) */
    } else
      v->lv_value = NULL;

    tra_asg = 0;
    delmac(p,1);                        /* Delete the original macro */
    tra_asg = tra_tmp;
    return(0);
}

int
dolocal() {                             /* Do the LOCAL command */
    int i, x;
    char * s;
    char * list[MAXLOCALVAR+2];         /* Up to 64 variables per line */

    if ((x = cmtxt("Variable name(s)","",&s,NULL)) < 0)
      return(x);

    xwords(s,MAXLOCALVAR,list,0);       /* Break up line into "words" */

    /* Note: Arrays do not use the localhead list, but have their own stack */

    for (i = 1; i < MAXLOCALVAR && list[i]; i++) { /* Go through the list */
        if (addlocal(list[i]) < 0)
          goto localbad;
    }
    return(success = 1);

  localbad:
    printf("?Failure to allocate storage for local variables");
    freelocal(cmdlvl);
    return(-9);
}

/*  D O O U T P U T  --  Returns 0 on failure, 1 on success */

#ifndef NOKVERBS
#define K_BUFLEN 30
#define SEND_BUFLEN 255
#define sendbufd(x) { osendbuf[sendndx++] = x;\
 if (sendndx == SEND_BUFLEN) {dooutput(s,cx); sendndx = 0;}}
#endif /* NOKVERBS */

int outesc = 1;                         /* Process special OUTPUT escapes */

int
dooutput(s, cx) char *s; int cx; {
#ifdef SSHBUILTIN
    extern int ssh_cas;
    extern char * ssh_cmd;
#endif /* SSHBUILTIN */
    int x, xx, y, quote;                /* Workers */
    int is_tn = 0;

    is_tn = (local && network && IS_TELNET()) ||
      (!local && sstelnet);

    debug(F111,"dooutput s",s,(int)strlen(s));

    if (local) {                        /* Condition external line */
#ifdef NOLOCAL
        goto outerr;
#else
	if (ttchk() < 0) {
	    if (!network) {
		if (carrier != CAR_OFF) {
		    int x;
		    x = ttgmdm();
		    if ((x > -1) && ((x & BM_DCD) == 0)) {
			printf(
"?Carrier signal required but not present - Try SET CARRIER-WATCH OFF.\n"
                              );
			return(0);
		    }
		} else {
		    printf(
"?Problem with serial port or modem or cable - Try SHOW COMMUNICATIONS.\n"
                          );
		    return(0);
		}
	    }
	    printf("?Connection %s %s is not open or not functioning.\n",
		   network ? "to" : "on",
		   ttname
		   );
	    return(0);
	}
        if (ttvt(speed,flow) < 0) {
            printf("?OUTPUT initialization error\n");
            return(0);
        }
#endif /* NOLOCAL */
    }
#ifdef SSHBUILTIN
    if ( network && nettype == NET_SSH && ssh_cas && ssh_cmd && 
         !(strcmp(ssh_cmd,"kermit") && strcmp(ssh_cmd,"sftp"))) {
        if (!quiet)
            printf("?SSH Subsystem active: %s\n", ssh_cmd);
        return(0);
    }
#endif /* SSHBUILTIN */

    if (!cmdgquo()) {                   /* COMMAND QUOTING OFF */
        x = strlen(s);                  /* Just send the string literally */
        xx = local ? ttol((CHAR *)s,x) : conxo(x,s);
        return(success = (xx == x) ? 1 : 0);
    }
    quote = 0;                          /* Initialize backslash (\) quote */
    obn = 0;                            /* Reset count */
    obp = obuf;                         /* and pointers */

  outagain:
    while ((x = *s++)) {                /* Loop through the string */
        y = 0;                          /* Error code, 0 = no error. */
        debug(F000,"dooutput","",x);
        if (quote) {                    /* This character is quoted */
#ifndef NOKVERBS
           if (x == 'k' || x == 'K') {  /* \k or \K */
               extern struct keytab kverbs[];
               extern int nkverbs;
               extern char * keydefptr;
               extern int keymac;
               extern int keymacx;
               int x, y, brace = 0;
               int pause;
               char * p, * b;
               char kbuf[K_BUFLEN + 1]; /* Key verb name buffer */
               char osendbuf[SEND_BUFLEN +1];
               int  sendndx = 0;

               if (xxout(obuf,obn) < 0) /* Flush buffer */
                 goto outerr;
               debug(F100,"OUTPUT KVERB","",0); /* Send a KVERB */
               {                        /* Have K verb? */
                   if (!*s) {
                       break;
                   }
/*
  We assume that the verb name is {braced}, or it extends to the end of the
  string, s, or it ends with a space, control character, or backslash.
*/
                   p = kbuf;            /* Copy verb name into local buffer */
                   x = 0;
                   while ((x++ < K_BUFLEN) && (*s > SP) && (*s != CMDQ)) {
                       if (brace && *s == '}') {
                           break;
                       }
                       *p++ = *s++;
                   }
                   if (*s && !brace)    /* If we broke because of \, etc, */
                     s--;               /*  back up so we get another look. */
                   brace = 0;
                   *p = NUL;            /* Terminate. */
                   p = kbuf;            /* Point back to beginning */
                   debug(F110,"dooutput kverb",p,0);
                   y = xlookup(kverbs,p,nkverbs,&x); /* Look it up */
                   debug(F101,"dooutput lookup",0,y);
                   if (y > -1) {
                       if (sendndx) {
                           dooutput(osendbuf,cx);
                           sendndx = 0;
                       }
                       dokverb(VCMD,y);
#ifndef NOSPL
                   } else {             /* Is it a macro? */
                       y = mxlook(mactab,p,nmac);
                       if (y > -1) {
                           cmpush();
                           keymac = 1;  /* Flag for key macro active */
                           keymacx = y; /* Key macro index */
                           keydefptr = s; /* Where to resume next time */
                           debug(F111,"dooutput mxlook",keydefptr,y);
                           parser(1);
                           cmpop();
                       }
#endif /* NOSPL */
                   }
               }
               quote = 0;
               continue;
           } else
#endif /* NOKVERBS */
             if (outesc && (x == 'n' || x == 'N')) { /* \n or \N */
                 if (xxout(obuf,obn) < 0) /* Flush buffer */
                   goto outerr;
                 debug(F100,"OUTPUT NUL","",0); /* Send a NUL */
                 if (local)
                   ttoc(NUL);
                 else
                   conoc(NUL);
                 quote = 0;
                 continue;

             } else if (outesc && (x == 'b' || x == 'B')) { /* \b or \B */

                if (xxout(obuf,obn) < 0) /* Flush buffer first */
                  goto outerr;
                debug(F100,"OUTPUT BREAK","",0);
#ifndef NOLOCAL
                ttsndb();               /* Send BREAK signal */
#else
                 if (local)
                   ttoc(NUL);
                 else
                   conoc(NUL);
#endif /* NOLOCAL */
                quote = 0;              /* Turn off quote flag */
                continue;               /* and not the b or B */
#ifdef CK_LBRK
             } else if (outesc && (x == 'l' || x == 'L')) { /* \l or \L */
                 if (xxout(obuf,obn) < 0) /* Flush buffer first */
                   goto outerr;
                 debug(F100,"OUTPUT Long BREAK","",0);
#ifndef NOLOCAL
                 ttsndlb();             /* Send Long BREAK signal */
#else
                 if (local)
                   ttoc(NUL);
                 else
                   conoc(NUL);
#endif /* NOLOCAL */
                 quote = 0;             /* Turn off quote flag */
                 continue;              /* and not the l or L */
#endif /* CK_LBRK */

             } else if (x == CMDQ) {    /* Backslash itself */
                 debug(F100,"OUTPUT CMDQ","",0);
                 xx = oboc(dopar(CMDQ)); /* Output the backslash. */
                 if (xx < 0)
                   goto outerr;
                 quote = 0;
                 continue;

             } else {                   /* if \ not followed by special esc */
                /* Note: Atari ST compiler won't allow macro call in "if ()" */
                 xx = oboc(dopar(CMDQ)); /* Output the backslash. */
                 if (xx < 0)
                   goto outerr;
                 quote = 0;             /* Turn off quote flag */
             }
        } else if (x == CMDQ) {         /* This is the quote character */
            quote = 1;                  /* Go back and get next character */
            continue;                   /* which is quoted */
        }
        xx = oboc(dopar((char)x));      /* Output this character */
        debug(F111,"dooutput",obuf,obn);
        if (xx < 0)
          goto outerr;
#ifdef COMMENT
        if (seslog && duplex) {         /* Log the character if log is on */
            logchar((char)x);
        }
#endif /* COMMENT */
        if (x == '\015') {              /* String contains carriage return */
            int stuff = -1, stuff2 = -1;
            if (tnlm) {                 /* TERMINAL NEWLINE ON */
                stuff = LF;             /* Stuff LF */
            }
#ifdef TNCODE
            /* TELNET NEWLINE ON/OFF/RAW */
            if (is_tn) {
                switch (TELOPT_ME(TELOPT_BINARY) ? /* NVT or BINARY */
                        tn_b_nlm :
                        tn_nlm
                        ) {
                  case TNL_CR:
                    break;
                  case TNL_CRNUL:
                    stuff2 = stuff;
                    stuff  = NUL;
                    break;
                  case TNL_CRLF:
                    stuff2 = stuff;
                    stuff = LF;
                    break;
                }
            }
#endif /* TNCODE */
            if (stuff > -1) {           /* Stuffing another character... */
                xx = oboc(dopar((CHAR)stuff));
                if (xx < 0)
                  goto outerr;
#ifdef COMMENT
                if (seslog && duplex) { /* Log stuffed char if appropriate */
                    logchar((char)stuff);
                }
#endif /* COMMENT */
            }
            if (stuff2 > -1) {          /* Stuffing another character... */
                xx = oboc(dopar((CHAR)stuff2));
                if (xx < 0)
                  goto outerr;
#ifdef COMMENT
                if (seslog && duplex) { /* Log stuffed char if appropriate */
                    logchar((char)stuff2);
                }
#endif /* COMMENT */
            }
            if (xxout(obuf,obn) < 0)    /* Flushing is required here! */
              goto outerr;
        }
    }
    if (cx == XXLNOUT) {
        s = "\015";
        cx = 0;
        goto outagain;
    }
    if (quote == 1)                     /* String ended with backslash */
      xx = oboc(dopar(CMDQ));

    if (obn > 0)                        /* OUTPUT done */
      if (xxout(obuf,obn) < 0)          /* Flush the buffer if necessary. */
        goto outerr;
    return(1);

outerr:                                 /* OUTPUT command error handler */
    if (msgflg) printf("?OUTPUT execution error\n");
    return(0);

/* Remove "local" OUTPUT macro defininitions */

#ifdef COMMENT
/* No more macros ... */
#undef oboc
#undef obfls
#endif /* COMMENT */
}
#endif /* NOSPL */

/* Display version herald and initial prompt */

VOID
herald() {
    int x = 0, i;
    extern int srvcdmsg;
    extern char * cdmsgfile[];
    char * ssl;
    char * krb4;
    char * krb5;

#ifndef NOCMDL
    extern char * bannerfile;
    debug(F110,"herald bannerfile",bannerfile,0);
    if (bannerfile) {
        concb((char)escape);
        if (dotype(bannerfile,1,0,0,NULL,0,NULL,0,0,NULL,0) > 0) {
            debug(F111,"herald","srvcdmsg",srvcdmsg);
            if (srvcdmsg) {
                for (i = 0; i < 8; i++) {
                    debug(F111,"herald cdmsgfile[i]",cdmsgfile[i],i);
                    if (zchki(cdmsgfile[i]) > -1) {
                        printf("\n");
                        dotype(cdmsgfile[i],
                               xaskmore,0,0,NULL,0,NULL,0,0,NULL,0);
                        break;
                    }
                }
            }
            return;
        }
    }
#endif /* NOCMDL */

#ifdef COMMENT
    /* The following generates bad code in SCO compilers. */
    /* Observed in both OSR5 and Unixware 2 -- after executing this */
    /* statement when all conditions are false, x has a value of -32. */
    if (noherald || quiet || bgset > 0 || (bgset != 0 && backgrd != 0))
      x = 1;
#else
    x = 0;
    if (noherald || quiet)
      x = 1;
    else if (bgset > 0)
      x = 1;
    else if (bgset < 0 && backgrd > 0)
      x = 1;
#endif /* COMMENT */

    ssl = "";
    krb4 = "";
    krb5 = "";
#ifdef CK_AUTHENTICATION
#ifdef CK_SSL    
    ssl = "+SSL";
#endif	/* CK_SSL */
#ifdef KRB4
    krb4 = "+KRB4";
#endif	/* KRB4 */
#ifdef KRB5
    krb5 = "+KRB5";
#endif	/* KRB5 */
#endif	/* CK_AUTHENTICATION */

    if (x == 0) {
#ifdef datageneral
        printf("%s, for%s\n",versio,ckxsys);
#else
#ifdef OSK
        printf("%s, for%s\n",versio,ckxsys);
#else
#ifdef CK_64BIT
        printf("%s, for%s%s%s%s (64-bit)\n\r",versio,ckxsys,ssl,krb4,krb5);
#else
        printf("%s, for%s%s%s%s\n\r",versio,ckxsys,ssl,krb4,krb5);
#endif/* CK_64BIT */
#endif /* OSK */
#endif /* datageneral */
        printf(" Copyright (C) 1985, %s,\n", ck_cryear);
        printf("  Trustees of Columbia University in the City of New York.\n");
#ifdef COMMENT
#ifdef OS2
       shoreg();
#endif /* OS2 */
#endif /* COMMENT */

        if (!quiet && !backgrd) {
#ifdef COMMENT
/* "Default file-transfer mode is AUTOMATIC" is useless information... */
            char * s;
            extern int xfermode;
#ifdef VMS
            s = "AUTOMATIC";
#else
            if (xfermode == XMODE_A) {
                s = "AUTOMATIC";
            } else {
                s = gfmode(binary,1);
            }
            if (!s) s = "";
#endif /* VMS */
            if (*s)
              printf("Default file-transfer mode is %s\n", s);
#endif /* COMMENT */

            debug(F111,"herald","srvcdmsg",srvcdmsg);
            if (srvcdmsg) {
                for (i = 0; i < 8; i++) {
                    debug(F111,"herald cdmsgfile[i]",cdmsgfile[i],i);
                    if (zchki(cdmsgfile[i]) > -1) {
                        printf("\n");
                        dotype(cdmsgfile[i],
                               xaskmore,0,0,NULL,0,NULL,0,0,NULL,0);
                        break;
                    }
                }
            }
            printf("Type ? or HELP for help.\n");
        }
    }
}

/*  G F M O D E  --  Get File (transfer) Mode  */

char *
gfmode(binary,upcase) int binary, upcase; {
    char * s;
    switch (binary) {
      case XYFT_T: s = upcase ? "TEXT" : "text"; break;
#ifdef VMS
      case XYFT_B: s = upcase ? "BINARY FIXED" : "binary fixed"; break;
      case XYFT_I: s = upcase ? "IMAGE" : "image"; break;
      case XYFT_L: s = upcase ? "LABELED" : "labeled"; break;
      case XYFT_U: s = upcase ? "BINARY UNDEF" : "binary undef"; break;
#else
#ifdef MAC
      case XYFT_B: s = upcase ? "BINARY" : "binary"; break;
      case XYFT_M: s = upcase ? "MACBINARY" : "macbinary"; break;
#else
      case XYFT_B: s = upcase ? "BINARY" : "binary"; break;
#ifdef CK_LABELED
      case XYFT_L: s = upcase ? "LABELED" : "labeled"; break;
#endif /* CK_LABELED */
#endif /* MAC */
#endif /* VMS */
      case XYFT_X: s = upcase ? "TENEX" : "tenex"; break;
      default: s = "";
    }
    return(s);
}

#ifndef NOSPL
static int
isaa(s) char * s; {                     /* Is associative array */
    char c;
    int x;
    if (!s) s = "";
    if (!*s) return(0);
    s++;
    while ((c = *s++)) {
        if (c == '<') {
            x = strlen(s);
            return ((*(s+x-1) == '>') ? 1 : 0);
        }
    }
    return(0);
}

/*  M L O O K  --  Lookup the macro name in the macro table  */

/*
  Call this way:  v = mlook(table,word,n);

    table - a 'struct mtab' table.
    word  - the target string to look up in the table.
    n     - the number of elements in the table.

  The keyword table must be arranged in ascending alphabetical order, and
  all letters must be lowercase.

  Returns the table index, 0 or greater, if the name was found, or:

   -3 if nothing to look up (target was null),
   -2 if ambiguous,
   -1 if not found.

  A match is successful if the target matches a keyword exactly, or if
  the target is a prefix of exactly one keyword.  It is ambiguous if the
  target matches two or more keywords from the table.
*/
int
mlook(table,cmd,n) struct mtab table[]; char *cmd; int n; {
    register int i;
    int v, w, cmdlen = 0;
    char c = 0, c1, * s;
    if (!cmd) cmd = "";

    for (s = cmd; *s; s++) cmdlen++;    /* (instead of strlen) */
    debug(F111,"MLOOK",cmd,cmdlen);

    c1 = *cmd;
    if (isupper(c1))
      c1 = tolower(c1);
    if (cmdlen < 1)
      return(-3);

/* Not null, look it up */

    if (n < 12) {                       /* Not worth it for small tables */
        i = 0;
    } else {                            /* Binary search for where to start */
        int lo = 0;
        int hi = n;
        int count = 0;
        while (lo+2 < hi && ++count < 12) {
            i = lo + ((hi - lo) / 2);
            c = *(table[i].kwd);
            if (isupper(c)) c = tolower(c);
            if (c < c1) {
                lo = i;
            } else {
                hi = i;
            }
        }
        i = (c < c1) ? lo+1 : lo;
    }
    for ( ; i < n-1; i++) {
        s = table[i].kwd;
        if (!s) s = "";
        if (!*s) continue;              /* Empty table entry */
        c = *s;
        if (isupper(c)) c = tolower(c);
        if (c1 != c) continue;          /* First char doesn't match */
        if (!ckstrcmp(s,cmd,-1,0))      /* Have exact match? */
          return(i);
        v = !ckstrcmp(s,cmd,cmdlen,0);
        w = ckstrcmp(table[i+1].kwd,cmd,cmdlen,0);
        if (v && w)                     /* Have abbreviated match? */
          return(i);
        if (v)                          /* Ambiguous? */
          return(-2);
        if (w > 0)                      /* Past our alphabetic area? */
          return(-1);
    }

/* Last (or only) element */

    if (!ckstrcmp(table[n-1].kwd,cmd,cmdlen,0))
      return(n-1);

    return(-1);
}

/* mxlook is like mlook, but an exact full-length match is required */

int
mxlook(table,cmd,n) char *cmd; struct mtab table[]; int n; {
    register int i;
    int w, cmdlen = 0, one = 0;
    register char c = 0, c1, * s;

    if (!cmd) cmd = "";                 /* Check args */

    for (s = cmd; *s; s++) cmdlen++;    /* (instead of strlen) */
    debug(F111,"MXLOOK",cmd,cmdlen);

    c1 = *cmd;                          /* First char of string to look up */
    if (isupper(c1))
      c1 = tolower(c1);
    if (!*(cmd+1))                      /* Special handling for 1-char names */
      one = 1;

    if (cmdlen < 1)                     /* Nothing to look up */
      return(-3);

    if (n < 12) {                       /* Not worth it for small tables */
        i = 0;
    } else {                            /* Binary search for where to start */
        int lo = 0;
        int hi = n;
        int count = 0;
        while (lo+2 < hi && ++count < 12) {
            i = lo + ((hi - lo) / 2);
            c = *(table[i].kwd);
            if (isupper(c)) c = tolower(c);
            if (c < c1) {
                lo = i;
            } else {
                hi = i;
            }
        }
        i = (c < c1) ? lo+1 : lo;
    }
    for ( ; i < n; i++) {               /* Look thru table */
        s = table[i].kwd;               /* This entry */
        if (!s) s = "";
        if (!*s) continue;              /* Empty table entry */
        c = *s;
        if (isupper(c)) c = tolower(c);
        if (c1 != c) continue;          /* First char doesn't match */
        if (one) {                      /* Name is one char long */
            if (!*(s+1))
              return(i);                /* So is table entry */
        }
#ifdef COMMENT
        if (((int)strlen(s) == cmdlen) &&
            (!ckstrcmp(s,cmd,cmdlen,0))) return(i);
#else
        w = ckstrcmp(s,cmd,-1,0);
        if (!w) {
            debug(F111,"MXLOOK",mactab[i].mval,i);
            return(i);
        }
        if (w > 0) return(-1);
#endif /* COMMENT */
    }
    return(-1);
}

/* mxxlook is like mxlook, but case-sensitive */

int
mxxlook(table,cmd,n) char *cmd; struct mtab table[]; int n; {
    int i, cmdlen;
    if (!cmd) cmd = "";
    if (((cmdlen = strlen(cmd)) < 1) || (n < 1)) return(-3);
    /* debug(F111,"mxxlook target",cmd,n); */
    for (i = 0; i < n; i++) {
        if (((int)strlen(table[i].kwd) == cmdlen) &&
            (!strncmp(table[i].kwd,cmd,cmdlen)))
          return(i);
    }
    return(-1);
}

static int
traceval(nam, val) char * nam, * val; { /* For TRACE command */
    if (val)
      printf(">>> %s: \"%s\"\n", nam, val);
    else
      printf(">>> %s: (undef)\n", nam);
    return(0);
}

#ifdef USE_VARLEN                       /* Not used */

/*  V A R L E N  --  Get length of variable's value.

  Given a variable name, return the length of its definition or 0 if the
  variable is not defined.  If it is defined, set argument s to point to its
  definition.  Otherwise set s to NULL.
*/
int
varlen(nam,s) char *nam; char **s; {    /* Length of value of variable */
    int x, z;
    char *p = NULL, c;

    *s = NULL;
    if (!nam) return(0);                /* Watch out for null pointer */
    if (*nam == CMDQ) {
        nam++;
        if (*nam == '%') {              /* If it's a variable name */
            if (!(c = *(nam+1))) return(0); /* Get letter or digit */
            p = (char *)0;              /* Initialize value pointer */
            if (maclvl > -1 && c >= '0' && c <= '9') { /* Digit? */
                p = m_arg[maclvl][c - '0']; /* Pointer from macro-arg table */
            } else {                    /* It's a global variable */
                if (c < 33 || c > GVARS) return(0);
                p = g_var[c];           /* Get pointer from global-var table */
            }
        } else if (*nam == '&') {               /* An array reference? */
            char **q;
            if (arraynam(nam,&x,&z) < 0) /* If syntax is bad */
              return(-1);               /* return -1. */
            x -= ARRAYBASE;             /* Convert name to number. */
            if ((q = a_ptr[x]) == NULL) /* If array not declared, */
              return(0);                /* return -2. */
            if (z > a_dim[x])           /* If subscript out of range, */
              return(0);                /* return -3. */
            p = q[z];
        }
    } else {                            /* Macro */
        z = isaa(nam);
        x = z ? mxxlook(mactab,nam,nmac) : mlook(mactab,nam,nmac);
        if (x < 0)
          return(0);
        p = mactab[x].mval;
    }
    if (p)
      *s = p;
    else
      p = "";
    return((int)strlen(p));
}
#endif /* USE_VARLEN */

/*
  This routine is for the benefit of those compilers that can't handle
  long string constants or continued lines within them.  Long predefined
  macros like FOR, WHILE, and XIF have their contents broken up into
  arrays of string pointers.  This routine concatenates them back into a
  single string again, and then calls the real addmac() routine to enter
  the definition into the macro table.
*/
int
addmmac(nam,s) char *nam, *s[]; {       /* Add a multiline macro definition */
    int i, x, y; char *p;
    x = 0;                              /* Length counter */
    for (i = 0; (y = (int)strlen(s[i])) > 0; i++) { /* Add up total length */
        debug(F111,"addmmac line",s[i],y);
        x += y;
    }
    debug(F101,"addmmac lines","",i);
    debug(F101,"addmmac loop exit","",y);
    debug(F111,"addmmac length",nam,x);
    if (x < 0) return(-1);

    p = malloc(x+1);                    /* Allocate space for all of it. */
    if (!p) {
        printf("?addmmac malloc error: %s\n",nam);
        debug(F110,"addmmac malloc error",nam,0);
        return(-1);
    }
    *p = '\0';                          /* Start off with null string. */
    for (i = 0; *s[i]; i++)             /* Concatenate them all together. */
      ckstrncat(p,s[i],x+1);
    y = (int)strlen(p);                 /* Final precaution. */
    debug(F111,"addmmac constructed string",p,y);
    if (y == x) {
        y = addmac(nam,p);              /* Add result to the macro table. */
    } else {
        debug(F100,"addmmac length mismatch","",0);
        printf("\n!addmmac internal error!\n");
        y = -1;
    }
    free(p);                            /* Free the temporary copy. */
    return(y);
}

static char evalmacrobuf[TMPBUFSIZ];
int
evalmacroarg(p) char **p; {
    char * s = evalmacrobuf;
    int t = TMPBUFSIZ;
    (VOID) zzstring(*p,&s,&t);
    *p = evalmacrobuf;
}

/* Here is the real addmac routine. */

/* Returns -1 on failure, macro table index >= 0 on success. */

int mtchanged = 0;

int
addmac(nam,def) char *nam, *def; {      /* Add a macro to the macro table */
    int i, x, y, z, namlen, deflen, flag = 0;
    int replacing = 0, deleting = 0;
    char * p = NULL, c, *s;
    extern int tra_asg; int tra_tmp;

    if (!nam) return(-1);
    if (!*nam) return(-1);

#ifdef IKSD
    if (inserver &&
#ifdef IKSDCONF
        iksdcf
#else /* IKSDCONF */
        1
#endif /* IKSDCONF */
        ) {
        if (!ckstrcmp("on_exit",nam,-1,0) ||
            !ckstrcmp("on_logout",nam,-1,0))
          return(-1);
    }
#endif /* IKSD */

    namlen = 0;
    p = nam;
    while (*p++) namlen++;              /* (instead of strlen) */

    tra_tmp = tra_asg;                  /* trace... */
    debug(F111,"addmac nam",nam,namlen);
    if (!def) {                         /* Watch out for null pointer */
        deflen = 0;
        debug(F111,"addmac def","(null pointer)",deflen);
    } else {
        deflen = 0;
        p = def;
        while (*p++) deflen++;          /* (instead of strlen) */
        debug(F010,"addmac def",def,0);
    }
#ifdef USE_VARLEN                       /* NOT USED */
    /* This does not boost performance much because varlen() does a lot */
    x = varlen(nam,&s);
    if (x > 0 && x >= deflen) {
        strcpy(s,def);                  /* NOT USED */
        flag = 1;
        p = s;
    }
#endif /* USE_VARLEN */

    if (*nam == CMDQ) nam++;            /* Backslash quote? */
    if (*nam == '%') {                  /* Yes, if it's a variable name, */
        if (!(c = *(nam + 1))) return(-1); /* Variable name letter or digit */
        if (!flag) {
            tra_asg = 0;
            delmac(nam,0);              /* Delete any old value. */
            tra_asg = tra_tmp;
        }
        if (deflen < 1) {               /* Null definition */
            p = NULL;                   /* Better not malloc or strcpy! */
        } else if (!flag) {             /* A substantial definition */
            p = malloc(deflen + 1);     /* Allocate space for it */
            if (!p) {
                printf("?addmac malloc error 2\n");
                return(-1);
            } else strcpy(p,def);       /* Copy def into new space (SAFE) */
        }

        /* Now p points to the definition, or is a null pointer */

        if (c >= '0' && c <= '9') {     /* \%0-9 variable */
            if (maclvl < 0) {           /* Are we calling or in a macro? */
                g_var[c] = p;           /* No, it's top level one */
                makestr(&(toparg[c - '0']),p); /* Take care \&_[] too */
            } else {                    /* Yes, it's a macro argument */
                m_arg[maclvl][c - '0'] = p; /* Assign the value */
                makestr(&(m_xarg[maclvl][c - '0']),p); /* And a copy here */
            }
        } else {                        /* It's a \%a-z variable */
            if (c < 33 || (unsigned int)c > GVARS) return(-1);
            if (isupper(c)) c = (char) tolower(c);
            g_var[c] = p;               /* Put pointer in global-var table */
        }
        if (tra_asg) traceval(nam,p);
        return(0);
    } else if (*nam == '&') {           /* An array reference? */
        char **q = NULL;
        int rc = 0;
        if ((y = arraynam(nam,&x,&z)) < 0) /* If syntax is bad */
          return(-1);                   /* return -1. */
        if (chkarray(x,z) < 0)          /* If array not declared or */
          rc = -2;                      /* subscript out of range, ret -2 */
        if (!flag) {
            tra_asg = 0;
            delmac(nam,0);              /* Delete any old value. */
            tra_asg = tra_tmp;
        }
        x -= ARRAYBASE;                 /* Convert name letter to index. */
        if (x > 'z' - ARRAYBASE + 1)
          rc = -1;
        if (rc != -1) {
            if ((q = a_ptr[x]) == NULL) /* If array not declared, */
              return(-3);               /* return -3. */
        }
        if (rc < 0)
          return(rc);
        if (!flag) {
            if (deflen > 0) {
                if ((p = malloc(deflen+1)) == NULL) { /* Allocate space */
                    printf("addmac macro error 7: %s\n",nam);
                    return(-4);         /* for new def, return -4 on fail. */
                }
                strcpy(p,def);          /* Copy def into new space (SAFE). */
            } else p = NULL;
        }
        q[z] = p;                       /* Store pointer to it. */
        if (x == 0) {                   /* Arg vector array */
            if (z >= 0 && z <= 9) {     /* Copy values to corresponding  */
                if (maclvl < 0) {       /* \%1..9 variables. */
                    makestr(&(toparg[z]),p);
                } else {
                    makestr(&(m_arg[maclvl][z]),p);
                }
            }
        }
        if (tra_asg) traceval(nam,p);
        return(0);                      /* Done. */
    }
/* Not a macro argument or a variable, so it's a macro definition */

#ifdef USE_VARLEN
    if (flag) {
        if (tra_asg) traceval(nam,p);
        return(0);
    }
#endif /* USE_VARLEN */
    x = isaa(nam) ?                     /* If it's an associative array */
      mxxlook(mactab,nam,nmac) :        /* look it up this way */
        mxlook(mactab,nam,nmac);        /* otherwise this way. */
    if (x > -1) {                       /* If found... */
        if (deflen > 0)                 /* and a new definition was given */
          replacing = 1;                /* we're replacing */
        else                            /* otherwise */
          deleting = 1;                 /* we're deleting */
    }
    if (deleting) {                     /* Deleting... */
        if (delmac(nam,0) < 0)
          return(-1);
        mtchanged++;
        if (tra_asg) traceval(nam,p);
        return(0);
    } else if (deflen < 1)              /* New macro with no definition */
      return(0);                        /* Nothing to do. */

    if (replacing) {                    /* Replacing an existing macro */
        if (mactab[x].mval) {           /* If it currently has a definition, */
            free(mactab[x].mval);       /* free it. */
            mactab[x].mval = NULL;
        }
        mtchanged++;
        y = x;                          /* Replacement index. */

    } else {                            /* Adding a new macro... */
        char c1, c2;                    /* Use fast lookup to find the */
        c1 = *nam;                      /* alphabetical slot. */
        if (isupper(c1)) c1 = (char) tolower(c1);

        if (nmac < 5) {                 /* Not worth it for small tables */
            y = 0;
        } else {                        /* First binary search to find */
            int lo = 0;                 /* where to start */
            int hi = nmac;
            int count = 0;
            char c = 0;
            while (lo+2 < hi && ++count < 12) {
                y = lo + ((hi - lo) / 2);
                c = *(mactab[y].kwd);
                if (isupper(c)) c = (char) tolower(c);
                if (c < c1) {
                    lo = y;
                } else {
                    hi = y;
                }
            }
            y = (c < c1) ? lo+1 : lo;
        }

        /* Now search linearly from starting location */
        for ( ; y < MAC_MAX && mactab[y].kwd != NULL; y++) {
            c2 = *(mactab[y].kwd);
            if (isupper(c2)) c2 = (char) tolower(c2);
            if (c1 > c2)
              continue;
            if (c1 < c2)
              break;
            if (ckstrcmp(nam,mactab[y].kwd,-1,0) <= 0)
              break;
        }
        if (y == MAC_MAX) {             /* Macro table is full. */
            debug(F101,"addmac table overflow","",y);
            printf("?Macro table overflow\n");
            return(-1);
        }
        if (mactab[y].kwd != NULL) {    /* Must insert */
            for (i = nmac; i > y; i--) { /* Move the rest down one slot */
                mactab[i].kwd = mactab[i-1].kwd;
                mactab[i].mval = mactab[i-1].mval;
                mactab[i].flgs = mactab[i-1].flgs;
            }
        }
        mtchanged++;
        p = malloc(namlen + 1);         /* Allocate space for name */
        if (!p) {
            printf("?Addmac: Out of memory - \"%s\"\n",nam);
            return(-1);
        }
        strcpy(p,nam);                  /* Copy name into new space (SAFE) */
        mactab[y].kwd = p;              /* Add pointer to table */
    }
    if (deflen > 0) {                   /* If we have a definition */
        p = malloc(deflen + 1);         /* Get space */
        if (p == NULL) {
            printf("?Space exhausted - \"%s\"\n", nam);
            if (mactab[y].kwd) {
                free(mactab[y].kwd);
                mactab[y].kwd = NULL;
            }
            return(-1);
        } else {
            strcpy(p,def);              /* Copy the definition (SAFE) */
        }
    } else {                            /* definition is empty */
        p = NULL;
    }
    mactab[y].mval = p;                 /* Macro points to definition */
    mactab[y].flgs = 0;                 /* No flags */
    if (!replacing)                     /* If new macro */
      nmac++;                           /* count it */
    if (tra_asg) traceval(nam,p);
    return(y);
}

int
xdelmac(x) int x; {                     /* Delete a macro given its index */
    int i;
    extern int tra_asg;
    if (x < 0) return(x);
    if (tra_asg)
      traceval(mactab[x].kwd,NULL);

    if (mactab[x].kwd) {                /* Free the storage for the name */
        free(mactab[x].kwd);
        mactab[x].kwd = NULL;
    }
    if (mactab[x].mval) {               /* and for the definition */
        free(mactab[x].mval);
        mactab[x].mval = NULL;
    }
    for (i = x; i < nmac; i++) {        /* Now move up the others. */
        mactab[i].kwd = mactab[i+1].kwd;
        mactab[i].mval = mactab[i+1].mval;
        mactab[i].flgs = mactab[i+1].flgs;
    }
    nmac--;                             /* One less macro */

    mactab[nmac].kwd = NULL;            /* Delete last item from table */
    mactab[nmac].mval = NULL;
    mactab[nmac].flgs = 0;
    mtchanged++;
    return(0);
}

int
delmac(nam,exact) char *nam; int exact; { /* Delete the named macro */
    int x, z;
    char *p, c;
    extern int tra_asg;

    if (!nam) return(0);                /* Watch out for null pointer */
    debug(F110,"delmac nam",nam,0);
#ifdef IKSD
    if ( inserver &&
#ifdef IKSDCONF
        iksdcf
#else /* IKSDCONF */
        1
#endif /* IKSDCONF */
        ) {
        if (!ckstrcmp("on_exit",nam,-1,0) ||
            !ckstrcmp("on_logout",nam,-1,0))
          return(-1);
    }
#endif /* IKSD */

    if (*nam == CMDQ) nam++;
    if (*nam == '%') {                  /* If it's a variable name */
        if (!(c = *(nam+1))) return(0); /* Get variable name letter or digit */
        p = (char *)0;                  /* Initialize value pointer */
        if (maclvl < 0 && c >= '0' && c <= '9') { /* Top-level digit? */
            p = toparg[c - '0'];
            if (p) if (p != g_var[c]) {
                free(p);
                toparg[c - '0'] = NULL;
            }
            p = g_var[c];
            g_var[c] = NULL;            /* Zero the table entry */
        } else if (maclvl > -1 && c >= '0' && c <= '9') { /* Digit? */
            p = m_xarg[maclvl][c - '0'];
            if (p) if (p != g_var[c]) {
                free(p);
                m_xarg[maclvl][c - '0'] = NULL;
            }
            p = m_arg[maclvl][c - '0']; /* Get pointer from macro-arg table */
            m_arg[maclvl][c - '0'] = NULL; /* Zero the table pointer */
        } else {                        /* It's a global variable */
            if (c < 33 || (unsigned int)c > GVARS) return(0);
            p = g_var[c];               /* Get pointer from global-var table */
            g_var[c] = NULL;            /* Zero the table entry */
        }
        if (p) {
            debug(F010,"delmac def",p,0);
            free(p);                    /* Free the storage */
            p = NULL;
        } else debug(F110,"delmac def","(null pointer)",0);
        if (tra_asg) traceval(nam,NULL);
        return(0);
    }
    if (*nam == '&') {                  /* An array reference? */
        char **q;
        if (arraynam(nam,&x,&z) < 0)    /* If syntax is bad */
          return(-1);                   /* return -1. */
        x -= ARRAYBASE;                 /* Convert name to number. */
        if ((q = a_ptr[x]) == NULL)     /* If array not declared, */
          return(-2);                   /* return -2. */
        if (z > a_dim[x])               /* If subscript out of range, */
          return(-3);                   /* return -3. */
        if (q[z]) {                     /* If there is an old value, */
            debug(F010,"delmac def",q[z],0);
            if (x != 0)                 /* Macro arg vector is just a copy */
              free(q[z]);               /* Others are real so free them */
            q[z] = NULL;
            if (x == 0) {               /* Arg vector array */
                if (z >= 0 && z <= 9) { /* Copy values to corresponding  */
                    if (maclvl < 0) {   /* \%1..9 variables. */
                        makestr(&(toparg[z]),NULL);
                    } else {
                        makestr(&(m_arg[maclvl][z]),NULL);
                    }
                }
            }
            if (tra_asg) traceval(nam,NULL);
        } else debug(F010,"delmac def","(null pointer)",0);
    }

   /* Not a variable or an array, so it must be a macro. */

    z = isaa(nam);
    debug(F111,"delmac isaa",nam,z);
    debug(F111,"delmac exact",nam,exact);
    x = z ? mxxlook(mactab,nam,nmac) :
      exact ? mxlook(mactab,nam,nmac) :
        mlook(mactab,nam,nmac);
    if (x < 0) {
        debug(F111,"delmac mlook",nam,x);
        return(x);
    }
    return(xdelmac(x));
}

VOID
initmac() {                             /* Init macro & variable tables */
    int i, j, x;

    nmac = 0;                           /* No macros */
    for (i = 0; i < MAC_MAX; i++) {     /* Initialize the macro table */
        mactab[i].kwd = NULL;
        mactab[i].mval = NULL;
        mactab[i].flgs = 0;
    }
    mtchanged++;
    x = (MAXARGLIST + 1) * sizeof(char **);
    for (i = 0; i < MACLEVEL; i++) {    /* Init the macro argument tables */
        m_xarg[i] = (char **) malloc(x);
        mrval[i] = NULL;                /* Macro return value */
        /* Pointer to entire argument vector, level i, for \&_[] array */
        for (j = 0; j <= MAXARGLIST; j++) { /* Macro argument list */
            if (j < 10)                 /* For the \%0..\%9 variables */
              m_arg[i][j] = NULL;       /* Pointer to arg j, level i. */
            if (m_xarg[i])              /* For \&_[] - all args. */
              m_xarg[i][j] = NULL;
        }
    }
    for (i = 0; i < GVARS; i++) {       /* And the global variables table */
        g_var[i] = NULL;
    }
    /* And the table of arrays */
    for (i = 0; i < (int) 'z' - ARRAYBASE + 1; i++) {
        a_ptr[i] = (char **) NULL;      /* Null pointer for each */
        a_dim[i] = 0;                   /* and a dimension of zero */
        a_link[i] = -1;
        for (j = 0; j < CMDSTKL; j++) {
            aa_ptr[j][i] = (char **) NULL;
            aa_dim[j][i] = 0;
        }
    }
}

int
popclvl() {                             /* Pop command level, return cmdlvl */
    extern int tra_cmd;
    struct localvar * v;
    int i, topcmd;
    debug(F101,"popclvl cmdlvl","",cmdlvl);
    if (cmdlvl > 0) {
        if ((v = localhead[cmdlvl])) {  /* Did we save any variables? */
            while (v) {                 /* Yes */
                if (v->lv_value)        /* Copy old ones back */
                  addmac(v->lv_name,v->lv_value);
                else
                  delmac(v->lv_name,1);
                v = v->lv_next;
            }
            freelocal(cmdlvl);          /* Free local storage */
        }
        /* Automatic arrays do not use the localhead list */

        for (i = 0; i < 28; i++) {      /* Free any local arrays */
            if (aa_ptr[cmdlvl][i]) {	/* Does this one exist? */
                dclarray((char)(i+ARRAYBASE),-1); /* Destroy global one */
                a_ptr[i] = aa_ptr[cmdlvl][i];
                a_dim[i] = aa_dim[cmdlvl][i];
                aa_ptr[cmdlvl][i] = (char **)NULL;
                aa_dim[cmdlvl][i] = 0;
            } else if (aa_dim[cmdlvl][i] == -23) { /* Secret code */
                /*
                  A local array declared at this level when there was no
                  array of the same name at any higher level.  See comment
                  in pusharray().
                */
                dclarray((char)(i+ARRAYBASE),-1);
                a_ptr[i] = (char **)NULL; /* Delete top-level array */
                a_dim[i] = 0;             /* created by pusharray - Feb 2016 */
                aa_ptr[cmdlvl][i] = (char **)NULL;
                aa_dim[cmdlvl][i] = 0;
            }
            /* Otherwise do nothing - it is a local array that was declared */
            /* at a level above this one so leave it alone. */
        }
    }
    if (cmdlvl < 1) {                   /* If we're already at top level */
        cmdlvl = 0;                     /* just make sure all the */
        tlevel = -1;                    /* stack pointers are set right */
        maclvl = -1;                    /* and return */
    } else if (cmdstk[cmdlvl].src == CMD_TF) { /* Reading from TAKE file? */
        debug(F101,"popclvl tlevel","",tlevel);
        if (tlevel > -1) {              /* Yes, */
            fclose(tfile[tlevel]);      /* close it */

            if (tra_cmd)
              printf("[%d] -F: \"%s\"\n",cmdlvl,tfnam[tlevel]);
            debug(F111,"CMD -F",tfnam[tlevel],cmdlvl);
            if (tfnam[tlevel]) {        /* free storage for name */
                free(tfnam[tlevel]);
                tfnam[tlevel] = NULL;
            }
            tlevel--;                   /* and pop take level */
            cmdlvl--;                   /* and command level */
            quiet = xquiet[cmdlvl];
            vareval = xvarev[cmdlvl];
        } else
          tlevel = -1;
    } else if (cmdstk[cmdlvl].src == CMD_MD) { /* In a macro? */
        topcmd = lastcmd[maclvl];
        debug(F101,"popclvl maclvl","",maclvl);
        if (maclvl > -1) {              /* Yes, */
#ifdef COMMENT
            int i;
            char **q;
#endif /* COMMENT */
            macp[maclvl] = "";          /* set macro pointer to null string */
            *cmdbuf = '\0';             /* clear the command buffer */

            if ((maclvl > 0) &&         /* 2 May 1999 */
                (m_arg[maclvl-1][0]) &&
                (!strncmp(m_arg[maclvl-1][0],"_xif",4) ||
                 !strncmp(m_arg[maclvl-1][0],"_for",4) ||
                 !strncmp(m_arg[maclvl-1][0],"_swi",4) ||
                 !strncmp(m_arg[maclvl-1][0],"_whi",4)) &&
                mrval[maclvl+1]) {
                makestr(&(mrval[maclvl-1]),mrval[maclvl+1]);
            }
            if (maclvl+1 < MACLEVEL) {
                if (mrval[maclvl+1]) {  /* Free any deeper return values. */
                    free(mrval[maclvl+1]);
                    mrval[maclvl+1] = NULL;
                }
            }
            if (tra_cmd)
              printf("[%d] -M: \"%s\"\n",cmdlvl,m_arg[cmdstk[cmdlvl].lvl][0]);
            debug(F111,"CMD -M",m_arg[cmdstk[cmdlvl].lvl][0],cmdlvl);

            maclvl--;                   /* Pop macro level */
            cmdlvl--;                   /* and command level */
            debug(F101,"popclvl mac new maclvl","",maclvl);
            debug(F010,"popclvl mac mrval[maclvl+1]",mrval[maclvl+2],0);

            quiet = xquiet[cmdlvl];
	    vareval = xvarev[cmdlvl];
            if (maclvl > -1) {
                a_ptr[0] = m_xarg[maclvl];
                a_dim[0] = n_xarg[maclvl] - 1;
		debug(F111,"a_dim[0]","B",a_dim[0]);
            } else {
                a_ptr[0] = topxarg;
                a_dim[0] = topargc - 1;
		debug(F111,"a_dim[0]","C",a_dim[0]);
            }
        } else {
            maclvl = -1;
        }
#ifndef NOSEXP
        debug(F101,"popclvl topcmd","",topcmd);
        if (topcmd == XXSEXP) {
            extern char * sexpval;
            makestr(&(mrval[maclvl+1]),sexpval);
        }
#endif /* NOSEXP */
    } else {
        cmdlvl--;
    }
    debug(F101,"popclvl cmdlvl","",cmdlvl);
    if (prstring[cmdlvl]) {
        cmsetp(prstring[cmdlvl]);
        makestr(&(prstring[cmdlvl]),NULL);
    }
#ifndef MAC
    if (cmdlvl < 1 || xcmdsrc == CMD_KB) { /* If at prompt */
        setint();
        concb((char)escape);            /* Go into cbreak mode */
    }
#endif /* MAC */
    xcmdsrc = cmdstk[cmdlvl].src;
    debug(F101,"popclvl xcmdsrc","",xcmdsrc);
    debug(F101,"popclvl tlevel","",tlevel);
    return(cmdlvl < 1 ? 0 : cmdlvl);    /* Return command level */
}
#else /* No script programming language */
int popclvl() {                         /* Just close current take file. */
    if (tlevel > -1) {                  /* if any... */
        if (tfnam[tlevel]) {
            free(tfnam[tlevel]);
            tfnam[tlevel] = NULL;
        }
        fclose(tfile[tlevel--]);
    }
    if (tlevel == -1) {                 /* And if back at top level */
        setint();
        concb((char)escape);            /* and go back into cbreak mode. */
    }
    xcmdsrc = tlevel > -1 ? CMD_TF : 0;
    return(tlevel + 1);
}
#endif /* NOSPL */


#ifndef NOSPL
static int
iseom(m) char * m; {                    /* Test if at end of macro def */
    if (!m)
      m = "";
    debug(F111,"iseom",m,maclvl);
    while (*m) {
        /* Anything but Space and Comma means more macro is left */
        if ((*m > SP) && (*m != ',')) {
            debug(F111,"iseom return",m,0);
            return(0);
        }
        m++;
    }
    debug(F111,"iseom return",m,1);
    return(1);                          /* Nothing left */
}
#endif /* NOSPL */

/* Pop all command levels that can be popped */

int
prepop() {
    if (cmdlvl > 0) {                   /* If command level is > 0 and... */
        while (
#ifndef NOSPL
               ((cmdstk[cmdlvl].src == CMD_TF) && /* Command source is file */
#endif /* NOSPL */
            (tlevel > -1) &&
            feof(tfile[tlevel]))        /* And at end of file... */
#ifndef NOSPL
               /* Or command source is macro... */
               || ((cmdstk[cmdlvl].src == CMD_MD) &&
                (maclvl > -1) &&
                iseom(macp[maclvl])))  /* and at end of macro, then... */
#endif /* NOSPL */
        {
              popclvl();                /* pop command level. */
        }
    }
    return(cmdlvl < 1 ? 0 : cmdlvl);    /* Return command level */
}

/* STOP - get back to C-Kermit prompt, no matter where from. */

int
dostop() {
    extern int cmddep;
    while (popclvl()) ;         /* Pop all macros & take files */
#ifndef NOSPL
    if (cmddep > -1)            /* And all recursive cmd pkg invocations */
      while (cmpop() > -1) ;
#endif /* NOSPL */
    cmini(ckxech);              /* Clear the command buffer. */
    return(0);
}

/* Close the given log */

int
doclslog(x) int x; {
    int y;
    switch (x) {
#ifdef DEBUG
      case LOGD:
        if (deblog <= 0) {
            printf("?Debugging log wasn't open\n");
            return(0);
        }
        debug(F100,"Debug Log Closed","",0L);
        *debfil = '\0';
        deblog = 0;
        return(zclose(ZDFILE));
#endif /* DEBUG */

#ifndef NOXFER
      case LOGP:
        if (pktlog <= 0) {
            printf("?Packet log wasn't open\n");
            return(0);
        }
        *pktfil = '\0';
        pktlog = 0;
        return(zclose(ZPFILE));
#endif /* NOXFER */

#ifndef NOLOCAL
      case LOGS:
        if (seslog <= 0) {
            printf("?Session log wasn't open\n");
            return(0);
        }
        *sesfil = '\0';
        setseslog(0);
        return(zclose(ZSFILE));
#endif /* NOLOCAL */

#ifdef TLOG
      case LOGT: {
#ifdef IKSD
          extern int iklogopen, xferlog;
#endif /* IKSD */
          if (tralog <= 0
#ifdef IKSD
              && !iklogopen
#endif /* IKSD */
              ) {
              if (msgflg)
                printf("?Transaction log wasn't open\n");
              return(0);
          }
#ifdef IKSD
          if (iklogopen && !inserver) {
              close(xferlog);
              iklogopen = 0;
          }
#endif /* IKSD */
          if (tralog) {
              tlog(F100,"Transaction Log Closed","",0L);
              zclose(ZTFILE);
          }
          *trafil = '\0';
          tralog = 0;
          return(1);
      }
#endif /* TLOG */

#ifdef CKLOGDIAL
      case LOGM:
        if (dialog <= 0) {
            if (msgflg) printf("?Connection log wasn't open\n");
            return(0);
        }
        *diafil = '\0';
        dialog = 0;
        return(zclose(ZDIFIL));
#endif /* CKLOGDIAL */

#ifndef NOSPL
      case LOGW:                        /* WRITE file */
      case LOGR:                        /* READ file */
        y = (x == LOGR) ? ZRFILE : ZWFILE;
        if (chkfn(y) < 1)               /* If no file to close */
          return(1);                    /* succeed silently. */
        return(zclose(y));              /* Otherwise, close the file. */
#endif /* NOSPL */

      default:
        printf("\n?Unexpected log designator - %d\n", x);
        return(0);
    }
}

static int slc = 0;                     /* Screen line count */

char *
showstring(s) char * s; {
    return(s ? s : "(null)");
}

char *
showoff(x) int x; {
    return(x ? "on" : "off");
}

char *
showooa(x) int x; {
    switch (x) {
      case SET_OFF:  return("off");
      case SET_ON:   return("on");
      case SET_AUTO: return("automatic");
      default:       return("(unknown)");
    }
}

#ifdef GEMDOS
isxdigit(c) int c; {
    return(isdigit(c) ||
           (c >= 'a' && c <= 'f') ||
           (c >= 'A' && c <= 'F'));
}
#endif /* GEMDOS */

#ifndef NOSETKEY
#ifdef OS2
static struct keytab shokeytab[] = {    /* SHOW KEY modes */
    "all",    1, 0,
    "one",    0, 0
};
static int nshokey = (sizeof(shokeytab) / sizeof(struct keytab));

#define SHKEYDEF TT_MAX+5
struct keytab shokeymtab[] = {
    "aaa",       TT_AAA,     CM_INV,    /* AnnArbor */
    "adm3a",     TT_ADM3A,   0,         /* LSI ADM-3A */
    "adm5",      TT_ADM5,    0,         /* LSI ADM-5 */
    "aixterm",   TT_AIXTERM, 0,         /* IBM AIXterm */
    "annarbor",  TT_AAA,     0,         /* AnnArbor */
    "ansi-bbs",  TT_ANSI,    0,         /* ANSI.SYS (BBS) */
    "at386",     TT_AT386,   0,         /* Unixware ANSI */
    "avatar/0+", TT_ANSI,    0,         /* AVATAR/0+ */
    "ba80",      TT_BA80,    0,         /* Nixdorf BA80 */
    "be",        TT_BEOS,    CM_INV|CM_ABR,
    "beos-ansi", TT_BEOS,    CM_INV,    /* BeOS ANSI */
    "beterm",    TT_BEOS,    0,         /* BeOS Console */
    "d200",      TT_DG200,   CM_INV|CM_ABR, /* Data General DASHER 200 */
    "d210",      TT_DG210,   CM_INV|CM_ABR, /* Data General DASHER 210 */
    "d217",      TT_DG217,   CM_INV|CM_ABR, /* Data General DASHER 217 */
    "default",   SHKEYDEF,   0,
    "dg200",     TT_DG200,   0,         /* Data General DASHER 200 */
    "dg210",     TT_DG210,   0,         /* Data General DASHER 210 */
    "dg217",     TT_DG217,   0,         /* Data General DASHER 217 */
    "emacs",     TT_KBM_EMACS,   0,     /* Emacs mode */
    "h19",       TT_H19,     CM_INV,    /* Heath-19 */
    "heath19",   TT_H19,     0,         /* Heath-19 */
    "hebrew",    TT_KBM_HEBREW, 0,      /* Hebrew mode */
    "hft",       TT_HFT,     0,         /* IBM HFT */
    "hp2621a",   TT_HP2621,  0,         /* HP 2621A */
    "hpterm",    TT_HPTERM,  0,         /* HP TERM */
    "hz1500",    TT_HZL1500, 0,         /* Hazeltine 1500 */
    "ibm3151",   TT_IBM31,   0,         /* IBM 3101-xx,3161 */
    "linux",     TT_LINUX,   0,         /* Linux */
    "qansi",     TT_QANSI,   0,         /* QNX ANSI */
    "qnx",       TT_QNX,     0,         /* QNX */
    "russian",   TT_KBM_RUSSIAN, 0,     /* Russian mode */
    "scoansi",   TT_SCOANSI, 0,         /* SCO ANSI */
    "sni-97801", TT_97801,   0,         /* Sinix 97801 */
    "sun",       TT_SUN,     0,         /* Sun Console */
#ifdef OS2PM
#ifdef COMMENT
    "tek4014", TT_TEK40, 0,
#endif /* COMMENT */
#endif /* OS2PM */
    "tty",     TT_NONE,  0,
    "tvi910+", TT_TVI910, 0,
    "tvi925",  TT_TVI925, 0,
    "tvi950",  TT_TVI950, 0,
    "vc404",   TT_VC4404, 0,
    "vc4404",  TT_VC4404, CM_INV,
    "vip7809", TT_VIP7809, 0,
    "vt100",   TT_VT100, 0,
    "vt102",   TT_VT102, 0,
    "vt220",   TT_VT220, 0,
    "vt220pc", TT_VT220PC, 0,
    "vt320",   TT_VT320, 0,
    "vt320pc", TT_VT320PC, 0,
    "vt52",    TT_VT52,  0,
    "wp",      TT_KBM_WP, 0,
    "wy160",   TT_WY160,  0,
    "wy30",    TT_WY30,  0,
    "wy370",   TT_WY370, 0,
    "wy50",    TT_WY50,  0,
    "wy60",    TT_WY60,  0,
    "wyse30",  TT_WY30,  CM_INV,
    "wyse370", TT_WY370, CM_INV,
    "wyse50",  TT_WY50,  CM_INV,
    "wyse60",  TT_WY60,  CM_INV
};
int nshokeym = (sizeof(shokeymtab) / sizeof(struct keytab));
#endif /* OS2 */

VOID
#ifdef OS2
shokeycode(c,m) int c, m;
#else
shokeycode(c) int c;
#endif
/* shokeycode */ {
    KEY ch;
    CHAR *s;
#ifdef OS2
    int i;
    con_event km;
#else /* OS2 */
    int km;
#endif /* OS2 */

#ifdef OS2
    extern int mskkeys;
    char * mstr = "";

    if (c >= KMSIZE) {
        bleep(BP_FAIL);
        return;
    }
#else /* OS2 */
    printf(" Key code \\%d => ", c);
#endif /* OS2 */

#ifndef OS2
    km = mapkey(c);

#ifndef NOKVERBS
    if (IS_KVERB(km)) {                 /* \Kverb? */
        int i, kv;
        kv = km & ~(F_KVERB);
        printf("Verb: ");
        for (i = 0; i < nkverbs; i++)
          if (kverbs[i].kwval == kv) {
              printf("\\K%s",kverbs[i].kwd);
              break;
          }
        printf("\n");
    } else
#endif /* NOKVERBS */
      if (IS_CSI(km)) {
          int xkm = km & 0xFF;
          if (xkm <= 32 || xkm >= 127)
            printf("String: \\{27}[\\{%d}\n",xkm);
          else
            printf("String: \\{27}[%c\n",xkm);
      } else if (IS_ESC(km)) {
          int xkm = km & 0xFF;
          if (xkm <= 32 || xkm >= 127)
            printf("String: \\{27}\\{%d}\n",xkm);
          else
            printf("String: \\{27}%c\n",xkm);
      } else if (macrotab[c]) {         /* See if there's a macro */
          printf("String: ");           /* If so, display its definition */
          s = macrotab[c];
          shostrdef(s);
          printf("\n");
#ifndef NOKVERBS
    } else if (km >= 0x100) {           /* This means "undefined" */
        printf("Undefined\n");
#endif /* NOKVERBS */
    } else {                            /* No macro, show single character */
        printf("Character: ");
        ch = km;
        if (ch < 32 || ch == 127
#ifdef OS2
            || ch > 255
#endif /* OS2 */
#ifndef NEXT
#ifndef AUX
#ifndef XENIX
#ifndef OS2
            || (ch > 127 && ch < 160)
#endif /* OS2 */
#endif /* XENIX */
#endif /* AUX */
#endif /* NEXT */
            )
/*
  These used to be %d, but gcc 1.93 & later complain about type mismatches.
  %u is supposed to be totally portable.
*/
          printf("\\%u",(unsigned int) ch);
        else printf("%c \\%u",(CHAR) (ch & 0xff),(unsigned int) ch);
        if (ch == (KEY) c)
          printf(" (self, no translation)\n");
        else
          printf("\n");
    }
#else /* OS2 */
    if (m < 0) {
        km = mapkey(c);
        mstr = "default";
    } else {
        km = maptermkey(c,m);
        for (i = 0; i < nshokeym; i++) {
            if (m == shokeymtab[i].kwval) {
                mstr = shokeymtab[i].kwd;
                break;
            }
        }
    }
    s = keyname(c);
    debug(F111,"shokeycode mstr",mstr,m);
    debug(F111,"shokeycode keyname",s,c);
    printf(" %sKey code \\%d %s (%s) => ",
            mskkeys ? "mskermit " : "",
            mskkeys ? cktomsk(c) : c,
            s == NULL ? "" : s, mstr);

    switch (km.type) {
#ifndef NOKVERBS
      case kverb: {
          int i, kv;
          kv = km.kverb.id & ~(F_KVERB);
          printf("Verb: ");
          for (i = 0; i < nkverbs; i++) {
              if (kverbs[i].kwval == kv) {
                  printf("\\K%s",kverbs[i].kwd);
                  break;
              }
          }
          printf("\n");
          break;
      }
#endif /* NOKVERBS */
      case csi: {
          int xkm = km.csi.key & 0xFF;
          if (xkm <= 32 || xkm >= 127)
            printf("String: \\{27}[\\{%d}\n",xkm);
          else
            printf("String: \\{27}[%c\n",xkm);
          break;
      }
      case esc: {
          int xkm = km.esc.key & 0xFF;
          if (xkm <= 32 || xkm >= 127)
            printf("String: \\{%d}\\{%d}\n",ISDG200(tt_type)?30:27,xkm);
          else
            printf("String: \\{%d}%c\n",ISDG200(tt_type)?30:27,xkm);
          break;
      }
      case macro: {
          printf("String: ");           /* Macro, display its definition */
          shostrdef(km.macro.string);
          printf("\n");
          break;
      }
      case literal: {
          printf("Literal string: ");   /* Literal, display its definition */
          shostrdef(km.literal.string);
          printf("\n");
          break;
      }
      case error: {
          if (c >= 0x100) {
              printf("Undefined\n");
          } else {
              printf("Character: ");
              ch = c;
              if (ch < 32 || ch == 127 || ch > 255
#ifndef NEXT
#ifndef AUX
#ifndef XENIX
#ifndef OS2
                   || (ch > 127 && ch < 160)
#endif /* OS2 */
#endif /* XENIX */
#endif /* AUX */
#endif /* NEXT */
                   )
/*
  These used to be %d, but gcc 1.93 & later complain about type mismatches.
  %u is supposed to be totally portable.
*/
                  printf("\\%u",(unsigned int) ch);
              else printf("%c \\%u",(CHAR) (ch & 0xff),(unsigned int) ch);
              printf(" (self, no translation)\n");
          }
          break;
      }
      case key: {
          printf("Character: ");
          ch = km.key.scancode;
          if (ch < 32 || ch == 127 || ch > 255
#ifndef NEXT
#ifndef AUX
#ifndef XENIX
#ifndef OS2
              || (ch > 127 && ch < 160)
#else
               || (ch > 127)
#endif /* OS2 */
#endif /* XENIX */
#endif /* AUX */
#endif /* NEXT */
              )
/*
  These used to be %d, but gcc 1.93 & later complain about type mismatches.
  %u is supposed to be totally portable.
*/
            printf("\\%u",(unsigned int) ch);
          else printf("%c \\%u",(CHAR) (ch & 0xff),(unsigned int) ch);
          if (ch == (KEY) c)
            printf(" (self, no translation)\n");
          else
            printf("\n");
          break;
      }
    }
#endif /* OS2 */
}
#endif /* NOSETKEY */

VOID
shostrdef(s) CHAR * s; {
    CHAR ch;
    if (!s) s = (CHAR *)"";
    while ((ch = *s++)) {
        if (ch < 32 || ch == 127 || ch == 255
/*
  Systems whose native character sets have graphic characters in C1...
*/
#ifndef NEXT                            /* NeXT */
#ifndef AUX                             /* Macintosh */
#ifndef XENIX                           /* IBM PC */
#ifdef OS2
/*
  It doesn't matter whether the local host can display 8-bit characters;
  they are not portable among character-sets and fonts.  Who knows what
  would be displayed...
*/
            || (ch > 127)
#else /* OS2 */
            || (ch > 127 && ch < 160)
#endif /* OS2 */
#endif /* XENIX */
#endif /* AUX */
#endif /* NEXT */
            )
          printf("\\{%d}",ch);          /* Display control characters */
        else putchar((char) ch);        /* in backslash notation */
    }
}

#define xxdiff(v,sys) strncmp(v,sys,strlen(sys))

#ifndef NOSHOW
VOID
shover() {
#ifdef OS2
    extern char ckxsystem[];
#endif /* OS2 */
    extern char *ck_patch, * cklibv;
    printf("\nVersions:\n %s\n",versio);
    printf(" Numeric: %ld\n",vernum);
#ifdef OS2
    printf(" Operating System: %s\n", ckxsystem);
#else /* OS2 */
    printf(" Built for: %s\n", ckxsys);
#ifdef CK_UTSNAME
    if (unm_nam[0])
      printf(" Running on: %s %s %s %s\n", unm_nam,unm_ver,unm_rel,unm_mch);
#endif /* CK_UTSNAME */
    printf(" Patches: %s\n", *ck_patch ? ck_patch : "(none)");
#endif /* OS2 */
    if (xxdiff(ckxv,ckxsys))
      printf(" %s for%s\n",ckxv,ckxsys);
    else
      printf(" %s\n",ckxv);
    if (xxdiff(ckzv,ckzsys))
      printf(" %s for%s\n",ckzv,ckzsys);
    else
      printf(" %s\n",ckzv);
    printf(" %s\n",cklibv);
    printf(" %s\n",protv);
    printf(" %s\n",fnsv);
    printf(" %s\n %s\n",cmdv,userv);
#ifndef NOCSETS
    printf(" %s\n",xlav);
#endif /* NOCSETS */
#ifndef MAC
#ifndef NOLOCAL
    printf(" %s\n",connv);
#ifdef OS2
    printf(" %s\n",ckyv);
#endif /* OS2 */
#endif /* NOLOCAL */
#endif /* MAC */
#ifndef NODIAL
    printf(" %s\n",dialv);
#endif /* NODIAL */
#ifndef NOSCRIPT
    printf(" %s\n",loginv);
#endif /* NOSCRIPT */
#ifdef NETCONN
    printf(" %s\n",cknetv);
#ifdef OS2
    printf(" %s\n",ckonetv);
#ifdef CK_NETBIOS
    printf(" %s\n",ckonbiv);
#endif /* CK_NETBIOS */
#endif /* OS2 */
#endif /* NETCONN */
#ifdef TNCODE
    printf(" %s\n",cktelv);
#endif /* TNCODE */
#ifdef SSHBUILTIN
    printf(" %s\n",cksshv);
#ifdef SFTP_BUILTIN
    printf(" %s\n",cksftpv);
#endif /* SFTP_BUILTIN */
#endif /* SSHBUILTIN */
#ifdef OS2
#ifdef OS2MOUSE
    printf(" %s\n",ckomouv);
#endif /* OS2MOUSE */
#endif /* OS2 */
#ifdef NEWFTP
    printf(" %s\n",ckftpv);
#endif /* NEWFTP */
#ifdef CK_AUTHENTICATION
    printf(" %s\n",ckathv);
#endif /* CK_AUTHENTICATION */
#ifdef CK_ENCRYPTION
#ifdef CRYPT_DLL
    printf(" %s\n",ck_crypt_dll_version());
#else /* CRYPT_DLL */
    printf(" %s\n",ckcrpv);
#endif /* CRYPT_DLL */
#endif /* CK_ENCRYPTION */
#ifdef CK_SSL
    printf(" %s\n",cksslv);
#endif /* CK_SSL */
    printf("\n");
}

#ifdef CK_LABELED
VOID
sholbl() {
#ifdef VMS
    printf("VMS Labeled File Features:\n");
    printf(" acl %s (ACL info %s)\n",
           showoff(lf_opts & LBL_ACL),
           lf_opts & LBL_ACL ? "preserved" : "discarded");
    printf(" backup-date %s (backup date/time %s)\n",
           showoff(lf_opts & LBL_BCK),
           lf_opts & LBL_BCK ? "preserved" : "discarded");
    printf(" name %s (original filename %s)\n",
           showoff(lf_opts & LBL_NAM),
           lf_opts & LBL_NAM ? "preserved" : "discarded");
    printf(" owner %s (original file owner id %s)\n",
           showoff(lf_opts & LBL_OWN),
           lf_opts & LBL_OWN ? "preserved" : "discarded");
    printf(" path %s (original file's disk:[directory] %s)\n",
           showoff(lf_opts & LBL_PTH),
           lf_opts & LBL_PTH ? "preserved" : "discarded");
#else
#ifdef OS2
    printf("OS/2 Labeled File features (attributes):\n");
    printf(" archive:   %s\n", showoff(lf_opts & LBL_ARC));
    printf(" extended:  %s\n", showoff(lf_opts & LBL_EXT));
    printf(" hidden:    %s\n", showoff(lf_opts & LBL_HID));
    printf(" read-only: %s\n", showoff(lf_opts & LBL_RO ));
    printf(" system:    %s\n", showoff(lf_opts & LBL_SYS));
#endif /* OS2 */
#endif /* VMS */
}
#endif /* CK_LABELED */

VOID
shotcs(csl,csr) int csl, csr; {         /* Show terminal character set */
#ifndef NOCSETS
#ifdef OS2
#ifndef NOTERM
    extern struct _vtG G[4], *GL, *GR;
    extern int decnrcm, sni_chcode;
    extern int tt_utf8, dec_nrc, dec_kbd, dec_lang;
    extern prncs;

    printf(" Terminal character-sets:\n");
    if (IS97801(tt_type_mode)) {
        if (cmask == 0377)
          printf("     Mode: 8-bit Mode\n");
        else
          printf("     Mode: 7-bit Mode\n");
        printf("     CH.CODE is %s\n",sni_chcode?"On":"Off");
    } else if (ISVT100(tt_type_mode)) {
        if (decnrcm)
          printf("     Mode: 7-bit National Mode\n");
        else
          printf("     Mode: 8-bit Multinational Mode\n");
    }
    if ( isunicode() )
        printf("    Local: Unicode display / %s input\n",
                csl == TX_TRANSP ? "transparent" :
                csl == TX_UNDEF ? "undefined" : txrinfo[csl]->keywd);
    else
        printf("    Local: %s\n",
                csl == TX_TRANSP ? "transparent" :
                csl == TX_UNDEF ? "undefined" : txrinfo[csl]->keywd);

    if ( tt_utf8 ) {
        printf("   Remote: UTF-8\n");
    } else {
        printf("   Remote: %sG0: %s (%s)\n",
           GL == &G[0] ? "GL->" : GR == &G[0] ? "GR->" : "    ",
           txrinfo[G[0].designation]->keywd,
           G[0].designation == TX_TRANSP ? "" :
           G[0].size == cs94 ? "94 chars" :
           G[0].size == cs96 ? "96 chars" : "multi-byte");
        printf("           %sG1: %s (%s)\n",
           GL == &G[1] ? "GL->" : GR == &G[1] ? "GR->" : "    ",
           txrinfo[G[1].designation]->keywd,
           G[1].designation == TX_TRANSP ? "" :
           G[1].size == cs94 ? "94 chars" :
           G[1].size == cs96 ? "96 chars" : "multi-byte");
        printf("           %sG2: %s (%s)\n",
           GL == &G[2] ? "GL->" : GR == &G[2] ? "GR->" : "    ",
           txrinfo[G[2].designation]->keywd,
           G[2].designation == TX_TRANSP ? "" :
           G[2].size == cs94 ? "94 chars" :
           G[2].size == cs96 ? "96 chars" : "multi-byte");
        printf("           %sG3: %s (%s)\n",
           GL == &G[3] ? "GL->" : GR == &G[3] ? "GR->" : "    ",
           txrinfo[G[3].designation]->keywd,
           G[3].designation == TX_TRANSP ? "" :
           G[3].size == cs94 ? "94 chars" :
           G[3].size == cs96 ? "96 chars" : "multi-byte");
    }
    printf("\n");
    printf(" Keyboard character-sets:\n");
    printf("   Multinational: %s\n",txrinfo[dec_kbd]->keywd);
    printf("        National: %s\n",txrinfo[dec_nrc]->keywd);
    printf("\n");
    printf(" Printer character-set: %s\n",txrinfo[prncs]->keywd);
#endif /* NOTERM */
#else /* OS2 */
#ifndef MAC
    char *s;

    debug(F101,"TERM LOCAL CSET","",csl);
    debug(F101,"TERM REMOTE CSET","",csr);
    printf(" Terminal character-set: ");
    if (tcs_transp) {                   /* No translation */
        printf("transparent\n");
    } else {                            /* Translation */
        printf("%s (remote) %s (local)\n",
               fcsinfo[csr].keyword,fcsinfo[csl].keyword);
        if (csr != csl) {
            switch(gettcs(csr,csl)) {
              case TC_USASCII:  s = "ascii";        break;
              case TC_1LATIN:   s = "latin1-iso";   break;
              case TC_2LATIN:   s = "latin2-iso";   break;
              case TC_CYRILL:   s = "cyrillic-iso"; break;
              case TC_JEUC:     s = "japanese-euc"; break;
              case TC_HEBREW:   s = "hebrew-iso";   break;
              case TC_GREEK:    s = "greek-iso";    break;
              case TC_9LATIN:   s = "latin9-iso";   break;
              default:          s = "transparent";  break;
            }
            if (strcmp(s,fcsinfo[csl].keyword) &&
                strcmp(s,fcsinfo[csr].keyword))
              printf("                         (via %s)\n",s);
        }
    }
#endif /* MAC */
#endif /* OS2 */
#endif /* NOCSETS */
}

#ifndef NOLOCAL
#ifdef OS2
extern char htab[];
VOID
shotabs() {
    int i,j,k,n;

    printf("Tab Stops:\n\n");
    for (i = 0, j = 1, k = VscrnGetWidth(VCMD); i < MAXTERMCOL; ) {
        do {
            printf("%c",htab[++i]=='T'?'T':'-');
        } while (i % k && i < MAXTERMCOL);
        printf("\n");
        for ( ; j <= i; j++) {
            switch ( j%10 ) {
	      case 1:
                printf("%c",j == 1 ? '1' : '.');
                break;
	      case 2:
	      case 3:
	      case 4:
	      case 5:
	      case 6:
	      case 7:
                printf("%c",'.');
                break;
	      case 8:
                n = (j+2)/100;
                if (n)
		  printf("%d",n);
                else 
		  printf("%c",'.');
                break;
	      case 9:
                n = (j+1)%100/10;
                if (n)
		  printf("%d",n);
                else if (j>90)
		  printf("0");
                else 
		  printf("%c",'.');
                break;
	      case 0:
                printf("0");
                break;
            }
        }
        printf("\n");
    }
#ifdef COMMENT
    for (i = 1; i <= 70; i++)
      printf("%c",htab[i]=='T'?'T':'-');
    printf("\n1.......10........20........30........40........50........60\
........70\n\n");
    for (; i <= 140; i++)
      printf("%c",htab[i]=='T'?'T':'-');
    printf("\n........80........90.......100.......110.......120.......130\
.......140\n\n");
    for (; i <= 210; i++)
      printf("%c",htab[i]=='T'?'T':'-');
    printf("\n.......150.......160.......170.......180.......190.......200\
.......210\n\n");
    for (; i <= 255; i++)
      printf("%c",htab[i]=='T'?'T':'-');
    printf("\n.......220.......230.......240.......250..255\n");
#endif

}
#endif /* OS2 */
#endif /* NOLOCAL */

#ifdef OS2MOUSE
VOID
shomou() {
    int button, event, id, i;
    char * name = "";

    printf("Mouse settings:\n");
    printf("   Button Count:   %d\n",mousebuttoncount());
    printf("   Active:         %s\n\n",showoff(tt_mouse));

    for (button = 0; button < MMBUTTONMAX; button++)
      for (event = 0; event < MMEVENTSIZE; event++)
        if (mousemap[button][event].type != error)
          switch (mousemap[button][event].type) {
            case key:
              printf("   %s = Character: %c \\%d\n",
                     mousename(button,event),
                     mousemap[button][event].key.scancode,
                     mousemap[button][event].key.scancode );
              break;
            case kverb:
              id = mousemap[button][event].kverb.id & ~(F_KVERB);
              if (id != K_IGNORE) {
                  for (i = 0; i< nkverbs; i++)
                    if (id == kverbs[i].kwval) {
                        name = kverbs[i].kwd;
                        break;
                    }
                  printf("   %s = Kverb: \\K%s\n",
                         mousename(button,event),
                         name
                         );
              }
              break;
            case macro:
              printf("   %s = Macro: ",
                     mousename(button,event) );
              shostrdef(mousemap[button][event].macro.string);
              printf("\n");
              break;
          }
}
#endif /* OS2MOUSE */

#ifndef NOLOCAL
VOID
shotrm() {
    char *s;
    extern char * getiact();
    extern int tt_print, adl_err;
#ifndef NOTRIGGER
    extern char * tt_trigger[];
#endif /* NOTRIGGER */
#ifdef CKTIDLE
    extern char * tt_idlesnd_str;
    extern int tt_idlesnd_tmo;
    extern int tt_idlelimit, tt_idleact;
#endif /* CKTIDLE */
#ifdef OS2
    extern int wy_autopage, autoscroll, sgrcolors, colorreset, user_erasemode,
      decscnm, decscnm_usr, tt_diff_upd, tt_senddata,
      wy_blockend, marginbell, marginbellcol, tt_modechg, dgunix;
    int lines = 0;
#ifdef KUI
    extern CKFLOAT tt_linespacing[];
    extern tt_cursor_blink;
#endif /* KUI */
#ifdef PCFONTS
    int i;
    char *font;

    if (IsOS2FullScreen()) {            /* Determine the font name */
        if (!os2LoadPCFonts()) {
            for (i = 0; i < ntermfont; i++) {
                if (tt_font == term_font[i].kwval) {
                    font = term_font[i].kwd;
                    break;
                }
            }
        } else {
            font = "(DLL not available)";
        }
    } else {
        font =     "(full screen only)";
    }
#endif /* PCFONTS */
#ifdef KUI
    char font[64] = "(unknown)";
    if ( ntermfont > 0 ) {
        int i;
        for (i = 0; i < ntermfont; i++) {
            if (tt_font == term_font[i].kwval) {
                ckstrncpy(font,term_font[i].kwd,59);
                ckstrncat(font," ",64);
                ckstrncat(font,ckitoa(tt_font_size/2),64);
                if ( tt_font_size % 2 )
                    ckstrncat(font,".5",64);
                break;
            }
        }
    }
#endif /* KUI */

    printf("Terminal parameters:\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
    printf(" %19s: %1d%-12s  %13s: %1d%-14s\n",
           "Bytesize: Command",
           (cmdmsk == 0377) ? 8 : 7,
           " bits","Terminal",
           (cmask == 0377) ? 8 : 7," bits");
    if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
    printf(" %19s: %-13s","Type",
           (tt_type >= 0 && tt_type <= max_tt) ?
           tt_info[tt_type].x_name :
           "unknown" );
    if (tt_type >= 0 && tt_type <= max_tt)
      if (strlen(tt_info[tt_type].x_id))
        printf("  %13s: <ESC>%s","ID",tt_info[tt_type].x_id);
    printf("\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
    printf(" %19s: %-13s  %13s: %-15s\n","Echo",
           duplex ? "local" : "remote","Locking-shift",showoff(sosi));
    if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
    printf(" %19s: %-13s  %13s: %-15s\n","Newline-mode", showoff(tnlm),
	   "Cr-display",tt_crd ? "crlf" : "normal");
    if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
    printf(" %19s: %-13s  %13s: %-15s\n","Cursor",
#ifdef KUI
	    (tt_cursor == 2) ? (tt_cursor_blink ? 
				 "full (*)" : "full (.)") :
	    (tt_cursor == 1) ? (tt_cursor_blink ? 
				 "half (*)" : "half (.)") :
	    (tt_cursor_blink ? "underline (*)" : "underline (.)"),
#else /* KUI */
           (tt_cursor == 2) ? "full" :
           (tt_cursor == 1) ? "half" : "underline",
#endif /* KUI */
#ifdef CK_AUTODL
           "autodownload",autodl == TAD_ON ?
           (adl_err ? "on, error stop" : "on, error continue") : 
           autodl == TAD_ASK ? 
           (adl_err ? "ask, error stop" : "ask, error continue") :
           "off"
#else /* CK_AUTODL */
           "", ""
#endif /* CK_AUTODL */
           );
    if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
    printf(" %19s: %-13s  %13s: %-15s\n","Arrow-keys",
           tt_arrow ? "application" : "cursor",
           "Keypad-mode", tt_keypad ? "application" : "numeric"
           );

    if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }

    /* Just to make sure we are using current info */
    updanswerbk();

    /*
       This line doesn't end with '\n' because the answerback string
       is terminated with a newline
    */
    printf(" %19s: %-13s  %13s: %-15s","Answerback",
           showoff(tt_answer),"response",answerback);
    switch (tt_bell) {
      case XYB_NONE:
        s = "none";
        break;
      case XYB_VIS:
        s= "visible";
        break;
      case XYB_AUD | XYB_BEEP:
        s="beep";
        break;
      case XYB_AUD | XYB_SYS:
        s="system sounds";
        break;
      default:
        s="(unknown)";
    }
    printf(" %19s: %-13s  %13s: %-15s\n","Bell",s,
           "Wrap",showoff(tt_wrap));
    if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
    printf(" %19s: %-13s  %13s: %-15s\n","Autopage",showoff(wy_autopage),
           "Autoscroll",showoff(autoscroll));
    if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
    printf(" %19s: %-13s  %13s: %-15s\n","SGR Colors",showoff(sgrcolors),
           "ESC[0m color",colorreset?"default-color":"current-color");
    if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
    printf(" %19s: %-13s  %13s: %-15s\n",
            "Erase color",user_erasemode?"default-color":"current-color",
           "Screen mode",decscnm?"reverse":"normal");
    if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }

    printf(" %19s: %-13d  %13s: %-15d\n","Transmit-timeout",tt_ctstmo,
           "Output-pacing",tt_pacing);
    if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }

    printf(" %19s: %-13d  %13s: %s\n","Idle-timeout",tt_idlelimit,
           "Idle-action", getiact());

    if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
    printf(" %19s: %-13s  %13s: %-15s\n","Send data",
          showoff(tt_senddata),"End of Block", wy_blockend?"crlf/etx":"us/cr");
    if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
#ifndef NOTRIGGER
    printf(" %19s: %-13s  %13s: %d seconds\n","Auto-exit trigger",
           tt_trigger[0],"Output pacing",tt_pacing );
    if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
#endif /* NOTRIGGER */
    printf(" %19s: %-13s  %13s: %-15d\n","Margin bell",
           showoff(marginbell),"at column", marginbellcol);
    if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
    switch (tt_modechg) {
      case TVC_DIS: s = "disabled"; break;
      case TVC_ENA: s = "enabled";  break;
      case TVC_W95: s = "win95-restricted"; break;
      default: s = "(unknown)";
    }
    printf(" %19s: %-13s  %13s: %-15s\n","DG Unix mode",
           showoff(dgunix),"Video change", s);
    if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }

#ifdef CK_APC
    if (apcstatus == APC_ON) s = "on";
    else if (apcstatus == APC_OFF) s = "off";
    else if (apcstatus == APC_ON|APC_UNCH) s = "unchecked";
    else if (apcstatus == APC_ON|APC_NOINP) s = "no-input";
    else if (apcstatus == APC_ON|APC_UNCH|APC_NOINP) s = "unchecked-no-input";
    printf(" %19s: %-13s  %13s: %-15s\n",
           "APC", s,
#ifdef PCFONTS
           "Font (VGA)",font
#else /* PCFONTS */
#ifdef KUI
           "Font",font
#else
           "Font","(not supported)"
#endif /* KUI */
#endif /* PCFONTS */

           );
#endif /* CK_APC */
    if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }

#ifdef CK_TTGWSIZ                       /* Console terminal screen size */
    if (tt_cols[VTERM] < 0 || tt_rows[VTERM] < 0)
      ttgwsiz();                        /* Try to get latest size */
#endif /* CK_TTGWSIZ */
    printf(" %19s: %-13d  %13s: %-15d\n","Height",tt_rows[VTERM],
           "Width",tt_cols[VTERM]);
    if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
#ifdef KUI
    printf(" %19s: %-12f  %14s: %-15d\n","Line spacing",tt_linespacing[VTERM],
           "Display Height",VscrnGetDisplayHeight(VTERM));
    if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
#endif /* KUI */
    printf(" %19s: %-13s  %13s: %d lines\n","Roll-mode",
          tt_roll[VTERM]?"insert":"overwrite","Scrollback", tt_scrsize[VTERM]);
    if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }

    if (updmode == tt_updmode)
      if (updmode == TTU_FAST)
        s = "fast (fast)";
      else
        s = "smooth (smooth)";
    else
      if (updmode == TTU_FAST)
        s = "fast (smooth)";
      else
        s = "smooth (fast)";

    printf(" %19s: %-13s  %13s: %d ms\n","Screen-update: mode",s,
           "interval",tt_update);
    if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
    printf(" %19s: %-13s  %13s: %-15s\n",
           "Screen-optimization",showoff(tt_diff_upd),
           "Status line",showoff(tt_status[VTERM]));
    if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
    printf(" %19s: %-13s  %13s: %-15s\n","Debug",
           showoff(debses),"Session log", seslog? sesfil : "(none)" );
    if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }

    /* Display colors (should become SHOW COLORS) */
    {
        USHORT row, col;
        char * colors[16] = {
            "black","blue","green","cyan","red","magenta","brown","lgray",
            "dgray","lblue","lgreen","lcyan","lred","lmagent","yellow","white"
        };
        printf("\n");
        if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }

        printf(" Color:");
#ifndef ONETERMUPD
        GetCurPos(&row, &col);
        WrtCharStrAtt("border",    6, row, 9, &colorborder );
        WrtCharStrAtt("debug",     5, row, 17, &colordebug );
        WrtCharStrAtt("helptext",  8, row, 25, &colorhelp );
        WrtCharStrAtt("reverse",   7, row, 34, &colorreverse );
        WrtCharStrAtt("select",    6, row, 42, &colorselect );
        WrtCharStrAtt("status",    6, row, 50, &colorstatus );
        WrtCharStrAtt("terminal",  8, row, 58, &colornormal );
        WrtCharStrAtt("underline", 9, row, 67, &colorunderline );
#endif /* ONETERMUPD */
        row = VscrnGetCurPos(VCMD)->y+1;
        VscrnWrtCharStrAtt(VCMD, "border",    6, row, 9, &colorborder );
        VscrnWrtCharStrAtt(VCMD, "debug",     5, row, 17, &colordebug );
        VscrnWrtCharStrAtt(VCMD, "helptext",  8, row, 25, &colorhelp );
        VscrnWrtCharStrAtt(VCMD, "reverse",   7, row, 34, &colorreverse );
        VscrnWrtCharStrAtt(VCMD, "select",    6, row, 42, &colorselect );
        VscrnWrtCharStrAtt(VCMD, "status",    6, row, 50, &colorstatus );
        VscrnWrtCharStrAtt(VCMD, "terminal",  8, row, 58, &colornormal );
        VscrnWrtCharStrAtt(VCMD, "underline",  9, row, 67, &colorunderline );
        printf("\n");
        if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }

        /* Foreground color names */
        printf("%6s: %-8s%-8s%-9s%-8s%-8s%-8s%-9s%-9s\n","fore",
                "",
                colors[colordebug&0x0F],
                colors[colorhelp&0x0F],
                colors[colorreverse&0x0F],
                colors[colorselect&0x0F],
                colors[colorstatus&0x0F],
                colors[colornormal&0x0F],
                colors[colorunderline&0x0F]);
        if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }

        /* Background color names */
        printf("%6s: %-8s%-8s%-9s%-8s%-8s%-8s%-9s%-9s\n","back",
                colors[colorborder],
                colors[colordebug>>4],
                colors[colorhelp>>4],
                colors[colorreverse>>4],
                colors[colorselect>>4],
                colors[colorstatus>>4],
                colors[colornormal>>4],
                colors[colorunderline>>4] );
        if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
        printf("\n");
        if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
        printf(" Color:");
#ifndef ONETERMUPD
        GetCurPos(&row, &col);
        WrtCharStrAtt("graphic",   7, row, 9, &colorgraphic );
        WrtCharStrAtt("command",   7, row, 17, &colorcmd );
        WrtCharStrAtt("italic",    6, row, 26, &coloritalic );
#endif /* ONETERMUPD */
        row = VscrnGetCurPos(VCMD)->y+1;
        VscrnWrtCharStrAtt(VCMD, "graphic",   7, row, 9,  &colorgraphic );
        VscrnWrtCharStrAtt(VCMD, "command",   7, row, 17, &colorcmd );
        VscrnWrtCharStrAtt(VCMD, "italic",    6, row, 26, &coloritalic );
        printf("\n");
        if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }

        /* Foreground color names */
        printf("%6s: %-8s%-8s%-8s\n","fore",
                colors[colorgraphic&0x0F],
                colors[colorcmd&0x0F],
                colors[coloritalic&0x0F]);
        if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }

        /* Background color names */
        printf("%6s: %-8s%-8s%-8s\n","back",
                colors[colorgraphic>>4],
                colors[colorcmd>>4],
                colors[coloritalic>>4]);
        if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
    }
    printf("\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
    {
        extern int trueblink, truedim, truereverse, trueunderline, trueitalic;
        printf(
	    " Attribute:  \
blink: %-3s  dim: %-3s  italic: %-3s  reverse: %-3s  underline: %-3s\n",
	    trueblink?"on":"off", truedim?"on":"off", trueitalic?"on":"off", 
	    truereverse?"on":"off", trueunderline?"on":"off");
        if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
    }
    {
        extern vtattrib WPattrib;
        printf(" ASCII Protected chars: %s%s%s%s%s%s%s\n",
                WPattrib.blinking?"blink ":"",
                WPattrib.italic?"italic ":"",
                WPattrib.reversed?"reverse ":"",
                WPattrib.underlined?"underline ":"",
                WPattrib.bold?"bold ":"",
                WPattrib.dim?"dim ":"",
                WPattrib.invisible?"invisible ":"");
        if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
    }

    printf("\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
    (VOID) shoesc(escape);
    if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }
    printf(" See SHOW CHARACTER-SETS for character-set info\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return; else lines = 0; }

#else /* OS2 */   /* Beginning of new non-OS2 version */

    printf("\n");
    printf("Terminal parameters:\n");
    printf(" %19s: %1d%-12s  %13s: %1d%-14s\n",
           "Bytesize: Command",
           (cmdmsk == 0377) ? 8 : 7,
           " bits","Terminal",
           (cmask == 0377) ? 8 : 7," bits");
    s = getenv("TERM");
#ifdef XPRINT
    printf(" %19s: %-13s  %13s: %-15s\n",
           "Type",
           s ? s : "(unknown)",
           "Print",
           showoff(tt_print)
           );
#else
    printf(" %19s: %-13s\n","Type", s ? s : "(unknown)");
#endif /* XPRINT */
    printf(" %19s: %-13s  %13s: %-15s\n","Echo",
           duplex ? "local" : "remote","Locking-shift",showoff(sosi));
    printf(" %19s: %-13s  %13s: %-15s\n","Newline-mode",
           showoff(tnlm),"Cr-display",tt_crd ? "crlf" : "normal");

#ifdef CK_APC
    if (apcstatus == APC_ON) s = "on";
    else if (apcstatus == APC_OFF) s = "off";
    else if (apcstatus == (APC_ON|APC_UNCH)) s = "unchecked";
    else if (apcstatus == (APC_ON|APC_NOINP)) s = "no-input";
    else if (apcstatus == (APC_ON|APC_UNCH|APC_NOINP))
      s = "unchecked-no-input";
    printf(" %19s: %-13s  %13s: %-15s\n",
           "APC", s,
#ifdef CK_AUTODL
           "Autodownload", autodl ?
           (adl_err ? "on, error stop" : "on, error continue") : "off"
#else
           "",""
#endif /* CK_AUTODL */
           );
#endif /* CK_APC */

#ifdef CK_TTGWSIZ                       /* Console terminal screen size */
    ttgwsiz();                          /* Try to get latest size */
    printf(" %19s: %-13d  %13s: %-15d\n","Height",tt_rows, "Width", tt_cols);
#endif /* CK_TTGWSIZ */

    printf(" %19s: %-13s  %13s: %-15s\n","Debug",
           showoff(debses),"Session log", seslog? sesfil : "(none)" );

#ifdef CKTIDLE
    printf(" %19s: %-13d  %13s: %s\n","Idle-timeout",tt_idlelimit,
           "Idle-action", getiact());
#endif /* CKTIDLE */

    printf(" %19s: %-13s  ","Lf-display", tt_lfd ? "crlf" : "normal");
#ifdef UNIX
#ifndef NOJC
    printf("%13s: %-15s","Suspend", showoff(xsuspend));
#endif /* NOJC */
#endif /* UNIX */
    printf("\n");

#ifndef NOTRIGGER
    printf(" %19s: %-13s\n","Trigger",
           tt_trigger[0] ? tt_trigger[0] : "(none)");
#endif /* NOTRIGGER */
    printf("\n");

    (VOID) shoesc(escape);
#ifndef NOCSETS
    shotcs(tcsl,tcsr);          /* Show terminal character sets */
#endif /* NOCSETS */

#endif /* OS2 */
}

VOID
shmdmlin() {                            /* Briefly show modem & line */
#ifndef NODIAL
#ifndef MINIDIAL
#ifdef OLDTBCODE
    extern int tbmodel;
    _PROTOTYP( char * gtbmodel, (void) );
#endif /* OLDTBCODE */
#endif /* MINIDIAL */
#endif /* NODIAL */
    if (local)
#ifdef OS2
      printf(" Port: %s, Modem type: ",ttname);
#else
      printf(" Line: %s, Modem type: ",ttname);
#endif /* OS2 */
    else
      printf(
#ifdef OS2
" Communication device not yet selected with SET PORT\n Modem type: "
#else
" Communication device not yet selected with SET LINE\n Modem type: "
#endif /* OS2 */
             );
#ifndef NODIAL
    printf("%s",gmdmtyp());
#ifndef MINIDIAL
#ifdef OLDTBCODE
    if (tbmodel) printf(" (%s)",gtbmodel()); /* Telebit model info */
#endif /* OLDTBCODE */
#endif /* MINIDIAL */
#else
    printf("(disabled)");
#endif /* NODIAL */
}

#ifdef CK_TAPI
void
shotapi(int option) {
    int rc=0,k ;
    char *s=NULL;
    LPDEVCFG        lpDevCfg = NULL;
    LPCOMMCONFIG    lpCommConfig = NULL;
    LPMODEMSETTINGS lpModemSettings = NULL;
    DCB *           lpDCB = NULL;
    extern struct keytab * tapiloctab;  /* Microsoft TAPI Locations */
    extern int ntapiloc;
    extern struct keytab * tapilinetab; /* Microsoft TAPI Line Devices */
    extern int ntapiline;
    extern int tttapi;                  /* TAPI in use */
    extern int tapipass;                /* TAPI Passthrough mode */
    extern int tapiconv;                /* TAPI Conversion mode */
    extern int tapilights;
    extern int tapipreterm;
    extern int tapipostterm;
    extern int tapimanual;
    extern int tapiinactivity;
    extern int tapibong;
    extern int tapiusecfg;
    extern char tapiloc[];
    extern int tapilocid;
    extern int TAPIAvail;

    if (!TAPIAvail) {
        printf("TAPI Support not enabled\r\n");
        return;
    }
    switch (option) {
      case 0:
        printf("TAPI Settings:\n");
        printf("  Line:                      %s\n",
               tttapi ? ttname : "(none in use)");

        cktapiBuildLocationTable(&tapiloctab, &ntapiloc);
        if (tapilocid == -1)
          tapilocid = cktapiGetCurrentLocationID();

        /* Find the current tapiloc entry */
        /* and use it as the default. */
        for (k = 0; k < ntapiloc; k++) {
            if (tapiloctab[k].kwval == tapilocid)
              break;
        }
        if (k >= 0 && k < ntapiloc)
          s = tapiloctab[k].kwd;
        else
          s = "(unknown)";
        printf("  Location:                  %s\n",s);
        printf("  Modem-dialing:             %s\n",tapipass?"off":"on");
        printf("  Phone-number-conversions:  %s\n",
                tapiconv==CK_ON?"on":tapiconv==CK_AUTO?"auto":"off");
        printf("  Modem-lights:              %s %s\n",tapilights?"on ":"off",
                tapipass?"(n/a)":"");
        printf("  Predial-terminal:          %s %s\n",tapipreterm?"on ":"off",
                tapipass?"(n/a)":"");
        printf("  Postdial-terminal:         %s %s\n",tapipostterm?"on ":"off",
                tapipass?"(n/a)":"");
        printf("  Manual-dial:               %s %s\n",tapimanual?"on ":"off",
                tapipass?"(n/a)":"");
        printf("  Inactivity-timeout:        %d seconds %s\n",tapiinactivity,
                tapipass?"(n/a)":"");
        printf("  Wait-for-bong:             %d seconds %s\n",tapibong,
                tapipass?"(n/a)":"");
        printf("  Use-windows-configuration: %s %s\n",
                tapiusecfg?"on ":"off", tapipass?"(n/a)":"");
        printf("\n");

#ifdef BETATEST
        if (tapipass) {
printf("K-95 uses the TAPI Line in an exclusive mode.  Other applications\n");
printf("may open the device but may not place calls nor answer calls.\n");
printf("Dialing is performed using the K-95 dialing procedures.  SET MODEM\n");
printf("TYPE TAPI after the SET TAPI LINE command to activate the modem\n");
printf("definition associated with the active TAPI LINE device.\n\n");

        } else {

printf("K-95 uses the TAPI Line in a cooperative mode.  Other applications\n");
printf("may open the device, place and answer calls.  Dialing is performed\n");
printf("by TAPI.  K-95 SET MODEM commands are not used.\n\n");
        }

        if (tapiconv == CK_ON ||
            tapiconv == CK_AUTO && !tapipass) {
printf(
"Phone numbers are converted from canonical to dialable form by TAPI\n");
printf("using the dialing rules specified in the TAPI Dialing Properties\n");
printf("dialog.\n\n");

        } else {

printf(
"Phone numbers are converted from canonical to dialable form by K-95\n");
printf(
"using the dialing rules specified with the SET DIAL commands.  TAPI\n");
printf(
"Dialing Properties are imported automaticly upon startup and whenever\n");
printf("the TAPI Dialing Properties are altered or when the TAPI Location\n");
printf("is changed.\n\n");
        }
#endif /* BETATEST */

        if (tapipass) {
            printf("Type SHOW MODEM to see MODEM configuration.\n");
            if (tapiconv == CK_ON)
              printf("Type SHOW DIAL to see DIAL-related items.\n");
        } else {
            if (tapiconv == CK_ON || tapiconv == CK_AUTO)
              printf("Type SHOW DIAL to see DIAL-related items.\n");
        }
        break;
      case 1:
        cktapiDisplayTapiLocationInfo();
        break;
      case 2:
        rc = cktapiGetModemSettings(&lpDevCfg,&lpModemSettings,
                                     &lpCommConfig,&lpDCB);
        if (rc) {
            cktapiDisplayModemSettings(lpDevCfg,lpModemSettings,
                                         lpCommConfig,lpDCB);
        } else {
            printf("?Unable to retrieve Modem Settings\n");
        }
        break;
      case 3: {
          HANDLE hModem = GetModemHandleFromLine((HLINE)0);
          if (hModem)
            DisplayCommProperties(hModem);
          else
            printf("?Unable to retrieve a valid Modem Handle\n");
          CloseHandle(hModem);
          break;
      }
    }
    printf("\n");
}
#endif /* CK_TAPI */
#endif /* NOLOCAL */

#ifdef PATTERNS
static VOID
shopat() {
    extern char * binpatterns[], * txtpatterns[];
    extern int patterns, filepeek;
    char **p, *s;
    int i, j, k, n, flag, width;
#ifdef CK_TTGWSIZ
    ttgwsiz();                          /* Try to get latest size */
#ifdef OS2
    width = tt_cols[VCMD];
#else /* OS2 */
    width = tt_cols;
#endif /* OS2 */
    if (width < 1)
#endif /* CK_TTGWSIZ */
      width = 80;
    printf("\n");
    printf(" Set file type:            %s\n",gfmode(binary,1));
    printf(" Set file patterns:        %s", showooa(patterns));
#ifdef CK_LABELED
    if (binary == XYFT_L)
      printf(" (but SET FILE TYPE LABELED overrides)\n");
    else
#endif /* CK_LABELED */
#ifdef VMS
    if (binary == XYFT_I)
      printf(" (but SET FILE TYPE IMAGE overrides)\n");
    else
#endif /* VMS */
    if (filepeek)
      printf(" (but SET FILE SCAN ON overrides)\n");
    else
      printf("\n");
    printf(" Maximum patterns allowed: %d\n", FTPATTERNS);
    for (k = 0; k < 2; k++) {           /* For each kind of patter */
        printf("\n");
        if (k == 0) {                   /* binary... */
            printf(" File binary-patterns: ");
            p = binpatterns;
        } else {                        /* text... */
            printf(" File text-patterns:   ");
            p = txtpatterns;
        }
        if (!p[0]) {
            printf("(none)\n");
        } else {
            printf("\n ");
            n = 2;
            for (i = 0; i < FTPATTERNS; i++) { /* For each pattern */
                if (!p[i])              /* Done */
                  break;
                s = p[i];               /* Look for embedded space */
                for (j = 0, flag = 1; *s; s++, j++) /* and also get length */
                  if (*s == SP)
                    flag = 3;
                n += j + flag;          /* Length of this line */
                if (n >= width - 1) {
                    printf("\n ");
                    n = j+2;
                }
                printf(flag == 3 ? " {%s}" : " %s", p[i]);
            }
            if (n > 2)
              printf("\n");
        }
    }
    printf("\n");
}
#endif /* PATTERNS */

#ifndef NOSPL
static VOID
shooutput() {
    printf(" Output pacing:          %d (milliseconds)\n",pacing);
    printf(" Output special-escapes: %s\n", showoff(outesc));
}

static VOID
shoinput() {
#ifdef CKFLOAT
    extern char * inpscale;
#endif	/* CKFLOAT */

#ifdef CK_AUTODL
    printf(" Input autodownload:     %s\n", showoff(inautodl));
#endif /* CK_AUTODL */
    printf(" Input cancellation:     %s\n", showoff(inintr));
    printf(" Input case:             %s\n", inpcas[cmdlvl] ?
           "observe" : "ignore");
    printf(" Input buffer-length:    %d\n", inbufsize);
    printf(" Input echo:             %s\n", showoff(inecho));
    printf(" Input silence:          %d (seconds)\n", insilence);
#ifdef OS2
    printf(" Input terminal:         %s\n", showoff(interm));
#endif /* OS2 */
    printf(" Input timeout:          %s\n", intime[cmdlvl] ?
           "quit" : "proceed");
#ifdef CKFLOAT
    printf(" Input scale-factor:     %s\n", inpscale ? inpscale : "1.0");
#endif	/* CKFLOAT */

    if (instatus < 0)
      printf(" Last INPUT:             -1 (INPUT command not yet given)\n");
    else
      printf(" Last INPUT:             %d (%s)\n", instatus,i_text[instatus]);
}
#endif /* NOSPL */

#ifndef NOSPL
int
showarray() {
#ifdef COMMENT
    char * p, * q, ** ap;
    int i;
#endif /* COMMENT */
    char *s; int x = 0, y;
    int range[2];

    if ((y = cmfld("Array name","",&s,NULL)) < 0)
      if (y != -3)
        return(y);
    ckstrncpy(line,s,LINBUFSIZ);
    s = line;
    if ((y = cmcfm()) < 0)
      return(y);
    if (*s) {
        char ** ap;
        if ((x = arraybounds(s,&(range[0]),&(range[1]))) < 0) {
            printf("?Bad array: %s\n",s);
            return(-9);
        }
        ap = a_ptr[x];
        if (!ap) {
            printf("Array not declared: %s\n", s);
            return(success = 1);
        } else {
            int i, n, max;
            max = (range[1] > 0) ?
              range[1] :
                ((range[0] > 0) ? range[0] : a_dim[x]);
            if (range[0] < 0)
              range[0] = 0;
            if (max > a_dim[x])
              max = a_dim[x];
            n = 1;
            printf("\\&%c[]: Dimension = %d",arrayitoa(x),a_dim[x]);
            if (a_link[x] > -1)
              printf(" (Link to \\&%c[])",arrayitoa(a_link[x]));
            printf("\n");
            for (i = range[0]; i <= max; i++) {
                if (ap[i]) {
                    printf("%3d. %s\n",i,ap[i]);
                    if (xaskmore) {
                        if (cmd_cols > 0) {
                            x = strlen(ap[i]) + 5;
                            y = (x % cmd_cols) ? 1 : 0;
                            n += (x / cmd_cols) + y;
                        } else {
                            n++;
                        }
                        if (n > (cmd_rows - 3)) {
                            if (!askmore())
                              break;
                            else
                              n = 0;
                        }
                    }
                }
            }
        }
        return(1);
    }

    /* All arrays - just show name and dimension */

    for (y = 0; y < (int) 'z' - ARRAYBASE + 1; y++) {
        if (a_ptr[y]) {
            if (x == 0) printf("Declared arrays:\n");
            x = 1;
            printf(" \\&%c[%d]",
                   (y == 1) ? 64 : y + ARRAYBASE, a_dim[y]);
            if (a_link[y] > -1)
              printf(" => \\&%c[]",arrayitoa(a_link[y]));
            printf("\n");
        }
        if (!x) printf(" No arrays declared\n");
    }
    return(1);
}
#endif /* NOSPL */

int
doshow(x) int x; {
    int y, z, i; long zz;
    extern int optlines;
    char *s;
#ifdef OS2
    extern int os2gks;
    extern int tt_kb_mode;
#endif /* OS2 */
    extern int srvcdmsg;
    extern char * cdmsgstr, * ckcdpath;
    char fnbuf[100];

#ifndef NOSETKEY
    if (x == SHKEY) {                   /* SHOW KEY */
        int c;
#ifdef OS2
        if ((x = cmkey(shokeytab,nshokey,"How many keys should be shown?",
                        "one",xxstring)) < 0) return(x);
        switch (tt_kb_mode) {
          case KBM_EM:
            s = "emacs";
            break;
          case KBM_HE:
            s = "hebrew";
            break;
          case KBM_RU:
            s = "russian";
            break;
          case KBM_EN:
          default:
            s = "default";
            break;
        }
        if ((z = cmkey(shokeymtab,nshokeym,"Which definition should be shown?",
                        s,xxstring)) < 0) return(z);
        if (z == SHKEYDEF)
          z = -1;
#endif /* OS2 */

        if ((y = cmcfm()) < 0) return(y);

#ifdef IKSD
        if (inserver) {
            printf("Sorry, command disabled.\r\n");
            return(success = 0);
        }
#endif /* IKSD */

#ifdef MAC
        printf("Not implemented\n");
        return(0);
#else /* Not MAC */
#ifdef OS2
        if (x) {
            con_event evt;
            for (c = 0; c < KMSIZE; c++) {
                evt = (z < 0) ? mapkey(c) : maptermkey(c,z);
                if (evt.type != error) {
                    shokeycode(c,z);
                }
            }
        } else {
#endif /* OS2 */
            printf(" Press key: ");
#ifdef UNIX
#ifdef NOSETBUF
            fflush(stdout);
#endif /* NOSETBUF */
#endif /* UNIX */
            conbin((char)escape);       /* Put terminal in binary mode */
#ifdef OS2
            os2gks = 0;                 /* Raw scancode processing */
#endif /* OS2 */
            c = congks(0);              /* Get character or scan code */
#ifdef OS2
            os2gks = 1;                 /* Cooked scancode processing */
#endif /* OS2 */
            concb((char)escape);        /* Restore terminal to cbreak mode */
            if (c < 0) {                /* Check for error */
                printf("?Error reading key\n");
                return(0);
            }
#ifndef OS2
/*
  Do NOT mask when it can be a raw scan code, perhaps > 255
*/
            c &= cmdmsk;                /* Apply command mask */
#endif /* OS2 */
            printf("\n");
#ifdef OS2
            shokeycode(c,z);
#else /* OS2 */
            shokeycode(c);
#endif /* OS2 */
#ifdef OS2
        }
#endif /* OS2 */
        return(1);
#endif /* MAC */
    }
#ifndef NOKVERBS
    if (x == SHKVB) {                   /* SHOW KVERBS */
        if ((y = cmcfm()) < 0) return(y);
#ifdef IKSD
        if (inserver) {
            printf("Sorry, command disabled.\r\n");
            return(success = 0);
        }
#endif /* IKSD */
        printf("\nThe following %d keyboard verbs are available:\n\n",nkverbs);
        kwdhelp(kverbs,nkverbs,"","\\K","",3,0);
        printf("\n");
        return(1);
    }
#ifdef OS2
    if (x == SHUDK) {                   /* SHOW UDKs */
        extern void showudk(void);
        if ((y = cmcfm()) < 0) return(y);
#ifdef IKSD
        if (inserver) {
            printf("Sorry, command disabled.\r\n");
            return(success = 0);
        }
#endif /* IKSD */
        showudk();
        return(1);
    }
#endif /* OS2 */
#endif /* NOKVERBS */
#endif /* NOSETKEY */

#ifndef NOSPL
    if (x == SHMAC) {                   /* SHOW MACRO */
        struct FDB kw, fl, cm;
        int i, k, n = 0, left, flag, confirmed = 0;
        char * p, *q[64];
        for (i = 0; i < nmac; i++) {    /* copy the macro table */
            mackey[i].kwd = mactab[i].kwd; /* into a regular keyword table */
            mackey[i].kwval = i;        /* with value = pointer to macro tbl */
            mackey[i].flgs = mactab[i].flgs;
        }
        p = line;
        left = LINBUFSIZ;
        while (!confirmed && n < 64) {
            cmfdbi(&kw,                 /* First FDB - macro table */
                   _CMKEY,              /* fcode */
                   "Macro name",        /* hlpmsg */
                   "",                  /* default */
                   "",                  /* addtl string data */
                   nmac,                /* addtl numeric data 1: tbl size */
                   0,                   /* addtl numeric data 2: 4 = cmswi */
                   xxstring,            /* Processing function */
                   mackey,              /* Keyword table */
                   &fl                  /* Pointer to next FDB */
                   );
            cmfdbi(&fl,                 /* 2nd FDB - something not in mactab */
                   _CMFLD,              /* fcode */
                   "",                  /* hlpmsg */
                   "",                  /* default */
                   "",                  /* addtl string data */
                   0,                   /* addtl numeric data 1 */
                   0,                   /* addtl numeric data 2 */
                   xxstring,
                   NULL,
                   &cm
                   );
            cmfdbi(&cm,                 /* 3rd FDB - Confirmation */
                   _CMCFM,              /* fcode */
                   "",                  /* hlpmsg */
                   "",                  /* default */
                   "",                  /* addtl string data */
                   0,                   /* addtl numeric data 1 */
                   0,                   /* addtl numeric data 2 */
                   NULL,
                   NULL,
                   NULL
                   );
            x = cmfdb(&kw);             /* Parse something */
            if (x < 0)
              return(x);
            s = atmbuf;                 /* What the user typed */
            switch (cmresult.fcode) {
              case _CMKEY:              /* If it was a keyword */
                y = mlook(mactab,atmbuf,nmac); /* get full name */
                if (y > -1)
                  s = mactab[y].kwd;    /* (fall thru on purpose...) */
              case _CMFLD:
                k = ckstrncpy(p,s,left) + 1; /* Copy result to list */
                left -= k;
                if (left <= 0) {
                    *p = NUL;
                    break;
                }
                q[n++] = p;             /* Point to this item */
                p += k;                 /* Move buffer pointer past it */
                break;
              case _CMCFM:              /* End of command */
                confirmed++;
              default:
                break;
            }
        }
        if (n == 0) {
            printf("Macros:\n");
            slc = 1;
            for (y = 0; y < nmac; y++)
              if (shomac(mactab[y].kwd,mactab[y].mval) < 0) break;
            return(1);
        }
        slc = 0;
        for (i = 0; i < n; i++) {
            flag = 0;
            s = q[i];
            if (!s) s = "";
            if (!*s) continue;
            if (iswild(s)) {            /* Pattern match */
                for (k = 0, x = 0; x < nmac; x++) {
                    if (ckmatch(s,mactab[x].kwd,0,1)) {
                        shomac(mactab[x].kwd,mactab[x].mval);
                        k++;
                    }
                }
                if (!k)
                  x = -1;
                else
                  continue;
            } else {                    /* Exact match */
                x = mxlook(mactab,s,nmac);
                flag = 1;
            }
            if (flag && x == -1)
              x = mlook(mactab,s,nmac);
            switch (x) {
              case -3:                  /* Nothing to look up */
              case -1:                  /* Not found */
                printf("%s - (not defined)\n",s);
                break;
              case -2:                  /* Ambiguous, matches more than one */
                printf("%s - ambiguous\n",s);
                break;
              default:                  /* Matches one exactly */
                shomac(mactab[x].kwd,mactab[x].mval);
                break;
            }
        }
        return(1);
    }
#endif /* NOSPL */

/*
  Other SHOW commands only have two fields.  Get command confirmation here,
  then handle with big switch() statement.
*/
#ifndef NOSPL
    if (x != SHBUI && x != SHARR)
#endif /* NOSPL */
      if (x == SHFUN) {                 /* For SHOW FUNCTIONS */
          int y;
          if ((y = cmtxt("Match string for function names","",&s,NULL)) < 0)
            return(y);
          fnbuf[0] = NUL;
          if (!s) s = "";
          if (*s) ckstrncpy(fnbuf,s,100);
      } else {
          if ((y = cmcfm()) < 0)
            return(y);
      }
#ifdef COMMENT
    /* This restriction is too general. */
#ifdef IKSD
    if (inserver &&
#ifdef CK_LOGIN
        isguest
#else
        0
#endif /* CK_LOGIN */
        ) {
        printf("Sorry, command disabled.\r\n");
        return(success = 0);
    }
#endif /* IKSD */
#endif /* COMMENT */

    switch (x) {

#ifdef ANYX25
#ifndef IBMX25
      case SHPAD:
        shopad(0);
        break;
#endif /* IBMX25 */
#endif /* ANYX25 */

      case SHNET:
#ifdef NOLOCAL
        printf(" No network support in this version of C-Kermit.\n");
#else
#ifndef NETCONN
        printf(" No network support in this version of C-Kermit.\n");
#else
        shonet();
#endif /* NETCONN */
#endif /* NOLOCAL */
        break;

      case SHPAR:
        shopar();
        break;

#ifndef NOXFER
      case SHATT:
        shoatt();
        break;
#endif /* NOXFER */

#ifndef NOSPL
      case SHCOU:
        printf(" %d\n",count[cmdlvl]);
        break;
#endif /* NOSPL */

#ifndef NOSERVER
      case SHSER:                       /* Show Server */
        i = 0;
#ifndef NOFRILLS
        printf("Function:          Status:\n");
        i++;
        printf(" GET                %s\n",nm[en_get]);
        i++;
        printf(" SEND               %s\n",nm[en_sen]);
        i++;
        printf(" MAIL               %s\n",nm[inserver ? 0 : en_mai]);
        i++;
        printf(" PRINT              %s\n",nm[inserver ? 0 : en_pri]);
        i++;
#ifndef NOSPL
        printf(" REMOTE ASSIGN      %s\n",nm[en_asg]);
        i++;
#endif /* NOSPL */
        printf(" REMOTE CD/CWD      %s\n",nm[en_cwd]);
        i++;
#ifdef ZCOPY
        printf(" REMOTE COPY        %s\n",nm[en_cpy]);
        i++;
#endif /* ZCOPY */
        printf(" REMOTE DELETE      %s\n",nm[en_del]);
        printf(" REMOTE DIRECTORY   %s\n",nm[en_dir]);
        printf(" REMOTE HOST        %s\n",nm[inserver ? 0 : en_hos]);
        i += 3;
#ifndef NOSPL
        printf(" REMOTE QUERY       %s\n",nm[en_que]);
        i++;
#endif /* NOSPL */
        printf(" REMOTE MKDIR       %s\n",nm[en_mkd]);
        printf(" REMOTE RMDIR       %s\n",nm[en_rmd]);
        printf(" REMOTE RENAME      %s\n",nm[en_ren]);
        printf(" REMOTE SET         %s\n",nm[en_set]);
        printf(" REMOTE SPACE       %s\n",nm[en_spa]);
        printf(" REMOTE TYPE        %s\n",nm[en_typ]);
        printf(" REMOTE WHO         %s\n",nm[inserver ? 0 : en_who]);
        printf(" BYE                %s\n",nm[en_bye]);
        printf(" FINISH             %s\n",nm[en_fin]);
        printf(" EXIT               %s\n",nm[en_xit]);
        printf(" ENABLE             %s\n",nm[en_ena]);
        i += 11;
#endif /* NOFRILLS */
        if (i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
        printf("Server timeout:      %d\n",srvtim);
        if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
        printf("Server idle-timeout: %d\n",srvidl);
        if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
        printf("Server keepalive     %s\n", showoff(srvping));
        if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
        printf("Server cd-message    %s\n", showoff(srvcdmsg));
        if (srvcdmsg && cdmsgstr)
          printf("Server cd-message    %s\n", cdmsgstr);
        if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
        printf("Server display:      %s\n", showoff(srvdis));
        if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
        printf("Server login:        ");
        if (!x_user) {
            printf("(none)\n");
        } else {
            printf("\"%s\", \"%s\", \"%s\"\n",
                   x_user,
                   x_passwd ? x_passwd : "",
                   x_acct ? x_acct : ""
                   );
        }
        if (++i > cmd_rows - 3) { if (!askmore()) return(1); else i = 0; }
        printf("Server get-path: ");
        if (ngetpath == 0) {
            printf("    (none)\n");
        } else {
            printf("\n");
            i += 3;
            for (x = 0; x < ngetpath; x++) {
                if (getpath[x]) printf(" %d. %s\n", x, getpath[x]);
                if (++i > (cmd_rows - 3)) { /* More than a screenful... */
                    if (!askmore())
                      break;
                    else
                      i = 0;
                }
            }
        }
        break;
#endif /* NOSERVER */

      case SHSTA:                       /* Status of last command */
        printf(" %s\n", success ? "SUCCESS" : "FAILURE");
        return(0);                      /* Don't change it */

      case SHSTK: {                     /* Stack for MAC debugging */
#ifdef MAC
          long sp;
          sp = -1;
          loadA0 ((char *)&sp);         /* set destination address */
          SPtoaA0();                    /* move SP to destination */
          printf("Stack at 0x%x\n", sp);
          show_queue();                 /* more debugging */
          break;
#else
          shostack();
#endif /* MAC */
          break;
      }


#ifndef NOLOCAL
#ifdef OS2
      case SHTAB:                       /* SHOW TABS */
#ifdef IKSD
        if (inserver) {
            printf("Sorry, command disabled.\r\n");
            return(success = 0);
        }
#endif /* IKSD */
        shotabs();
        break;
#endif /* OS2 */

      case SHTER:                       /* SHOW TERMINAL */
#ifdef IKSD
        if (inserver) {
            printf("Sorry, command disabled.\r\n");
            return(success = 0);
        }
#endif /* IKSD */
        shotrm();
        break;

#ifdef OS2
      case SHVSCRN:                     /* SHOW Virtual Screen - for debug */
        shovscrn();
        break;
#endif /* OS2 */
#endif /* NOLOCAL */

#ifdef OS2MOUSE
      case SHMOU:                       /* SHOW MOUSE */
#ifdef IKSD
        if (inserver) {
            printf("Sorry, command disabled.\r\n");
            return(success = 0);
        }
#endif /* IKSD */
        shomou();
        break;
#endif /* OS2MOUSE */

#ifndef NOFRILLS
      case SHVER:
        shover();
        break;
#endif /* NOFRILLS */

#ifndef NOSPL
      case SHBUI:                       /* Built-in variables */
	line[0] = NUL;
        if ((y = cmtxt("Variable name or pattern","",&s,xxstring)) < 0)
          return(y);
        ckstrncpy(line,s,LINBUFSIZ);
        /* if (line[0]) ckstrncat(line,"*",LINBUFSIZ); */

      case SHFUN:                       /* or built-in functions */
#ifdef CK_TTGWSIZ
#ifdef OS2
        if (tt_cols[VTERM] < 0 || tt_rows[VTERM] < 0)
          ttgwsiz();
#else /* OS2 */
        if (ttgwsiz() > 0) {            /* Get current screen size */
            if (tt_rows > 0 && tt_cols > 0) {
                cmd_rows = tt_rows;
                cmd_cols = tt_cols;
            }
        }
#endif /* OS2 */
#endif /* CK_TTGWSIZ */

        if (x == SHFUN) {               /* Functions */
            printf("\nThe following functions are available:\n\n");
            kwdhelp(fnctab,nfuncs,(char *)fnbuf,"\\F","()",3,8);
            printf("\n");
#ifndef NOHELP
            printf(
"HELP FUNCTION <name> gives the calling conventions of the given function.\n\n"
                   );
#endif /* NOHELP */
            break;
        } else {                        /* Variables */
	    int j, flag = 0, havearg = 0;
	    struct stringarray * q = NULL;
	    char ** pp;
	    if (line[0]) {		/* Have something to search for */
		havearg = 1;		/* Maybe a list of things */
                q = cksplit(1,0,line,NULL,"_-^$*?[]{}",0,0,0,0);
		if (!q) break;
		pp = q->a_head;
	    }
	    i = 0;
	    for (y = 0; y < nvars; y++) {
		if ((vartab[y].flgs & CM_INV))
		  continue;
		if (havearg) {		/* If I have something to match */
		    char * s2;
		    for (flag = 0, j = 1; j <= q->a_size && !flag; j++) {
			s2 = pp[j] ? pp[j] : "";
#ifdef COMMENT
/* This is not needed because it's what the 4 arg does in ckmatch() */
			len = strlen(s2);
			if (len > 0) {
			    if (s2[len-1] != '$') {/* To allow anchors */
				ckmakmsg(line,LINBUFSIZ,pp[j],"*",NULL,NULL);
				s2 = line;
			    }
			}
#endif /* COMMENT */
			if (ckmatch(s2,vartab[y].kwd,0,4) > 0) {
			    flag = 1;	/* Matches */
			    break;
			}
		    }
		    if (!flag)		/* Doesn't match */
		      continue;
		}
		s = nvlook(vartab[y].kwd);
		printf(" \\v(%s) = ",vartab[y].kwd);
		if (vartab[y].kwval == VN_NEWL) { /* \v(newline) */
		    while (*s)		/* Show control chars symbolically */
		      printf("\\{%d}",*s++);
		    printf("\n");
		} else if (vartab[y].kwval == VN_IBUF  || /* \v(input) */
			   vartab[y].kwval == VN_QUE   || /* \v(query) */
#ifdef OS2
			   vartab[y].kwval == VN_SELCT || /* \v(select) */
#endif /* OS2 */
			   (vartab[y].kwval >= VN_M_AAA && /* modem ones */
			    vartab[y].kwval <= VN_M_ZZZ)
			   ) {
		    int r = 12;		/* This one can wrap around */
		    char buf[10];
		    while (*s) {
			if (isprint(*s)) {
			    buf[0] = *s;
			    buf[1] = NUL;
			    r++;
			} else {
			    sprintf(buf,"\\{%d}",*s); /* SAFE */
			    r += (int) strlen(buf);
			}
			if (r >= cmd_cols - 1) {
			    printf("\n");
			    r = 0;
			    i++;
			}
			printf("%s",buf);
			s++;
		    }
		    printf("\n");
		} else
		  printf("%s\n",s);
		if (++i > (cmd_rows - 3)) { /* More than a screenful... */
		    if ((y >= nvars - 1) || !askmore())
		      break;
		    else
		      i = 0;
		}
	    }
        }
        break;

      case SHVAR:                       /* Global variables */
        x = 0;                          /* Variable count */
        slc = 1;                        /* Screen line count for "more?" */
        for (y = 33; y < GVARS; y++)
          if (g_var[y]) {
              if (x++ == 0) printf("Global variables:\n");
              sprintf(line," \\%%%c",y); /* SAFE */
              if (shomac(line,g_var[y]) < 0) break;
          }
        if (!x) printf(" No variables defined\n");
        break;

      case SHARG: {                     /* Args */
          char * s, * s1, * s2, * tmpbufp;
          int t;
          if (maclvl > -1) {
              printf("Macro arguments at level %d (\\v(argc) = %d):\n",
                     maclvl,
                     macargc[maclvl]
                     );
              for (y = 0; y < macargc[maclvl]; y++) {
                  s1 = m_arg[maclvl][y];
                  if (!s1) s1 = "(NULL)";
                  s2 = m_xarg[maclvl][y];
                  if (!s2) s2 = "(NULL)";
#ifdef COMMENT
                  if (y < 10)
                    printf(" \\%%%d = %s\n",y,s1);
                  else
                    printf(" \\&_[%d] = %s\n",y,s2);
#else
                  printf(" \\&_[%d] = %s\n",y,s2);
#endif  /* COMMENT */
              }
          } else {
              printf("Top-level arguments (\\v(argc) = %d):\n", topargc);
              for (y = 0; y < topargc; y++) {
                  s1 = g_var[y + '0'];
                  if (!s1) s1 = "(NULL)";
                  s2 = toparg[y];
                  if (!s2) s2 = "(NULL)";
                  if (y < 10 && g_var[y])
                    printf(" \\%%%d = %s\n",y,s1);
                  if (toparg[y])
                    printf(" \\&_[%d] = %s\n",y,s2);
              }
          }
        }
        break;

      case SHARR:                       /* Arrays */
        return(showarray());
#endif /* NOSPL */

#ifndef NOXFER
      case SHPRO:                       /* Protocol parameters */
        shoparp();
        printf("\n");
        break;
#endif /* NOXFER */

#ifndef NOLOCAL
      case SHCOM:                       /* Communication parameters */
        printf("\n");
        shoparc();
#ifdef OS2
        {
            int i;
            char *s = "(unknown)";
            for (i = 0; i < nprty; i++)
              if (prtytab[i].kwval == priority) {
                  s = prtytab[i].kwd;
                  break;
              }
            printf(" Priority: %s\n", s );
        }
#endif /* OS2 */

        printf("\n");
#ifdef NETCONN
        if (!network
#ifdef IKSD
             && !inserver
#endif /* IKSD */
             ) {
#endif /* NETCONN */
            shomdm();
            printf("\n");
#ifdef NETCONN
        }
#endif /* NETCONN */

#ifndef NODIAL
#ifdef IKSD
        if ( !inserver )
#endif /* IKSD */
        {
            printf("Type SHOW DIAL to see DIAL-related items.\n");
            printf("Type SHOW MODEM to see modem-related items.\n");
#ifdef CK_TAPI
            printf("Type SHOW TAPI to see TAPI-related items.\n");
#endif /* CK_TAPI */
            printf("\n");
        }
#endif /* NODIAL */
        break;
#endif /* NOLOCAL */

      case SHFIL:                       /* File parameters */
        shofil();
        /* printf("\n"); */             /* (out o' space) */
        break;

#ifndef NOCSETS
      case SHLNG:                       /* Languages */
        shoparl();
        break;
#endif /* NOCSETS */

#ifndef NOSPL
      case SHSCR:                       /* Scripts */
        printf(" Command quoting:        %s\n", showoff(cmdgquo()));
        printf(" Take  echo:             %s\n", showoff(techo));
        printf(" Take  error:            %s\n", showoff(takerr[cmdlvl]));
        printf(" Macro echo:             %s\n", showoff(mecho));
        printf(" Macro error:            %s\n", showoff(merror[cmdlvl]));
        printf(" Quiet:                  %s\n", showoff(quiet));
        printf(" Variable evaluation:    %s [\\%%x and \\&x[] variables]\n",
	       vareval ? "recursive" : "simple");
        printf(" Function diagnostics:   %s\n", showoff(fndiags));
        printf(" Function error:         %s\n", showoff(fnerror));
#ifdef CKLEARN
        {
            extern char * learnfile;
            extern int learning;
            if (learnfile) {
                printf(" LEARN file:             %s (%s)\n",
                       learnfile,
                       learning ? "ON" : "OFF"
                       );
            } else
              printf(" LEARN file:             (none)\n");
        }
#endif /* CKLEARN */
        shoinput();
        shooutput();
#ifndef NOSCRIPT
        printf(" Script echo:            %s\n", showoff(secho));
#endif /* NOSCRIPT */
        printf(" Command buffer length:  %d\n", CMDBL);
        printf(" Atom buffer length:     %d\n", ATMBL);
        break;
#endif /* NOSPL */

#ifndef NOXMIT
      case SHXMI:
        printf("\n");
        printf(" File type:                       %s\n",
               binary ? "binary" : "text");
#ifndef NOCSETS
        printf(" File character-set:              %s\n",
               fcsinfo[fcharset].keyword);
#ifdef OS2
        if ( isunicode() ) {
        printf(" Terminal Character (remote):     %s\n",
              tt_utf8 ? "utf-8" : tcsr == TX_TRANSP ? "transparent" :
              tcsr == TX_UNDEF ? "undefined" : txrinfo[tcsr]->keywd);
        printf(" Terminal Character (local):      %s\n",
              tcsl == TX_TRANSP ? "transparent" :
              tcsl == TX_UNDEF ? "undefined" : txrinfo[tcsl]->keywd);
        } else {
        printf(" Terminal Character (remote):     %s\n",
              tt_utf8 ? "utf-8" : tcsr == TX_TRANSP ? "transparent" :
              tcsr == TX_UNDEF ? "undefined" : txrinfo[tcsr]->keywd);
        printf(" Terminal Character (local):      %s\n",
              tcsl == TX_TRANSP ? "transparent" :
              tcsl == TX_UNDEF ? "undefined" : txrinfo[tcsl]->keywd);
        }
#else /* OS2 */
        printf(" Terminal character-set (remote): %s\n",
               fcsinfo[tcsr].keyword);
        printf(" Terminal character-set (local):  %s\n",
               fcsinfo[tcsl].keyword);
#endif /* OS2 */
#endif /* NOCSETS */
        printf(" Terminal bytesize:               %d\n",
               (cmask == 0xff) ? 8 : 7);
        printf(" Terminal echo:                   %s\n",
               duplex ? "local" : "remote");
        printf(" Transmit EOF:                    ");
        if (*xmitbuf == NUL) {
            printf("(none)\n");
        } else {
            char *p;
            p = xmitbuf;
            while (*p) {
                if (*p < SP)
                  printf("^%c",ctl(*p));
                else
                  printf("%c",*p);
                p++;
            }
            printf("\n");
        }
        if (xmitf)
          printf(" Transmit Fill:                   %d\n", xmitf);
        else
          printf(" Transmit Fill:                   (none)\n");
        printf(" Transmit Linefeed:               %s\n",showoff(xmitl));
        if (xmitp)
          printf(" Transmit Prompt:                 %d (%s)\n",
                 xmitp,
                 chartostr(xmitp)
                 );
        else
          printf(" Transmit Prompt:                 (none)\n");
        printf(" Transmit Echo:                   %s\n", showoff(xmitx));
        printf(" Transmit Locking-Shift:          %s\n", showoff(xmits));
        printf(" Transmit Pause:                  %d (millisecond%s)\n",
               xmitw,
               (xmitw == 1) ? "" : "s"
               );
        printf(" Transmit Timeout:                %d (second%s)\n",
               xmitt,
               (xmitt == 1) ? "" : "s"
               );
        printf("\n");
        break;
#endif /* NOXMIT */

#ifndef NODIAL
      case SHMOD:                       /* SHOW MODEM */
#ifdef IKSD
        if (inserver) {
            printf("Sorry, command disabled.\r\n");
            return(success = 0);
        }
#endif /* IKSD */
        shomodem();                     /* Show SET MODEM items */
        break;
#endif /* NODIAL */

#ifndef MAC
      case SHDFLT:
        printf("%s\n",zgtdir());
        break;
#endif /* MAC */

#ifndef NOLOCAL
      case SHESC:
#ifdef IKSD
        if (inserver) {
            printf("Sorry, command disabled.\r\n");
            return(success = 0);
        }
#endif /* IKSD */
        return(shoesc(escape));

#ifndef NODIAL
      case SHDIA:                       /* SHOW DIAL */
#ifdef IKSD
        if (inserver) {
            printf("Sorry, command disabled.\r\n");
            return(success = 0);
        }
#endif /* IKSD */
        shmdmlin();
        printf(", speed: ");
        if ((zz = ttgspd()) < 0) {
            printf("unknown");
        } else {
            if (zz == 8880) printf("75/1200"); else printf("%ld",zz);
        }
        if (carrier == CAR_OFF) s = "off";
        else if (carrier == CAR_ON) s = "on";
        else if (carrier == CAR_AUT) s = "auto";
        else s = "unknown";
        printf(", carrier: %s", s);
        if (carrier == CAR_ON) {
            if (cdtimo) printf(", timeout: %d sec", cdtimo);
            else printf(", timeout: none");
        }
        printf("\n");
        doshodial();
        if (local
#ifdef NETCONN
            && !network
#endif /* NETCONN */
            ) {
            printf("Type SHOW MODEM to see modem settings.\n");
#ifdef CK_TAPI
            printf("Type SHOW TAPI to see TAPI-related items\n");
#endif /* CK_TAPI */
            printf("Type SHOW COMMUNICATIONS to see modem signals.\n");
        }
        break;
#endif /* NODIAL */
#endif /* NOLOCAL */

#ifndef NOXFER
#ifdef CK_LABELED
      case SHLBL:                       /* Labeled file info */
        sholbl();
        break;
#endif /* CK_LABELED */
#endif /* NOXFER */

      case SHCSE:                       /* Character sets */
#ifdef NOCSETS
        printf(
" Character set translation is not supported in this version of C-Kermit\n");
#else
        shocharset();
#ifndef NOXFER
        printf("\n Unknown-Char-Set: %s\n",
               unkcs ? "Keep" : "Discard");
#endif /* NOXFER */
#ifdef OS2
        printf("\n");
#endif /* OS2 */
        shotcs(tcsl,tcsr);
        printf("\n");
#ifdef OS2
        /* PC Code Page information */
        {
            char cpbuf[128];
            int cplist[16], cps;
            int activecp;
            cps = os2getcplist(cplist, sizeof(cplist));

            sprintf(cpbuf,              /* SAFE */
                    "%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d",
                     cps > 1 ? cplist[1] : 0,
                     cps > 2 ? cplist[2] : 0, cps > 3 ? cplist[3] : 0,
                     cps > 4 ? cplist[4] : 0, cps > 5 ? cplist[5] : 0,
                     cps > 6 ? cplist[6] : 0, cps > 7 ? cplist[7] : 0,
                     cps > 8 ? cplist[8] : 0, cps > 9 ? cplist[9] : 0,
                     cps > 10 ? cplist[10] : 0, cps > 11 ? cplist[11] : 0,
                     cps > 12 ? cplist[12] : 0
                     );
            printf(" Code Pages:\n");
            activecp = os2getcp();
            if ( activecp ) {
              printf("     Active: %d\n",activecp);
              if (!isWin95())
                printf("  Available: %s\n",cpbuf);
            } else
              printf("     Active: n/a\n");
            printf("\n");
        }
#endif /* OS2 */
#endif /* NOCSETS */
        break;

      case SHFEA:                       /* Features */
        shofea();
        break;

#ifdef CK_SPEED
      case SHCTL:                       /* Control-Prefix table */
        shoctl();
        break;
#endif /* CK_SPEED */

      case SHEXI: {
          extern int exithangup, exitmsg;
          printf("\n Exit warning %s\n", xitwarn ?
                 (xitwarn == 1 ? "on" : "always") : "off");
          printf(" Exit message: %s\n", exitmsg ?
                 (exitmsg == 1 ? "on" : "stderr") : "off");
          printf(" Exit on-disconnect: %s\n", showoff(exitonclose));
          printf(" Exit hangup: %s\n", showoff(exithangup));
          printf(" Current exit status: %d\n\n", xitsta);
          break;
      }
      case SHPRT: {
#ifdef PRINTSWI
          extern int printtimo, printertype, noprinter;
          extern char * printterm, * printsep;
          extern int prncs;
#ifdef BPRINT
          extern int printbidi;
#endif /* BPRINT */
#endif /* PRINTSWI */

#ifdef IKSD
        if (inserver &&
#ifdef CK_LOGIN
            isguest
#else /* CK_LOGIN */
            0
#endif /* CK_LOGIN */
             ) {
            printf("Sorry, command disabled.\r\n");
            return(success = 0);
        }
#endif /* IKSD */
#ifdef PRINTSWI
          if (noprinter) {
              printf("Printer: (none)\n\n");
              break;
          }
#endif /* PRINTSWI */

          printf("Printer: %s%s\n",

                 printpipe ? "| " : "",
                 printername ? printername :
#ifdef OS2
                 "PRN"
#else
                 "(default)"
#endif /* OS2 */
                 );
#ifdef PRINTSWI
#ifdef BPRINT
          if (printbidi) {
              printf(" /BIDIRECTIONAL\n");
              if (pportspeed > 0)
                printf(" /SPEED:%ld\n",pportspeed);
              printf(" /PARITY:%s\n",parnam((char)pportparity));
              printf(" /FLOW:%s\n",
                     pportflow == FLO_NONE ? "NONE" :
                     (pportflow == FLO_RTSC ? "RTS/CTS" : "XON/XOFF")
                     );
          } else
            printf(" /OUTPUT-ONLY\n");
#endif /* BPRINT */
          switch (printertype) {
            case PRT_NON: printf(" /NONE\n"); break;
            case PRT_FIL: printf(" /FILE\n"); break;
            case PRT_PIP: printf(" /PIPE\n"); break;
            case PRT_DOS: printf(" /DOS-DEVICE\n"); break;
            case PRT_WIN: printf(" /WINDOWS-QUEUE\n"); break;
          }
          printf(" /TIMEOUT:%d\n",printtimo);
          if (printterm) {
              printf(" /END-OF-JOB-STRING:");
              shostrdef(printterm);
              printf("\n");
          } else
            printf(" /END-OF-JOB-STRING:(none)\n");
          printf(" /JOB-HEADER-FILE:%s\n",printsep ? printsep : "(none)");
          printf(" /CHARACTER-SET: %s\n",txrinfo[prncs]->keywd);
#endif /* PRINTSWI */
          printf("\n");
          break;
      }

      case SHCMD: {
#ifdef DOUBLEQUOTING
          extern int dblquo;
#endif /* DOUBLEQUOTING */
#ifdef CK_AUTODL
          printf(" Command autodownload: %s\n",showoff(cmdadl));
#else
          printf(" Command autodownload: (not available)\n");
#endif /* CK_AUTODL */
          printf(" Command bytesize: %d bits\n", (cmdmsk == 0377) ? 8 : 7);
          printf(" Command error-display: %d\n", cmd_err);
#ifdef CK_RECALL
          printf(" Command recall-buffer-size: %d\n",cm_recall);
#else
          printf(" Command recall-buffer not available in this version\n");
#endif /* CK_RECALL */
#ifdef CK_RECALL
          printf(" Command retry: %s\n",showoff(cm_retry));
#else
          printf(" Command retry not available in this version\n");
#endif /* CK_RECALL */
          printf(" Command interruption: %s\n", showoff(cmdint));
          printf(" Command quoting: %s\n", showoff(cmdgquo()));
#ifdef DOUBLEQUOTING
          printf(" Command doublequoting: %s\n", showoff(dblquo));
#endif /* DOUBLEQUOTING */
          printf(" Command more-prompting: %s\n", showoff(xaskmore));
          printf(" Command height: %d\n", cmd_rows);
          printf(" Command width:  %d\n", cmd_cols);
#ifndef IKSDONLY
#ifdef OS2
          printf(" Command statusline: %s\n",showoff(tt_status[VCMD]));
#endif /* OS2 */
#endif /* IKSDONLY */
#ifdef LOCUS
          printf(" Locus:          %s",
                 autolocus ? (autolocus == 2 ? "ask" : "auto") :
		 (locus ? "local" : "remote"));
          if (autolocus)
            printf(" (%s)", locus ? "local" : "remote");
          printf("\n");
#endif /* LOCUS */
          printf(" Hints:          %s\n", showoff(hints));
          printf(" Quiet:          %s\n", showoff(quiet));
          printf(" Maximum command length: %d\n", CMDBL);
#ifndef NOSPL
          {
              char * s;
              int k;
              printf(" Maximum number of macros: %d\n", MAC_MAX);
              printf(" Macros defined: %d\n", nmac);
              printf(" Maximum macro depth: %d\n", MACLEVEL);
              printf(" Maximum TAKE depth: %d\n", MAXTAKE);
              s = "(not defined)";
              k = mlook(mactab,"on_unknown_command",nmac);
              if (k > -1) if (mactab[k].mval) s = mactab[k].mval;
              printf(" ON_UNKNOWN_COMMAND: %s\n",s);
          }
#endif /* NOSPL */
#ifdef UNIX
#ifndef NOJC
          printf(" Suspend: %s\n", showoff(xsuspend));
#endif /* NOJC */
#endif /* UNIX */
          printf(" Access to external commands and programs%s allowed\n",
#ifndef NOPUSH
                 !nopush ? "" :
#endif /* NOPUSH */
                  " not");
          break;
      }

#ifndef NOSPL
      case SHALRM:
        if (ck_alarm)
          printf("Alarm at %s %s\n",alrm_date,alrm_time);
        else
          printf("(no alarm set)\n");
        break;
#endif /* NOSPL */

#ifndef NOMSEND
      case SHSFL: {
          extern struct filelist * filehead;
          if (!filehead) {
              printf("send-list is empty\n");
          } else {
              struct filelist * flp;
              char * s;
              flp = filehead;
              while (flp) {
                  s = flp->fl_alias;
                  if (!s) s = "(none)";
                  printf("%s, mode: %s, alias: %s\n",
                         flp->fl_name,
                         gfmode(flp->fl_mode,0),
                         s
                         );
                  flp = flp->fl_next;
              }
          }
      }
      break;
#endif /* NOMSEND */

#ifdef CKXXCHAR
      case SHDBL:
        shodbl();
        break;
#endif /* CKXXCHAR */

#ifndef NOPUSH
#ifndef NOFRILLS
      case SHEDIT:
        if (!editor[0]) {
            s = getenv("EDITOR");
            if (s) ckstrncpy(editor,s,CKMAXPATH);
        }
        printf("\n editor:  %s\n", editor[0] ? editor : "(none)");
        if (editor[0]) {
            printf(" options: %s\n", editopts[0] ? editopts : "(none)");
            printf(" file:    %s\n", editfile[0] ? editfile : "(none)");
        }
        printf("\n");
        break;

#ifdef BROWSER
      case SHBROWSE:
        if (!browser[0]) {
            s = getenv("BROWSER");
            if (s) ckstrncpy(browser,s,CKMAXPATH);
        }
        printf("\n browser: %s\n", browser[0] ? browser : "(none)");
        if (browser[0]) {
            printf(" options: %s\n", browsopts[0] ? browsopts : "(none)");
            printf(" url:     %s\n", browsurl[0] ? browsurl : "(none)");
        }
        printf("\n");
        break;
#endif /* BROWSER */
#endif /*  NOFRILLS */
#endif /* NOPUSH */

#ifndef NOLOCAL
#ifdef CK_TAPI
      case SHTAPI:                      /* TAPI options */
#ifdef IKSD
        if (inserver) {
            printf("Sorry, command disabled.\r\n");
            return(success = 0);
        }
#endif /* IKSD */
        shotapi(0);
        break;
      case SHTAPI_L:                    /* TAPI Locations */
#ifdef IKSD
        if (inserver) {
            printf("Sorry, command disabled.\r\n");
            return(success = 0);
        }
#endif /* IKSD */
        shotapi(1);
        break;
      case SHTAPI_M:                    /* TAPI Modem */
#ifdef IKSD
        if (inserver) {
            printf("Sorry, command disabled.\r\n");
            return(success = 0);
        }
#endif /* IKSD */
        shotapi(2);
        break;
      case SHTAPI_C:                    /* TAPI Comm */
#ifdef IKSD
        if (inserver) {
            printf("Sorry, command disabled.\r\n");
            return(success = 0);
        }
#endif /* IKSD */
        shotapi(3);
        break;
#endif /* CK_TAPI */

      case SHTCP:                       /* SHOTCP */
        printf("\n");
        shotcp(0);
        printf("\n");
        break;

#ifdef TNCODE
      case SHTEL:                       /* TELNET */
        printf("\n");
        shotel(0);
        printf("\n");
        break;

      case SHTOPT:                      /* TELNET OPTIONS */
        printf("\n");
        shotopt(0);
        printf("\n");
        break;
#endif /* TNCODE */

      case SHOTMPDIR:                   /* TEMPORARY DIRECTORY */
      {
          extern char * tempdir;
          if (!tempdir) {
              printf(" (none)\n");
          } else if (!*tempdir) {
              printf(" (none)\n");
          } else {
              printf(" %s\n", tempdir);
          }
          break;
      }
#ifdef CK_TRIGGER
      case SHTRIG: {
          extern char * tt_trigger[], * triggerval;
          int i;
          if (!tt_trigger[0]) {
              printf(" Triggers: (none)\n");
          } else {
              printf(" Triggers:\n");
              for (i = 0; i < TRIGGERS; i++) {
                  if (!tt_trigger[i])
                    break;
                  printf("  \"%s\"\n",tt_trigger[i]);
              }
              printf(" Most recent trigger encountered: ");
              if (triggerval)
                printf("\"%s\"\n",triggerval);
              else
                printf("(none)\n");
          }
          break;
      }
#endif /* CK_TRIGGER */
#endif /* NOLOCAL */

#ifndef NOSPL
      case SHINP:
        shoinput();
        break;
#endif /* NOSPL */

      case SHLOG: {
#ifndef MAC
#ifdef IKSD
          if (inserver &&
#ifdef CK_LOGIN
              isguest
#else /* CK_LOGIN */
              0
#endif /* CK_LOGIN */
             ) {
            printf("Sorry, command disabled.\r\n");
            return(success = 0);
        }
#endif /* IKSD */
#ifdef DEBUG
          printf("\n Debug log:       %s", deblog ? debfil : "(none)");
	  {
	      extern int debtim;
	      if (debtim) printf(" (timestamps)");
	      printf("\n");
	  }
#endif /* DEBUG */
#ifndef NOXFER
          printf(" Packet log:      %s\n",   pktlog ? pktfil : "(none)");
#endif /* NOXFER */
#ifndef NOLOCAL
          printf(" Session log:     %s",   seslog ? sesfil : "(none)");
	  {
	      extern int sessft, slogts, slognul;
	      switch (sessft) {
		case XYFT_T: printf(" (text)"); break;
		case XYFT_B: printf(" (binary)"); break;
		case XYFT_D: printf(" (debug)"); break;
	      }
	      if (slogts) printf("(timestamped)");
	      if (slognul) printf("(null-padded)");
	      printf("\n");
	  }

#endif /* NOLOCAL */
#ifdef TLOG
          printf(" Transaction log: %s (%s)\n",
                 (tralog ? (*trafil ? trafil : "(none)") : "(none)"),
                 (tlogfmt ? ((tlogfmt == 2) ? "ftp" : "verbose") : "brief")
                 );
#endif /* TLOG */
#ifdef CKLOGDIAL
            printf(" Connection log:  %s\n", dialog ? diafil : "(none)");
#endif /* CKLOGDIAL */
          printf("\n");
#endif /* MAC */
          break;
      }

#ifndef NOSPL
      case SHOUTP:                      /* OUTPUT */
        shooutput();
        break;
#endif /* NOSPL */

#ifdef PATTERNS
      case SHOPAT:                      /* PATTERNS */
        shopat();
        break;
#endif /* PATTERNS */

#ifdef STREAMING
      case SHOSTR: {                    /* STREAMING */
          extern int streamrq, clearrq, cleared;
          extern long tfcps;
          debug(F101,"SHOW RELIABLE reliable","",reliable);
          printf("\n Reliable:     %s\n",showooa(reliable));
          printf(" Clearchannel: %s\n",showooa(clearrq));
          printf(" Streaming:    %s\n\n",showooa(streamrq));
          if ((!local && (streamrq == SET_ON)) ||
              (streamrq == SET_AUTO && reliable))
            printf(" Streaming will be done if requested.\n");
          else if ((streamrq == SET_OFF) ||
                   ((streamrq == SET_AUTO) && !reliable))
            printf(" Streaming will not be requested and will not be done.\n");
          else if ((streamrq == SET_ON) ||
                   ((streamrq == SET_AUTO) && reliable))
            printf(
" Streaming will be requested and will be done if the other Kermit agrees.\n");
          printf(" Last transfer: %sstreaming%s, %ld cps.\n",
                 streamed > 0 ? "" : "no ",
                 cleared ? ", clearchannel" : "",
                 tfcps
                 );
          printf("\n");
          break;
      }
#endif /* STREAMING */

      case SHOIKS:
        return(sho_iks());
        break;

#ifdef CK_AUTHENTICATION
      case SHOAUTH:
        return(sho_auth(0));
#endif /* CK_AUTHENTICATION */

#ifndef NOFTP
      case SHOFTP: {
#ifdef IKSD
        if (inserver) {
            printf("Sorry, command disabled.\r\n");
            return(success = 0);
        }
#endif /* IKSD */
#ifdef SYSFTP
        {
            extern char ftpapp[], ftpopts[];
            printf(" ftp-client:  %s\n", ftpapp[0] ? ftpapp : "(none)");
            if (ftpapp[0])
              printf(" ftp options: %s\n", ftpopts[0] ? ftpopts : "(none)");
        }
#else
#ifdef NEWFTP
        shoftp(0);
#else
        printf("(No FTP client included in this version of Kermit.)\n");
#endif /* NEWFTP */
#endif /* SYSFTP */
        break;
      }
#endif /* NOFTP */

#ifndef NOCMDL
      case SHXOPT: {
#ifdef IKSDB
          extern int dbenabled;
          extern char * dbfile, * dbdir;
#endif /* IKSDB */
#ifdef CKWTMP
          extern int ckxwtmp;
          extern char * wtmpfile;
#endif /* CKWTMP */
#ifdef CK_LOGIN
          extern int ckxanon, xferlog, logintimo;
          extern char * xferfile;
#ifdef UNIX
          extern int ckxpriv;
#endif /* UNIX */
#ifdef CK_PERMS
          extern int ckxperms;
#endif /* CK_PERMS */
#endif /* CK_LOGIN */
          extern char * bannerfile, * helpfile;

#ifdef IKSD
          if (inserver &&
#ifdef CK_LOGIN
              isguest
#else /* CK_LOGIN */
              0
#endif /* CK_LOGIN */
              ) {
              printf("Sorry, command disabled.\r\n");
              return(success = 0);
          }
#endif /* IKSD */
          printf("\n");
          if (!cmdint)
            printf(" --nointerrupts\n");
          printf(" --bannerfile=%s\n",bannerfile ? bannerfile : "(null)");
          printf(" --cdfile:%s\n",cdmsgstr ? cdmsgstr : "(null)");
          printf(" --cdmessage:%d\n",srvcdmsg);
          printf(" --helpfile:%d\n",helpfile);
          if (inserver) {
              printf("\n");
              break;
          }
#ifdef CKSYSLOG
#ifdef SYSLOGLEVEL
          printf(" --syslog:%d (forced)\n",ckxsyslog);
#else
          printf(" --syslog:%d\n",ckxsyslog);
#endif /* SYSLOGLEVEL */
#endif /* CKSYSLOG */
#ifdef CKWTMP
          printf(" --wtmplog:%d\n",ckxwtmp);
          printf(" --wtmpfile=%s\n",wtmpfile ? wtmpfile : "(null)");
#endif /* CKWTMP */
#ifdef IKSD
#ifdef CK_LOGIN
          printf(" --anonymous:%d\n",ckxanon);
#ifdef UNIX
          printf(" --privid:%d\n",ckxpriv);
#endif /* UNIX */
#ifdef CK_PERMS
          printf(" --permission:%04o\n",ckxperms);
#endif /* CK_PERMS */
          printf(" --initfile:%s\n",anonfile ? anonfile : "(null)");
          printf(" --userfile:%s\n",userfile ? userfile : "(null)");
          printf(" --root:%s\n",anonroot ? anonroot : "(null)");
          printf(" --xferlog=%d\n",xferlog);
          printf(" --xferfile=%s\n",xferfile ? xferfile : "(null)");
          printf(" --timeout=%d\n",logintimo);
#endif /* CK_LOGIN */
#ifdef IKSDB
          printf(" --database=%d\n",dbenabled);
          printf(" --dbfile=%s\n",dbfile ? dbfile : "(null)");
          if (dbdir)
            printf("   (db directory=[%s])\n",dbdir);
#endif /* IKSDB */
#ifdef IKSDCONF
          printf(" IKSD conf=%s\n",iksdconf);
#endif /* IKSDCONF */
#endif /* IKSD */
          printf("\n");
          break;
      }
#endif /* NOCMDL */

      case SHCD: {
	  extern char * myhome;
	  s = getenv("CDPATH");
	  if (!s) s = "(none)";
	  printf("\n current directory:  %s\n", zgtdir());
	  printf(" previous directory: %s\n", prevdir ? prevdir : "(none)");
	  printf(" cd home:            %s\n", homepath());
	  printf(" cd path:            %s\n", ckcdpath ? ckcdpath : s);
	  printf(" cd message:         %s\n", showoff(srvcdmsg & 2));
	  printf(" server cd-message:  %s\n", showoff(srvcdmsg & 1));
	  printf(" cd message file:    %s\n\n",cdmsgstr ? cdmsgstr : "(none)");
	  break;
      }
#ifndef NOCSETS
      case SHASSOC:
        (VOID) showassoc();
        break;
#endif /* NOCSETS */

#ifdef CKLOGDIAL
      case SHCONNX:
#ifdef NEWFTP
        if (ftpisconnected()) {
            extern char cxlogbuf[];
            dologshow(W_FTP | 1);
            if (cxlogbuf[0])
              dologshow(1);
        } else {
#endif /* NEWFTP */
            dologshow(1);
#ifdef NEWFTP
        }
#endif /* NEWFTP */
        break;
#endif /* CKLOGDIAL */

      case SHOPTS:
        optlines = 0;
#ifndef NOFRILLS
        (VOID) showdelopts();
#endif /* NOFRILLS */
#ifdef DOMYDIR
        (VOID) showdiropts();
#endif /* DOMYDIR */
#ifdef CKPURGE
        (VOID) showpurgopts();
#endif /* CKPURGE */
        (VOID) showtypopts();
        break;

#ifndef NOLOCAL
      case SHOFLO:
        (VOID) shoflow();
        break;
#endif /* NOLOCAL */

#ifndef NOXFER
      case SHOXFER:
        (VOID) shoxfer();
        break;
#endif /* NOXFER */

#ifdef CK_RECALL
      case SHHISTORY:
        (VOID) cmhistory();
        break;
#endif /* CK_RECALL */

#ifndef NOSEXP
#ifndef NOSPL
      case SHSEXP:
        (VOID) shosexp();
        break;
#endif /* NOSPL */
#endif /* NOSEXP */

#ifdef ANYSSH
      case SHOSSH:
        (VOID) shossh();
        break;
#endif /* ANYSSH */

#ifdef KUI
      case SHOGUI:
        (VOID) shogui();
        break;
#endif /* KUI */

#ifndef NOFRILLS
#ifndef NORENAME
      case SHOREN:
        (VOID) shorename();
        break;
#endif	/* NORENAME */
#endif	/* NOFRILLS */

      case SHOLOC: {
#ifdef HAVE_LOCALE
	char *s;
	extern int nolocale;
        printf("\n");

	printf("Locale %s:\n", nolocale ? "disabled" : "enabled");

#ifdef COMMENT
	s = setlocale(LC_ALL, NULL);
        if (!s) s = "";
	printf("LC_ALL=%s\n",s);
#endif /* COMMENT */

	s = setlocale(LC_COLLATE, NULL);
        if (!s) s = "";
	printf("  LC_COLLATE=\"%s\"\n",s);

	s = setlocale(LC_CTYPE, NULL);
        if (!s) s = "";
	printf("  LC_CTYPE=\"%s\"\n",s);

	s = setlocale(LC_MONETARY, NULL);
        if (!s) s = "";
	printf("  LC_MONETARY=\"%s\"\n",s);

	s = setlocale(LC_MESSAGES, NULL);
        if (!s) s = "";
	printf("  LC_MESSAGES=\"%s\"\n",s);

	s = setlocale(LC_NUMERIC, NULL);
        if (!s) s = "";
	printf("  LC_NUMERIC=\"%s\"\n",s);

	s = setlocale(LC_TIME, NULL);
        if (!s) s = "";
	printf("  LC_TIME=\"%s\"\n",s);

	printf("  LANG=\"%s\"\n",getenv("LANG"));
        printf("\n");
#else
        printf("\n");
        printf("  Locale support is not included in this version of Kermit\n");
        printf("\n");
#endif /* HAVE_LOCALE */

	break;
      }
      default:
        printf("\nNothing to show...\n");
        return(-2);

    }
    return(success = 1);
}

#ifndef NOXFER
int
shoatt() {
    printf("Attributes: %s\n", showoff(atcapr));
    if (!atcapr) return(0);
    printf(" Blocksize: %s\n", showoff(atblki));
    printf(" Date: %s\n", showoff(atdati));
    printf(" Disposition: %s\n", showoff(atdisi));
    printf(" Encoding (Character Set): %s\n", showoff(atenci));
    printf(" Length: %s\n", showoff(atleni));
    printf(" Type (text/binary): %s\n", showoff(attypi));
    printf(" System ID: %s\n", showoff(atsidi));
    printf(" System Info: %s\n", showoff(atsysi));
#ifdef CK_PERMS
    printf(" Permissions In:  %s\n", showoff(atlpri));
    printf(" Permissions Out: %s\n", showoff(atlpro));
#endif /* CK_PERMS */
#ifdef STRATUS
    printf(" Format: %s\n", showoff(atfrmi));
    printf(" Creator: %s\n", showoff(atcrei));
    printf(" Account: %s\n", showoff(atacti));
#endif /* STRATUS */
    return(0);
}
#endif /* NOXFER */

#ifndef NOSPL
int                                     /* SHOW MACROS */
shomac(s1, s2) char *s1, *s2; {
    int x, n, pp;
    pp = 0;                             /* Parenthesis counter */

    debug(F110,"shomac s1",s1,0);
    debug(F110,"shomac s2",s2,0);

#ifdef IKSD
    if ( inserver &&
#ifdef IKSDCONF
        iksdcf
#else /* IKSDCONF */
        1
#endif /* IKSDCONF */
        ) {
        if (!ckstrcmp("on_exit",s1,-1,0) ||
            !ckstrcmp("on_logout",s1,-1,0))
          return(0);
    }
#endif /* IKSD */

    if (!s1)
      return(0);
    else
      printf("%s = ",s1);               /* Print blank line and macro name */
    n = (int)strlen(s1) + 4;            /* Width of current line */
    if (!s2) s2 = "(not defined)";

    while ((x = *s2++)) {               /* Loop thru definition */
        if (x == '(') pp++;             /* Treat commas within parens */
        if (x == ')') pp--;             /* as ordinary text */
        if (pp < 0) pp = 0;             /* Outside parens, */
        if (x == ',' && pp == 0) {      /* comma becomes comma-dash-NL. */
            putchar(',');
            putchar('-');
            x = '\n';
        }
        if (inserver && (x == '\n'))    /* Send CR before LF */
          putchar(CR);
        putchar((CHAR)x);               /* Output the character */
        if (x == '\n') {                /* If it was a newline */
#ifdef UNIX
#ifdef NOSETBUF
            fflush(stdout);
#endif /* NOSETBUF */
#endif /* UNIX */
            putchar(' ');               /* Indent the next line 1 space */
            while(*s2 == ' ') s2++;     /* skip past leading blanks */
            n = 2;                      /* restart the character counter */
            slc++;                      /* and increment the line counter. */
        } else if (++n > (cmd_cols - 1)) { /* If line is too wide */
            putchar('-');               /* output a dash */
            if (inserver)
              putchar(CR);              /* and a carriage return */
            putchar(NL);                /* and a newline */
#ifdef UNIX
#ifdef NOSETBUF
            fflush(stdout);
#endif /* NOSETBUF */
#endif /* UNIX */
            n = 1;                      /* and restart the char counter */
            slc++;                      /* and increment the line counter */
        }
        if (n < 3 && slc > (cmd_rows - 3)) { /* If new line and screen full */
            if (!askmore()) return(-1); /* ask if they want more. */
            n = 1;                      /* They do, start a new line */
            slc = 0;                    /* and restart line counter */
        }
    }
    if (inserver)
      putchar(CR);
    putchar(NL);                        /* End of definition */
    if (++slc > (cmd_rows - 3)) {
        if (!askmore()) return(-1);
        slc = 0;
    }
    return(0);
}
#endif /* NOSPL */
#endif /* NOSHOW */

int x_ifnum = 0;                        /* Flag for IF NUMERIC active */

#ifndef NOSPL
/* Evaluate an arithmetic expression. */
/* Code adapted from ev, by Howie Kaye of Columbia U & others. */

static int xerror = 0;
int divbyzero = 0;
static char *cp;
static CK_OFF_T tokval;
static char curtok;
static CK_OFF_T expval;

#define LONGBITS (8*sizeof (CK_OFF_T))
#define NUMBER 'N'
#define N_EOT 'E'

/*
 Replacement for strchr() and index(), neither of which seem to be universal.
*/

static char *
#ifdef CK_ANSIC
windex(char * s, char c)
#else
windex(s,c) char *s, c;
#endif /* CK_ANSIC */
/* windex */ {
    while (*s != NUL && *s != c) s++;
    if (*s == c) return(s); else return(NULL);
}


/*
 g e t t o k

 Returns the next token.  If token is a NUMBER, sets tokval appropriately.
*/
static char
gettok() {
    char tbuf[80] /* ,*tp */ ;          /* Buffer to accumulate number */

    while (isspace(*cp))                /* Skip past leading spaces */
      cp++;

    debug(F110,"GETTOK",cp,0);

    switch (*cp) {
      case '$':                         /* ??? */
      case '+':                         /* Add */
      case '-':                         /* Subtract or Negate */
      case '@':                         /* Greatest Common Divisor */
      case '*':                         /* Multiply */
      case '/':                         /* Divide */
      case '%':                         /* Modulus */
      case '<':                         /* Left shift */
      case '>':                         /* Right shift */
      case '&':                         /* And */
      case '|':                         /* Or */
      case '#':                         /* Exclusive Or */
      case '~':                         /* Not */
      case '^':                         /* Exponent */
      case '!':                         /* Factorial */
      case '(':                         /* Parens for grouping */
      case ')': return(*cp++);          /* operator, just return it */
      case '\n':
      case '\0': return(N_EOT);         /* End of line, return that */
    }
#ifdef COMMENT
/* This is the original code, which allows only integer numbers. */

    if (isxdigit(*cp)) {                /* Digit, must be a number */
        int radix = 10;                 /* Default radix */
        for (tp = tbuf; isxdigit(*cp); cp++)
          *tp++ = (char) (isupper(*cp) ? tolower(*cp) : *cp);
        *tp = '\0';                     /* End number */
        switch(isupper(*cp) ? tolower(*cp) : *cp) { /* Examine break char */
          case 'h':
          case 'x': radix = 16; cp++; break; /* if radix signifier... */
          case 'o':
          case 'q': radix = 8; cp++; break;
          case 't': radix = 2; cp++; break;
        }
        for (tp = tbuf, tokval = 0; *tp != '\0'; tp++)  {
            int dig;
            dig = *tp - '0';            /* Convert number */
            if (dig > 10) dig -= 'a'-'0'-10;
            if (dig >= radix) {
                if (cmdlvl == 0 && !x_ifnum && !xerror)
                  printf("?Invalid digit '%c' in number\n",*tp);
                xerror = 1;
                return(NUMBER);
            }
            tokval = radix*tokval + dig;
        }
        return(NUMBER);
    }
    if (cmdlvl == 0 && !x_ifnum && !xerror)
      printf("Invalid character '%c' in input\n",*cp);
    xerror = 1;
    cp++;
    return(gettok());
#else
/* This code allows non-numbers to be treated as macro names */
    {
        int i, x;
        char * s, * cp1;
        cp1 = cp;
        tp = tbuf;
        for (i = 0; i < 80; i++) {
            /* Look ahead to next break character */
            /* pretty much anything that is not in the switch() above. */
            if (isalpha(*cp) || isdigit(*cp) ||
                *cp == '_' || *cp == ':' || *cp == '.' ||
                *cp == '[' || *cp == ']' ||
                *cp == '{' || *cp == '}'
                )
              tbuf[i] = *cp++;
            else
              break;
        }
        if (i >= 80) {
            printf("Too long - \"%s\"\n", cp1);
            xerror = 1;
            cp++;
            return(gettok());
        }
        if (xerror) return(NUMBER);

        tbuf[i] = NUL;
        s = tbuf;
        if (!isdigit(tbuf[0])) {
            char * s2 = NULL;
            x = mxlook(mactab,tbuf,nmac);
            debug(F111,"gettok mxlook",tbuf,x);
            if (x < 0) {
                if (cmdlvl == 0 && !x_ifnum && !xerror)
                  printf("Bad number - \"%s\"\n",tbuf);
                xerror = 1;
                cp++;
                return(gettok());
            }
            s2 = mactab[x].mval;
            if (!s2) s2 = "";
            if (*s2) s = s2;
        }
#ifdef CKFLOAT
        x = isfloat(s,0);
#else
        x = chknum(s);
#endif /* CKFLOAT */
        if (x > 0) {
            tokval = ckatofs(s);
        } else {
            if (cmdlvl == 0 && !x_ifnum && !xerror)
              printf("Bad number - \"%s\"\n",tbuf);
            xerror = 1;
            cp++;
            return(gettok());
        }
        return(NUMBER);
    }
#endif /* COMMENT */
}

static CK_OFF_T
#ifdef CK_ANSIC
expon(CK_OFF_T x, CK_OFF_T y)
#else
expon(x,y) CK_OFF_T x,y;
#endif /* CK_ANSIC */
/* expon */ {
    CK_OFF_T result = 1;
    int sign = 1;
    if (y < 0) return(0);
    if (x < 0) {
        x = -x;
        if (y & 1) sign = -1;
    }
    while (y != 0) {
        if (y & 1) result *= x;
        y >>= 1;
        if (y != 0) x *= x;
  }
  return(result * sign);
}

/*
 * factor ::= simple | simple ^ factor
 *
 */
static VOID
factor() {
    CK_OFF_T oldval;
    simple();
    if (curtok == '^') {
        oldval = expval;
        curtok = gettok();
        factor();
        expval = expon(oldval,expval);
    }
}

/*
 * termp ::= NULL | {*,/,%,&} factor termp
 *
 */
static VOID
termp() {
    while (curtok == '*' || curtok == '/' || curtok == '%' || curtok == '&') {
        CK_OFF_T oldval;
        char op;
        op = curtok;
        curtok = gettok();              /* skip past operator */
        oldval = expval;
        factor();
        switch(op) {
          case '*': expval = oldval * expval; break;
          case '/':
          case '%':
            if (expval == 0) {
                if (!x_ifnum)
                  printf("?Divide by zero\n");
                xerror = 1;
                divbyzero = 1;
                expval = -1;
            } else
              expval = (op == '/') ? (oldval / expval) : (oldval % expval);
            break;
          case '&':
            expval = oldval & expval; break;
        }
    }
}

static CK_OFF_T
#ifdef CK_ANSIC
fact(CK_OFF_T x)
#else
fact(x) CK_OFF_T x;
#endif /* CK_ANSIC */
/* fact */ {                            /* factorial */
    CK_OFF_T result = 1;
    while (x > 1)
      result *= x--;
    return(result);
}

/*
 * term ::= factor termp
 *
 */
static VOID
term() {
    factor();
    termp();
}

static CK_OFF_T
#ifdef CK_ANSIC
gcd(CK_OFF_T x, CK_OFF_T y)
#else
gcd(x,y) CK_OFF_T x,y;
#endif /* CK_ANSIC */
/* gcd */ {                             /* Greatest Common Divisor */
    int nshift = 0;
    if (x < 0) x = -x;
    if (y < 0) y = -y;                  /* validate arguments */
    if (x == 0 || y == 0) return(x + y);    /* this is bogus */

    while (!((x & 1) | (y & 1))) {      /* get rid of powers of 2 */
        nshift++;
        x >>= 1;
        y >>= 1;
    }
    while (x != 1 && y != 1 && x != 0 && y != 0) {
        while (!(x & 1)) x >>= 1;       /* eliminate unnecessary */
        while (!(y & 1)) y >>= 1;       /* powers of 2 */
        if (x < y) {                    /* force x to be larger */
            CK_OFF_T t;
            t = x;
            x = y;
            y = t;
        }
        x -= y;
    }
    if (x == 0 || y == 0) return((x + y) << nshift); /* gcd is non-zero one */
    else return((CK_OFF_T) 1 << nshift);    /* else gcd is 1 */
}

/*
 * exprp ::= NULL | {+,-,|,...} term exprp
 *
 */
static VOID
exprp() {
    while (windex("+-|<>#@",curtok) != NULL) {
        CK_OFF_T oldval;
        char op;
        op = curtok;
        curtok = gettok();              /* skip past operator */
        oldval = expval;
        term();
        switch(op) {
          case '+' : expval = oldval + expval; break;
          case '-' : expval = oldval - expval; break;
          case '|' : expval = oldval | expval; break;
          case '#' : expval = oldval ^ expval; break;
          case '@' : expval = gcd(oldval,expval); break;
          case '<' : expval = oldval << expval; break;
          case '>' : expval = oldval >> expval; break;
        }
    }
}

/*
 * expr ::= term exprp
 *
 */
static VOID
expr() {
    term();
    exprp();
}

static CK_OFF_T
xparse() {
    curtok = gettok();
    expr();
#ifdef COMMENT
    if (curtok == '$') {
        curtok = gettok();
        if (curtok != NUMBER) {
            if (cmdlvl == 0 && !x_ifnum)
              printf("?Illegal radix\n");
            xerror = 1;
            return(0);
        }
        curtok = gettok();
    }
#endif /* COMMENT */
    if (curtok != N_EOT) {
        if (cmdlvl == 0 && !x_ifnum && !xerror)
          printf("?Extra characters after expression\n");
        xerror = 1;
    }
    return(expval);
}

char *                                  /* Silent front end for evala() */
evalx(s) char *s; {
    char * p;
    int t;
    t = x_ifnum;
    x_ifnum = 1;
    p = evala(s);
    x_ifnum = t;
    return(p);
}

char *
evala(s) char *s; {
    CK_OFF_T v;				/* Numeric value */
    if (!s) return("");
    xerror = 0;                         /* Start out with no error */
    divbyzero = 0;
    cp = s;                             /* Make the argument global */
    v = xparse();                       /* Parse the string */
    return(xerror ? "" : ckfstoa(v));	/* Return empty string on error */
}

/*
 * simplest ::= NUMBER | ( expr )
 *
 */
static VOID
simplest() {
    char * p;
    p = cp;
    if (curtok == NUMBER)
      expval = tokval;
    else if (curtok == '(') {
        curtok = gettok();              /* skip over paren */
        expr();
        if (curtok != ')') {
            if (cmdlvl == 0 && !x_ifnum && !xerror)
              printf("?Missing right parenthesis\n");
            xerror = 1;
        }
        debug(F110,"GETTOK SIMPLEST ()",p,0);

    } else {
        if (cmdlvl == 0 && !x_ifnum && !xerror)
          printf("?Operator unexpected\n");
        xerror = 1;
    }
    curtok = gettok();
}

/*
 * simpler ::= simplest | simplest !
 *
 */
static VOID
simpler() {
    simplest();
    if (curtok == '!') {
        curtok = gettok();
        expval = fact(expval);
    }
}

/*
 * simple ::= {-,~,!} simpler | simpler
 *
 */

static VOID
simple() {
    if (curtok == '-' || curtok == '~' || curtok == '!' || curtok == '+') {
        int op = curtok;
        curtok = gettok();              /* skip over - sign */
        simpler();                      /* parse the factor again */
        if (op != '+')
          expval = (op == '-') ? -expval : ((op == '!') ? !expval : ~expval);
    } else simpler();
}

/*  D C L A R R A Y  --  Declare an array  */
/*
  Call with:
   char a = single character designator for the array, e.g. "a".
   int  n = size of array.  -1 means to undeclare the array.
  Returns:
   0 or greater on success, having created the requested array with
     with n+1 elements, 0..n.  If an array of the same name existed
     previously, it is destroyed.  The new array has all its elements
     initialized to NULL pointers.  When an array is successfully created,
     the return value is its index (0 = 'a', 1 = 'b', and so on.)
  -1 on failure (because 'a' out of range or malloc failure).
*/
int
#ifdef CK_ANSIC
dclarray(char a, int n)
#else
dclarray(a,n) char a; int n;
#endif /* CK_ANSIC */
/* dclarray */ {
    char c, **p; int i, n2, rc;

    if (a > 63 && a < 91) a += 32;      /* Convert letters to lowercase */
    if (a < ARRAYBASE || a > 122)       /* Verify name */
      return(-1);

    if (n < 0)                          /* Check arg */
      return(-1);
    if (n+1 < 0)                        /* MAXINT+1 wraps around */
      return(-1);

    c = a;
    a -= ARRAYBASE;                     /* Convert name to number */
    rc = a;				/* Array index will be return code */
    if ((p = a_ptr[a]) != NULL) {       /* Delete old array of same name */
        if (a_link[a] > -1) {           /* Is it a link? */
            if (n == 0) {               /* If we're just deleting it */
                a_ptr[a] = (char **) NULL; /* clear all the info. */
                a_dim[a] = 0;
                a_link[a] = -1;
                return(0);
            }                           /* Not deleting */
            a = a_link[a];              /* Switch to linked-to array */
        }
        n2 = a_dim[a];                  /* Real array */
        for (i = 0; i <= n2; i++) {     /* First delete its elements */
            if (p[i]) {
                free(p[i]);
                p[i] = NULL;
            }
        }
        free((char *)a_ptr[a]);         /* Then the element list */
        if (n == 0) {                   /* If undeclaring this array... */
            for (i = 0; i < 122 - ARRAYBASE; i++) { /* Any linked arrays? */
                if (i != a && a_link[i] == a) {     /* Find them */
                    a_ptr[i] = (char **) NULL;      /* and remove them */
                    a_dim[i] = 0;
                    a_link[i] = -1;
                }
            }
        }
        a_ptr[a] = (char **) NULL;      /* Remove pointer to element list */
        a_dim[a] = 0;                   /* Set dimension at zero. */
        a_link[a] = -1;                 /* Unset link word */
    }
    if (n < 0)				/* If only undeclaring, */
      return(0);			/*  we're done. */
    p = (char **) malloc((n+1) * sizeof(char **)); /* Allocate for new array */
    if (p == NULL) return(-1);          /* Check */
    a_ptr[a] = p;                       /* Save pointer to member list */
    a_dim[a] = n;                       /* Save dimension */
    for (i = 0; i <= n; i++)            /* Initialize members to null */
      p[i] = NULL;
    for (i = 0; i < (int) 'z' - ARRAYBASE; i++) { /* Any linked arrays? */
        if (i != a && a_link[i] == a) { /* Find and update them */
            a_ptr[i] = p;
            a_dim[i] = n;
        }
    }
    return(rc);
}

/*  X A R R A Y  -- Convert array name to array index  */

int
xarray(s) char * s; {
    char buf[8];
    int x;
    char c;

    if (!s) s = "";
    debug(F110,"xarray",s,0);
    if (!*s)
      return(-1);
    x = strlen(s);

    buf[0] = NUL;
    buf[1] = NUL;
    buf[2] = s[0];
    buf[3] = (x > 0) ? s[1] : NUL;
    buf[4] = (x > 1) ? s[2] : NUL;
    buf[5] = (x > 2) ? s[3] : NUL;
    buf[6] = NUL;
    debug(F110,"xarray buf[3]",&buf[3],0);
    s = buf+2;
    if (*s == '&') {
        buf[1] = CMDQ;
        s--;
    } else if (*s != CMDQ) {
        buf[0] = CMDQ;
        buf[1] = '&';
        s = buf;
    }
    debug(F110,"xarray s",s,0);
    c = *(s+2);
    if (isupper(c))
      c = tolower(c);
    if (c == '@')
      c = 96;
    x = (int)c - ARRAYBASE;
    if (*(s+3) == '[')
      *(s+3) = NUL;
    if (x < 0) {
	return(-1);
    }
    if (x > ('z' - ARRAYBASE)) {
	debug(F101,"xarray x out of range","",x);
	return(-1);
    }
    if (*(s+3)) {
	debug(F110,"xarray syntax",s,0);
	return(-1);
    }
    return(x);
}

/*
  boundspair() -- parses blah[n:m]

  For use with array segment specifiers and compact substring notation.
  Ignores the "blah" part, gets the values of n and m, which can be
  numbers, variables, or arithmetic expressions; anything that resolves
  to a number.

  Call with:
   s    - string to parse
   sep  - array of permissible bounds separator chars
   lo   - pointer to low-bound result (or -1)
   hi   - pointer to hi-bound result (or -1)
   zz   - pointer to separator char that was encountered (or NUL)
  Returns:
   -1 on failure
    0 on success
*/      

int
#ifdef CK_ANSIC
boundspair(char *s, char *sep, int *lo, int *hi, char *zz)
#else
boundspair(s,sep,lo,hi,zz) char *s, *sep, *zz; int *lo, *hi;
#endif /* CK_ANSIC */
{
    int i, x, y, range[2], bc = 0;
    char c = NUL, *s2 = NULL, buf[256], *p, *q, *r, *e[2], *tmp = NULL;

    debug(F110,"boundspair s",s,0);
    debug(F110,"boundspair sep",sep,0);

    *lo = -1;                           /* Default bounds */
    *hi = -1;
    *zz = 0;				/* Default bounds separator */

    range[0] = -1;                      /* It's OK -- get contents */
    range[1] = -1;                      /* of subscript brackets */
    if (!s) s = "";
    if (!*s)
      return(-1);
    makestr(&tmp,s);                    /* Make a pokeable copy */
    p = tmp;
    q = NULL;
    r = NULL;
    for (p = s; *p; p++) {		/* Get the two elements */
	if (*p == '[') {
	    bc++;			/* Bracket counter */
	    if (bc == 1 && !q) q = p+1;
	} else if (*p == ']') {
	    bc--;
	    if (bc == 0 && q) *p = NUL;
	} else if (bc == 1) {		/* If within brackers */
	    s2 = ckstrchr(sep,*p);	/* Check for separator */
	    if (s2) {
		debug(F000,"boundspair *s2","",*s2);
		if (c) {        
		    debug(F000,"boundspair","Too many separators",*s2);
		    makestr(&tmp,NULL);
		    return(-1);
		}
		c = *s2;		/* Separator character */
		*p = NUL;
		r = p+1;
	    }
	}
    }
    if (bc == 0 && !q) {
	/* This allows such constructions as "show array a" */
	debug(F110,"boundspair","no brackets",0);
	makestr(&tmp,NULL);
	return(0);
    }
    if (bc != 0 || !q) {
	debug(F110,"boundspair","unbalanced or missing brackets",0);
	makestr(&tmp,NULL);
	return(-1);
    }
    if (!q) q = "";
    if (!*q) q = "-1";
    if (!r) r = "";
    if (!*r) r = "-1";

    e[0] = q;
    e[1] = r;

    debug(F000,"boundspair c","",c);
    debug(F110,"boundspair q",q,0);
    debug(F110,"boundspair r",r,0);

    for (i = 0; i < 2 && e[i]; i++) {
	y = 255;			/* Expand variables, etc. */
	s = buf;
	zzstring(e[i],&s,&y);
	s = evalx(buf);			/* Evaluate it arithmetically */
	if (s) if (*s)
	  ckstrncpy(buf,s,256);
	if (!chknum(buf)) {		/* Did we get a number? */
	    debug(F110,"boundspair element not numeric",buf,0);
	    makestr(&tmp,NULL);		/* No, fail. */
	    return(-1);
	}
	range[i] = atoi(buf);
    }
    makestr(&tmp,NULL);                 /* Free temporary poked string */
    *lo = range[0];                     /* Return what we got */
    *hi = range[1];
    *zz = c;
    debug(F101,"boundspair lo","",*lo);
    debug(F101,"boundspair hi","",*hi);
    return(0);
}

/*  A R R A Y B O U N D S  --  Parse array segment notation \&a[n:m]  */

/*
  Call with s = array reference, plus two pointers to ints.
  Returns -1 on error, or array index, with the two ints set as follows:
   \&a[]     -1, -1
   \&a[3]     3, -1
   \&a[3:17]  3, 17
  The array need not be declared -- this routine is just for parsing.
*/
int
arraybounds(s,lo,hi) char * s; int * lo, * hi; {
    int i, x, y, range[2];
    char zz, buf[256], * p, * q;
    char * tmp = NULL;

    *lo = -1;                           /* Default bounds */
    *hi = -1;

    if (!s) s = "";                     /* Defense de null args */
    if (!*s)
      return(-1);

    x = xarray(s);                      /* Check basic structure */
    debug(F111,"arraybounds xarray",s,x);
    if (x < 0)                          /* Not OK, fail. */
      return(-1);
    y = boundspair(s,":",lo,hi,&zz);
    debug(F111,"arraybounds boundspair",s,y);
    debug(F101,"arraybounds lo","",*lo);
    debug(F101,"arraybounds hi","",*hi);
    if (y < 0)				/* Get bounds */
      return(-1);
    return(x);
}

/*  A R R A Y N A M  --  Parse an array name  */

/*
  Call with pointer to string that starts with the array reference.
  String may begin with either \& or just &.
  On success,
    Returns letter ID (always lowercase) in argument c,
      which can also be accent grave (` = 96; '@' is converted to grave);
    Dimension or subscript in argument n;
    IMPORTANT: These arguments must be provided by the caller as addresses
    of ints (not chars), for example:
      char *s; int x, y;
      arraynam(s,&x,&y);
  On failure, returns a negative number, with args n and c set to zero.
*/
int
arraynam(ss,c,n) char *ss; int *c; int *n; {
    int i, y, pp, len;
    char x;
    char *s, *p, *sx, *vnp;
    /* On stack to allow for recursive calls... */
    char vnbuf[ARRAYREFLEN+1];          /* Entire array reference */
    char ssbuf[ARRAYREFLEN+1];          /* Subscript in "plain text" */
    char sxbuf[16];                     /* Evaluated subscript */

    *c = *n = 0;                        /* Initialize return values */
    len = strlen(ss);
    for (pp = 0,i = 0; i < len; i++) {          /* Check length */
        if (ss[i] == '[') {
            pp++;
        } else if (ss[i] == ']') {
            if (--pp == 0)
              break;
        }
    }
    if (i > ARRAYREFLEN) {
        printf("?Array reference too long - %s\n",ss);
        return(-9);
    }
    ckstrncpy(vnbuf,ss,ARRAYREFLEN);
    vnp = vnbuf;
    if (vnbuf[0] == CMDQ && vnbuf[1] == '&') vnp++;
    if (*vnp != '&') {
        printf("?Not an array - %s\n",vnbuf);
        return(-9);
    }
    x = *(vnp + 1);                     /* Fold case of array name */

    /* We don't use isupper & tolower here on purpose because these */
    /* would produce undesired effects with accented letters. */
    if (x > 63 && x < 91) x  = *(vnp + 1) = (char) (x + 32);
    if ((x < ARRAYBASE) || (x > 122) || (*(vnp+2) != '[')) {
        if (msgflg) {
            printf("?Invalid format for array name - %s\n",vnbuf);
            return(-9);
        } else
          return(-2);
    }
    *c = x;                             /* Return the array name */
    s = vnp+3;                          /* Get dimension */
    p = ssbuf;
    pp = 1;                             /* Bracket counter */
    for (i = 0; i < ARRAYREFLEN && *s != NUL; i++) { /* Copy up to ] */
        if (*s == '[') pp++;
        if (*s == ']' && --pp == 0) break;
        *p++ = *s++;
    }
    if (*s != ']') {
        printf("?No closing bracket on array dimension - %s\n",vnbuf);
        return(-9);
    }
    p--;                                /* Trim whitespace from end */
    while (*p == SP || *p == HT)
      p--;
    p++;
    *p = NUL;                           /* Terminate subscript with null */
    p = ssbuf;                          /* Point to beginning of subscript */
    while (*p == SP || *p == HT)        /* Trim whitespace from beginning */
      p++;
    sx = sxbuf;                         /* Where to put expanded subscript */
    y = 16;
    {
	/* Even if VARIABLE-EVALUATION SIMPLE use RECURSIVE for subscripts */
	/* NOTE: This is vulnerable to SIGINT and whatnot... */
	int tmp = vareval;		/* Save VARIABLE-EVALUATION setting */
	vareval = 1;			/* Force it to RECURSIVE */
	zzstring(p,&sx,&y);		/* Convert variables, etc. */
	vareval = tmp;			/* Restore VARIABLE-EVALUATION */
    }
    sx = sxbuf;
    while (*sx == SP) sx++;
    /* debug(F110,"arraynam sx","",sx); */
    if (!*sx) {                         /* Empty brackets... */
        *n = -17;                       /* (Secret code :-) */
        return(-2);
    }
    p = evala(sx);                      /* Run it thru \fneval()... */
    if (p) if (*p) ckstrncpy(sxbuf,p,16); /* We know it has to be a number. */

    if (!chknum(sxbuf)) {               /* Make sure it's all digits */
        if (msgflg) {
            printf("?Array dimension or subscript missing or not numeric\n");
            return(-9);
        } else
          return(-2);
    }
    if ((y = atoi(sxbuf)) < 0) {
        if (cmflgs == 0) printf("\n");
        if (msgflg) {
            printf("?Array dimension or subscript not positive or zero\n");
            return(-9);
        } else
          return(-2);
    }
    *n = y;                             /* Return the subscript or dimension */
    return(0);
}

/* chkarray returns 0 or greater if array exists, negative otherwise */

int
chkarray(a,i) int a, i; {               /* Check if array is declared */
    int x;                              /* and if subscript is in range */
    if (a == 64) a = 96;                /* Convert atsign to grave accent */
    x = a - ARRAYBASE;                  /* Values must be in range 95-122 */
#ifdef COMMENT
    if (x == 0 && maclvl < 0)           /* Macro arg vector but no macro */
      return(0);
#endif /* COMMENT */
    if (x < 0 || x > 'z' - ARRAYBASE)   /* Not in range */
      return(-2);
    if (a_ptr[x] == NULL) return(-1);   /* Not declared */
    if (i > a_dim[x]) return(-2);       /* Declared but out of range. */
    return(a_dim[x]);                   /* All ok, return dimension */
}

#ifdef COMMENT                          /* This isn't used. */
char *
arrayval(a,i) int a, i; {               /* Return value of \&a[i] */
    int x; char **p;                    /* (possibly NULL) */
    if (a == 64) a = 96;                /* Convert atsign to grave accent */
    x = a - ARRAYBASE;                  /* Values must be in range 95-122 */
    if (x < 0 || x > 27) return(NULL);  /* Not in range */
    if ((x > 0) && (p = a_ptr[x]) == NULL) /* Array not declared */
      return(NULL);
    if (i > a_dim[x])                   /* Subscript out of range. */
      return(NULL);
    return(p[i]);                       /* All ok, return pointer to value. */
}
#endif /* COMMENT */

/*
  pusharray() is called when an array name is included in a LOCAL statement.
  It moves the pointers from the global definition to the stack, and removes
  the global definition.  Later, if the same array is declared in the local
  context, it occupies the global definition in the normal way.  But when
  popclvl() is called, it replaces the global definition with the one saved
  here.  The "secret code" is used to indicate to popclv() that it should
  remove the global array when popping through this level -- otherwise if a
  local array were declared that had no counterpart at any higher level, it
  would never be deleted.  This allows Algol-like inheritance to work both
  on the way down and on the way back up.
*/
int
pusharray(x,z) int x, z; {
    int y;
    debug(F000,"pusharray x","",x);
    debug(F101,"pusharray z","",z);
    y = chkarray(x,z);
    debug(F101,"pusharray y","",y);
    x -= ARRAYBASE;                     /* Convert name letter to index. */
    if (x < 0 || x > 27)
      return(-1);
    if (y < 0) {
        aa_ptr[cmdlvl][x] = (char **) NULL;
        aa_dim[cmdlvl][x] = -23;        /* Secret code (see popclvl()) */
    } else {
        aa_ptr[cmdlvl][x] = a_ptr[x];
        aa_dim[cmdlvl][x] = y;
    }
    a_ptr[x] = (char **) NULL;
    a_dim[x] = 0;
    return(0);
}

/*  P A R S E V A R  --  Parse a variable name or array reference.  */
/*
 Call with:
   s  = pointer to candidate variable name or array reference.
   *c = address of integer in which to return variable ID.
   *i = address of integer in which to return array subscript.
 Returns:
   -2:  syntax error in variable name or array reference.
    1:  successful parse of a simple variable, with ID in c.
    2:  successful parse of an array reference, w/ID in c and subscript in i.
*/
int
parsevar(s,c,i) char *s; int *c, *i; {
    char *p;
    int x,y,z;

    p = s;
    if (*s == CMDQ) s++;                /* Point after backslash */

    if (*s != '%' && *s != '&') {       /* Make sure it's % or & */
        printf("?Not a variable name - %s\n",p);
        return(-9);
    }
    if ((int)strlen(s) < 2) {
        printf("?Incomplete variable name - %s\n",p);
        return(-9);
    }
    if (*s == '%' && *(s+2) != '\0') {
        printf("?Only one character after '%%' in variable name, please\n");
        return(-9);
    }
    if (*s == '&' && *(s+2) != '[') {
        printf("?Array subscript expected - %s\n",p);
        return(-9);
    }
    if (*s == '%') {                    /* Simple variable. */
        y = *(s+1);                     /* Get variable ID letter/char */
        if (isupper(y)) y -= ('a'-'A'); /* Convert upper to lower case */
        *c = y;                         /* Set the return values. */
        *i = -1;                        /* No array subscript. */
        return(1);                      /* Return 1 = simple variable */
    }
    if (*s == '&') {                    /* Array reference. */
        y = arraynam(s,&x,&z);          /* Go parse it. */
        debug(F101,"parsevar arraynam","",y);
        if ((y) < 0) {
            if (y == -2)
              return(pusharray(x,z));
            if (y != -9)
              printf("?Invalid array reference - %s\n",p);
            return(-9);
        }
        if (chkarray(x,z) < 0) {        /* Check if declared, etc. */
            printf("?Array not declared or subscript out of range\n");
            return(-9);
        }
        *c = x;                         /* Return array letter */
        *i = z;                         /* and subscript. */
        return(2);
    }
    return(-2);                         /* None of the above. */
}


#define VALN 32

/* Get the numeric value of a variable */
/*
  Call with pointer to variable name, pointer to int for return value.
  Returns:
    0 on success with second arg containing the value.
   -1 on failure (bad variable syntax, variable not defined or not numeric).
*/
int
varval(s,v) char *s; CK_OFF_T *v; {
    char valbuf[VALN+1];                /* s is pointer to variable name */
    char name[256];
    char *p;
    int y;

    if (*s != CMDQ) {                   /* Handle macro names too */
        ckmakmsg(name,256,"\\m(",s,")",NULL);
        s = name;
    }
    p = valbuf;                         /* Expand variable into valbuf. */
    y = VALN;
    if (zzstring(s,&p,&y) < 0) return(-1);
    p = valbuf;                         /* Make sure value is numeric  */
    if (!*p) {                          /* Be nice -- let an undefined */
        valbuf[0] = '0';                /* variable be treated as 0.   */
        valbuf[1] = NUL;
    }
    if (chknum(p)) {                    /* Convert numeric string to int */
        *v = ckatofs(p);		/* OK */
    } else {                            /* Not OK */
        p = evala(p);                   /* Maybe it's an expression */
        if (!chknum(p))                 /* Did it evaluate? */
          return(-1);                   /* No, failure. */
        else                            /* Yes, */
          *v = ckatofs(p);		/* success */
    }
    return(0);
}

/* Increment or decrement a variable */
/* Returns -1 on failure, 0 on success */

int
incvar(s,x,z) char *s; CK_OFF_T x; int z; {  /* Increment a numeric variable */
    CK_OFF_T n;				/* s is pointer to variable name */
                                        /* x is amount to increment by */
                                        /* z != 0 means add */
                                        /* z = 0 means subtract */
    if (varval(s,&n) < 0)               /* Convert numeric string to int */
      return(-1);
    if (z)                              /* Increment it by the given amount */
      n += x;
    else                                /* or decrement as requested. */
      n -= x;
    addmac(s,ckfstoa(n));		/* Replace old variable */
    return(0);
}

/* D O D O  --  Do a macro */

/*
  Call with x = macro table index, s = pointer to arguments.
  Returns 0 on failure, 1 on success.
*/
int
dodo(x,s,flags) int x; char *s; int flags; {
    int y;
    extern int tra_asg, tra_cmd; int tra_tmp; /* For TRACE */
#ifndef NOLOCAL
#ifdef OS2
    extern int term_io;
    int term_io_sav = term_io;
#endif /* OS2 */
#endif /* NOLOCAL */

    if (x < 0)                          /* It can happen! */
      return(-1);

    tra_tmp = tra_asg;

    if (++maclvl >= MACLEVEL) {         /* Make sure we have storage */
        debug(F101,"dodo maclvl too deep","",maclvl);
        --maclvl;
        printf("Macros nested too deeply\n");
        return(0);
    }
    macp[maclvl] = mactab[x].mval;      /* Point to the macro body */
    macx[maclvl] = mactab[x].mval;      /* Remember where the beginning is */

#ifdef COMMENT
    makestr(&(m_line[maclvl]),s);       /* Entire arg string for "\%*" */
#endif /* COMMENT */

    cmdlvl++;                           /* Entering a new command level */
    if (cmdlvl >= CMDSTKL) {            /* Too many macros + TAKE files? */
        debug(F101,"dodo cmdlvl too deep","",cmdlvl);
        cmdlvl--;
        printf("?TAKE files and DO commands nested too deeply\n");
        return(0);
    }
#ifdef DEBUG
    if (deblog) {
        debug(F111,"CMD +M",mactab[x].kwd,cmdlvl);
        debug(F010,"CMD ->",s,0);
    }
#endif /* DEBUG */

#ifdef VMS
    conres();                           /* So Ctrl-C, etc, will work. */
#endif /* VMS */
#ifndef NOLOCAL
#ifdef OS2
    term_io = 0;                        /* Disable terminal emulator I/O */
#endif /* OS2 */
#endif /* NOLOCAL */
    ifcmd[cmdlvl] = 0;
    iftest[cmdlvl] = 0;
    count[cmdlvl] = count[cmdlvl-1];    /* Inherit COUNT from previous level */
    intime[cmdlvl] = intime[cmdlvl-1];  /* Inherit previous INPUT TIMEOUT */
    inpcas[cmdlvl] = inpcas[cmdlvl-1];  /*   and INPUT CASE */
    takerr[cmdlvl] = takerr[cmdlvl-1];  /*   and TAKE ERROR */
    merror[cmdlvl] = merror[cmdlvl-1];  /*   and MACRO ERROR */
    xquiet[cmdlvl] = quiet;
    xvarev[cmdlvl] = vareval;
    xcmdsrc = CMD_MD;
    cmdstk[cmdlvl].src = CMD_MD;        /* Say we're in a macro */
    cmdstk[cmdlvl].lvl = maclvl;        /* and remember the macro level */
    cmdstk[cmdlvl].ccflgs = flags & ~CF_IMAC; /* Set flags */

    /* Initialize return value except in FOR, WHILE, IF, and SWITCH macros */

    if (!(flags & CF_IMAC) && mrval[maclvl]) {
        free(mrval[maclvl]);
        mrval[maclvl] = NULL;
    }

    /* Clear old %0..%9 arguments */

    addmac("%0",mactab[x].kwd);         /* Define %0 = name of macro */
    makestr(&(m_xarg[maclvl][0]),mactab[x].kwd);
    varnam[0] = '%';
    varnam[2] = '\0';
    tra_asg = 0;
    for (y = 1; y < 10; y++) {          /* Clear args %1..%9 */
        if (m_arg[maclvl][y]) {         /* Don't call delmac() unless */
            varnam[1] = (char) (y + '0'); /* we have to... */
            delmac(varnam,0);
        }
    }
    tra_asg = tra_tmp;

/* Break the big "s" string up into macro arguments */

    xwords(s,MAXARGLIST,NULL,0);

#ifndef NOLOCAL
#ifdef OS2
    term_io = term_io_sav;
#endif /* OS2 */
#endif /* NOLOCAL */
    if (tra_cmd)
      printf("[%d] +M: \"%s\"\n",cmdlvl,mactab[x].kwd);
    return(1);
}

/* Insert "literal" quote around each comma-separated command to prevent */
/* its premature expansion.  Only do this if object command is surrounded */
/* by braces. */

static char* flit = "\\flit(";

int
litcmd(src,dest,n) char **src, **dest; int n; {
    int bc = 0, pp = 0;
    char c, *s, *lp, *ss;

    s = *src;
    lp = *dest;

    debug(F010,"litcmd",s,0);

    while (*s == SP) s++;               /* Strip extra leading spaces */

    if (*s == '{') {                    /* Starts with brace */
        pp = 0;                         /* Paren counter */
        bc = 1;                         /* Count leading brace */
        *lp++ = *s++;                   /* Copy it */
        if (--n < 1) return(-1);        /* Check space */
        while (*s == SP) s++;           /* Strip interior leading spaces */
        ss = flit;                      /* Point to "\flit(" */
        while ((*lp++ = *ss++))         /* Copy it */
          if (--n < 1)                  /* and check space */
            return(-1);
        lp--;                           /* Back up over null */

        while (*s) {                    /* Go thru rest of text */
            c = *s;
            if (c == '{') bc++;         /* Count brackets */
            if (c == '(') pp++;         /* and parens */
            if (c == ')') {             /* Right parenthesis. */
                pp--;                   /* Count it. */
                if (pp < 0) {           /* An unbalanced right paren... */
#ifdef COMMENT
/*
  The problem here is that "\{" appears to be a quoted brace and therefore
  isn't counted; then the "}" matches an earlier opening brace, causing
  (e.g.) truncation of macros by getncm().
*/
                    if (n < 5)          /* Out of space in dest buffer? */
                      return(-1);       /* If so, give up. */
                    *lp++ = CMDQ;       /* Must be quoted to prevent */
                    *lp++ = '}';        /* premature termination of */
                    *lp++ = '4';        /* \flit(...) */
                    *lp++ = '1';
                    *lp++ = '}';
                    n -= 5;
#else
/* Here we rely on the fact the \nnn never takes more than 3 digits */
                    if (n < 4)          /* Out of space in dest buffer? */
                      return(-1);       /* If so, give up. */
                    *lp++ = CMDQ;       /* Must be quoted to prevent */
                    *lp++ = '0';        /* premature termination of */
                    *lp++ = '4';        /* \flit(...) */
                    *lp++ = '1';
                    n -= 4;
#endif /* COMMENT */
                    pp++;               /* Uncount it. */
                    s++;
                    continue;
                }
            }
            if (c == '}') {             /* Closing brace. */
                if (--bc == 0) {        /* Final one? */
                    *lp++ = ')';        /* Add closing paren for "\flit()" */
                    if (--n < 1) return(-1);
                    *lp++ = c;
                    if (--n < 1) return(-1);
                    s++;
                    break;
                }
            }
            *lp++ = c;                  /* General case */
            if (--n < 1) return(-1);
            s++;
        }
        *lp = NUL;
    } else {                            /* No brackets around, */
        while ((*lp++ = *s++))          /* just copy. */
          if (--n < 1)
            return(-1);
        lp--;
    }
    *src = s;                           /* Return updated source */
    *dest = lp;                         /* and destination pointers */
    if (bc)                             /* Fail if braces unbalanced */
      return(-1);
    else                                /* Otherwise succeed. */
      return(0);
}
#endif /* NOSPL */

/* Functions moved here from ckuusr.c to even out the module sizes... */

/*
  Breaks up string s -- IN PLACE! -- into a list of up to max words.
  Pointers to each word go into the array list[].
  max is the maximum number of words (pointers).
  If list is NULL, then they are added to the macro table.
  flag = 0 means the last field is to be one word, like all the other fields,
         so anything after it is discarded.
  flag = 1 means the last field extends to the end of the string, even if
         there are lots of words left, so the last field contains the
         remainder of the string.
*/
VOID
xwords(s,max,list,flag) char *s; int max; char *list[]; int flag; {
    char *p;
    int b, i, k, q, y, z;
    int macro = 0;

    if (!list) {
        debug(F100," xwords list is NULL","",0);
        macro = 1;
    } else {
        debug(F100," xwords LIST is defined","",0);
    }
    debug(F100,"xwords ENTRY","",0);

#ifndef NOSPL
/*
    debug(F110," xwords macro",(char *)m_xarg[maclvl][0],0);
*/
    debug(F101," xwords maclvl","",maclvl);
    debug(F101," xwords max","",max);
    debug(F101," xwords flag","",flag);
    debug(F110," xwords string",s,0);
    debug(F101," xwords macro","",macro);
#endif /* NOSPL */

    p = s;                              /* Pointer to beginning of string */
    q = 0;                              /* Flag for doublequote removal */
    b = 0;                              /* Flag for outer brace removal */
    k = 0;                              /* Flag for in-word */
    y = 0;                              /* Brace nesting level */
    z = 0;                              /* "Word" counter, 0 thru max */

    if (!s) s = "";                     /* Nothing to do */
    if (!*s) return;
    if (list)
      for (i = 0; i <= max; i++)        /* Initialize pointers */
        list[i] = NULL;

    if (flag) max--;

#ifndef NOSPL
    /*
      Macro arguments at this point are a single string... must split it up.
      As of C-Kermit 9.0.304 Dev.22, 24 April 2017, we use cksplit() for
      this instead of tons of messy code in xwords() written decades ago
      to do what cksplit() does better.
    */
    if (macro) {
        struct stringarray * q = NULL;
        char **pp = NULL;
        int n;
        if (maclvl < 0) {
            debug(F101," xwords maclvl < 0","",maclvl);
            newerrmsg("Internal error: maclvl < 0");
        }
        debug(F101," xwords splitting macro arguments.. maclvl","",maclvl);
  
        /* Space is the only separator; grouping is with "" or {} */
        q = cksplit(1,0,p," ","ALL",1+2,0,0,1);
        z = q->a_size;                  /* Number of "words" in string */
        if (z <= 0) return;
        pp = q->a_head;
        if (pp) {
/*
  In C-Kermit 9.0.304 Dev.22, April 2017, we have to get the macro arguments
  from the previous macro level (prev).  Up to now, the macro arguments were
  evaluated when the DO command was parsed, before dodo() or xwords() were
  ever called.  Now we're evaluating them after already entering the new macro
  stack level: evalmacroarg() is just a front end for zzstring(), which is at
  the heart of all variable-substitution operations.  To evaluate a \%1-9
  variable, zzstring() looks in the CURRENT macro stack frame.  Rather than
  mess with zzstring(), I set maclvl back before calling evalmacroarg() and
  restore it immediately afterward.  It's the only safe way to do this,
  Because zzstring() has no way of knowing whether (say) \%1 is on the DO
  command line or in some other context.
*/
            debug(F101," xwords macro cksplit items","",z);
            if (z > max) z = max;
            for (i = 1; i <= z; i++) {  /* Loop through macro arguments. */
                p = pp[i];
                debug(F111," xwords arg i",p,i);
                maclvl--;               /* Get argument from previous level */
                evalmacroarg(&p);       /* Evaluate it */
                maclvl++;               /* Use its value on currentlevel */
                debug(F111," xwords arg i evaluated",p,i);
                makestr(&(m_xarg[maclvl][i]),p);
                if (i < 10) {
                    varnam[1] = (char) (i + '0'); /* Assign last arg */
                    addmac(varnam,p);
                    debug(F111," xwords arg name",varnam,maclvl);
                    debug(F111," xwords def def ",p,maclvl);
                }
            }
            /* Handle argc and the dimension of the \&_[] arg vector array */

            if (maclvl < 0) {           /* (How can this be?) */
                a_dim[0] = z;               /* Array dimension is one less */
                topargc = z + 1;            /* than \v(argc) */
                debug(F111," xwords a_dim[0]","IMPOSSIBLE",a_dim[0]);
            } else {
                macargc[maclvl] = z + 1;    /* Set \v(argc) variable */
                n_xarg[maclvl] = z + 1;     /* This is the actual number */
                a_ptr[0] = m_xarg[maclvl];  /* Point \&_[] at the args */
                a_dim[0] = z;               /* And give it this dimension */
                debug(F111," xwords a_dim[0]","E",a_dim[0]);
            }
        }
        return;
    }
#endif /* NOSPL */
/*
  Not macro args, some other kind of list.
  This whole mess could be a cksplit() call...
*/
    while (1) {                         /* Go thru word list */
        if (!s || (*s == '\0')) {       /* No more characters? */
            if (k != 0) {               /* Was I in a word? */
                if (z == max) break;    /* Yes, only go up to max. */
                z++;                    /* Count this word. */
                list[z] = p;            /* Assign pointer. */
                debug(F111," xwords list item p z",p,z);
            }
            break;                      /* And get out. */
        }
        if (k == 0 && (*s == SP || *s == HT)) { /* Eat leading blanks */
            s++;
            continue;
        } else if (q == 0 && *s == '{') { /* An opening brace */
            if (k == 0 && y == 0) {     /* If leading brace */
                p = s+1;                /* point past it */
                b = 1;                  /* and flag that we did this */
            }
            k = 1;                      /* Flag that we're in a word */
            y++;                        /* Count the brace. */
        } else if (q == 0 && *s == '}') { /* A closing brace. */
            y--;                        /* Count it. */
            if (y <= 0 && b != 0) {     /* If it matches the leading brace */
                char c;
                c = *(s+1);
                if (!c || c == SP || c == HT) { /* at EOL or followed by SP */
                    *s = SP;            /* change it to a space */
                    b = 0;              /* and we're not in braces any more */
                }
            }
#ifdef DOUBLEQUOTING
        /* Opening doublequote */
        } else if (k == 0 && b == 0 && *s == '"' && dblquo) {
            y++;
            p = s+1;                    /* point past it */
            q = 1;                      /* and flag that we did this */
            k = 1;                      /* Flag that we're in a word */
        /* Closing double quote */
        } else if (q > 0 && k > 0 && b == 0 && *s == '"' && dblquo) {
            char c;
            c = *(s+1);
            if (!c || c == SP || c == HT) { /* at EOL or followed by SP */
                y--;
                *s = SP;                /* change it to a space */
                q = 0;                  /* and we're not in quotes any more */
            }
#endif /* DOUBLEQUOTING */

        } else if (*s != SP && *s != HT) { /* Nonspace means we're in a word */
            if (k == 0) {               /* If we weren't in a word before, */
                p = s;                  /* Mark the beginning */
                if (flag && z == max) { /* Want last word to be remainder? */
                    z++;
                    list[z] = p;        /* Yes, point to it */
                    break;              /* and quit */
                }
                k = 1;                  /* Set in-word flag */
            }
        }
        /* If we're not inside a braced quantity, and we are in a word, and */
        /* we have hit whitespace, then we have a word. */
        if ((y < 1) && (k != 0) && (*s == SP || *s == HT) && !b) {
            if (!flag || z < max)       /* if we don't want to keep rest */
              *s = '\0';                /* terminate the arg with null */
            k = 0;                      /* say we're not in a word any more */
            y = 0;                      /* start braces off clean again */
            if (z == max) break;        /* Only go up to max. */
            z++;                        /* count this arg */
            list[z] = p;
            p = s+1;
        }
        s++;                            /* Point past this character */
    }
    if ((z == 0) && (y > 1)) {          /* Extra closing brace(s) at end */
        z++;
        list[z] = p;
    }
    return;
}

#ifndef NOSPL

/*  D O S H I F T  --  Do the SHIFT Command; shift macro args left by n */

/*  Note: at some point let's consolidate m_arg[][] and m_xarg[][]. */

int
doshift(n) int n; {                     /* n = shift count */
    int i, top, level;
    char /* *s, *m, */ buf[6];          /* Buffer to build scalar names */
    char * sx = tmpbuf;
    int nx = TMPBUFSIZ;

    debug(F101,"SHIFT count","",n);
    debug(F101,"SHIFT topargc","",topargc);

    if (n < 1)                          /* Stay in range */
      return(n == 0 ? 1 : 0);

    level = maclvl;
    top = (level < 0) ? topargc : macargc[level];

    if (n >= top)
      n = top - 1;

#ifdef DEBUG
    if (deblog) {
        debug(F101,"SHIFT count 2","",n);
        debug(F101,"SHIFT level","",level);
        if (level > -1)
          debug(F101,"SHIFT macargc[level]","",macargc[level]);
    }
#endif /* DEBUG */

    buf[0] = '\\';                      /* Initialize name template */
    buf[1] = '%';
    buf[2] = NUL;
    buf[3] = NUL;

    for (i = 1; i <= n; i++) {          /* Free shifted-over args */
        if (level < 0) {
            makestr(&(toparg[i]),NULL);
        } else {
            makestr(&(m_xarg[level][i]),NULL);
        }
        if (i < 10) {                   /* Is this necessary? */
            buf[2] = (char)(i+'0');
            delmac(buf,0);
        }
    }
    for (i = 1; i <= top-n; i++) {      /* Shift remaining args */
        if (level < 0) {
#ifdef COMMENT
            toparg[i] = toparg[i+n];    /* Full vector */
#else
            makestr(&(toparg[i]),toparg[i+n]); /* Full vector */
#endif /* COMMENT */
            if (i < 10)                 /* Scalars... */
              makestr(&(g_var[i+'0']),toparg[i+n]);
        } else {
#ifdef COMMENT
            m_xarg[level][i] = m_xarg[level][i+n];
#else
            makestr(&(m_xarg[level][i]),m_xarg[level][i+n]);
#endif /* COMMENT */
            if (i < 10) {
                buf[2] = (char)(i+'0');
                debug(F010,"SHIFT buf",buf,0);
                addmac(buf,m_xarg[level][i+n]);
            }
        }
    }
    for (i = top-n; i <= top; i++) {    /* Clear n args from the end */
        if (level < 0) {
#ifdef COMMENT
            toparg[i] = NULL;
#else
            makestr(&(toparg[i]),NULL);
#endif /* COMMENt */
            if (i < 10)
              makestr(&(g_var[i+'0']),NULL);
        } else {
#ifdef COMMENT
            m_xarg[level][i] = NULL;
#else
            makestr(&(m_xarg[level][i]),NULL);
#endif /* COMMENt */
            if (i < 10) {
                buf[2] = (char)(i+'0');
                delmac(buf,0);
            }
        }
    }
    if (level > -1) {                   /* Macro args */
        macargc[level] -= n;            /* Adjust count */
        n_xarg[maclvl] = macargc[level]; /* Here too */
        a_dim[0] = macargc[level] - 1;  /* Adjust array dimension */
	debug(F111,"a_dim[0]","F",a_dim[0]);
        zzstring("\\fjoin(&_[],{ },1)",&sx,&nx); /* Handle \%* */
#ifdef COMMENT
        makestr(&(m_line[level]),tmpbuf);
#endif /* COMMENT */
    } else {                            /* Ditto for top level */
        topargc -= n;
        a_dim[0] = topargc - 1;
	debug(F111,"a_dim[0]","G",a_dim[0]);
        zzstring("\\fjoin(&_[],{ },1)",&sx,&nx);
#ifdef COMMENT
        makestr(&topline,tmpbuf);
#endif /* COMMENT */
    }
    return(1);
}
#endif /* NOSPL */

int
docd(cx) int cx; {                      /* Do the CD command */
    int x;
    extern int server, srvcdmsg, cdactive;
    extern char * cdmsgfile[], * ckcdpath;
    char *s, *p;
#ifdef MAC
    char temp[34];
#endif /* MAC */
#ifdef IKSDCONF
extern int iksdcf;
#endif /* IKSDCONF */

#ifndef NOFRILLS
    if (cx == XXBACK) {
        if ((x = cmcfm()) < 0)
        cwdf = 1;
        if (prevdir) {
            s = zgtdir();
            if (!zchdir(prevdir)) {
                cwdf = 0;
                perror(s);
            } else {
                makestr(&prevdir,s);
            }
        }
        return(cwdf);
    }
#endif /* NOFRILLS */

    if (cx == XXCDUP) {
#ifdef VMS
        s = "[-]";
#else
#ifdef datageneral
        s = "^";
#else
        s = "..";
#endif /* datageneral */
#endif /* VMS */
        ckstrncpy(line,s,LINBUFSIZ);
        goto gocd;
    }
#ifndef NOSPL
    if (cx == XXKCD) {			/* Symbolic (Kermit) CD */
	char * p;
	int n, k;
	x = cmkey(kcdtab,nkcdtab,"Symbolic directory name","home",xxstring);
	if (x < 0)
	  return(x);
	x = lookup(kcdtab,atmbuf,nkcdtab,&k); /* Get complete keyword */
	if (x < 0) {
	    printf("?Lookup error\n");	/* shouldn't happen */
	    return(-9);
	}
        if ((x = cmcfm()) < 0)
	  return(x);
	if (k == VN_HOME) {		/* HOME: allow SET HOME to override */
	    ckstrncpy(line,homepath(),LINBUFSIZ);
	} else {			/* Other symbolic name */
	    /* Convert to variable syntax */
	    ckmakmsg(tmpbuf,TMPBUFSIZ,"\\v(",kcdtab[k].kwd,")",NULL);
	    p = line;			/* Expand the variable */
	    n = LINBUFSIZ;
	    zzstring(tmpbuf,&p,&n);
	    if (!line[0]) {		/* Fail if variable not defined */
		printf("?%s - not defined\n",tmpbuf);
		return(success = 0);
	    }
	}
	s = line;			/* All OK, go try to CD... */
	goto gocd;
    }
#endif /* NOSPL */

    cdactive = 1;
#ifdef GEMDOS
    if ((x = cmdir("Name of local directory, or carriage return",
                   homepath(),
                   &s,
                   NULL
                   )
         ) < 0 )
      return(x);
#else
#ifdef OS2
    if ((x = cmdirp("Name of PC disk and/or directory,\n\
       or press the Enter key for the default",
                    homepath(),
                    &s,
                    ckcdpath ? ckcdpath : getenv("CDPATH"),
                    xxstring
                    )
         ) < 0 )
      return(x);
#else
#ifdef MAC
    x = ckstrncpy(temp,homepath(),32);
    if (x > 0) if (temp[x-1] != ':') { temp[x] = ':'; temp[x+1] = NUL; }
    if ((x = cmtxt("Name of Macintosh volume and/or folder,\n\
 or press the Return key for the desktop on the boot disk",
                   temp,&s, xxstring)) < 0 )
      return(x);
#else
    if ((x = cmdirp("Carriage return for home directory,\n\
or name of directory on this computer",
#ifdef VMS
                    "SYS$LOGIN",        /* With no colon */
#else
                    homepath(),		/* In VMS this is "SYS$LOGIN:" */
#endif /* VMS */
                    &s,
                    ckcdpath ? ckcdpath : getenv("CDPATH"),
                    xxstring
                    )) < 0)
      return(x);
#endif /* MAC */
#endif /* OS2 */
#endif /* GEMDOS */
    ckstrncpy(line,s,LINBUFSIZ);        /* Make a safe copy */
    s = line;
#ifdef VMS
    if (ckmatch("*.DIR;1$",s,0,0))
      if (cvtdir(s,tmpbuf,TMPBUFSIZ) > 0)
        s = tmpbuf;
#endif /* VMS */
    debug(F110,"docd",s,0);
#ifndef MAC
    if ((x = cmcfm()) < 0)              /* Get confirmation */
      return(x);
#endif /* MAC */

  gocd:

#ifdef datageneral
    x = strlen(line);                   /* homdir ends in colon, */
    if (x > 1 && line[x-1] == ':')      /* and "dir" doesn't like that... */
      line[x-1] = NUL;
#endif /* datageneral */

#ifdef MAC
    cwdf = 1;
    if (!zchdir(s)) {
        cwdf = 0;
        if (*s != ':') {                /* If it failed, */
            char *p;                    /* supply leading colon */
            int len = (int)strlen(s) + 2;
            p = malloc(len);            /* and try again... */
            if (p) {
                strcpy(p,":");          /* safe */
                strcat(p,s);            /* safe */
                if (zchdir(p))
                  cwdf = 1;
                free(p);
                p = NULL;
            }
        }
    }
    if (!cwdf)
      perror(s);
#else
    p = zgtdir();
    if (!zchdir(s)) {
        cwdf = 0;
#ifdef CKROOT
        if (ckrooterr)
          printf("?Off limits: \"%s\"\n",s);
        else
#endif /* CKROOT */
          perror(s);
    } else cwdf = 1;
#endif /* MAC */

    x = 0;
    if (cwdf) {
        makestr(&prevdir,p);
        debug(F111,"docd","srvcdmsg",srvcdmsg);
        if (srvcdmsg
#ifdef IKSDCONF
            && !(inserver && !iksdcf)
#endif /* IKSDCONF */
            ) {
            int i;
            for (i = 0; i < 8; i++) {
                debug(F111,"docd cdmsgfile[i]",cdmsgfile[i],i);
                if (zchki(cdmsgfile[i]) > -1) {
                    x = 1;
                    dotype(cdmsgfile[i],xaskmore,0,0,NULL,0,NULL,0,0,NULL,0);
                    break;
                }
            }
        }
    }
/* xdocd: */
    if (!x && srvcdmsg && !server
#ifdef IKSDCONF
        && !(inserver && !iksdcf)
#endif /* IKSDCONF */
        && !quiet && !xcmdsrc)
      printf("%s\n", zgtdir());

    return(cwdf);
}

static int on_ctrlc = 0;

VOID
fixcmd() {                      /* Fix command parser after interruption */
#ifndef NOSPL
#ifndef NOONCTRLC
    if (nmac) {                         /* Any macros defined? */
        int k;                          /* Yes */
        char * s = "on_ctrlc";          /* Name of Ctrl-C handling macro */
        k = mlook(mactab,s,nmac);       /* Look it up. */
        if (k >= 0) {                   /* If found, */
            if (on_ctrlc++ == 0) {      /* if not already executing, */
                if (dodo(k,"",0) > -1)  /* set it up, */
                  parser(1);            /* execute it, */
            }
            delmac(s,1);                /* and undefine it. */
        }
    }
    on_ctrlc = 0;
#endif /* NOONCTRLC */
#endif /* NOSPL */
    dostop();                   /* Back to top level (also calls conint()). */
    bgchk();                    /* Check background status */
    if (*psave) {               /* If old prompt saved, */
        cmsetp(psave);          /* restore it. */
        *psave = NUL;
    }
    success = 0;                /* Tell parser last command failed */
}

#ifndef NOSHOW                          /* SHOW FEATURES */
/*
  Note, presently optlist[] index overflow is not checked.
  There is plenty of room (less than 360 entries for 1000 slots).
  When space starts to get tight, check for noptlist >= NOPTLIST
  every time noptlist is incremented.
*/
#define NOPTLIST 1024
static int noptlist = 0;
static char * optlist[NOPTLIST+1];
static int hpos = 0;

int
prtopt(lines,s) int * lines; char *s; { /* Print an option */
    int y, i;                           /* Does word wrap. */
    if (!s) s = "";
    i = *lines;
    if (!*s) {                          /* Empty argument */
        if (hpos > 0) {                 /* means to end this line. */
            printf("\n");               /* Not needed if already at */
            if (++i > (cmd_rows - 3)) { /* beginning of new line. */
                if (!askmore())
                  return(0);
                else
                  i = 0;
            }
        }
        printf("\n");                   /* And then make a blank line */
        if (++i > (cmd_rows - 3)) {
            if (!askmore())
              return(0);
            else
              i = 0;
        }
        hpos = 0;
        *lines = i;
        return(1);
    }
    y = (int)strlen(s) + 1;
    hpos += y;
    debug(F101,"prtopt hpos","",hpos);
    debug(F101,"prtopt cmd_cols","",cmd_cols);

    if (
#ifdef OS2
        hpos > ((cmd_cols > 40) ? (cmd_cols - 1) : 79)
#else /* OS2 */
        hpos > ((tt_cols > 40) ? (tt_cols - 1) : 79)
#endif /* OS2 */
        ) {
        printf("\n");
        if (++i > (cmd_rows - 3)) {
            if (!askmore())
              return(0);
            else
              i = 0;
        }
        printf(" %s",s);
        hpos = y;
    } else
      printf(" %s",s);
    *lines = i;
    return(1);
}

static VOID
initoptlist() {
    int i;
    if (noptlist > 0)
      return;
    for (i = 0; i < NOPTLIST; i++)
      optlist[i] = NULL;

#ifdef MAC
#ifdef MPW
    makestr(&(optlist[noptlist++]),"MPW");
#endif /* MPW */
#endif /* MAC */

#ifdef MAC
#ifdef THINK_C
    makestr(&(optlist[noptlist++]),"THINK_C");
#endif /* THINK_C */
#endif /* MAC */

#ifdef __386__
    makestr(&(optlist[noptlist++]),"__386__");
#endif /* __386__ */

/* Memory models... */

#ifdef __FLAT__
    makestr(&(optlist[noptlist++]),"__FLAT__");
#endif /* __FLAT__ */
#ifdef __SMALL__
    makestr(&(optlist[noptlist++]),"__SMALL__");
#endif /* __SMALL__ */
#ifdef __MEDIUM__
    makestr(&(optlist[noptlist++]),"__MEDIUM__");
#endif /* __MEDIUM__ */
#ifdef __COMPACT__
    makestr(&(optlist[noptlist++]),"__COMPACT__");
#endif /* __COMPACT__ */
#ifdef __LARGE__
    makestr(&(optlist[noptlist++]),"__LARGE__");
#endif /* __LARGE__ */

#ifdef DEBUG
#ifdef IFDEBUG
    makestr(&(optlist[noptlist++]),"IFDEBUG");
#else
    makestr(&(optlist[noptlist++]),"DEBUG");
#endif /* IFDEBUG */
#endif /* DEBUG */
#ifdef TLOG
    makestr(&(optlist[noptlist++]),"TLOG");
#endif /* TLOG */
#ifdef BIGBUFOK
    makestr(&(optlist[noptlist++]),"BIGBUFOK");
#endif /* BIGBUFOK */
#ifdef INPBUFSIZ
    sprintf(line,"INPBUFSIZ=%d",INPBUFSIZ); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* INPBUFSIZE */
#ifdef LINBUFSIZ
    sprintf(line,"LINBUFSIZ=%d",LINBUFSIZ); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* LINBUFSIZE */
#ifdef INBUFSIZE
    sprintf(line,"INBUFSIZE=%d",INBUFSIZE); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* INBUFSIZE */
#ifdef OBUFSIZE
    sprintf(line,"OBUFSIZE=%d",OBUFSIZE); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* OBUFSIZE */
#ifdef FD_SETSIZE
    sprintf(line,"FD_SETSIZE=%d",FD_SETSIZE); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* FD_SETSIZE */
#ifdef XFRCAN
    makestr(&(optlist[noptlist++]),"XFRCAN");
#endif /* XFRCAN */
#ifdef XPRINT
    makestr(&(optlist[noptlist++]),"XPRINT");
#endif /* XPRINT */
#ifdef PIPESEND
    makestr(&(optlist[noptlist++]),"PIPESEND");
#endif /* PIPESEND */
#ifdef CK_SPEED
    makestr(&(optlist[noptlist++]),"CK_SPEED");
#endif /* CK_SPEED */
#ifdef CK_FAST
    makestr(&(optlist[noptlist++]),"CK_FAST");
#endif /* CK_FAST */
#ifdef CK_APC
    makestr(&(optlist[noptlist++]),"CK_APC");
#endif /* CK_APC */
#ifdef CK_AUTODL
    makestr(&(optlist[noptlist++]),"CK_AUTODL");
#endif /* CK_AUTODL */
#ifdef CK_MKDIR
    makestr(&(optlist[noptlist++]),"CK_MKDIR");
#endif /* CK_MKDIR */
#ifdef HAVE_LOCALE
    makestr(&(optlist[noptlist++]),"HAVE_LOCALE");
#endif /* HAVE_LOCALE */
#ifdef HAVE_SNPRINTF
    makestr(&(optlist[noptlist++]),"HAVE_SNPRINTF");
#endif /* HAVE_SNPRINTF */
#ifdef NOMKDIR
    makestr(&(optlist[noptlist++]),"NOMKDIR");
#endif /* NOMKDIR */
#ifdef CK_LABELED
    makestr(&(optlist[noptlist++]),"CK_LABELED");
#endif /* CK_LABELED */
#ifdef NODIAL
    makestr(&(optlist[noptlist++]),"NODIAL");
#endif /* NODIAL */
#ifdef MINIDIAL
    makestr(&(optlist[noptlist++]),"MINIDIAL");
#endif /* MINIDIAL */
#ifdef WHATAMI
    makestr(&(optlist[noptlist++]),"WHATAMI");
#endif /* WHATAMI */
#ifdef DYNAMIC
    makestr(&(optlist[noptlist++]),"DYNAMIC");
#endif /* DYNAMIC */
#ifndef NOSPL
    sprintf(line,"CMDDEP=%d",CMDDEP);   /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* NOSPL */

#ifdef MAXPATHLEN
    sprintf(line,"MAXPATHLEN=%d",MAXPATHLEN); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* MAXPATHLEN */

#ifdef DEVNAMLEN
    sprintf(line,"DEVNAMLEN=%d",DEVNAMLEN); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* DEVNAMLEN */

#ifdef NO_PARAM_H
    makestr(&(optlist[noptlist++]),"NO_PARAM_H");
#endif /* NO_PARAM_H */

#ifdef INCL_PARAM_H
    makestr(&(optlist[noptlist++]),"INCL_PARAM_H");
#endif /* INCL_PARAM_H */

    sprintf(line,"CKMAXPATH=%d",CKMAXPATH); /* SAFE */
    makestr(&(optlist[noptlist++]),line);

    sprintf(line,"CKMAXOPEN=%d",CKMAXOPEN); /* SAFE */
    makestr(&(optlist[noptlist++]),line);

#ifndef UNIX
    /*
      These aren't actually used... In Unix we get maximum number of open
      files from sysconf() at runtime.
    */
    sprintf(line,"Z_MAXCHAN=%d",Z_MAXCHAN); /* SAFE */
    makestr(&(optlist[noptlist++]),line);

#ifdef OPEN_MAX
    sprintf(line,"OPEN_MAX=%d",OPEN_MAX); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* OPEN_MAX */

#ifdef _POSIX_OPEN_MAX
    sprintf(line,"_POSIX_OPEN_MAX=%d",_POSIX_OPEN_MAX); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* _POSIX_OPEN_MAX */
#endif /* UNIX */

#ifdef CKCHANNELIO
    {
        extern int z_maxchan;
#ifdef UNIX
        extern int ckmaxfiles;
        sprintf(line,"ckmaxfiles=%d",ckmaxfiles); /* SAFE */
        makestr(&(optlist[noptlist++]),line);
#endif /* UNIX */
        sprintf(line,"z_maxchan=%d",z_maxchan); /* SAFE */
        makestr(&(optlist[noptlist++]),line);
    }
#endif /* CKCHANNELIO */

#ifdef FOPEN_MAX
    sprintf(line,"FOPEN_MAX=%d",FOPEN_MAX); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* FOPEN_MAX */

#ifdef MAXGETPATH
    sprintf(line,"MAXGETPATH=%d",MAXGETPATH); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* MAXGETPATH */

#ifdef CMDBL
    sprintf(line,"CMDBL=%d",CMDBL);     /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* CMDBL */

#ifdef VNAML
    sprintf(line,"VNAML=%d",VNAML);     /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* VNAML */

#ifdef ARRAYREFLEN
    sprintf(line,"ARRAYREFLEN=%d",ARRAYREFLEN); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* ARRAYREFLEN */

#ifdef UIDBUFLEN
    sprintf(line,"UIDBUFLEN=%d",UIDBUFLEN); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* UIDBUFLEN */

#ifdef FORDEPTH
    sprintf(line,"FORDEPTH=%d",FORDEPTH); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* FORDEPTH */

#ifdef MAXTAKE
    sprintf(line,"MAXTAKE=%d",MAXTAKE); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* MAXTAKE */

#ifdef MACLEVEL
    sprintf(line,"MACLEVEL=%d",MACLEVEL); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* MACLEVEL */

#ifdef MAC_MAX
    sprintf(line,"MAC_MAX=%d",MAC_MAX); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* MAC_MAX */

#ifdef _LARGEFILE_SOURCE
    makestr(&(optlist[noptlist++]),"_LARGEFILE_SOURCE");
#endif	/* _LARGEFILE_SOURCE */

#ifdef _FILE_OFFSET_BITS
    sprintf(line,"_FILE_OFFSET_BITS=%d",_FILE_OFFSET_BITS); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif	/* _FILE_OFFSET_BITS */

#ifdef __USE_FILE_OFFSET64
    makestr(&(optlist[noptlist++]),"__USE_FILE_OFFSET64");
#endif	/* __USE_FILE_OFFSET64 */

#ifdef __USE_LARGEFILE64
    makestr(&(optlist[noptlist++]),"__USE_LARGEFILE64");
#endif	/* __USE_LARGEFILE64 */

#ifdef COMMENT
#ifdef CHAR_MAX
    sprintf(line,"CHAR_MAX=%llx",CHAR_MAX); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* CHAR_MAX */
#ifdef UCHAR_MAX
    sprintf(line,"UCHAR_MAX=%llx",UCHAR_MAX); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* UCHAR_MAX */
#ifdef SHRT_MAX
    sprintf(line,"SHRT_MAX=%llx",SHRT_MAX); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* SHRT_MAX */
#ifdef USHRT_MAX
    sprintf(line,"USHRT_MAX=%llx",USHRT_MAX); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* USHRT_MAX */
#ifdef INT_MAX
    sprintf(line,"INT_MAX=%llx",INT_MAX); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* INT_MAX */
#ifdef UINT_MAX
    sprintf(line,"UINT_MAX=%llx",UINT_MAX); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* UINT_MAX */
#ifdef MAX_LONG
    sprintf(line,"MAX_LONG=%llx",MAX_LONG); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* MAX_LONG */
#ifdef LONG_MAX
    sprintf(line,"LONG_MAX=%llx",LONG_MAX); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* LONG_MAX */
#ifdef ULONG_MAX
    sprintf(line,"ULONG_MAX=%llx",ULONG_MAX); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* ULONG_MAX */
#ifdef MAXINT
    sprintf(line,"MAXINT=%llx",MAXINT); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* MAXINT */
#ifdef MAXLONG
    sprintf(line,"MAXLONG=%llx",MAXLONG); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* MAXLONG */
#ifdef NT
#ifdef LLONG_MAX
    sprintf(line,"LLONG_MAX=%I64x",LLONG_MAX); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* LLONG_MAX */
#ifdef ULLONG_MAX
    sprintf(line,"ULLONG_MAX=%I64x",ULLONG_MAX); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* ULLONG_MAX */
#ifdef MAXLONGLONG
    sprintf(line,"MAXLONGLONG=%I64x",MAXLONGLONG);  /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* MAXLONGLONG */
#else
#ifdef LLONG_MAX
    sprintf(line,"LLONG_MAX=%llx",LLONG_MAX); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* LLONG_MAX */
#ifdef ULLONG_MAX
    sprintf(line,"ULLONG_MAX=%llx",ULLONG_MAX); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* ULLONG_MAX */
#ifdef MAXLONGLONG
    sprintf(line,"MAXLONGLONG=%llx",MAXLONGLONG);  /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* MAXLONGLONG */
#endif
#ifdef _INTEGRAL_MAX_BITS
    sprintf(line,"_INTEGRAL_MAX_BITS=%d",_INTEGRAL_MAX_BITS);  /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* _INTEGRAL_MAX_BITS */
#endif	/* COMMENT */

#ifdef MINPUTMAX
    sprintf(line,"MINPUTMAX=%d",MINPUTMAX); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* MINPUTMAX */

#ifdef MAXWLD
    sprintf(line,"MAXWLD=%d",MAXWLD); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#else
#ifdef OS2
    makestr(&(optlist[noptlist++]),"MAXWLD=unlimited");
#endif /* OS2 */
#endif /* MAXWLD */

#ifdef MSENDMAX
    sprintf(line,"MSENDMAX=%d",MSENDMAX); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* MSENDMAX */

#ifdef MAXDDIR
    sprintf(line,"MAXDDIR=%d",MAXDDIR); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* MAXDDIR */

#ifdef MAXDNUMS
    sprintf(line,"MAXDNUMS=%d",MAXDNUMS); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* MAXDNUMS */

#ifdef UNIX
    makestr(&(optlist[noptlist++]),"UNIX");
#endif /* UNIX */

#ifdef VMS
    makestr(&(optlist[noptlist++]),"VMS");
#ifdef __VMS_VER
    sprintf(line,"__VMS_VER=%d",__VMS_VER); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* __VMS_VER */
#ifdef VMSV70
    makestr(&(optlist[noptlist++]),"VMSV70");
#endif /* VMSV70 */
#ifdef OLD_VMS
    makestr(&(optlist[noptlist++]),"OLD_VMS");
#endif /* OLD_VMS */
#ifdef vms
    makestr(&(optlist[noptlist++]),"vms");
#endif /* vms */
#ifdef VMSV60
    makestr(&(optlist[noptlist++]),"VMSV60");
#endif /* VMSV60 */
#ifdef VMSV80
    makestr(&(optlist[noptlist++]),"VMSV80");
#endif /* VMSV80 */
#ifdef VMSSHARE
    makestr(&(optlist[noptlist++]),"VMSSHARE");
#endif /* VMSSHARE */
#ifdef NOVMSSHARE
    makestr(&(optlist[noptlist++]),"NOVMSSHARE");
#endif /* NOVMSSHARE */
#endif /* VMS */

#ifdef datageneral
    makestr(&(optlist[noptlist++]),"datageneral");
#endif /* datageneral */
#ifdef apollo
    makestr(&(optlist[noptlist++]),"apollo");
#endif /* apollo */
#ifdef aegis
    makestr(&(optlist[noptlist++]),"aegis");
#endif /* aegis */
#ifdef A986
    makestr(&(optlist[noptlist++]),"A986");
#endif /* A986 */
#ifdef AMIGA
    makestr(&(optlist[noptlist++]),"AMIGA");
#endif /* AMIGA */
#ifdef CONVEX9
    makestr(&(optlist[noptlist++]),"CONVEX9");
#endif /* CONVEX9 */
#ifdef CONVEX10
    makestr(&(optlist[noptlist++]),"CONVEX10");
#endif /* CONVEX9 */
#ifdef MAC
    makestr(&(optlist[noptlist++]),"MAC");
#endif /* MAC */
#ifdef AUX
    makestr(&(optlist[noptlist++]),"AUX");
#endif /* AUX */

#ifdef OS2
    makestr(&(optlist[noptlist++]),"OS2");
#ifdef NT
    makestr(&(optlist[noptlist++]),"NT");
#endif /* NT */
#endif /* OS2 */

#ifdef OSK
    makestr(&(optlist[noptlist++]),"OS9");
#endif /* OSK */

#ifdef MSDOS
    makestr(&(optlist[noptlist++]),"MSDOS");
#endif /* MSDOS */

#ifdef DIRENT
    makestr(&(optlist[noptlist++]),"DIRENT");
#endif /* DIRENT */

#ifdef SDIRENT
    makestr(&(optlist[noptlist++]),"SDIRENT");
#endif /* SDIRENT */

#ifdef NDIR
    makestr(&(optlist[noptlist++]),"NDIR");
#endif /* NDIR */

#ifdef XNDIR
    makestr(&(optlist[noptlist++]),"XNDIR");
#endif /* XNDIR */

#ifdef SAVEDUID
    makestr(&(optlist[noptlist++]),"SAVEDUID");
#endif /* SAVEDUID */

#ifdef RENAME
    makestr(&(optlist[noptlist++]),"RENAME");
#endif /* RENAME */

#ifdef CK_TMPDIR
    makestr(&(optlist[noptlist++]),"CK_TMPDIR");
#endif /* CK_TMPDIR */

#ifdef NOCCTRAP
    makestr(&(optlist[noptlist++]),"NOCCTRAP");
#endif /* NOCCTRAP */

#ifdef NOCOTFMC
    makestr(&(optlist[noptlist++]),"NOCOTFMC");
#endif /* NOCOTFMC */

#ifdef NOFRILLS
    makestr(&(optlist[noptlist++]),"NOFRILLS");
#endif /* NOFRILLS */

#ifdef PARSENSE
    makestr(&(optlist[noptlist++]),"PARSENSE");
#endif /* PARSENSE */

#ifdef TIMEH
    makestr(&(optlist[noptlist++]),"TIMEH");
#endif /* TIMEH */

#ifdef NOTIMEH
    makestr(&(optlist[noptlist++]),"TIMEH");
#endif /* NOTIMEH */

#ifdef SYSTIMEH
    makestr(&(optlist[noptlist++]),"SYSTIMEH");
#endif /* SYSTIMEH */

#ifdef NOSYSTIMEH
    makestr(&(optlist[noptlist++]),"SYSTIMEH");
#endif /* NOSYSTIMEH */

#ifdef SYSTIMEBH
    makestr(&(optlist[noptlist++]),"SYSTIMEBH");
#endif /* SYSTIMEBH */

#ifdef NOSYSTIMEBH
    makestr(&(optlist[noptlist++]),"SYSTIMEBH");
#endif /* NOSYSTIMEBH */

#ifdef UTIMEH
    makestr(&(optlist[noptlist++]),"UTIMEH");
#endif /* UTIMEH */

#ifdef SYSUTIMEH
    makestr(&(optlist[noptlist++]),"SYSUTIMEH");
#endif /* SYSUTIMEH */

#ifdef CK_NEED_SIG
    makestr(&(optlist[noptlist++]),"CK_NEED_SIG");
#endif /* CK_NEED_SIG */

#ifdef CK_TTYFD
    makestr(&(optlist[noptlist++]),"CK_TTYFD");
#endif /* CK_TTYFD */

#ifdef NETCONN
    makestr(&(optlist[noptlist++]),"NETCONN");
#endif /* NETCONN */

#ifdef TCPSOCKET
    makestr(&(optlist[noptlist++]),"TCPSOCKET");
#ifdef NOTCPOPTS
    makestr(&(optlist[noptlist++]),"NOTCPOPTS");
#endif /* NOTCPOPTS */
#ifdef CK_DNS_SRV
    makestr(&(optlist[noptlist++]),"CK_DNS_SRV");
#endif /* CK_DNS_SRV */
#ifdef NO_DNS_SRV
    makestr(&(optlist[noptlist++]),"NO_DNS_SRV");
#endif /* NO_DNS_SRV */
#ifdef CKGHNLHOST
    makestr(&(optlist[noptlist++]),"CKGHNLHOST");
#endif /* CKGHNLHOST */
#ifdef NOLISTEN
    makestr(&(optlist[noptlist++]),"NOLISTEN");
#endif /* NOLISTEN */
#ifdef SOL_SOCKET
    makestr(&(optlist[noptlist++]),"SOL_SOCKET");
#endif /* SOL_SOCKET */
#ifdef SO_OOBINLINE
    makestr(&(optlist[noptlist++]),"SO_OOBINLINE");
#endif /* SO_OOBINLNE */
#ifdef SO_DONTROUTE
    makestr(&(optlist[noptlist++]),"SO_DONTROUTE");
#endif /* SO_DONTROUTE */
#ifdef SO_KEEPALIVE
    makestr(&(optlist[noptlist++]),"SO_KEEPALIVE");
#endif /* SO_KEEPALIVE */
#ifdef SO_LINGER
    makestr(&(optlist[noptlist++]),"SO_LINGER");
#endif /* SO_LINGER */
#ifdef TCP_NODELAY
    makestr(&(optlist[noptlist++]),"TCP_NODELAY");
#endif /* TCP_NODELAY */
#ifdef SO_SNDBUF
    makestr(&(optlist[noptlist++]),"SO_SNDBUF");
#endif /* SO_SNDBUF */
#ifdef SO_RCVBUF
    makestr(&(optlist[noptlist++]),"SO_RCVBUF");
#endif /* SO_RCVBUF */
#ifdef h_addr
    makestr(&(optlist[noptlist++]),"h_addr");
#endif /* h_addr */
#ifdef HADDRLIST
    makestr(&(optlist[noptlist++]),"HADDRLIST");
#endif /* HADDRLIST */
#ifdef CK_SOCKS
    makestr(&(optlist[noptlist++]),"CK_SOCKS");
#ifdef CK_SOCKS5
    makestr(&(optlist[noptlist++]),"CK_SOCKS5");
#endif /* CK_SOCKS5 */
#ifdef CK_SOCKS_NS
    makestr(&(optlist[noptlist++]),"CK_SOCKS_NS");
#endif /* CK_SOCKS_NS */
#endif /* CK_SOCKS */
#ifdef RLOGCODE
    makestr(&(optlist[noptlist++]),"RLOGCODE");
#endif /* RLOGCODE */
#ifdef NETCMD
    makestr(&(optlist[noptlist++]),"NETCMD");
#endif /* NETCMD */
#ifdef NONETCMD
    makestr(&(optlist[noptlist++]),"NONETCMD");
#endif /* NONETCMD */
#ifdef NETPTY
    makestr(&(optlist[noptlist++]),"NETPTY");
#endif /* NETPTY */
#ifdef CK_ENVIRONMENT
    makestr(&(optlist[noptlist++]),"CK_ENVIRONMENT");
#endif /* CK_ENVIRONMENT */
#endif /* TCPSOCKET */
#ifdef TNCODE
    makestr(&(optlist[noptlist++]),"TNCODE");
#endif /* TNCODE */
#ifdef CK_FORWARD_X
    makestr(&(optlist[noptlist++]),"CK_FORWARD_X");
#endif /* CK_FORWARD_X */
#ifdef TN_COMPORT
    makestr(&(optlist[noptlist++]),"TN_COMPORT");
#endif /* TN_COMPORT */
#ifdef MULTINET
    makestr(&(optlist[noptlist++]),"MULTINET");
#endif /* MULTINET */
#ifdef DEC_TCPIP
    makestr(&(optlist[noptlist++]),"DEC_TCPIP");
#endif /* DEC_TCPIP */
#ifdef TCPWARE
    makestr(&(optlist[noptlist++]),"TCPWARE");
#endif /* TCPWARE */
#ifdef UCX50
    makestr(&(optlist[noptlist++]),"UCX50");
#endif /* UCX50 */
#ifdef CMU_TCPIP
    makestr(&(optlist[noptlist++]),"CMU_TCPIP");
#endif /* CMU_TCPIP */
#ifdef TTLEBUF
    makestr(&(optlist[noptlist++]),"TTLEBUF");
#endif /* TTLEBUF */
#ifdef NETLEBUF
    makestr(&(optlist[noptlist++]),"NETLEBUF");
#endif /* NETLEBUF */
#ifdef IKS_OPTION
    makestr(&(optlist[noptlist++]),"IKS_OPTION");
#endif /* IKS_OPTION */
#ifdef IKSDB
    makestr(&(optlist[noptlist++]),"IKSDB");
#endif /* IKSDB */
#ifdef IKSDCONF
    makestr(&(optlist[noptlist++]),"IKSDCONF");
#endif /* IKSDCONF */
#ifdef CK_LOGIN
    makestr(&(optlist[noptlist++]),"CK_LOGIN");
#endif /* CK_LOGIN */
#ifdef CK_PAM
    makestr(&(optlist[noptlist++]),"CK_PAM");
#endif /* CK_PAM */
#ifdef CK_SHADOW
    makestr(&(optlist[noptlist++]),"CK_SHADOW");
#endif /* CK_SHADOW */
#ifdef CONGSPD
    makestr(&(optlist[noptlist++]),"CONGSPD");
#endif /* CONGSPD */
#ifdef SUNX25
    makestr(&(optlist[noptlist++]),"SUNX25");
#endif /* SUNX25 */
#ifdef IBMX25
    makestr(&(optlist[noptlist++]),"IBMX25");
#endif /* IBMX25 */
#ifdef HPX25
    makestr(&(optlist[noptlist++]),"HPX25");
#endif /* HPX25 */
#ifdef DECNET
    makestr(&(optlist[noptlist++]),"DECNET");
#endif /* DECNET */
#ifdef SUPERLAT
    makestr(&(optlist[noptlist++]),"SUPERLAT");
#endif /* SUPERLAT */
#ifdef NPIPE
    makestr(&(optlist[noptlist++]),"NPIPE");
#endif /* NPIPE */
#ifdef CK_NETBIOS
    makestr(&(optlist[noptlist++]),"CK_NETBIOS");
#endif /* CK_NETBIOS */
#ifdef ATT7300
    makestr(&(optlist[noptlist++]),"ATT7300");
#endif /* ATT7300 */
#ifdef ATT6300
    makestr(&(optlist[noptlist++]),"ATT6300");
#endif /* ATT6300 */
#ifdef HDBUUCP
    makestr(&(optlist[noptlist++]),"HDBUUCP");
#endif /* HDBUUCP */
#ifdef USETTYLOCK
    makestr(&(optlist[noptlist++]),"USETTYLOCK");
#endif /* USETTYLOCK */
#ifdef USE_UU_LOCK
    makestr(&(optlist[noptlist++]),"USE_UU_LOCK");
#endif /* USE_UU_LOCK */
#ifdef HAVE_LOCKDEV
    makestr(&(optlist[noptlist++]),"HAVE_LOCKDEV");
#endif /* HAVE_LOCKDEV */
#ifdef HAVE_BAUDBOY
    makestr(&(optlist[noptlist++]),"HAVE_BAUDBOY");
#endif /* HAVE_BAUDBOY */
#ifdef HAVE_OPENPTY
    makestr(&(optlist[noptlist++]),"HAVE_OPENPTY");
#endif /* HAVE_OPENPTY */
#ifdef TTPTYCMD
    makestr(&(optlist[noptlist++]),"TTPTYCMD");
#endif /* TTPTYCMD */
#ifdef NOUUCP
    makestr(&(optlist[noptlist++]),"NOUUCP");
#endif /* NOUUCP */
#ifdef LONGFN
    makestr(&(optlist[noptlist++]),"LONGFN");
#endif /* LONGFN */
#ifdef RDCHK
    makestr(&(optlist[noptlist++]),"RDCHK");
#endif /* RDCHK */
#ifdef SELECT
    makestr(&(optlist[noptlist++]),"SELECT");
#endif /* SELECT */
#ifdef USLEEP
    makestr(&(optlist[noptlist++]),"USLEEP");
#endif /* USLEEP */
#ifdef NAP
    makestr(&(optlist[noptlist++]),"NAP");
#endif /* NAP */
#ifdef NAPHACK
    makestr(&(optlist[noptlist++]),"NAPHACK");
#endif /* NAPHACK */
#ifdef CK_POLL
    makestr(&(optlist[noptlist++]),"CK_POLL");
#endif /* CK_POLL */
#ifdef NOIEXTEN
    makestr(&(optlist[noptlist++]),"NOIEXTEN");
#endif /* NOIEXTEN */
#ifdef EXCELAN
    makestr(&(optlist[noptlist++]),"EXCELAN");
#endif /* EXCELAN */
#ifdef INTERLAN
    makestr(&(optlist[noptlist++]),"INTERLAN");
#endif /* INTERLAN */
#ifdef NOFILEH
    makestr(&(optlist[noptlist++]),"NOFILEH");
#endif /* NOFILEH */
#ifdef NOSYSIOCTLH
    makestr(&(optlist[noptlist++]),"NOSYSIOCTLH");
#endif /* NOSYSIOCTLH */
#ifdef DCLPOPEN
    makestr(&(optlist[noptlist++]),"DCLPOPEN");
#endif /* DCLPOPEN */
#ifdef NOSETBUF
    makestr(&(optlist[noptlist++]),"NOSETBUF");
#endif /* NOSETBUF */
#ifdef NOXFER
    makestr(&(optlist[noptlist++]),"NOXFER");
#endif /* NOXFER */
#ifdef NOCURSES
    makestr(&(optlist[noptlist++]),"NOCURSES");
#endif /* NOCURSES */
#ifdef NOSERVER
    makestr(&(optlist[noptlist++]),"NOSERVER");
#endif /* NOSERVER */
#ifdef NOPATTERNS
    makestr(&(optlist[noptlist++]),"NOPATTERNS");
#else
#ifdef PATTERNS
    makestr(&(optlist[noptlist++]),"PATTERNS");
#endif /* PATTERNS */
#endif /* NOPATTERNS */
#ifdef NOCKEXEC
    makestr(&(optlist[noptlist++]),"NOCKEXEC");
#else
#ifdef CKEXEC
    makestr(&(optlist[noptlist++]),"CKEXEC");
#endif /* CKEXEC */
#endif /* NOCKEXEC */
#ifdef NOAUTODL
    makestr(&(optlist[noptlist++]),"NOAUTODL");
#endif /* NOAUTODL */
#ifdef NOMSEND
    makestr(&(optlist[noptlist++]),"NOMSEND");
#endif /* NOMSEND */
#ifdef NOFDZERO
    makestr(&(optlist[noptlist++]),"NOFDZERO");
#endif /* NOFDZERO */
#ifdef NOPOPEN
    makestr(&(optlist[noptlist++]),"NOPOPEN");
#endif /* NOPOPEN */
#ifdef NOPARTIAL
    makestr(&(optlist[noptlist++]),"NOPARTIAL");
#endif /* NOPARTIAL */
#ifdef NOKVERBS
    makestr(&(optlist[noptlist++]),"NOKVERBS");
#endif /* NOKVERBS */
#ifdef NOSETREU
    makestr(&(optlist[noptlist++]),"NOSETREU");
#endif /* NOSETREU */
#ifdef LCKDIR
    makestr(&(optlist[noptlist++]),"LCKDIR");
#endif /* LCKDIR */
#ifdef ACUCNTRL
    makestr(&(optlist[noptlist++]),"ACUCNTRL");
#endif /* ACUCNTRL */
#ifdef BSD4
    makestr(&(optlist[noptlist++]),"BSD4");
#endif /* BSD4 */
#ifdef BSD44
    makestr(&(optlist[noptlist++]),"BSD44");
#endif /* BSD44 */
#ifdef BSD41
    makestr(&(optlist[noptlist++]),"BSD41");
#endif /* BSD41 */
#ifdef BSD43
    makestr(&(optlist[noptlist++]),"BSD43");
#endif /* BSD43 */
#ifdef BSD29
    makestr(&(optlist[noptlist++]),"BSD29");
#endif /* BSD29 */
#ifdef BSDI
    makestr(&(optlist[noptlist++]),"BSDI");
#endif /* BSDI */
#ifdef __bsdi__
    makestr(&(optlist[noptlist++]),"__bsdi__");
#endif /* __bsdi__ */
#ifdef __NetBSD__
    makestr(&(optlist[noptlist++]),"__NetBSD__");
#endif /* __NetBSD__ */
#ifdef __OpenBSD__
    makestr(&(optlist[noptlist++]),"__OpenBSD__");
#endif /* __OpenBSD__ */
#ifdef __FreeBSD__
    makestr(&(optlist[noptlist++]),"__FreeBSD__");
#endif /* __FreeBSD__ */
#ifdef FREEBSD4
    makestr(&(optlist[noptlist++]),"FREEBSD4");
#endif /* FREEBSD4 */
#ifdef FREEBSD8
    makestr(&(optlist[noptlist++]),"FREEBSD8");
#endif /* FREEBSD8 */
#ifdef FREEBSD9
    makestr(&(optlist[noptlist++]),"FREEBSD9");
#endif /* FREEBSD9 */
#ifdef __linux__
    makestr(&(optlist[noptlist++]),"__linux__");
#endif /* __linux__ */
#ifdef LINUX_HI_SPD
    makestr(&(optlist[noptlist++]),"LINUX_HI_SPD");
#endif /* LINUX_HI_SPD */
#ifdef LYNXOS
    makestr(&(optlist[noptlist++]),"LYNXOS");
#endif /* LYNXOS */
#ifdef V7
    makestr(&(optlist[noptlist++]),"V7");
#endif /* V7 */
#ifdef AIX370
    makestr(&(optlist[noptlist++]),"AIX370");
#endif /* AIX370 */
#ifdef RTAIX
    makestr(&(optlist[noptlist++]),"RTAIX");
#endif /* RTAIX */
#ifdef HPUX
    makestr(&(optlist[noptlist++]),"HPUX");
#endif /* HPUX */
#ifdef HPUX9
    makestr(&(optlist[noptlist++]),"HPUX9");
#endif /* HPUX9 */
#ifdef HPUX10
    makestr(&(optlist[noptlist++]),"HPUX10");
#endif /* HPUX10 */
#ifdef HPUX1000
    makestr(&(optlist[noptlist++]),"HPUX1000");
#endif /* HPUX1000 */
#ifdef HPUX1100
    makestr(&(optlist[noptlist++]),"HPUX1100");
#endif /* HPUX1100 */
#ifdef HPUXPRE65
    makestr(&(optlist[noptlist++]),"HPUXPRE65");
#endif /* HPUXPRE65 */
#ifdef DGUX
    makestr(&(optlist[noptlist++]),"DGUX");
#endif /* DGUX */
#ifdef DGUX430
    makestr(&(optlist[noptlist++]),"DGUX430");
#endif /* DGUX430 */
#ifdef DGUX540
    makestr(&(optlist[noptlist++]),"DGUX540");
#endif /* DGUX540 */
#ifdef DGUX543
    makestr(&(optlist[noptlist++]),"DGUX543");
#endif /* DGUX543 */
#ifdef DGUX54410
    makestr(&(optlist[noptlist++]),"DGUX54410");
#endif /* DGUX54410 */
#ifdef DGUX54411
    makestr(&(optlist[noptlist++]),"DGUX54411");
#endif /* DGUX54411 */
#ifdef sony_news
    makestr(&(optlist[noptlist++]),"sony_news");
#endif /* sony_news */
#ifdef CIE
    makestr(&(optlist[noptlist++]),"CIE");
#endif /* CIE */
#ifdef XENIX
    makestr(&(optlist[noptlist++]),"XENIX");
#endif /* XENIX */
#ifdef SCO_XENIX
    makestr(&(optlist[noptlist++]),"SCO_XENIX");
#endif /* SCO_XENIX */
#ifdef ISIII
    makestr(&(optlist[noptlist++]),"ISIII");
#endif /* ISIII */
#ifdef I386IX
    makestr(&(optlist[noptlist++]),"I386IX");
#endif /* I386IX */
#ifdef RTU
    makestr(&(optlist[noptlist++]),"RTU");
#endif /* RTU */
#ifdef PROVX1
    makestr(&(optlist[noptlist++]),"PROVX1");
#endif /* PROVX1 */
#ifdef PYRAMID
    makestr(&(optlist[noptlist++]),"PYRAMID");
#endif /* PYRAMID */
#ifdef TOWER1
    makestr(&(optlist[noptlist++]),"TOWER1");
#endif /* TOWER1 */
#ifdef UTEK
    makestr(&(optlist[noptlist++]),"UTEK");
#endif /* UTEK */
#ifdef ZILOG
    makestr(&(optlist[noptlist++]),"ZILOG");
#endif /* ZILOG */
#ifdef TRS16
    makestr(&(optlist[noptlist++]),"TRS16");
#endif /* TRS16 */
#ifdef MINIX
    makestr(&(optlist[noptlist++]),"MINIX");
#endif /* MINIX */
#ifdef MINIX2
    makestr(&(optlist[noptlist++]),"MINIX2");
#endif /* MINIX2 */
#ifdef MINIX3
    makestr(&(optlist[noptlist++]),"MINIX3");
#endif /* MINIX3 */
#ifdef MINIX315
    makestr(&(optlist[noptlist++]),"MINIX315");
#endif /* MINIX315 */
#ifdef C70
    makestr(&(optlist[noptlist++]),"C70");
#endif /* C70 */
#ifdef AIXPS2
    makestr(&(optlist[noptlist++]),"AIXPS2");
#endif /* AIXPS2 */
#ifdef AIXRS
    makestr(&(optlist[noptlist++]),"AIXRS");
#endif /* AIXRS */
#ifdef UTSV
    makestr(&(optlist[noptlist++]),"UTSV");
#endif /* UTSV */
#ifdef ATTSV
    makestr(&(optlist[noptlist++]),"ATTSV");
#endif /* ATTSV */
#ifdef SVR3
    makestr(&(optlist[noptlist++]),"SVR3");
#endif /* SVR3 */
#ifdef SVR4
    makestr(&(optlist[noptlist++]),"SVR4");
#endif /* SVR4 */
#ifdef DELL_SVR4
    makestr(&(optlist[noptlist++]),"DELL_SVR4");
#endif /* DELL_SVR4 */
#ifdef ICL_SVR4
    makestr(&(optlist[noptlist++]),"ICL_SVR4");
#endif /* ICL_SVR4 */
#ifdef OSF
    makestr(&(optlist[noptlist++]),"OSF");
#endif /* OSF */
#ifdef OSF1
    makestr(&(optlist[noptlist++]),"OSF1");
#endif /* OSF1 */
#ifdef __OSF
    makestr(&(optlist[noptlist++]),"__OSF");
#endif /* __OSF */
#ifdef __OSF__
    makestr(&(optlist[noptlist++]),"__OSF__");
#endif /* __OSF__ */
#ifdef __osf__
    makestr(&(optlist[noptlist++]),"__osf__");
#endif /* __osf__ */
#ifdef __OSF1
    makestr(&(optlist[noptlist++]),"__OSF1");
#endif /* __OSF1 */
#ifdef __OSF1__
    makestr(&(optlist[noptlist++]),"__OSF1__");
#endif /* __OSF1__ */
#ifdef PTX
    makestr(&(optlist[noptlist++]),"PTX");
#endif /* PTX */
#ifdef POSIX
    makestr(&(optlist[noptlist++]),"POSIX");
#endif /* POSIX */
#ifdef BSD44ORPOSIX
    makestr(&(optlist[noptlist++]),"BSD44ORPOSIX");
#endif /* BSD44ORPOSIX */
#ifdef SVORPOSIX
    makestr(&(optlist[noptlist++]),"SVORPOSIX");
#endif /* SVORPOSIX */
#ifdef SVR4ORPOSIX
    makestr(&(optlist[noptlist++]),"SVR4ORPOSIX");
#endif /* SVR4ORPOSIX */
#ifdef OS2ORVMS
    makestr(&(optlist[noptlist++]),"OS2ORVMS");
#endif /* OS2ORVMS */
#ifdef OS2ORUNIX
    makestr(&(optlist[noptlist++]),"OS2ORUNIX");
#endif /* OS2ORUNIX */
#ifdef VMSORUNIX
    makestr(&(optlist[noptlist++]),"VMSORUNIX");
#endif /* VMSORUNIX */
#ifdef VMS64BIT
    makestr(&(optlist[noptlist++]),"VMS64BIT");	/* VMS on Alpha or IA64 */
#endif /* VMS64BIT */
#ifdef VMSI64
    makestr(&(optlist[noptlist++]),"VMSI64"); /* VMS on IA64 */
#endif /* VMSI64 */
#ifdef _POSIX_SOURCE
    makestr(&(optlist[noptlist++]),"_POSIX_SOURCE");
#endif /* _POSIX_SOURCE */
#ifdef _XOPEN_SOURCE
    makestr(&(optlist[noptlist++]),"_XOPEN_SOURCE");
#endif
#ifdef _ALL_SOURCE
    makestr(&(optlist[noptlist++]),"_ALL_SOURCE");
#endif
#ifdef _SVID3
    makestr(&(optlist[noptlist++]),"_SVID3");
#endif /* _SVID3 */
#ifdef Plan9
    makestr(&(optlist[noptlist++]),"Plan9");
#endif /* Plan9 */
#ifdef SOLARIS
    makestr(&(optlist[noptlist++]),"SOLARIS");
#ifdef SOLARIS24
    makestr(&(optlist[noptlist++]),"SOLARIS24");
#endif /* SOLARIS24 */
#ifdef SOLARIS25
    makestr(&(optlist[noptlist++]),"SOLARIS25");
#endif /* SOLARIS25 */
#ifdef SOLARIS26
    makestr(&(optlist[noptlist++]),"SOLARIS26");
#endif /* SOLARIS26 */
#ifdef SOLARIS7
    makestr(&(optlist[noptlist++]),"SOLARIS7");
#endif /* SOLARIS7 */
#ifdef SOLARIS8
    makestr(&(optlist[noptlist++]),"SOLARIS8");
#endif /* SOLARIS8 */
#ifdef SOLARIS9
    makestr(&(optlist[noptlist++]),"SOLARIS9");
#endif /* SOLARIS9 */
#ifdef SOLARIS10
    makestr(&(optlist[noptlist++]),"SOLARIS10");
#endif /* SOLARIS10 */
#endif /* SOLARIS */

#ifdef SUNOS4
    makestr(&(optlist[noptlist++]),"SUNOS4");
#endif /* SUNOS4 */
#ifdef SUN4S5
    makestr(&(optlist[noptlist++]),"SUN4S5");
#endif /* SUN4S5 */
#ifdef IRIX
    makestr(&(optlist[noptlist++]),"IRIX");
#endif /* IRIX */
#ifdef ENCORE
    makestr(&(optlist[noptlist++]),"ENCORE");
#endif /* ENCORE */
#ifdef ultrix
    makestr(&(optlist[noptlist++]),"ultrix");
#endif
#ifdef sxaE50
    makestr(&(optlist[noptlist++]),"sxaE50");
#endif
#ifdef mips
    makestr(&(optlist[noptlist++]),"mips");
#endif
#ifdef MIPS
    makestr(&(optlist[noptlist++]),"MIPS");
#endif
#ifdef vax
    makestr(&(optlist[noptlist++]),"vax");
#endif
#ifdef VAX
    makestr(&(optlist[noptlist++]),"VAX");
#endif
#ifdef alpha
    makestr(&(optlist[noptlist++]),"alpha");
#endif
#ifdef ALPHA
    makestr(&(optlist[noptlist++]),"ALPHA");
#endif
#ifdef __ALPHA
    makestr(&(optlist[noptlist++]),"__ALPHA");
#endif
#ifdef __alpha
    makestr(&(optlist[noptlist++]),"__alpha");
#endif
#ifdef __AXP
    makestr(&(optlist[noptlist++]),"__AXP");
#endif
#ifdef AXP
    makestr(&(optlist[noptlist++]),"AXP");
#endif
#ifdef axp
    makestr(&(optlist[noptlist++]),"axp");
#endif
#ifdef __ALPHA__
    makestr(&(optlist[noptlist++]),"__ALPHA__");
#endif
#ifdef __alpha__
    makestr(&(optlist[noptlist++]),"__alpha__");
#endif
#ifdef sun
    makestr(&(optlist[noptlist++]),"sun");
#endif
#ifdef sun3
    makestr(&(optlist[noptlist++]),"sun3");
#endif
#ifdef sun386
    makestr(&(optlist[noptlist++]),"sun386");
#endif
#ifdef _SUN
    makestr(&(optlist[noptlist++]),"_SUN");
#endif
#ifdef sun4
    makestr(&(optlist[noptlist++]),"sun4");
#endif
#ifdef sparc
    makestr(&(optlist[noptlist++]),"sparc");
#endif
#ifdef _CRAY
    makestr(&(optlist[noptlist++]),"_CRAY");
#endif /* _CRAY */
#ifdef NEXT33
    makestr(&(optlist[noptlist++]),"NEXT33");
#endif
#ifdef NEXT
    makestr(&(optlist[noptlist++]),"NEXT");
#endif
#ifdef NeXT
    makestr(&(optlist[noptlist++]),"NeXT");
#endif
#ifdef MACH
    makestr(&(optlist[noptlist++]),"MACH");
#endif

#ifdef MACOSX
    makestr(&(optlist[noptlist++]),"MACOSX");
#endif
#ifdef MACOSX10
    makestr(&(optlist[noptlist++]),"MACOSX10");
#endif
#ifdef MACOSX103
    makestr(&(optlist[noptlist++]),"MACOSX10e");
#endif
#ifdef COMMENT
/* not used */
#ifdef MACOSX103
    makestr(&(optlist[noptlist++]),"MACOSX103");
#endif
#endif	/* COMMENT */

#ifdef sgi
    makestr(&(optlist[noptlist++]),"sgi");
#endif
#ifdef M_SYS5
    makestr(&(optlist[noptlist++]),"M_SYS5");
#endif
#ifdef __SYSTEM_FIVE
    makestr(&(optlist[noptlist++]),"__SYSTEM_FIVE");
#endif
#ifdef sysV
    makestr(&(optlist[noptlist++]),"sysV");
#endif
#ifdef M_XENIX                          /* SCO Xenix V and UNIX/386 */
    makestr(&(optlist[noptlist++]),"M_XENIX");
#endif
#ifdef M_UNIX                           /* SCO UNIX */
    makestr(&(optlist[noptlist++]),"M_UNIX");
#endif
#ifdef _M_UNIX                          /* SCO UNIX 3.2v4 = ODT 2.0 */
    makestr(&(optlist[noptlist++]),"_M_UNIX");
#endif
#ifdef CK_SCOV5
    makestr(&(optlist[noptlist++]),"CK_SCOV5");
#endif
#ifdef SCO_OSR504
    makestr(&(optlist[noptlist++]),"SCO_OSR504");
#endif
#ifdef M_IA64
    makestr(&(optlist[noptlist++]),"M_IA64");
#endif
#ifdef _M_IA64
    makestr(&(optlist[noptlist++]),"_M_IA64");
#endif
#ifdef ia64
    makestr(&(optlist[noptlist++]),"ia64");
#endif
#ifdef _ia64
    makestr(&(optlist[noptlist++]),"_ia64");
#endif
#ifdef _ia64_
    makestr(&(optlist[noptlist++]),"_ia64_");
#endif
#ifdef __ia64
    makestr(&(optlist[noptlist++]),"__ia64");
#endif
#ifdef M_I686
    makestr(&(optlist[noptlist++]),"M_I686");
#endif
#ifdef _M_I686
    makestr(&(optlist[noptlist++]),"_M_I686");
#endif
#ifdef i686
    makestr(&(optlist[noptlist++]),"i686");
#endif
#ifdef M_I586
    makestr(&(optlist[noptlist++]),"M_I586");
#endif
#ifdef _M_I586
    makestr(&(optlist[noptlist++]),"_M_I586");
#endif
#ifdef i586
    makestr(&(optlist[noptlist++]),"i586");
#endif
#ifdef M_I486
    makestr(&(optlist[noptlist++]),"M_I486");
#endif
#ifdef _M_I486
    makestr(&(optlist[noptlist++]),"_M_I486");
#endif
#ifdef i486
    makestr(&(optlist[noptlist++]),"i486");
#endif
#ifdef M_I386
    makestr(&(optlist[noptlist++]),"M_I386");
#endif
#ifdef _M_I386
    makestr(&(optlist[noptlist++]),"_M_I386");
#endif
#ifdef i386
    makestr(&(optlist[noptlist++]),"i386");
#endif
#ifdef __i386
    makestr(&(optlist[noptlist++]),"__i386");
#endif
#ifdef __x86
    makestr(&(optlist[noptlist++]),"__x86");
#endif
#ifdef __x86_64
    makestr(&(optlist[noptlist++]),"__x86_64");
#endif
#ifdef __amd64
    makestr(&(optlist[noptlist++]),"__amd64");
#endif
#ifdef _ILP32
    makestr(&(optlist[noptlist++]),"_ILP32");
#endif
#ifdef _ILP64
    makestr(&(optlist[noptlist++]),"_ILP64");
#endif
#ifdef _LP32
    makestr(&(optlist[noptlist++]),"_LP32");
#endif
#ifdef _LP64
    makestr(&(optlist[noptlist++]),"_LP64");
#endif
#ifdef __LP32__
    makestr(&(optlist[noptlist++]),"__LP32__");
#endif
#ifdef __LP64__
    makestr(&(optlist[noptlist++]),"__LP64__");
#endif
#ifdef _XGP4_2
    makestr(&(optlist[noptlist++]),"_XGP4_2");
#endif
#ifdef __ppc__
    makestr(&(optlist[noptlist++]),"__ppc__");
#endif
#ifdef __ppc32__
    makestr(&(optlist[noptlist++]),"__ppc32__");
#endif
#ifdef __ppc64__
    makestr(&(optlist[noptlist++]),"__ppc64__");
#endif
#ifdef CK_64BIT
    makestr(&(optlist[noptlist++]),"CK_64BIT");
#endif
#ifdef i286
    makestr(&(optlist[noptlist++]),"i286");
#endif
#ifdef M_I286
    makestr(&(optlist[noptlist++]),"M_I286");
#endif
#ifdef __sparc
    makestr(&(optlist[noptlist++]),"__sparc");
#endif
#ifdef __sparcv8
    makestr(&(optlist[noptlist++]),"__sparcv8");
#endif
#ifdef __sparcv9
    makestr(&(optlist[noptlist++]),"__sparcv9");
#endif
#ifdef mc68000
    makestr(&(optlist[noptlist++]),"mc68000");
#endif
#ifdef mc68010
    makestr(&(optlist[noptlist++]),"mc68010");
#endif
#ifdef mc68020
    makestr(&(optlist[noptlist++]),"mc68020");
#endif
#ifdef mc68030
    makestr(&(optlist[noptlist++]),"mc68030");
#endif
#ifdef mc68040
    makestr(&(optlist[noptlist++]),"mc68040");
#endif
#ifdef M_68000
    makestr(&(optlist[noptlist++]),"M_68000");
#endif
#ifdef M_68010
    makestr(&(optlist[noptlist++]),"M_68010");
#endif
#ifdef M_68020
    makestr(&(optlist[noptlist++]),"M_68020");
#endif
#ifdef M_68030
    makestr(&(optlist[noptlist++]),"M_68030");
#endif
#ifdef M_68040
    makestr(&(optlist[noptlist++]),"M_68040");
#endif
#ifdef m68k
    makestr(&(optlist[noptlist++]),"m68k");
#endif
#ifdef m88k
    makestr(&(optlist[noptlist++]),"m88k");
#endif
#ifdef pdp11
    makestr(&(optlist[noptlist++]),"pdp11");
#endif
#ifdef iAPX
    makestr(&(optlist[noptlist++]),"iAPX");
#endif
#ifdef hpux
    makestr(&(optlist[noptlist++]),"hpux");
#endif
#ifdef __hpux
    makestr(&(optlist[noptlist++]),"__hpux");
#endif
#ifdef __hp9000s800
    makestr(&(optlist[noptlist++]),"__hp9000s800");
#endif
#ifdef __hp9000s700
    makestr(&(optlist[noptlist++]),"__hp9000s700");
#endif
#ifdef __hp9000s500
    makestr(&(optlist[noptlist++]),"__hp9000s500");
#endif
#ifdef __hp9000s300
    makestr(&(optlist[noptlist++]),"__hp9000s300");
#endif
#ifdef __hp9000s200
    makestr(&(optlist[noptlist++]),"__hp9000s200");
#endif
#ifdef AIX
    makestr(&(optlist[noptlist++]),"AIX");
#endif
#ifdef _AIXFS
    makestr(&(optlist[noptlist++]),"_AIXFS");
#endif
#ifdef u370
    makestr(&(optlist[noptlist++]),"u370");
#endif
#ifdef u3b
    makestr(&(optlist[noptlist++]),"u3b");
#endif
#ifdef u3b2
    makestr(&(optlist[noptlist++]),"u3b2");
#endif
#ifdef multimax
    makestr(&(optlist[noptlist++]),"multimax");
#endif
#ifdef balance
    makestr(&(optlist[noptlist++]),"balance");
#endif
#ifdef ibmrt
    makestr(&(optlist[noptlist++]),"ibmrt");
#endif
#ifdef _IBMRT
    makestr(&(optlist[noptlist++]),"_IBMRT");
#endif
#ifdef ibmrs6000
    makestr(&(optlist[noptlist++]),"ibmrs6000");
#endif
#ifdef _AIX
    makestr(&(optlist[noptlist++]),"_AIX");
#endif /* _AIX */
#ifdef _IBMR2
    makestr(&(optlist[noptlist++]),"_IBMR2");
#endif
#ifdef UNIXWARE
    makestr(&(optlist[noptlist++]),"UNIXWARE");
#endif
#ifdef QNX
    makestr(&(optlist[noptlist++]),"QNX");
#ifdef __QNX__
    makestr(&(optlist[noptlist++]),"__QNX__");
#ifdef __16BIT__
    makestr(&(optlist[noptlist++]),"__16BIT__");
#endif
#ifdef CK_QNX16
    makestr(&(optlist[noptlist++]),"CK_QNX16");
#endif
#ifdef __32BIT__
    makestr(&(optlist[noptlist++]),"__32BIT__");
#endif
#ifdef CK_QNX32
    makestr(&(optlist[noptlist++]),"CK_QNX32");
#endif
#endif /* __QNX__ */
#endif /* QNX */

#ifdef QNX6
    makestr(&(optlist[noptlist++]),"QNX6");
#endif /* QNX6 */

#ifdef NEUTRINO
    makestr(&(optlist[noptlist++]),"NEUTRINO");
#endif /* NEUTRINO */

#ifdef __STRICT_BSD__
    makestr(&(optlist[noptlist++]),"__STRICT_BSD__");
#endif
#ifdef __STRICT_ANSI__
    makestr(&(optlist[noptlist++]),"__STRICT_ANSI__");
#endif
#ifdef _ANSI_C_SOURCE
    makestr(&(optlist[noptlist++]),"_ANSI_C_SOURCE");
#endif
#ifdef __STDC__
    makestr(&(optlist[noptlist++]),"__STDC__");
#endif
#ifdef cplusplus
    makestr(&(optlist[noptlist++]),"cplusplus");
#endif
#ifdef __DECC
    makestr(&(optlist[noptlist++]),"__DECC");
#ifdef __DECC_VER
    sprintf(line,"__DECC_VER=%d",__DECC_VER); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* __DECC_VER */
#endif /* __DECC */
#ifdef __CRTL_VER
    sprintf(line,"__CRTL_VER=%d",__CRTL_VER); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* __CRTL_VER */
#ifdef __GNUC__                         /* gcc in ansi mode */
    makestr(&(optlist[noptlist++]),"__GNUC__");
#endif
#ifdef GNUC                             /* gcc in traditional mode */
    makestr(&(optlist[noptlist++]),"GNUC");
#endif
#ifdef __EGCS__                         /* egcs in ansi mode */
    makestr(&(optlist[noptlist++]),"__EGCS__");
#endif
#ifdef __egcs__                         /* egcs in ansi mode */
    makestr(&(optlist[noptlist++]),"__egcs__");
#endif
#ifdef __WATCOMC__
    makestr(&(optlist[noptlist++]),"__WATCOMC__");
#endif
#ifdef CK_ANSIC
    makestr(&(optlist[noptlist++]),"CK_ANSIC");
#endif
#ifdef CK_ANSILIBS
    makestr(&(optlist[noptlist++]),"CK_ANSILIBS");
#endif
#ifdef CKCONINTB4CB
    makestr(&(optlist[noptlist++]),"CKCONINTB4CB");
#endif /* CKCONINTB4CB */
#ifdef NOTERMCAP
    makestr(&(optlist[noptlist++]),"NOTERMCAP");
#endif /* NOTERMCAP */
#ifdef __GLIBC__
    makestr(&(optlist[noptlist++]),"__GLIBC__");
#endif
#ifdef _SC_JOB_CONTROL
    makestr(&(optlist[noptlist++]),"_SC_JOB_CONTROL");
#endif
#ifdef _POSIX_JOB_CONTROL
    makestr(&(optlist[noptlist++]),"_POSIX_JOB_CONTROL");
#endif
#ifdef SIG_I
    makestr(&(optlist[noptlist++]),"SIG_I");
#endif /* SIG_I */
#ifdef SIG_V
    makestr(&(optlist[noptlist++]),"SIG_V");
#endif /* SIG_V */
#ifdef CK_POSIX_SIG
    makestr(&(optlist[noptlist++]),"CK_POSIX_SIG");
#endif
#ifdef SVR3JC
    makestr(&(optlist[noptlist++]),"SVR3JC");
#endif
#ifdef _386BSD
    makestr(&(optlist[noptlist++]),"_386BSD");
#endif
#ifdef _BSD
    makestr(&(optlist[noptlist++]),"_BSD");
#endif
#ifdef USE_MEMCPY
    makestr(&(optlist[noptlist++]),"USE_MEMCPY");
#endif /* USE_MEMCPY */
#ifdef USE_LSTAT
    makestr(&(optlist[noptlist++]),"USE_LSTAT");
#endif /* USE_LSTAT */
#ifdef TERMIOX
    makestr(&(optlist[noptlist++]),"TERMIOX");
#endif /* TERMIOX */
#ifdef STERMIOX
    makestr(&(optlist[noptlist++]),"STERMIOX");
#endif /* STERMIOX */
#ifdef CK_CURSES
    makestr(&(optlist[noptlist++]),"CK_CURSES");
#endif /* CK_CURSES */
#ifdef CK_NEWTERM
    makestr(&(optlist[noptlist++]),"CK_NEWTERM");
#endif /* CK_NEWTERM */
#ifdef CK_WREFRESH
    makestr(&(optlist[noptlist++]),"CK_WREFRESH");
#endif /* CK_WREFRESH */
#ifdef CK_PCT_BAR
    makestr(&(optlist[noptlist++]),"CK_PCT_BAR");
#endif /* CK_PCT_BAR */
#ifdef CK_DTRCD
    makestr(&(optlist[noptlist++]),"CK_DTRCD");
#endif /* CK_DTRCD */
#ifdef CK_DTRCTS
    makestr(&(optlist[noptlist++]),"CK_DTRCTS");
#endif /* CK_DTRCTS */
#ifdef CK_RTSCTS
    makestr(&(optlist[noptlist++]),"CK_RTSCTS");
#endif /* CK_RTSCTS */
#ifdef POSIX_CRTSCTS
    makestr(&(optlist[noptlist++]),"POSIX_CRTSCTS");
#endif /* POSIX_CRTSCTS */
#ifdef FIXCRTSCTS
    makestr(&(optlist[noptlist++]),"FIXCRTSCTS");
#endif /* FIXCRTSCTS */
#ifdef HWPARITY
    makestr(&(optlist[noptlist++]),"HWPARITY");
#endif /* HWPARITY */
#ifdef CK_SYSINI
#ifdef CK_INI_A
    makestr(&(optlist[noptlist++]),"CK_INI_A");
    ckmakmsg(line,LINBUFSIZ,"CK_SYSINI=\"",CK_SYSINI,"\"",NULL);
    makestr(&(optlist[noptlist++]),line);
#else
#ifdef CK_INI_B
    makestr(&(optlist[noptlist++]),"CK_INI_B");
    ckmakmsg(line,LINBUFSIZ,"CK_SYSINI=\"",CK_SYSINI,"\"",NULL);
    makestr(&(optlist[noptlist++]),line);
#else
    makestr(&(optlist[noptlist++]),"CK_SYSINI");
#endif /* CK_INI_B */
#endif /* CK_INI_A */
#endif /* CK_DSYSINI */
#ifdef CK_DSYSINI
    makestr(&(optlist[noptlist++]),"CK_DSYSINI");
#endif /* CK_DSYSINI */
#ifdef CK_TTGWSIZ
    makestr(&(optlist[noptlist++]),"CK_TTGWSIZ");
#endif /* CK_TTGWSIZ */
#ifdef CK_NAWS
    makestr(&(optlist[noptlist++]),"CK_NAWS");
#endif /* CK_NAWS */
#ifdef MDMHUP
    makestr(&(optlist[noptlist++]),"MDMHUP");
#endif /* MDMHUP */
#ifdef HUP_CLOSE_POSIX
    makestr(&(optlist[noptlist++]),"HUP_CLOSE_POSIX");
#endif /* HUP_CLOSE_POSIX */
#ifdef NO_HUP_CLOSE_POSIX
    makestr(&(optlist[noptlist++]),"NO_HUP_CLOSE_POSIX");
#endif /* NO_HUP_CLOSE_POSIX */
#ifdef DCMDBUF
    makestr(&(optlist[noptlist++]),"DCMDBUF");
#endif /* DCMDBUF */
#ifdef CK_RECALL
    makestr(&(optlist[noptlist++]),"CK_RECALL");
#endif /* CK_RECALL */
#ifdef BROWSER
    makestr(&(optlist[noptlist++]),"BROWSER");
#endif /* BROWSER */
#ifdef CLSOPN
    makestr(&(optlist[noptlist++]),"CLSOPN");
#endif /* CLSOPN */
#ifdef STRATUS
    makestr(&(optlist[noptlist++]),"STRATUS");
#endif /* STRATUS */
#ifdef __VOS__
    makestr(&(optlist[noptlist++]),"__VOS__");
#endif /* __VOS__ */
#ifdef STRATUSX25
    makestr(&(optlist[noptlist++]),"STRATUSX25");
#endif /* STRATUSX25 */
#ifdef OS2MOUSE
    makestr(&(optlist[noptlist++]),"OS2MOUSE");
#endif /* OS2MOUSE */
#ifdef CK_REXX
    makestr(&(optlist[noptlist++]),"CK_REXX");
#endif /* CK_REXX */
#ifdef CK_TIMERS
    makestr(&(optlist[noptlist++]),"CK_TIMERS");
#endif /* CK_TIMERS */
#ifdef TTSPDLIST
    makestr(&(optlist[noptlist++]),"TTSPDLIST");
#endif /* TTSPDLIST */
#ifdef CK_PERMS
    makestr(&(optlist[noptlist++]),"CK_PERMS");
#endif /* CK_PERMS */
#ifdef CKTUNING
    makestr(&(optlist[noptlist++]),"CKTUNING");
#endif /* CKTUNING */
#ifdef NEWFTP
    makestr(&(optlist[noptlist++]),"NEWFTP");
#endif /* NEWFTP */
#ifdef SYSFTP
    makestr(&(optlist[noptlist++]),"SYSFTP");
#endif /* SYSFTP */
#ifdef NOFTP
    makestr(&(optlist[noptlist++]),"NOFTP");
#endif /* NOFTP */
#ifdef CKHTTP
    makestr(&(optlist[noptlist++]),"CKHTTP");
#endif /* CKHTTP */
#ifdef NOHTTP
    makestr(&(optlist[noptlist++]),"NOHTTP");
#endif /* NOHTTP */
#ifdef CKROOT
    makestr(&(optlist[noptlist++]),"CKROOT");
#endif /* CKROOT */
#ifdef CKREALPATH
    makestr(&(optlist[noptlist++]),"CKREALPATH");
#endif /* CKREALPATH */
#ifdef STREAMING
    makestr(&(optlist[noptlist++]),"STREAMING");
#endif /* STREAMING */
#ifdef UNPREFIXZERO
    makestr(&(optlist[noptlist++]),"UNPREFIXZERO");
#endif /* UNPREFIXZERO */
#ifdef CKREGEX
    makestr(&(optlist[noptlist++]),"CKREGEX");
#endif /* CKREGEX */
#ifdef ZXREWIND
    makestr(&(optlist[noptlist++]),"ZXREWIND");
#endif /* ZXREWIND */
#ifdef CKSYSLOG
    makestr(&(optlist[noptlist++]),"CKSYSLOG");
#endif /* CKSYSLOG */
#ifdef SYSLOGLEVEL
    sprintf(line,"SYSLOGLEVEL=%d",SYSLOGLEVEL); /* SAFE */
    makestr(&(optlist[noptlist++]),line);
#endif /* SYSLOGLEVEL */
#ifdef NOSEXP
    makestr(&(optlist[noptlist++]),"NOSEXP");
#endif /* NOSEXP */
#ifdef CKLEARN
    makestr(&(optlist[noptlist++]),"CKLEARN");
#else
#ifdef NOLOEARN
    makestr(&(optlist[noptlist++]),"NOLOEARN");
#endif /* NOLOEARN */
#endif /* CKLEARN */
#ifdef BETATEST
    makestr(&(optlist[noptlist++]),"BETATEST");
#endif  /* BETATEST */

#ifdef NOFLOAT
    makestr(&(optlist[noptlist++]),"NOFLOAT");
#else
#ifdef FNFLOAT
    makestr(&(optlist[noptlist++]),"FNFLOAT");
#endif /* FNFLOAT */
#ifdef CKFLOAT
#ifdef GFTIMER
    makestr(&(optlist[noptlist++]),"GFTIMER");
#endif /* GFTIMER */
#ifdef CKFLOAT_S
    ckmakmsg(line,LINBUFSIZ,"CKFLOAT=",CKFLOAT_S,NULL,NULL);
    makestr(&(optlist[noptlist++]),line);
#else
    makestr(&(optlist[noptlist++]),"CKFLOAT");
#endif /* CKFLOAT_S */
#endif /* CKFLOAT */
#endif /* NOFLOAT */

#ifdef SSH
    makestr(&(optlist[noptlist++]),"SSH");
#endif /* SSH */
#ifdef NETDLL
    makestr(&(optlist[noptlist++]),"NETDLL");
#endif /* NETDLL */
#ifdef NETFILE
    makestr(&(optlist[noptlist++]),"NETFILE");
#endif /* NETFILE */
#ifdef CK_TAPI
    makestr(&(optlist[noptlist++]),"CK_TAPI");
#endif /* CK_TAPI */
#ifdef CK_SSL
    makestr(&(optlist[noptlist++]),"CK_SSL");
#ifdef OPENSSL_VERSION_TEXT
    ckmakmsg(line,LINBUFSIZ,
	     "OPENSSL_VERSION_TEXT=","\"",OPENSSL_VERSION_TEXT,"\"");
    makestr(&(optlist[noptlist++]),line);
#endif	/* OPENSSL_VERSION_TEXT */
#endif /* CK_SSL */
    debug(F101,"initoptlist noptlist","",noptlist);
    sh_sort(optlist,NULL,noptlist,0,0,0);
}

int
shofea() {
    int i;
    int flag = 0;
    int lines = 1;
#ifdef FNFLOAT
    extern int fp_digits, fp_rounding;
#endif /* FNFLOAT */
    extern int byteorder;
    printf("%s\n",versio);
    if (inserver)
      return(1);

    debug(F101,"shofea NOPTLIST","",NOPTLIST);
    initoptlist();
    debug(F101,"shofea noptlist","",noptlist);
#ifdef OS2
#ifdef NT
#ifdef _M_ALPHA
    printf("Microsoft Windows Operating Systems for Alpha CPUs.\n");
#else /* _M_ALPHA */
#ifdef _M_PPC
    printf("Microsoft Windows Operating Systems for PowerPC CPUs.\n");
#else /* _M_PPC */
#ifdef _M_MRX000
    printf("Microsoft Windows Operating Systems for MIPS CPUs.\n");
#else /* _M_MRX000 */
#ifdef _M_IX86
    printf("Microsoft Windows Operating Systems for 32-bit Intel CPUs.\n");
#else /* _M_IX86 */
    UNKNOWN WINDOWS PLATFORM
#endif /* _M_IX86 */
#endif /* _M_MRX000 */
#endif /* _M_PPC */
#endif /* _M_ALPHA */
#else /* NT */
#ifdef M_I286
    printf("IBM OS/2 16-bit.\n");
#else
    printf("IBM OS/2 32-bit.\n");
#endif /* M_I286 */
#endif /* NT */
    lines++;
#endif /* OS2 */
    printf("\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    printf("Major optional features included:\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }

    if (sizeof(CK_OFF_T) == 8) {
	printf(" Large files and large integers (64 bits)\n");
        if (++lines > cmd_rows - 3) {
	    if (!askmore()) return(1); else lines = 0;
	}
    }
#ifdef NETCONN
    printf(" Network support (type SHOW NET for further info)\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#ifdef IKS_OPTION
    printf(" Telnet Kermit Option\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* IKS_OPTION */
#ifdef CK_AUTHENTICATION
    printf(" Telnet Authentication Option\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#ifdef CK_KERBEROS
#ifdef KRB4
#ifdef KRB5
    printf(" Kerberos(TM) IV and Kerberos V authentication\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#else /* KRB5 */
    printf(" Kerberos(TM) IV authentication\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* KRB5 */
#else /* KRB4 */
#ifdef KRB5
    printf(" Kerberos(TM) V authentication\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* KRB5 */
#endif /* KRB4 */
#endif /* CK_KERBEROS */
#ifdef CK_SRP
    printf(" SRP(TM) (Secure Remote Password) authentication\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* CK_SRP */
#ifdef CK_SSL
    printf(" Secure Sockets Layer (SSL)\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    printf(" Transport Layer Security (TLS)\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* CK_SSL */
#ifdef SSHBUILTIN
    printf(" Secure Shell (SSH) [internal]\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* SSHBUILTIN */
#ifdef SSHCMD
    printf(" Secure Shell (SSH) [external]\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* SSHCMD */
#ifdef CK_ENCRYPTION
    printf(" Telnet Encryption Option\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#ifdef CK_DES
    printf(" Telnet DES Encryption\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* CK_DES */
#ifdef CK_CAST
    printf(" Telnet CAST Encryption\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* CK_CAST */

#ifdef CK_KERBEROS
#ifdef KRB5
#ifdef ALLOW_KRB_3DES_ENCRYPT
    printf(" Kerberos 3DES/AES Telnet Encryption\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* ALLOW_KRB_3DES_ENCRYPT */
#endif /* KRB5 */
#endif /* CK_KERBEROS */

#endif /* CK_ENCRYPTION */
#endif /* CK_AUTHENTICATION */
#ifdef CK_FORWARD_X
    printf(" X Windows forwarding\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* CK_FORWARD_X */
#ifdef TN_COMPORT
    printf(" Telnet Remote Com Port Control Option\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* TN_COMPORT */
#ifdef CK_SOCKS
#ifdef CK_SOCKS5
    printf(" SOCKS 5\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#else /* CK_SOCKS5 */
    printf(" SOCKS 4\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* CK_SOCKS5 */
#endif /* CK_SOCKS */
#ifdef NEWFTP
    printf(" Built-in FTP client\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* NEWFTP */
#ifdef CKHTTP
    printf(" Built-in HTTP client\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* CKHTTP */
#endif /* NETCONN */

#ifdef CK_RTSCTS
    printf(" Hardware flow control\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* CK_RTSCTS */

#ifdef CK_XYZ
#ifdef XYZ_INTERNAL
    printf(" Built-in XYZMODEM protocols\n");
#else
    printf(" External XYZMODEM protocol support\n");
#endif /* XYZ_INTERNAL */
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* CK_XYZ */

#ifndef NOCSETS
    printf(" Latin-1 (West European) character-set translation\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#ifdef LATIN2
    printf(" Latin-2 (East European) character-set translation\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* LATIN2 */
#ifdef CYRILLIC
    printf(" Cyrillic (Russian, Ukrainian, etc) character-set translation\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* CYRILLIC */
#ifdef GREEK
    printf(" Greek character-set translation\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* GREEK */
#ifdef HEBREW
    printf(" Hebrew character-set translation\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* HEBREW */
#ifdef KANJI
    printf(" Japanese character-set translation\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* KANJI */
#ifdef UNICODE
    printf(" Unicode character-set translation\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* UNICODE */
#ifdef CKOUNI
    if (isunicode())
      printf(" Unicode support for ISO-2022 Terminal Emulation\n");
    else
      printf(" Unicode translation for Terminal Character-Sets\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* CKOUNI */
#endif /* NOCSETS */

#ifdef NETPTY
    printf(" Pseudoterminal control\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* NETPTY */

#ifdef CK_REDIR
    printf(" REDIRECT command\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* CK_REDIR */

#ifdef CK_RESEND
    printf(" RESEND command\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* CK_RESEND */

#ifndef NOXFER
#ifdef CK_CURSES
    printf(" Fullscreen file transfer display\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* CK_CURSES */
#endif /* NOXFER */

#ifdef CK_SPEED
    printf(" Control-character unprefixing\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* CK_SPEED */

#ifdef STREAMING
    printf(" Streaming\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* STREAMING */

#ifdef CK_AUTODL
    printf(" Autodownload\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* CK_AUTODL */

#ifdef OS2MOUSE
    printf(" Mouse support\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* OS2MOUSE */

#ifdef CK_REXX
    printf(" REXX script language interface\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* CK_REXX */

#ifdef IKSD
#ifdef CK_LOGIN
    printf(" Internet Kermit Service with user login support\n");
#else /* CK_LOGIN */
    printf(" Internet Kermit Service without user login support\n");
#endif /* CK_LOGIN */
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* IKSD */

    printf("\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    printf("Major optional features not included:\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }

    if (sizeof(CK_OFF_T) <= 4) {
	printf(" No large files or large integers\n");
        if (++lines > cmd_rows - 3) {
	    if (!askmore()) return(1); else lines = 0;
	}
    }

#ifdef NOXFER
    printf(" No file-transfer protocols\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#else
#ifndef CK_CURSES
#ifndef MAC
    printf(" No fullscreen file transfer display\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* MAC */
#endif /* CK_CURSES */

#ifdef NOSERVER
    printf(" No server mode\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* NOSERVER */

#ifndef CK_SPEED
    printf(" No control-character unprefixing\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* CK_SPEED */

#ifndef STREAMING
    printf(" No streaming\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* STREAMING */

#ifndef CK_AUTODL
    printf(" No autodownload\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* CK_AUTODL */

#ifndef CK_XYZ
    printf(" No built-in XYZMODEM protocols\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* CK_XYZ */

#ifdef NOFLOAT
    printf(" No floating-point arithmetic\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
    printf(" No S-Expressions (LISP interpreter)\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#else
#ifdef NOSEXP
    printf(" No S-Expressions (LISP interpreter)\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif	/* NOSEXP */
#endif	/* NOFLOAT */

#ifdef NOTLOG
    printf(" No transaction log\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* NOTLOG */
#endif /* NOXFER */

#ifdef NODEBUG
    printf(" No debugging\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* NODEBUG */

#ifdef NOHELP
    printf(" No built-in help\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* NOHELP */

#ifdef NOLOCAL
    printf(" No making connections\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#else
#ifndef NETCONN
    printf(" No network support\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#else /* NETCONN */
#ifndef IKS_OPTION
    printf(" No Telnet Kermit Option\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* IKS_OPTION */
#endif /* NETCONN */

#ifdef NOSSH
    printf(" No Secure Shell (SSH)\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* NOSSH */
#ifndef CK_AUTHENTICATION
    printf(" No Kerberos(TM) authentication\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    printf(" No SRP(TM) (Secure Remote Password) protocol\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    printf(" No Secure Sockets Layer (SSL) protocol\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    printf(" No Transport Layer Security (TLS) protocol\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    printf(" No encryption\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#else /* CK_AUTHENTICATION */
#ifndef CK_KERBEROS
    printf(" No Kerberos(TM) authentication\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#else /* CK_KERBEROS */
#ifndef KRB4
    printf(" No Kerberos(TM) IV authentication\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* KRB4 */
#ifndef KRB5
    printf(" No Kerberos(TM) V authentication\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* KRB5 */
#endif /* CK_KERBEROS */
#ifndef CK_SRP
    printf(" No SRP(TM) (Secure Remote Password) authentication\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* CK_SRP */
#ifndef CK_SSL
    printf(" No Secure Sockets Layer (SSL) protocol\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    printf(" No Transport Layer Security (TLS) protocol\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* CK_SSL */
#ifndef CK_ENCRYPTION
    printf(" No Telnet Encryption Option\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#else /* CK_ENCRYPTION */
#ifndef OS2
#ifndef CK_DES
    printf(" No Telnet DES encryption\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* CK_DES */
#ifndef CK_CAST
    printf(" No Telnet CAST encryption\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* CK_CAST */

#ifdef COMMENT
#ifdef CK_KERBEROS
#ifdef KRB5
#ifndef ALLOW_KRB_3DES_ENCRYPT
    printf(" No Kerberos 3DES/AES Telnet Encryption\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* ALLOW_KRB_3DES_ENCRYPT */
#endif /* KRB5 */
#endif /* CK_KERBEROS */
#endif /* COMMENT */

#endif /* OS2 */
#endif /* CK_ENCRYPTION */
#endif /* CK_AUTHENTICATION */
#ifndef CK_FORWARD_X
    printf(" No X Windows forwarding\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* CK_FORWARD_X */
#ifndef TN_COMPORT
    printf(" No Telnet Remote Com Port Control Option\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* TN_COMPORT */
#ifndef CK_SOCKS
    printf(" No SOCKS\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* CK_SOCKS */
#ifndef NEWFTP
    printf(" No built-in FTP client\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* NEWFTP */
#ifdef NOHTTP
    printf(" No built-in HTTP client\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* NOHTTP */

#ifdef NODIAL
    printf(" No DIAL command\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#else
#ifdef MINIDIAL
    printf(" Support for most modem types excluded\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* MINIDIAL */
#endif /* NODIAL */
#endif /* NOLOCAL */

#ifndef CK_RTSCTS
#ifndef MAC
    printf(" No hardware flow control\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* MAC */
#endif /* CK_RTSCTS */

#ifdef NOXMIT
    printf(" No TRANSMIT command\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* NOXMIT */

#ifdef NOSCRIPT
    printf(" No SCRIPT command\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* NOSCRIPT */

#ifdef NOSPL
    printf(" No script programming features\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* NOSPL */

#ifdef NOCSETS
    printf(" No character-set translation\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#else

#ifndef LATIN2
    printf(" No Latin-2 character-set translation\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* LATIN2 */

#ifdef NOGREEK
    printf(" No Greek character-set translation\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* NOGREEK */

#ifdef NOHEBREW
    printf(" No Hebrew character-set translation\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* NOHEBREW */

#ifdef NOUNICODE
    printf(" No Unicode character-set translation\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* NOUNICODE */

#ifdef NOCYRIL
    printf(" No Cyrillic character-set translation\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* NOCYRIL */

#ifndef KANJI
    printf(" No Kanji character-set translation\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* KANJI */
#endif /* NOCSETS */

#ifdef NOCMDL
    printf(" No command-line arguments\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* NOCMDL */

#ifdef NOPUSH
    printf(" No escape to system\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* NOPUSH */

#ifdef NOJC
#ifdef UNIX
    printf(" No UNIX job control\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* UNIX */
#endif /* NOJC */

#ifdef NOSETKEY
    printf(" No SET KEY command\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* NOSETKEY */

#ifndef CK_REDIR
    printf(" No REDIRECT or PIPE command\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* CK_REDIR */

#ifdef UNIX
#ifndef NETPTY
    printf(" No pseudoterminal control\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* NETPTY */
#endif /* UNIX */

#ifndef CK_RESEND
    printf(" No RESEND command\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* CK_RESEND */

#ifdef OS2
#ifdef __32BIT__
#ifndef OS2MOUSE
    printf(" No Mouse support\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* __32BIT__ */
#endif /* OS2 */
#endif /* OS2MOUSE */

#ifdef OS2
#ifndef NT
#ifndef CK_REXX
    printf(" No REXX script language interface\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* CK_REXX */
#endif /* NT */
#endif /* OS2 */

#ifndef IKSD
    printf(" No Internet Kermit Service\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    flag = 1;
#endif /* IKSD */

    if (flag == 0) {
        printf(" None\n");
        if (++lines > cmd_rows - 3)
          { if (!askmore()) return(1); else lines = 0; }
    }
    printf("\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }

#ifdef CK_UTSNAME
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    printf("Host info:\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    printf(" Machine:    %s\n",unm_mch[0] ? unm_mch : "(unknown)");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    printf(" Model:      %s\n",unm_mod[0] ? unm_mod : "(unknown)");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    printf(" OS:         %s\n",unm_nam[0] ? unm_nam : "(unknown)");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    printf(" OS Release: %s\n",unm_rel[0] ? unm_rel : "(unknown)");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    printf(" OS Version: %s\n",unm_ver[0] ? unm_ver : "(unknown)");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
    printf("\n");
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* CK_UTSNAME */

/*
  Print compile-time (-D) options, as well as C preprocessor
  predefined symbols that might affect us...
*/
#ifdef KTARGET
    {
        char * s;                       /* Makefile target */
        s = KTARGET;
        if (!s) s = "";
        if (!*s) s = "(unknown)";
        printf("\n");
        if (++lines > cmd_rows - 3) {
            if (!askmore()) return(1); else lines = 0;
        }
        printf("Target: %s\n", s);
        if (++lines > cmd_rows - 3) {
            if (!askmore()) return(1); else lines = 0;
        }
    }
#endif /* KTARGET */

#ifdef __VERSION__
#ifdef __GNUC__
    printf("GCC version: %s\n", __VERSION__);
#else
    printf("Compiler version: %s\n", __VERSION__);
#endif /* __GNUC__ */
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }
#endif /* __VERSION__ */

#ifdef __DATE__                         /* GNU and other ANSI */
#ifdef __TIME__
    printf("Compiled %s %s, options:\n", __DATE__, __TIME__);
#else
    printf("Compiled %s, options:\n", __DATE__);
#endif /* __TIME__ */
#else /* !__DATE__ */
    printf("Compiler options:\n");
#endif /* __DATE__ */
    if (++lines > cmd_rows - 3) { if (!askmore()) return(1); else lines = 0; }

    for (i = 0; i < noptlist; i++)      /* Print sorted option list */
      if (!prtopt(&lines,optlist[i]))
        return(0);

    if (!prtopt(&lines,"")) return(0);  /* Start a new section */

/* Sizes of data types */

    ckmakmsg(line,
             LINBUFSIZ,
             "byte order: ",
             byteorder ? "little" : "big",
             " endian",
             NULL
             );
    {
/* Whether to use %d or %ld with sizeof is a portability issue, so... */
	int size = 0;

	if (!prtopt(&lines,line)) return(0);
	if (!prtopt(&lines,"")) return(0);  /* Start a new section */

	size = (int)sizeof(int);
	sprintf(line,"sizeofs: int=%d",size); /* SAFE */
	if (!prtopt(&lines,line)) return(0);

	size = (int)sizeof(long);
	sprintf(line,"long=%d",size); /* SAFE */
	if (!prtopt(&lines,line)) return(0);

#ifndef OS2
	/* Windows doesn't have off_t */
	size = (int)sizeof(off_t);
	sprintf(line,"off_t=%d",size); /* SAFE */
	if (!prtopt(&lines,line)) return(0);
#endif /* OS2 */

	size = (int)sizeof(CK_OFF_T);
	sprintf(line,"CK_OFF_T=%d",size); /* SAFE */
	if (!prtopt(&lines,line)) return(0);

#ifdef BIGBUFOK
	size = (int)sizeof(size_t);
	sprintf(line,"size_t=%d",size); /* SAFE */
	if (!prtopt(&lines,line)) return(0);
#endif /* BIGBUFOK */

	size = (int)sizeof(short);
	sprintf(line,"short=%d",size); /* SAFE */
	if (!prtopt(&lines,line)) return(0);

	size = (int)sizeof(char);
	sprintf(line,"char=%d",size); /* SAFE */
	if (!prtopt(&lines,line)) return(0);

	size = (int)sizeof(char *);
	sprintf(line,"char*=%d",size); /* SAFE */
	if (!prtopt(&lines,line)) return(0);

	size = (int)sizeof(float);
	sprintf(line,"float=%d",size); /* SAFE */
	if (!prtopt(&lines,line)) return(0);

	size = (int)sizeof(double);
	sprintf(line,"double=%d",size); /* SAFE */
	if (!prtopt(&lines,line)) return(0);
    }

#ifdef FNFLOAT
    if (!prtopt(&lines,"")) return(0);  /* Start a new section */
    if (!prtopt(&lines,"floating-point:")) return(0);
    sprintf(line,"precision=%d",fp_digits); /* SAFE */
    if (!prtopt(&lines,line)) return(0);
    sprintf(line,"rounding=%d",fp_rounding); /* SAFE */
    if (!prtopt(&lines,line)) return(0);
#endif /* FNFLOAT */

    prtopt(&lines,"");
    return(0);
}
#endif /* NOSHOW */
#endif /* NOICP */