File: ckuusy.c

package info (click to toggle)
ckermit 302-3
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 13,964 kB
  • sloc: ansic: 273,844; makefile: 10,035; sh: 66
file content (4744 lines) | stat: -rw-r--r-- 133,915 bytes parent folder | download | duplicates (3)
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
#include "ckcsym.h"
#define XFATAL fatal

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

/*  Command-Line Argument Parser */

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

  Copyright (C) 1985, 2009,
    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.
*/
#include "ckcdeb.h"

char * bannerfile = NULL;
char * helpfile = NULL;
extern int xferlog, filepeek, nolinks;
extern char * xferfile;
extern int debtim;

#include "ckcasc.h"
#include "ckcker.h"
#include "ckucmd.h"
#include "ckcnet.h"
#include "ckuusr.h"
#include "ckcxla.h"
#ifdef CK_SSL
#include "ck_ssl.h"
#endif /* CK_SSL */
#include <signal.h>

#ifdef OS2
#include <io.h>
#ifdef KUI
#include "ikui.h"
extern struct _kui_init kui_init;
#endif /* KUI */
#endif /* OS2 */

extern int inserver, fncnv, f_save, xfermode;
#ifdef PATTERNS
extern int patterns;
#endif /* PATTERNS */

#ifndef NOICP
extern int cmdint;
#endif /* NOICP */
extern int xsuspend;

#ifdef NETCONN
#ifdef ANYX25
extern int revcall, closgr, cudata;
extern char udata[];
extern int x25fd;
#endif /* ANYX25 */
#ifndef VMS
#ifndef OS2
#ifndef OSK
extern
#endif /* OSK */
#endif /* OS2 */
#endif /* VMS */

int telnetfd;
extern struct keytab netcmd[];
extern int tn_exit;
#ifndef NOICP
#ifndef NODIAL
extern int nnets, nnetdir;              /* Network services directory */
extern char *netdir[];
extern char *nh_p[];                    /* Network directory entry pointers */
extern char *nh_p2[];                   /* Network directory entry nettype */
extern char *nh_px[4][MAXDNUMS + 1];
#endif /* NODIAL */
extern int nhcount;
extern char * n_name;                   /* Network name pointer */
#endif /* NOICP */
#endif /* NETCONN */

#ifndef NOSPL
extern int nmac;
extern struct mtab *mactab;
#endif /* NOSPL */
extern char uidbuf[];

#ifdef CK_LOGIN
extern int logintimo;
#endif /* CK_LOGIN */

extern char * myname, * dftty;
extern int howcalled;

extern char *ckxsys, *ckzsys, **xargv, *xarg0, **cmlist, *clcmds;

extern int action, cflg, xargc, cnflg, local, quiet, escape, network, mdmtyp,
  bgset, backgrd, xargs, binary, parity, turn, turnch, duplex, flow, clfils,
  noinit, stayflg, nettype, cfilef, noherald, cmask, cmdmsk, exitonclose,
  haveline, justone, cxtype, xfinish, ttnproto;

extern long speed;
extern char ttname[];
extern char * pipedata, * cmdfil;

#ifndef NOXFER
extern char *cmarg, *cmarg2;

extern int nfils, stdouf, stdinf, displa, maxrps, rpsiz, ckwarn, urpsiz,
  wslotr, swcapr, ckdelay, recursive, reliable, xreliable, fnspath, fncact,
  clearrq, setreliable;

#ifdef PIPESEND
extern int usepipes, pipesend;
#endif /* PIPESEND */
extern int protocol;
#endif /* NOXFER */

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

#ifdef OS2
extern struct keytab os2devtab[];
extern int nos2dev;
extern int ttslip;
extern int tt_scroll, tt_escape;
#ifdef OS2PM
extern int os2pm;
#endif /* OS2PM */
#endif /* OS2 */

#ifdef CK_NETBIOS
extern unsigned char NetBiosAdapter;
#endif /* CK_NETBIOS */

#ifdef XFATAL
#undef XFATAL
#endif /* XFATAL */

#ifdef TNCODE
_PROTOTYP(static int dotnarg, (char x) );
#endif /* TNCODE */
#ifdef RLOGCODE
_PROTOTYP(static int dorlgarg, (char x) );
#endif /* RLOGCODE */
#ifdef SSHBUILTIN
_PROTOTYP(static int dossharg, (char x) );
#endif /* SSHBUILTIN */

int haveftpuid = 0;			/* Have FTP user ID */
static int have_cx = 0;			/* Have connection */

static char * failmsg = NULL;		/* Failure message */

#ifdef NEWFTP
extern char * ftp_host;
#endif /* NEWFTP */

extern int what;

#ifndef NOICP
#ifndef NODIAL
extern int nmdm, telephony;
extern struct keytab mdmtab[];
extern int usermdm, dialudt;
#endif /* NODIAL */
_PROTOTYP(static int pmsg, (char *) );
_PROTOTYP(static int fmsg, (char *) );
static int pmsg(s) char *s; { printf("%s\n", s); return(0); }
static int fmsg(s) char *s; { fatal(s); return(0); }
#define XFATAL(s) return(what==W_COMMAND?pmsg(s):fmsg(s))
#else
#define XFATAL fatal
#endif /* NOICP */

#ifndef NOHTTP
#define HTTP_GET 1
#define HTTP_PUT 2
#define HTTP_HED 3
#endif /* NOHTTP */

#ifdef CK_URL
/* URLs we recognize */

#define URL_FTP    1
#define URL_HTTP   2
#define URL_HTTPS  3
#define URL_IKSD   4
#define URL_TELNET 5
#define URL_LOGIN  6

struct keytab urltab[] = {
#ifdef NEWFTP
    "ftp",    URL_FTP,    0,
#endif /* NEWFTP */
#ifndef NOHTTP
    "http",   URL_HTTP,   0,
    "https",  URL_HTTPS,  0,
#endif /* NOHTTP */
    "iksd",   URL_IKSD,   0,
    "kermit", URL_IKSD,   0,
    "telnet", URL_TELNET, 0,
    "", 0, 0
};
int nurltab = sizeof(urltab)/sizeof(struct keytab) - 1;

#ifndef URLBUFLEN
#define URLBUFLEN 1024
#endif /* URLBUFLEN */
static char urlbuf[URLBUFLEN];
struct urldata g_url = {NULL,NULL,NULL,NULL,NULL,NULL,NULL};

/* u r l p a r s e  --  Parse a possible URL */

/*
  Returns 0 if the candidate does not seem to be a URL.
  Returns 1 if it might be a URL, with the above pointers set to its pieces:
    service : [ // ] [ user [ : password ] @ ] host [ : service ] [ / path ] -
              [ ? name [ = value ]]

  Example: ftp://ds.internic.net:21/rfc/rfc1234.txt
    url.svc = [ftp]
    url.usr = [(NULL)]
    url.psw = [(NULL)]
    url.hos = [ds.internic.net]
    url.por = [21]
    url.pth = [rfc/rfc1234.txt]

  It might be a URL if it contains a possible service name followed by a
  a colon (:).  Thus "telnet:xyzcorp.com" is a minimal URL, whereas a
  full-blown example would be:

    ftp://olga:secret@ftp.xyzcorp.com/public/oofa.txt

  The caller must verify the results, i.e. that the service string is a real
  TCP service, etc.  This routine just parses the fields.

  struct urldata defined in ckcker.h
*/

int
urlparse(s,url) char *s; struct urldata * url; {
    char * p = NULL, * urlbuf = NULL;
    int x;

    if (!s || !url)
        return(0);

    if (!*s)
        return(0);

    makestr(&urlbuf,s);

    if (url->sav) {			/* In case we were called before... */
        free(url->sav);
        url->sav = NULL;
    }
    if (url->svc) {
        free(url->svc);
        url->svc = NULL;
    }
    if (url->hos) {
        free(url->hos);
        url->hos = NULL;
    }
    if (url->por) {
        free(url->por);
        url->por = NULL;
    }
    if (url->usr) {
        free(url->usr);
        url->usr = NULL;
    }
    if (url->psw) {
        free(url->psw);
        url->psw = NULL;
    }
    if (url->pth) {
        free(url->pth);
        url->pth = NULL;
    }
    if (url->nopts) {
        int i;
        for (i = 0; i < url->nopts && i < MAX_URL_OPTS; i++ ) {
            if (url->opt[i].nam) {
                free(url->opt[i].nam);
                url->opt[i].nam = NULL;
            }
            if (url->opt[i].val) {
                free(url->opt[i].val);
                url->opt[i].val = NULL;
            }
        }
        url->nopts = 0;
    }
    p = urlbuf;				/* Was a service requested? */
    while (*p && *p != ':')		/* Look for colon */
      p++;
    if (*p == ':') {                    /* Have a colon */
        *p++ = NUL;			/* Get service name or number */
        if (*p == ':')			/* a second colon */
          *p++ = NUL;			/* get rid of that one too */
        while (*p == '/') *p++ = NUL;	/* and slashes */
#ifdef COMMENT
        /* Trailing slash is part of path - leave it - jaltman */
        x = strlen(p);                  /* Length of remainder */
        if (p[x-1] == '/')              /* If there is a trailing slash */
          p[x-1] = NUL;			/* remove it. */
#endif /* COMMENT */
        if (urlbuf[0]) {		/* Anything left? */
            char *q = p, *r = p, *w = p;
	    makestr(&url->svc,urlbuf);

            while (*p != NUL && *p != '@') /* look for @ */
	      p++;
            if (*p == '@') {		/* Signifies user ID, maybe password */
                *p++ = NUL;
		url->hos = p;
                while (*w != NUL && *w != ':')
                  w++;
                if (*w == ':')
                  *w++ = NUL;
		url->usr = r;		/* Username */
		if (*w)
		  url->psw = w;		/* Password */
                q = p;
            } else {			/* No username or password */
                p = q;
		url->hos = p;
            }
#ifdef COMMENT
	    debug(F111,"urlparse url->usr",url->usr,url->usr);
	    debug(F111,"urlparse url->psw",url->usr,url->psw);
	    debug(F111,"urlparse url->hos",url->usr,url->hos);
#endif	/* COMMENT */

            while (*p != NUL && *p != ':' && *p != '/')	/* Port? */
              p++;
            if (*p == ':') {		/* TCP port */
                *p++ = NUL;
                r = p;
		url->por = r;
                while (*p != NUL && *p != '/')
		  p++;
                /* '/' is part of path, leave it until we can copy */
                if (*p == '/') {
		    makestr(&url->pth,p);  /* Path */
		    *p = NUL;
                }
            } else {			/* No port */
                /* '/' is part of path, leave it */
                if (*p == '/') {
		    makestr(&url->pth,p);  /* Path */
		    *p = NUL;
                }
            }
        }
	/* Copy non-NULL result strings */
	if (url->svc) if (*url->svc) {
            p = url->svc;
            url->svc = NULL;
            makestr(&url->svc,p);
        }
	if (url->hos) if (*url->hos) {
            p = url->hos;
            url->hos = NULL;
            makestr(&url->hos,p);
        }
	if (url->por) if (*url->por) {
            p = url->por;
            url->por = NULL;
            makestr(&url->por,p);
        }
/*
  WARNING (Wed Oct  9 16:09:03 2002): We now allow the username and
  password to be empty strings.  These are treated differently from null
  pointers: an empty string means the URL included username and/or password
  fields that were empty, e.g. ftp://:@ftp.xyzcorp.com/somepath/somefile,
  which causes the client to prompt for the username and/or password.
*/
	if (url->usr) /* if (*url->usr) */ {
            p = url->usr;
            url->usr = NULL;
            makestr(&url->usr,p);
        }
	if (url->psw) /* if (*url->psw) */ {
            p = url->psw;
            url->psw = NULL;
            makestr(&url->psw,p);
        }
        /* Save a copy of the full url if one was found. */
	if (url->svc) 
	  makestr(&url->sav,s);
        free(urlbuf);
	return(url->svc ? 1 : 0);
    }
    return(0);
}
#endif /* CK_URL */

#ifndef NOCMDL

char *hlp1[] = {
#ifndef NOICP
" [filename] [-x arg [-x arg]...[-yyy]..] [ = text ] ]\n",
#else
"[-x arg [-x arg]...[-yyy]..]\n",
#endif /* NOICP */
"\n",
"  -x is an option requiring an argument, -y an option with no argument.\n",
"  If the first command-line argument is the name of a file, interactive-\n",
"  mode commands are executed from the file.  The '=' argument tells Kermit\n",
"  not to parse the remainder of the command line, but to make the words\n",
"  following '=' available as \\%1, \\%2, ... \\%9.  The command file \
(if any)\n",
"  is executed before the command-line options.\n",
"\n",
#ifndef NOICP
"If no action command is included, or -S is, then after the command line is\n",
"executed, Kermit issues its prompt and waits for you to type commands.\n",
#else
"Operation by command-line options only.\n",
#endif /* NOICP */
""
};

static
char *hlp2[] = {
"  [option-list] host[:port] [port]\n",
"  The option-list consists of zero, one, or more of:\n",
"  -8                Negotiate Telnet Binary in both directions\n",
"  -a                Require use of Telnet authentication\n",
"  -d                Turn on debug mode\n",
"  -E                No escape character\n",
"  -K                Refuse use of authentication; do not send username\n",
"  -l user           Set username and request Telnet authentication\n",
"  -L                Negotiate Telnet Binary Output only\n",
"  -x                Require Encryption\n",
"  -D                Disable forward-X\n",
"  -T cert=file      Use certificate in file\n",
"  -T key=file       Use private key in file\n",
"  -T crlfile=file   Use CRL in file\n",
"  -T crldir=dir     Use CRLs in directory\n",
"  -T cipher=string  Use only ciphers in string\n",
"  -f                Forward credentials to host\n",
"  -k realm          Set default Kerberos realm\n",
""
};

static
char *hlp3[] = {        /* rlogin */
"  [option-list] host[:port] [port]\n",
"  The option-list consists of zero, one, or more of:\n",
"  -d                Turn on debug mode\n",
"  -l user           Set username\n",
""
};

static
char *hlp4[] = {        /* ssh */
"  [option-list] host[:port] [port]\n",
"  The option-list consists of zero, one, or more of:\n",
#ifdef OS2
"  -# flags          Kermit 95 Startup Flags\n",
"       1              turn off Win95 special fixes\n",
"       2              do not load optional network dlls\n",
"       4              do not load optional tapi dlls\n",
"       8              do not load optional kerberos dlls\n",
"      16              do not load optional zmodem dlls\n",
"      32              use stdin for input instead of the console\n",
"      64              use stdout for output instead of the console\n",
"     128              do not terminate process in response to Session Logoff\n",
#endif /* OS2 */
"  -d                Turn on debug mode\n",
"  -Y                Disable init file processing\n",
"  -l user           Set username\n",
""
};

/* Command-line option help lines.  Update this when adding new options! */

char * opthlp[128];                     /* Option help */
char * arghlp[128];                     /* Argument for option */
int optact[128];                        /* Action-option flag */

VOID
fatal2(msg1,msg2) char *msg1, *msg2; {
    char buf[256];
    if (!msg1) msg1 = "";
    if (!msg2) msg2 = "";
    ckmakmsg(buf,256,"\"",msg1,"\" - ",msg2);
#ifndef NOICP
    if (what == W_COMMAND)
      printf("%s\n",buf);
    else
#endif /* NOICP */
      fatal((char *)buf);
}

static SIGTYP
#ifdef CK_ANSI
cl_int(int dummy)
#else /* CK_ANSI */
cl_int(dummy) int dummy;
#endif /* CK_ANSI */
{					/* Command-line interrupt handler */
    doexit(BAD_EXIT,1);
    SIGRETURN;
}

#ifdef NEWFTP
extern int ftp_action, ftp_cmdlin;

static int
xx_ftp(host, port) char * host, * port; {
#ifdef CK_URL
    extern int haveurl;
#endif /* CK_URL */
    extern char * ftp_logname;
    int use_tls = 0;
    char * p;

    if (port) if (!*port) port = NULL;

    if (!host)
      return(0);
    if (!*host)
      return(0);
    debug(F111,"ftp xx_ftp host",ftp_host,haveftpuid);
    debug(F111,"ftp xx_ftp uidbuf 1",uidbuf,haveftpuid);
    ftp_cmdlin = 1;			/* 1 = FTP started from command line */
    if (nfils > 0)
      ftp_cmdlin++;			/* 2 = same plus file transfer */

#ifndef NOURL
    /* debug(F111,"ftp xx_ftp g_url.usr",g_url.usr,g_url.usr); */
    if (haveurl && g_url.usr) {		/* Wed Oct  9 15:15:22 2002 */
	if (!*(g_url.usr)) {		/* Force username prompt if */
	    haveftpuid = 0;		/* "ftp://:@host" given. */
	    uidbuf[0] = NUL;
	    makestr(&ftp_logname,NULL);
	}	  
	debug(F111,"ftp xx_ftp uidbuf 2",uidbuf,haveftpuid);
    }
#endif /* NOURL */
    debug(F111,"ftp xx_ftp uidbuf 3",uidbuf,haveftpuid);
    if (haveftpuid) {
	makestr(&ftp_logname,uidbuf);
	debug(F111,"ftp_logname",ftp_logname,haveftpuid);
    }
    if (!port) {
	if ((p = ckstrchr(ftp_host,':')))
	  *p++ = NUL;
	port = p;
    }
    if (!port) {
#ifdef CK_URL
        if (haveurl) {
	    if (g_url.por) 
	      port = g_url.por;
            else if (g_url.svc)
	      port = g_url.svc;
            else 
	      port = "ftp";
        } else
#endif /* CK_URL */
	  port = "ftp";
    }

#ifdef CK_SSL
    if (haveurl && g_url.svc)
      use_tls = !ckstrcmp("ftps",g_url.svc,-1,0);
#endif /* CK_SSL */

    if (ftpopen(ftp_host,port,use_tls) < 1)
      return(-1);
    debug(F111,"ftp xx_ftp action",ckctoa((char)ftp_action),nfils);
    if (nfils > 0) {
	switch (ftp_action) {
	  case 'g':
	    return(cmdlinget(stayflg));
	  case 'p':
	  case 's':
	    return(cmdlinput(stayflg));
	}
    }
    return(1);
}
#endif /* NEWFTP */


#ifndef NOHTTP
static
char * http_hlp[] = {
    " -h             This message.\n",
    " -d             Debug to debug.log.\n",
    " -S             Stay (issue command prompt when done).\n",
    " -Y             Do not execute Kermit initialization file.\n",
    " -q             Quiet (suppress most messages).\n",
    " -u name        Username.\n",
    " -P password    Password.\n",
    " -g pathname    Get remote pathname.\n",
    " -p pathname    Put remote pathname.\n",
    " -H pathname    Head remote pathname.\n",
    " -l pathname    Local path for -g, -p, and -H.\n",
#ifdef CK_SSL
    " -z opt[=value] Security options...\n",
    "    cert=file   Client certificate file\n",
    "    certsok     Accept all certificates\n",
    "    key=file    Client private key file\n",
    "    secure      Use SSL\n",
    "    verify=n    0 = none, 1 = peer , 2 = certificate required\n",
#endif /* CK_SSL */
    ""
};

#define HT_CERTFI 0
#define HT_OKCERT 1
#define HT_KEY    2
#define HT_SECURE 3
#define HT_VERIFY 4

static struct keytab httpztab[] = {
    { "cert",    HT_CERTFI, CM_ARG },
    { "certsok", HT_OKCERT, 0 },
    { "key",     HT_KEY,    CM_ARG },
    { "secure",  HT_SECURE, 0 },
    { "verify",  HT_VERIFY, CM_ARG },
    { "", 0, 0 }
};
static int nhttpztab = sizeof(httpztab) / sizeof(struct keytab) - 1;
#endif /* NOHTTP */

/*  U S A G E */

VOID
usage() {
#ifdef MINIX
    conol("Usage: ");
    conol(xarg0);
    conol(" [-x arg [-x arg]...[-yyy]..] ]\n");
#else
    conol("Usage: ");
    conol(xarg0);
    if (howcalled == I_AM_KERMIT || howcalled == I_AM_IKSD ||
        howcalled == I_AM_SSHSUB)
      conola(hlp1);
    else if (howcalled == I_AM_TELNET)
      conola(hlp2);
    else if (howcalled == I_AM_RLOGIN)
      conola(hlp3);
    else if (howcalled == I_AM_SSH)
      conola(hlp4);
    if (howcalled == I_AM_KERMIT || howcalled == I_AM_IKSD ||
        howcalled == I_AM_SSHSUB) {
	int c;
	conoll("");
	conoll("Complete listing of command-line options:");
	conoll("");
	for (c = 31; c < 128; c++) {
	    if (!opthlp[c])
	      continue;
	    if (arghlp[c]) {
		printf(" -%c <arg>%s\n",
		       (char)c,
		       (optact[c] ? " (action option)" : "")
		       );
		printf("     %s\n",opthlp[c]);
		printf("     Argument: %s\n\n",arghlp[c]);
	    } else {			/* Option without arg */
		printf(" -%c  %s%s\n",
		       (char)c, opthlp[c],
		       (optact[c]?" (action option)":"")
		       );
		printf("     Argument: (none)\n\n");
	    }
	}
#ifdef OS2ORUNIX
	printf("To prevent this message from scrolling, use '%s -h | more'.\n",
	       xarg0);
#endif /* OS2ORUNIX */
	printf("For a list of extended options use '%s --help'.\n",
	       xarg0);
    }
#endif /* MINIX */
}


/*  C M D L I N  --  Get arguments from command line  */

int
cmdlin() {
    char x;                             /* Local general-purpose char */
    extern int haveurl;

#ifdef NEWFTP
    char * port = NULL;
#endif /* NEWFTP */

#ifndef NOXFER
    cmarg = "";                         /* Initialize globals */
    cmarg2 = "";
#endif /* NOXFER */
    action = 0;
    cflg = 0;

    signal(SIGINT,cl_int);

/* Here we handle different "Command Line Personalities" */

#ifdef TCPSOCKET
#ifndef NOHTTP
    if (howcalled == I_AM_HTTP) {       /* If I was called as HTTP... */
	char rdns[128];
#ifdef OS2
	char * agent = "Kermit 95";
#else   
	char * agent = "C-Kermit";
#endif /* OS2 */

        debug(F100,"http personality","",0);
#ifdef CK_URL
        if (haveurl) {
            int type;
            char * lfile;

	    type = lookup(urltab,g_url.svc,nurltab,NULL);
            if (!(type == URL_HTTP || type == URL_HTTPS)) {
                printf("?Internal Error: HTTP command line processing\n");
                debug(F100,"Error: HTTP command line processing","",0);
                doexit(BAD_EXIT,1);
            }
            rdns[0] = '\0';
            lfile = "";
            x = (http_open(g_url.hos,g_url.por ? g_url.por : g_url.svc, 
                           type == URL_HTTPS, rdns,128,NULL) == 0);
            if (x) {
#ifdef KUI
		char asname[CKMAXPATH+1];
#endif /* KUI */
                if (!quiet) {
                    if (rdns[0])
		      printf("Connected to %s [%s]\r\n",g_url.hos,rdns);
                    else
		      printf("Connected to %s\r\n",g_url.hos);
                }
                if (g_url.pth)
                  zstrip(g_url.pth,&lfile);
                else
		  g_url.pth = "/";

                if (!*lfile)
                  lfile = "index.html";

#ifdef KUI
		if (uq_file(NULL,	/* K95 GUI: Put up file box. */
			    NULL,	/* (not tested...) */
			    4,
			    NULL,
			    lfile,
			    asname,
			    CKMAXPATH+1
			    ) > 0)
		  lfile = asname;
#endif /* KUI */

                x = http_get(agent,
			     NULL,	/* hdrlist */
			     g_url.usr,
			     g_url.psw,
			     0,
			     lfile,
			     g_url.pth,
			     0		/* stdio */
			     );
                x = (http_close() == 0);
            } else {
                if (!quiet)
		  printf("?HTTP Connection failed.\r\n");
            }
            doexit(x ? GOOD_EXIT : BAD_EXIT, -1);
        } else 
#endif /* CK_URL */
	  {
	      int http_action = 0;
	      char * host = NULL, * svc = NULL, * lpath = NULL;
	      char * user = NULL, * pswd = NULL, * path = NULL;
	      char * xp;

	      while (--xargc > 0) {	/* Go through command line words */
		  xargv++;
		  debug(F111,"cmdlin http xargv",*xargv,xargc);
		  xp = *xargv+1;
		  if (**xargv == '-') { /* Got an option */
		      int xx;
		      x = *(*xargv+1);	/* Get the option letter */
		      switch (x) {
			case 'd':	/* Debug */
#ifdef DEBUG
			  if (deblog) {
			      debtim = 1;
			  } else {
			      deblog = debopn("debug.log",0);
			  }
#endif /* DEBUG */
			  break;
			case 'S':	/* Stay */
			case 'Y':	/* No initialization file */
			  break;	/* (already done in prescan) */
			case 'q':	/* Quiet */
			  quiet = 1;
			  break;
			case 'u':	/* Options that require arguments */
			case 'P':
			case 'g':
			case 'p':
			case 'H':
			case 'l':
			  if (*(xp+1)) {
			      XFATAL("Invalid argument bundling");
			  }
			  xargv++, xargc--;
			  if ((xargc < 1) || (**xargv == '-')) {
			      XFATAL("Missing argument");
			  }
			  switch (x) {
			    case 'u':
			      user = *xargv;
			      break;
			    case 'P':
			      pswd = *xargv;
			      break;
			    case 'l':
			      if (http_action != HTTP_PUT)
				lpath = *xargv;
			      break;
			    case 'g':
			      http_action = HTTP_GET;
			      path = *xargv;
			      debug(F111,"cmdlin http GET",path,http_action);
			      break;
			    case 'p':
			      http_action = HTTP_PUT;
			      path = *xargv;
			      break;
			    case 'H':
			      http_action = HTTP_HED;
			      path = *xargv;
			  }
			  break;

#ifdef CK_SSL
                        case 'z': {
			    /* *xargv contains a value of the form tag=value */
			    /* we need to lookup the tag and save the value  */
			    int x,y,z;
			    char * p, * q;
			    makestr(&p,*xargv);
			    y = ckindex("=",p,0,0,1);
			    if (y > 0)
                              p[y-1] = '\0';
			    x = lookup(httpztab,p,nhttpztab,&z);
			    if (x < 0) {
				printf("?Invalid security option: \"%s\"\n",p);
			    } else {
				printf("Security option: \"%s",p);
				if (httpztab[z].flgs & CM_ARG) {
				    q = &p[y];
				    if (!*q)
                                      fatal("?Missing required value");
				}
				/* -z options w/args */
				switch (httpztab[z].kwval) {
				  case HT_CERTFI:
				    makestr(&ssl_rsa_cert_file,q);
				    break;
				  case HT_OKCERT:
				    ssl_certsok_flag = 1;
				    break;
				  case HT_KEY:
				    makestr(&ssl_rsa_key_file,q);
				    break;
				  case HT_SECURE:
				    svc="https";
				    break;
				  case HT_VERIFY:
				    if (!rdigits(q))
                                      printf("?Bad number: %s\n",q);
				    ssl_verify_flag = atoi(q);
				    break;
				}
			    }
			    free(p);
			    break;
                        }
#endif /* CK_SSL */

			case 'h':	/* Help */
			default:
			  printf("Usage: %s host [ options... ]\n",xarg0);
			  conola(http_hlp);
			  doexit(GOOD_EXIT,-1);
		      }
		  } else {		/* No dash - must be hostname */
		      host = *xargv;
		      if (xargc > 1) {
			  svc = *(xargv+1);
			  if (svc) if (*svc == '-' || !*svc)
			    svc = NULL;
			  if (svc) {
			      xargv++;
			      xargc--;
			  }
		      }
		  }
	      }
	      if (!svc) svc = "";
	      if (!*svc) svc = "http";
	      if (!host) XFATAL("No http host given");

	      /* Check action args before opening the connection */
	      if (http_action) {
		  if (http_action == HTTP_PUT) {
		      if (!lpath)
			XFATAL("No local path for http PUT");
		  }
		  if (!path)
		    XFATAL("No remote path for http action");
	      }
	      /* Now it's OK to open the connection */
	      rdns[0] = NUL;
	      x = (http_open(host,
			     svc,!ckstrcmp("https",svc,-1,0),rdns,128,NULL
			     ) == 0);
	      if (!x) {
		  if (!quiet)
		    printf("?HTTP Connection failed.\r\n");
		  doexit(BAD_EXIT,-1);
	      }
	      if (!quiet) {
		  if (rdns[0])
		    printf("Connected to %s [%s]\r\n",host,rdns);
		  else
		    printf("Connected to %s\r\n",host);
	      }
	      if (http_action) {
                  int pcpy = 0;
		  if (http_action != HTTP_PUT) { /* Supply default */
		      if (!lpath) {		 /* local path... */
			  zstrip(path,&lpath);
			  if (!lpath)
			    lpath = "";
			  if (!*lpath)
			    lpath = "index.html";
		      }
		  }
                  if (*path != '/') {
                      char * p = (char *) malloc(strlen(path)+2);
                      if (!p) fatal("?Memory allocation error\n");
                      *p = '/';
                      strcpy(&p[1],path);      /* safe */
                      path = p;
                      pcpy = 1;
                  }
		  switch (http_action) {
		    case HTTP_GET:
		      x = http_get(agent,NULL,user,pswd,0,lpath,path,0);
		      break;
		      
		    case HTTP_PUT:
		      x = http_put(agent,NULL,"text/HTML",
				   user,pswd,0,lpath,path,NULL,0);
		      break;

		    case HTTP_HED:
		      x = http_head(agent,NULL,user,pswd,0,lpath,path,0);
		      break;
		  }
		  debug(F101,"cmdline http result","",x);
                  x = (http_close() == 0);
                  if (pcpy) free(path);
                  doexit(x ? GOOD_EXIT : BAD_EXIT, -1);
	      }
	      return(0);
	  }
    } else
#endif /* NOHTTP */
#ifdef NEWFTP
      if (howcalled == I_AM_FTP) {	/* If I was called as FTP... */
	  debug(F100,"ftp personality","",0);
#ifdef CK_URL
	  if (haveurl)
            doftparg('U');
	  else 
#endif /* CK_URL */
	    {
		while (--xargc > 0) {	/* Go through command line words */
		    xargv++;
		    debug(F111,"cmdlin ftp xargv",*xargv,xargc);
		    if (**xargv == '-') { /* Got an option */
			int xx;
			x = *(*xargv+1); /* Get the option letter */
			xx = doftparg(x);
			if (xx < 0) {
			    if (what == W_COMMAND)
			      return(0);
			    else
			      doexit(BAD_EXIT,1);
			}
		    } else {		/* No dash - must be hostname */
			makestr(&ftp_host,*xargv);
			if (xargc > 1) {
			    port = *(xargv+1);
			    if (port) if (*port == '-' || !*port)
			      port = NULL;
			    if (port) {
				xargv++;
				xargc--;
			    }
			}
			debug(F110,"cmdlin ftp host",ftp_host,0);
			debug(F110,"cmdlin ftp port",port,0);
		    }
		} /* while */
	    } /* if (haveurl) */

	  if (ftp_host) {
	      int xx;
#ifdef NODIAL
	      xx = xx_ftp(ftp_host,port);
	      if (xx < 0 && (haveurl || ftp_cmdlin > 1)) doexit(BAD_EXIT,-1);
#else
#ifdef NOICP
	      xx = xx_ftp(ftp_host,port);
	      if (xx < 0 && (haveurl || ftp_cmdlin > 1)) doexit(BAD_EXIT,-1);
#else
	      if (*ftp_host == '=') {	/* Skip directory lookup */
		  xx = xx_ftp(&ftp_host[1],port);
		  if (xx < 0 && (haveurl || ftp_cmdlin > 1))
		    doexit(BAD_EXIT,-1);
	      } else {			/* Want lookup */
		  int i;
		  nhcount = 0;		/* Check network directory */
		  debug(F101,"cmdlin nnetdir","",nnetdir);
		  if (nnetdir > 0)	/* If there is a directory... */
		    lunet(ftp_host);	/* Look up the name */
		  else			/* If no directory */
		    nhcount = 0;	/* we didn't find anything there */
#ifdef DEBUG
		  if (deblog) {
		      debug(F101,"cmdlin lunet nhcount","",nhcount);
		      if (nhcount > 0) {
			  debug(F110,"cmdlin lunet nh_p[0]",nh_p[0],0);
			  debug(F110,"cmdlin lunet nh_p2[0]",nh_p2[0],0);
			  debug(F110,"cmdlin lunet nh_px[0][0]",
				nh_px[0][0],0);
		      }
		  }
#endif /* DEBUG */
		  if (nhcount == 0) {
		      xx = xx_ftp(ftp_host,port);
		      if (xx < 0 && (haveurl || ftp_cmdlin > 1))
			doexit(BAD_EXIT,-1);
		  } else {
		      for (i = 0; i < nhcount; i++) {
			  if (ckstrcmp(nh_p2[i],"tcp/ip",6,0))
			    continue;
			  makestr(&ftp_host,nh_p[i]);
			  debug(F110,"cmdlin calling xx_ftp",ftp_host,0);
			  if (!quiet)
			    printf("Trying %s...\n",ftp_host);
			  if (xx_ftp(ftp_host,port) > -1)
			    break;
		      }
		  }
	      }
#endif /* NODIAL */
#endif /* NOICP */
	      if (!ftpisconnected())
		doexit(BAD_EXIT,-1);
	  }
	  return(0);
      }
#endif /* NEWFTP */

#ifdef TNCODE
    if (howcalled == I_AM_TELNET) {     /* If I was called as Telnet... */

        while (--xargc > 0) {		/* Go through command line words */
            xargv++;
            debug(F111,"cmdlin telnet xargv",*xargv,xargc);
            if (**xargv == '=')
	      return(0);
            if (!strcmp(*xargv,"--"))	/* getopt() conformance */
	      return(0);
#ifdef VMS
            else if (**xargv == '/')
	      continue;
#endif /* VMS */
            else if (**xargv == '-') {	/* Got an option (begins with dash) */
                int xx;
                x = *(*xargv+1);	/* Get the option letter */
                debug(F111,"cmdlin telnet args 1",*xargv,xargc);
                xx = dotnarg(x);
                debug(F101,"cmdlin telnet doarg","",xx);
                debug(F111,"cmdlin telnet args 2",*xargv,xargc);
                if (xx < 0) {
#ifndef NOICP
                    if (what == W_COMMAND)
		      return(0);
                    else
#endif /* NOICP */
		      {
#ifdef OS2
			  sleep(1);	/* Give it a chance... */
#endif /* OS2 */
			  doexit(BAD_EXIT,1); /* Go handle option */
		      }
                }
            } else {			/* No dash must be hostname */
                ckstrncpy(ttname,*xargv,TTNAMLEN+1);
                debug(F110,"cmdlin telnet host",ttname,0);

#ifndef NOICP
#ifndef NODIAL
                nhcount = 0;		/* Check network directory */
                debug(F101,"cmdlin telnet nnetdir","",nnetdir);
                if (nnetdir > 0)	/* If there is a directory... */
		  lunet(*xargv);	/* Look up the name */
                else			/* If no directory */
		  nhcount = 0;		/* we didn't find anything there */
#ifdef DEBUG
                if (deblog) {
                    debug(F101,"cmdlin telnet lunet nhcount","",nhcount);
                    if (nhcount > 0) {
                        debug(F110,"cmdlin telnet lunet nh_p[0]",nh_p[0],0);
                        debug(F110,"cmdlin telnet lunet nh_p2[0]",nh_p2[0],0);
                        debug(F110,"cmdlin telnet lunet nh_px[0][0]",
			      nh_px[0][0],0);
                    }
                }
#endif /* DEBUG */
                if (nhcount > 0 && nh_p2[0]) /* If network type specified */
		  if (ckstrcmp(nh_p2[0],"tcp/ip",6,0)) /* it must be TCP/IP */
		    nhcount = 0;
                if (nhcount == 1) {	/* Still OK, so make substitution */
                    ckstrncpy(ttname,nh_p[0],TTNAMLEN+1);
                    debug(F110,"cmdlin telnet lunet substitution",ttname,0);
                }
#endif /* NODIAL */
#endif /* NOICP */

                if (--xargc > 0 && !haveurl) { /* Service from command line? */
                    xargv++;
                    ckstrncat(ttname,":",TTNAMLEN+1);
                    ckstrncat(ttname,*xargv,TTNAMLEN+1);
                    debug(F110,"cmdlin telnet host2",ttname,0);
                }
#ifndef NOICP
#ifndef NODIAL
                else if (nhcount) {	/* No - how about in net directory? */
                    if (nh_px[0][0]) {
                        ckstrncat(ttname,":",TTNAMLEN+1);
                        ckstrncat(ttname,nh_px[0][0],TTNAMLEN+1);
                    }
                }
#endif /* NODIAL */
#endif /* NOICP */
                local = 1;		/* Try to open the connection */
                nettype = NET_TCPB;
                mdmtyp = -nettype;
                if (ttopen(ttname,&local,mdmtyp,0) < 0) {
                    XFATAL("can't open host connection");
                }
                network = 1;		/* It's open */
#ifdef CKLOGDIAL
                dolognet();
#endif /* CKLOGDIAL */
#ifndef NOXFER
                reliable = 1;		/* It's reliable */
                xreliable = 1;		/* ... */
                setreliable = 1;
#endif /* NOXFER */
                cflg = 1;		/* Connect */
                stayflg = 1;		/* Stay */
                tn_exit = 1;		/* Telnet-like exit condition */
                quiet = 1;
                exitonclose = 1;	/* Exit when connection closes */
#ifndef NOSPL
                if (local) {
                    if (nmac) {		/* Any macros defined? */
                        int k;		/* Yes */
                        k = mlook(mactab,"on_open",nmac); /* Look this up */
                        if (k >= 0) {                     /* If found, */
                            if (dodo(k,ttname,0) > -1)    /* set it up, */
                                parser(1);                /* and execute it */
                        }
                    }
                }
#endif /* NOSPL */
                break;
            }
        }
        return(0);
    }
#endif /* TNCODE */
#ifdef RLOGCODE
    else if (howcalled == I_AM_RLOGIN) { /* If I was called as Rlogin... */
        while (--xargc > 0) {		/* Go through command line words */
            xargv++;
            debug(F111,"cmdlin rlogin xargv",*xargv,xargc);
            if (**xargv == '=')
	      return(0);
            if (!strcmp(*xargv,"--"))	/* getopt() conformance */
	      return(0);
#ifdef VMS
            else if (**xargv == '/')
	      continue;
#endif /* VMS */
            else if (**xargv == '-') {	/* Got an option (begins with dash) */
                int xx;
                x = *(*xargv+1);	/* Get the option letter */
                debug(F111,"cmdlin rlogin args 1",*xargv,xargc);
                xx = dorlgarg(x);
                debug(F101,"cmdlin rlogin doarg","",xx);
                debug(F111,"cmdlin rlogin args 2",*xargv,xargc);
                if (xx < 0) {
#ifndef NOICP
                    if (what == W_COMMAND)
		      return(0);
                    else
#endif /* NOICP */
		      {
#ifdef OS2
			  sleep(1);	/* Give it a chance... */
#endif /* OS2 */
			  doexit(BAD_EXIT,1); /* Go handle option */
		      }
                }
            } else {			/* No dash must be hostname */
                ckstrncpy(ttname,*xargv,TTNAMLEN+1);
                debug(F110,"cmdlin rlogin host",ttname,0);

#ifndef NOICP
#ifndef NODIAL
                nhcount = 0;		/* Check network directory */
                debug(F101,"cmdlin rlogin nnetdir","",nnetdir);
                if (nnetdir > 0)	/* If there is a directory... */
		  lunet(*xargv);	/* Look up the name */
                else			/* If no directory */
		  nhcount = 0;		/* we didn't find anything there */
#ifdef DEBUG
                if (deblog) {
                    debug(F101,"cmdlin rlogin lunet nhcount","",nhcount);
                    if (nhcount > 0) {
                        debug(F110,"cmdlin rlogin lunet nh_p[0]",nh_p[0],0);
                        debug(F110,"cmdlin rlogin lunet nh_p2[0]",nh_p2[0],0);
                        debug(F110,"cmdlin rlogin lunet nh_px[0][0]",
			      nh_px[0][0],0);
                    }
                }
#endif /* DEBUG */
                if (nhcount > 0 && nh_p2[0]) /* If network type specified */
		  if (ckstrcmp(nh_p2[0],"tcp/ip",6,0)) /* it must be TCP/IP */
		    nhcount = 0;
                if (nhcount == 1) {	/* Still OK, so make substitution */
                    ckstrncpy(ttname,nh_p[0],TTNAMLEN+1);
                    debug(F110,"cmdlin rlogin lunet substitution",ttname,0);
                }
#endif /* NODIAL */
#endif /* NOICP */

                if (!haveurl) { /* Service from command line? */
                    ckstrncat(ttname,":login",TTNAMLEN+1);
                    debug(F110,"cmdlin rlogin host2",ttname,0);
                }
                local = 1;		/* Try to open the connection */
                nettype = NET_TCPB;
                mdmtyp = -nettype;
                if (ttopen(ttname,&local,mdmtyp,0) < 0) {
                    XFATAL("can't open host connection");
                }
                network = 1;		/* It's open */
#ifdef CKLOGDIAL
                dolognet();
#endif /* CKLOGDIAL */
#ifndef NOXFER
                reliable = 1;		/* It's reliable */
                xreliable = 1;		/* ... */
                setreliable = 1;
#endif /* NOXFER */
                cflg = 1;		/* Connect */
                stayflg = 1;		/* Stay */
                tn_exit = 1;		/* Telnet-like exit condition */
                quiet = 1;
                exitonclose = 1;	/* Exit when connection closes */
#ifndef NOSPL
                if (local) {
                    if (nmac) {		/* Any macros defined? */
                        int k;		/* Yes */
                        k = mlook(mactab,"on_open",nmac); /* Look this up */
                        if (k >= 0) {                     /* If found, */
                            if (dodo(k,ttname,0) > -1)    /* set it up, */
                                parser(1);                /* and execute it */
                        }
                    }
                }
#endif /* NOSPL */
                break;
            }
        }
        return(0);
    }
#endif /* RLOGCODE */
#endif /* TCPSOCKET */

#ifdef SSHBUILTIN
      if (howcalled == I_AM_SSH) {	/* If I was called as SSH... */
          extern char * ssh_hst, * ssh_cmd, * ssh_prt;
	  debug(F100,"ssh personality","",0);
#ifdef CK_URL
	  if (haveurl) {
              makestr(&ssh_hst,g_url.hos);
              makestr(&ssh_prt,g_url.svc);
	      ckstrncpy(ttname,ssh_hst,TTNAMLEN+1);
              ckstrncat(ttname,":",TTNAMLEN+1);
              ckstrncat(ttname,ssh_prt,TTNAMLEN+1);
          }
	  else 
#endif /* CK_URL */
	  {
              while (--xargc > 0) {	/* Go through command line words */
                  xargv++;
                  debug(F111,"cmdlin ssh xargv",*xargv,xargc);
                  if (**xargv == '=')
                      return(0);
                  if (!strcmp(*xargv,"--")) /* getopt() conformance */
                      return(0);
#ifdef VMS
                  else if (**xargv == '/')
                      continue;
#endif /* VMS */
		  /* Got an option (begins with dash) */
                  else if (**xargv == '-') {
                      int xx;
                      x = *(*xargv+1);	/* Get the option letter */
                      debug(F111,"cmdlin args 1",*xargv,xargc);
                      xx = dossharg(x);
                      debug(F101,"cmdlin doarg","",xx);
                      debug(F111,"cmdlin args 2",*xargv,xargc);
                      if (xx < 0) {
#ifndef NOICP
                          if (what == W_COMMAND)
			    return(0);
                          else
#endif /* NOICP */
                          {
#ifdef OS2
                              sleep(1);	/* Give it a chance... */
#endif /* OS2 */
                              doexit(BAD_EXIT,1); /* Go handle option */
                          }
                      }
                  } else {			/* No dash must be hostname */
                      ckstrncpy(ttname,*xargv,TTNAMLEN+1);
                      makestr(&ssh_hst,ttname);
                      debug(F110,"cmdlin ssh host",ttname,0);
#ifndef NOICP
#ifndef NODIAL
                      nhcount = 0;		/* Check network directory */
                      debug(F101,"cmdlin nnetdir","",nnetdir);
                      if (nnetdir > 0)	/* If there is a directory... */
			lunet(*xargv);	/* Look up the name */
                      else		/* If no directory */
			nhcount = 0;	/* we didn't find anything there */
#ifdef DEBUG
                      if (deblog) {
                          debug(F101,"cmdlin lunet nhcount","",nhcount);
                          if (nhcount > 0) {
                              debug(F110,"cmdlin lunet nh_p[0]",nh_p[0],0);
                              debug(F110,"cmdlin lunet nh_p2[0]",nh_p2[0],0);
                              debug(F110,
				    "cmdlin lunet nh_px[0][0]",nh_px[0][0],0);
                          }
                      }
#endif /* DEBUG */
		      /* If network type specified */
		      /* it must be TCP/IP */
                      if (nhcount > 0 && nh_p2[0])
			if (ckstrcmp(nh_p2[0],"tcp/ip",6,0))
			  nhcount = 0;
                      if (nhcount == 1) { /* Still OK, so make substitution */
                          ckstrncpy(ttname,nh_p[0],TTNAMLEN+1);
                          makestr(&ssh_hst,ttname);
                          debug(F110,"cmdlin lunet substitution",ttname,0);
                      }
#endif /* NODIAL */
#endif /* NOICP */
		      /* Service from command line? */
                      if (--xargc > 0 && !haveurl) {
                          xargv++;
                          ckstrncat(ttname,":",TTNAMLEN+1);
                          ckstrncat(ttname,*xargv,TTNAMLEN+1);
                          makestr(&ssh_prt,*xargv);
                          debug(F110,"cmdlin telnet host2",ttname,0);
                      }
#ifdef COMMENT
                      /* Do not substitute net dir service for ssh port */
#ifndef NOICP
#ifndef NODIAL
		      /* No - how about in net directory? */
                      else if (nhcount) {
                          if (nh_px[0][0]) {
                              ckstrncat(ttname,":",TTNAMLEN+1);
                              ckstrncat(ttname,nh_px[0][0],TTNAMLEN+1);
                              makestr(&ssh_prt,nh_px[0][0]);
                          }
                      }

#endif /* NODIAL */
#endif /* NOICP */
#endif /* COMMENT */
                      break;
                  }
              }
          }
          local = 1;			/* Try to open the connection */
          nettype = NET_SSH;
          mdmtyp = -nettype;
          if (ttopen(ttname,&local,mdmtyp,0) < 0) {
              XFATAL("can't open host connection");
          }
          network = 1;			/* It's open */
#ifdef CKLOGDIAL
          dolognet();
#endif /* CKLOGDIAL */
#ifndef NOXFER
          reliable = 1;			/* It's reliable */
          xreliable = 1;		/* ... */
          setreliable = 1;
#endif /* NOXFER */
          cflg = 1;			/* Connect */
          stayflg = 1;			/* Stay */
          tn_exit = 1;			/* Telnet-like exit condition */
          quiet = 1;
          exitonclose = 1;		/* Exit when connection closes */
#ifndef NOSPL
          if (local) {
              if (nmac) {		/* Any macros defined? */
                  int k;		/* Yes */
                  k = mlook(mactab,"on_open",nmac); /* Look this up */
                  if (k >= 0) {                     /* If found, */
                      if (dodo(k,ttname,0) > -1)    /* set it up, */
                          parser(1);                /* and execute it */
                  } 
              }     
          }
#endif /* NOSPL */
	  return(0);
      }
#endif /* SSHBUILTIN */

    if (howcalled == I_AM_SSHSUB)
      return(0);

/*
  From here down: We were called as "kermit" or "iksd".

  If we were started directly from a Kermit script file,
  the filename of the script is in argv[1], so skip past it.
*/
    if (xargc > 1) {
        int n = 1;
        if (*xargv[1] != '-') {

#ifdef KERBANG
            /* If we were started with a Kerbang script, the script */
            /* arguments were already picked up in prescan / cmdini() */
            /* and there is nothing here for us anyway. */
            if (!strcmp(xargv[1],"+"))
              return(0);
#endif /* KERBANG */

            if (cfilef) {               /* Command file found in prescan() */
                xargc -= n;             /* Skip past it */
                xargv += n;
                cfilef = 0;
                debug(F101,"cmdlin cfilef set to 0","",cfilef);
            }
        }
    }
/*
  Regular Unix-style command line parser, mostly conforming with 'A Proposed
  Command Syntax Standard for Unix Systems', Hemenway & Armitage, Unix/World,
  Vol.1, No.3, 1984.
*/
    while (--xargc > 0) {               /* Go through command line words */
        xargv++;
        debug(F111,"cmdlin xargv",*xargv,xargc);
        if (**xargv == '=')
          return(0);
        if (!strcmp(*xargv,"--"))       /* getopt() conformance */
          return(0);
#ifdef VMS
        else if (**xargv == '/')
          continue;
#endif /* VMS */
        else if (**xargv == '-') {      /* Got an option (begins with dash) */
            int xx;
            x = *(*xargv+1);            /* Get the option letter */
            debug(F111,"cmdlin args 1",*xargv,xargc);
            xx = doarg(x);
            debug(F101,"cmdlin doarg","",xx);
            debug(F111,"cmdlin args 2",*xargv,xargc);
            if (xx < 0) {
#ifndef NOICP
                if (what == W_COMMAND)
                  return(0);
                else
#endif /* NOICP */
                  {
#ifdef OS2
                      sleep(1);         /* Give it a chance... */
#endif /* OS2 */
                      doexit(BAD_EXIT,1); /* Go handle option */
                  }
            }
        } else if (!haveurl) {		/* No dash where expected */
	    char xbuf[32];
            char buf[128];
	    int k;
	    k = ckstrncpy(xbuf,*xargv,40);
	    if (k > 30) {
		xbuf[30] = '.';
		xbuf[29] = '.';
		xbuf[28] = '.';
	    }
	    xbuf[31] = NUL;
            ckmakmsg(buf,
		     128,
		     "invalid command-line option, type \"",
		     myname,
		     " -h\" for help",
		     NULL
		     );
	    fatal2(xbuf,buf);
        }
    }
#ifdef DEBUG
    if (deblog) {
#ifndef NOICP
        debug(F101,"cmdlin what","",what);
#endif /* NOICP */
        debug(F101,"cmdlin action","",action);
#ifndef NOXFER
        debug(F101,"cmdlin stdouf","",stdouf);
#endif /* NOXFER */
    }
#endif /* DEBUG */

#ifdef NOICP
    if (!action && !cflg && !cnflg) {
        debug(F100,"cmdlin NOICP fatal no action","",0);
        XFATAL("?No actions specified on command line");
    }
#else
    if (inserver && what == 0) {        /* Internet Kermit server checks */
        if (local || (action != 0 && action != 'x')) {
            if (local)
              printf("local\r\n");
            if (action)
              printf("action=%c\r\n",action);
            debug(F100,"cmdlin fatal 1","",0);
            XFATAL("No actions or connections allowed with -A");
        }
    }
#endif /* NOICP */

#ifndef NOLOCAL
    if (!local) {
        if ((action == 'c') || (cflg != 0)) {
            debug(F100,"cmdlin fatal 2","",0);
            XFATAL("-l or -j or -X required");
        }
    }
#endif /* NOLOCAL */
#ifndef NOXFER
    if (*cmarg2 != 0) {
        if ((action != 's') && (action != 'r') && (action != 'v')) {
            debug(F100,"cmdlin fatal 3","",0);
            XFATAL("-a without -s, -r, or -g");
        }
        if (action == 'r' || action == 'v') {
#ifdef CK_TMPDIR
            if (isdir(cmarg2)) {        /* -a is a directory */
                if (!zchdir(cmarg2)) {  /* try to change to it */
                    debug(F100,"cmdlin fatal 4","",0);
                    XFATAL("can't change to '-a' directory");
                } else cmarg2 = "";
            } else
#endif /* CK_TMPDIR */
              if (zchko(cmarg2) < 0) {
                  debug(F100,"cmdlin fatal 5","",0);
                  XFATAL("write access to -a file denied");
              }
        }
    }
    if ((action == 'v') && (stdouf) && (!local)) {
        if (is_a_tty(1)) {
            debug(F100,"cmdlin fatal 6","",0);
            XFATAL("unredirected -k can only be used in local mode");
        }
    }
    if ((action == 's') || (action == 'v') ||
        (action == 'r') || (action == 'x')) {
        if (local)
          displa = 1;
        if (stdouf) {
            displa = 0;
            quiet = 1;
        }
    }
    if (quiet) displa = 0;              /* No display if quiet requested */
#endif /* NOXFER */
#ifdef DEBUG
    if (action)
      debug(F000,"cmdlin returns action","",action);
    else
      debug(F101,"cmdlin returns action","",action);
#endif /* DEBUG */

    return(action);                     /* Then do any requested protocol */
}

/* Extended argument parsing: --keyword[:value] (or =value) */

/*
  XA_xxxx symbols are defined in ckuusr.h.
  If you add a new one, also remember to update doshow(),
  SHXOPT section, in ckuus5.c.
*/
struct keytab xargtab[] = {
#ifdef CK_LOGIN
    { "anonymous",   XA_ANON, CM_ARG|CM_PRE },
#endif /* CK_LOGIN */
    { "bannerfile",  XA_BAFI, CM_ARG },
    { "cdfile",      XA_CDFI, CM_ARG },
    { "cdmessage",   XA_CDMS, CM_ARG },
    { "cdmsg",       XA_CDMS, CM_ARG|CM_INV },
#ifdef KUI
    { "changedim",   XA_CHGD, CM_PRE },
#endif /* KUI */
#ifndef NOCSETS
    { "charset",     XA_CSET, CM_ARG|CM_PRE },
#endif /* NOCSETS */
#ifdef IKSDB
    { "database",    XA_DBAS, CM_ARG|CM_PRE },
    { "dbfile",      XA_DBFI, CM_ARG|CM_PRE },
#endif /* IKSDB */
#ifdef KUI
    { "facename",    XA_FNAM, CM_ARG|CM_PRE|CM_INV },
    { "fontname",    XA_FNAM, CM_ARG|CM_PRE },
    { "fontsize",    XA_FSIZ, CM_ARG|CM_PRE },
#endif /* KUI */
#ifdef COMMENT
#ifdef NEWFTP
    { "ftp",         XA_FTP,  CM_ARG },
#endif /* NEWFTP */
#endif /* COMMENT */
#ifndef NOLOCAL
#ifdef OS2
    { "height",      XA_ROWS, CM_ARG|CM_PRE },
#endif /* OS2 */
#endif /* NOLOCAL */
    { "help",        XA_HELP, 0 },
#ifndef NOHELP
    { "helpfile",    XA_HEFI, CM_ARG },
#endif /* NOHELP */
#ifdef CK_LOGIN
    { "initfile",    XA_ANFI, CM_ARG|CM_PRE },
#endif /* CK_LOGIN */
#ifdef OS2
    { "lockdown",    XA_LOCK, CM_PRE },
#ifdef KUI
    { "maximize",    XA_WMAX,  CM_PRE },
    { "minimize",    XA_WMIN,  CM_PRE },
    { "nobars",      XA_NOBAR, CM_PRE },
    { "noclose" ,    XA_NOCLOSE, CM_PRE },
#endif /* KUI */
    { "noescape",    XA_NOESCAPE, CM_PRE },
#endif /* OS2 */
    { "nointerrupts",XA_NOIN, CM_PRE },
#ifdef KUI
    { "nomenubar",   XA_NOMN, CM_PRE },
#endif /* KUI */
    { "noperms",     XA_NPRM, 0 },
#ifndef NOPUSH
    { "nopush",      XA_NOPUSH, CM_PRE },
#endif /* NOPUSH */
#ifdef OS2
    { "noscroll",    XA_NOSCROLL, CM_PRE },
#endif /* OS2 */
#ifdef KUI
    { "nostatusbar", XA_NOSB, CM_PRE },
    { "notoolbar",   XA_NOTB, CM_PRE },
#endif /* KUI */
#ifdef COMMENT
    { "password",    XA_PASS, CM_ARG|CM_INV },
#endif /* COMMENT */
#ifdef CK_LOGIN
#ifndef NOXFER
#ifdef CK_PERM
    { "permissions", XA_PERM, CM_ARG|CM_PRE },
    { "perms",       XA_PERM, CM_ARG|CM_PRE|CM_INV },
#endif /* CK_PERM */
#endif /* NOXFER */
#ifdef UNIX
    { "privid",      XA_PRIV, CM_ARG|CM_PRE },
#endif /* UNIX */
#ifndef NOLOCAL
#ifndef NOCSETS
    { "rcharset",    XA_CSET, CM_ARG|CM_PRE|CM_INV },
#endif /* NOCSETS */
#endif /* NOLOCAL */
#ifdef UNIX
    { "root",        XA_ROOT, CM_ARG|CM_PRE },
#else /* UNIX */
#ifdef CKROOT
    { "root",        XA_ROOT, CM_ARG|CM_PRE },
#endif /* CKROOT */
#endif /* UNIX */
#ifdef KUI
    { "scalefont",   XA_SCALE, CM_PRE },
#endif /* KUI */
#ifdef COMMENT
#ifdef SSHBUILTIN
    { "ssh",         XA_SSH,  CM_ARG },
#endif /* SSHBUILTIN */
#endif /* COMMENT */
#ifdef CKSYSLOG
    { "syslog",      XA_SYSL, CM_ARG|CM_PRE },
#endif /* CKSYSLOG */
#ifndef NOLOCAL
#ifdef COMMENT
#ifdef TNCODE
    { "telnet",      XA_TEL,  CM_ARG },
#endif /* TNCODE */
#endif /* COMMENT */
    { "termtype",    XA_TERM, CM_ARG|CM_PRE },
#endif /* NOLOCAL */
    { "timeout",     XA_TIMO, CM_ARG|CM_PRE },
#ifndef NOLOCAL
#ifdef OS2
    { "title",       XA_TITL, CM_ARG },
#endif /* OS2 */
#ifdef UNIX
    { "unbuffered",  XA_UNBUF, 0 },
#endif	/* UNIX */
#ifndef NOSPL
    { "user",        XA_USER, CM_ARG },
#endif /* NOSPL */
#endif /* NOLOCAL */
    { "userfile",    XA_USFI, CM_ARG|CM_PRE },
    { "version",     XA_VERS, 0 },
#ifndef NOLOCAL
#ifdef OS2
    { "width",       XA_COLS, CM_ARG|CM_PRE },
#endif /* OS2 */
#endif /* NOLOCAL */
#ifdef CKWTMP
    { "wtmpfile",    XA_WTFI, CM_ARG|CM_PRE },
    { "wtmplog",     XA_WTMP, CM_ARG|CM_PRE },
#endif /* CKWTMP */
#endif /* CK_LOGIN */
    { "xferfile",    XA_IKFI, CM_ARG|CM_PRE },
    { "xferlog",     XA_IKLG, CM_ARG|CM_PRE },
#ifndef NOLOCAL
#ifdef KUI
    { "xpos",        XA_XPOS, CM_ARG|CM_PRE },
    { "ypos",        XA_YPOS, CM_ARG|CM_PRE },
#endif /* KUI */
#endif /* NOLOCAL */
    {"", 0, 0 }
};
int nxargs = sizeof(xargtab)/sizeof(struct keytab) - 1;

static struct keytab oktab[] = {
    { "0",     0, 0 },
    { "1",     1, 0 },
    { "2",     2, 0 },
    { "3",     3, 0 },
    { "4",     4, 0 },
    { "5",     5, 0 },
    { "6",     6, 0 },
    { "7",     7, 0 },
    { "8",     8, 0 },
    { "9",     9, 0 },
    { "false", 0, 0 },
    { "no",    0, 0 },
    { "off",   0, 0 },
    { "ok",    1, 0 },
    { "on",    1, 0 },
    { "true",  1, 0 },
    { "yes",   1, 0 }
};
static int noktab = sizeof(oktab)/sizeof(struct keytab);

#define XARGBUFL 32

char * xopthlp[XA_MAX+1];               /* Extended option help */
char * xarghlp[XA_MAX+1];               /* Extended argument for option */

static VOID
inixopthlp() {
    int i, j;
    for (i = 0; i <= XA_MAX; i++) {     /* Initialize all to null */
        xopthlp[i] = NULL;
        xarghlp[i] = NULL;
    }
    for (i = 0; i < nxargs; i++) {      /* Then for each defined keyword */
        j = xargtab[i].kwval;           /* index by associated value */
        if (j < 0 || j > XA_MAX)
          continue;
        switch (j) {
#ifdef CK_LOGIN
          case XA_ANON:                 /* "--anonymous" */
            xopthlp[j] = "--anonymous:{on,off} [IKSD only]";
            xarghlp[j] = "Whether to allow anonymous IKSD logins";
            break;
#ifdef UNIX
	  case XA_PRIV:
            xopthlp[j] = "--privid:{on,off} [IKSD only]";
            xarghlp[j] = "Whether to allow privileged IDs to login to IKSD";
            break;
#endif /* UNIX */
#endif /* CK_LOGIN */
          case XA_BAFI:                 /* "--bannerfile" */
            xopthlp[j] = "--bannerfile:<filename>";
            xarghlp[j] = "File to display upon startup or IKSD login";
            break;
          case XA_CDFI:                 /* "--cdfile" */
            xopthlp[j] = "--cdfile:<filename>";
            xarghlp[j] = "File to display when server changes directory";
            break;
          case XA_CDMS:                 /* "--cdmessage" */
            xopthlp[j] = "--cdmessage:{on,off}";
            xarghlp[j] = "Whether to display CD message file";
            break;
          case XA_HELP:                 /* "--help" */
            xopthlp[j] = "--help";
            xarghlp[j] = "Print this help text about extended options";
            break;
          case XA_HEFI:                 /* "--help" */
            xopthlp[j] = "--helpfile:<filename>";
            xarghlp[j] = "File containing custom info for HELP command";
            break;
          case XA_IKFI:                 /* "--xferfile" */
            xopthlp[j] = "--xferfile:<filename> [IKSD only]";
            xarghlp[j] = "Name of ftpd-like logfile.";
            break;
          case XA_IKLG:                 /* "--xferlog" */
            xopthlp[j] = "--xferlog:{on,off} [IKSD only]";
            xarghlp[j] = "Whether to keep an ftpd-like logfile.";
            break;
#ifdef CK_LOGIN
          case XA_ANFI:                 /* "--initfile" */
            xopthlp[j] = "--initfile:<filename> [IKSD only]";
            xarghlp[j] = "Initialization file for anonymous users.";
            break;
#ifdef CK_PERM
          case XA_PERM:                 /* "--permissions" */
            xopthlp[j] = "--permissions:<octalnum> [IKSD only]";
            xarghlp[j] = "Permissions for files uploaded by anonymous users.";
            break;
#endif /* CK_PERM */
#ifdef UNIX
          case XA_ROOT:                 /* "--root" */
            xopthlp[j] = "--root:<directory> [IKSD only]";
            xarghlp[j] = "File-system root for anonymous users.";
            break;
#else /* UNIX */
#ifdef CKROOT
          case XA_ROOT:                 /* "--root" */
            xopthlp[j] = "--root:<directory> [IKSD only]";
            xarghlp[j] = "File-system root for anonymous users.";
            break;
#endif /* CKROOT */
#endif /* UNIX */
#endif /* CK_LOGIN */
#ifdef CKSYSLOG
          case XA_SYSL:                 /* "--syslog" */
            xopthlp[j] = "--syslog:<digit> [IKSD only]";
            xarghlp[j] = "Syslog recording level, 0-6.";
            break;
#endif /* CKSYSLOG */
          case XA_USFI:                 /* "--userfile" */
            xopthlp[j] = "--userfile:<filename> [IKSD only]";
            xarghlp[j] = "Forbidden user file.";
            break;
#ifdef CKWTMP
          case XA_WTFI:                 /* "--wtmpfile" */
            xopthlp[j] = "--wtmpfile:<filename> [IKSD only]";
            xarghlp[j] = "Name of wtmp logfile.";
            break;
          case XA_WTMP:                 /* "--wtmplog" */
            xopthlp[j] = "--wtmplog:{on,off} [IKSD only]";
            xarghlp[j] = "Whether to keep a wtmp logfile.";
            break;
#endif /* CKWTMP */
#ifdef CK_LOGIN
          case XA_TIMO:                 /* "--timeout" */
            xopthlp[j] = "--timeout:<seconds> [IKSD only]";
            xarghlp[j] =
 "How long to wait for login before closing the connection.";
            break;
#endif /* CK_LOGIN */
          case XA_NOIN:
            xopthlp[j] = "--nointerrupts";
            xarghlp[j] = "Disable keyboard interrupts.";
            break;
#ifdef UNIX
          case XA_UNBUF:
            xopthlp[j] = "--unbuffered";
            xarghlp[j] = "Force unbuffered console i/o.";
            break;
#endif	/* UNIX */
#ifdef IKSDB
          case XA_DBAS:
            xopthlp[j] = "--database:{on,off}";
            xarghlp[j] = "Enable/Disable IKSD database (IKSD only)";
            break;
          case XA_DBFI:
            xopthlp[j] = "--dbfile:<filename>";
            xarghlp[j] = "Specify IKSD database file (IKSD only)";
            break;
#endif /* IKSDB */
#ifdef CK_PERMS
	  case XA_NPRM:
            xopthlp[j] = "--noperms";
            xarghlp[j] = "Disable file-transfer Permissions attribute.";
            break;
#endif /* CK_PERMS */
#ifdef KUI
          case XA_CHGD:
	    xopthlp[j] = "--changedim";
	    xarghlp[j] = "Change Dimension on Window Resize";
          case XA_SCALE:
	    xopthlp[j] = "--scalefont";
	    xarghlp[j] = "Scale Font on Window Resize";
          case XA_WMAX:
	    xopthlp[j] = "--maximize";
	    xarghlp[j] = "start K95G window maximized.";
	    break;
          case XA_WMIN:
	    xopthlp[j] = "--minimize";
	    xarghlp[j] = "start K95G window minimized.";
	    break;
	  case XA_XPOS:
	    xopthlp[j] = "--xpos:n";
	    xarghlp[j] = "X-coordinate of window position (number).";
	    break;
	  case XA_YPOS:
	    xopthlp[j] = "--ypos:n";
	    xarghlp[j] = "Y-coordinate of window position (number).";
	    break;
	  case XA_FNAM:
	    xopthlp[j] = "--fontname:s (or --facename:s)";
	    xarghlp[j] = "Font/typeface name: string with _ replacing blank.";
	    break;
	  case XA_FSIZ:
	    xopthlp[j] = "--fontsize:n";
	    xarghlp[j] = "Font point size (number).";
	    break;
          case XA_NOMN:
            xopthlp[j] = "--nomenubar";
            xarghlp[j] = "No Menu Bar";
            break;
          case XA_NOTB:
            xopthlp[j] = "--notoolbar";
            xarghlp[j] = "No Tool Bar";
            break;
          case XA_NOSB:
            xopthlp[j] = "--nostatusbar";
            xarghlp[j] = "No Status Bar";
            break;
          case XA_NOBAR:
            xopthlp[j] = "--nobars";
            xarghlp[j] = "No Menu, Status, or Tool Bars";
            break;
#endif /* KUI */
#ifndef NOPUSH
          case XA_NOPUSH:
	    xopthlp[j] = "--nopush";
	    xarghlp[j] = "Disable external command execution.";
	    break;
#endif /* NOPUSH */
#ifdef OS2
          case XA_LOCK:
	    xopthlp[j] = "--lockdown";
	    xarghlp[j] = "Enable all lockdown options.";
	    break;
          case XA_NOCLOSE:
            xopthlp[j] = "--noclose";
            xarghlp[j] = "Disable Close Window and Menu Exit.";
            break;
          case XA_NOSCROLL:
	    xopthlp[j] = "--noscroll";
	    xarghlp[j] = "Disable scrollback operations.";
	    break;
          case XA_NOESCAPE:
	    xopthlp[j] = "--noescape";
	    xarghlp[j] = "Disable escape from connect mode.";
	    break;
	  case XA_ROWS:
	    xopthlp[j] = "--height:n";
	    xarghlp[j] = "Screen height (number of rows).";
	    break;
	  case XA_COLS:
	    xopthlp[j] = "--width:n";
	    xarghlp[j] = "Screen width (number of columns).";
	    break;
          case XA_TITL:
            xopthlp[j] = "--title:string";
            xarghlp[j] = "Window Title.";
            break;
#endif /* OS2 */
	  case XA_CSET:
	    xopthlp[j] = "--rcharset:name";
	    xarghlp[j] = "Name of remote terminal character set.";
	    break;
	  case XA_TERM:
	    xopthlp[j] = "--termtype:name";
#ifdef OS2
	    xarghlp[j] = "Choose terminal emulation.";
#else
	    xarghlp[j] = "Choose terminal type.";
#endif /* OS2 */
	    break;
	  case XA_USER:
	    xopthlp[j] = "--user:name";
#ifndef NETCONN
	    xarghlp[j] = "Username (for network login)";
#else
	    xarghlp[j] = "Username.";
#endif /* NETCONN */
	    break;
       }
    }
}

VOID
iniopthlp() {
    int i;
    for (i = 0; i < 128; i++) {
        optact[i] = 0;
        switch(i) {
#ifdef OS2
          case '#':                     /* K95 Startup Flags */
            opthlp[i] = "Kermit 95 Startup Flags";
            arghlp[i] = "\n"\
              "   1 - turn off Win95 special fixes\n"\
              "   2 - do not load optional network dlls\n"\
              "   4 - do not load optional tapi dlls\n"\
              "   8 - do not load optional kerberos dlls\n"\
              "  16 - do not load optional zmodem dlls\n"\
              "  32 - use stdin for input instead of the console\n"\
              "  64 - use stdout for output instead of the console\n"\
              " 128 - do not terminate process in response to Session Logoff";
            break;
#endif /* OS2 */
          case '0':                     /* In the middle */
            opthlp[i] =
              "100% transparent CONNECT mode for \"in-the-middle\" operation";
            arghlp[i] = NULL;
            break;

          case '8':
            opthlp[i] = "Connection is 8-bit clean";
            arghlp[i] = NULL;
            break;

#ifdef NEWFTP
          case '9':
            opthlp[i] = "Make a connection to an FTP server";
            arghlp[i] = "IP-address-or-hostname[:optional-TCP-port]";
            break;
#endif /* NEWFTP */

#ifdef IKSD
          case 'A':
            opthlp[i] = "Kermit is to be started as an Internet service";
#ifdef NT
            arghlp[i] = "  socket handle of incoming connection";
#else /* NT */
            arghlp[i] = NULL;
#endif /* NT */
            break;
#endif /* IKSD */
          case 'B': opthlp[i] =
	  "Kermit is running in Batch or Background (no controlling terminal)";
            break;
#ifndef NOSPL
          case 'C':
            opthlp[i] = "Interactive-mode Commands to be executed";
            arghlp[i] = "Commands separated by commas, list in doublequotes";
            break;
#endif /* NOSPL */
          case 'D':
            opthlp[i] = "Delay before starting to send";
            arghlp[i] = "Number of seconds";
            break;
          case 'E':
            opthlp[i] = "Exit automatically when connection closes";
            arghlp[i] = NULL;
            break;
#ifdef TCPSOCKET
          case 'F':
            opthlp[i] = "Use an existing TCP connection";
            arghlp[i] = "Numeric file descriptor of open TCP connection";
            break;
#endif /* TCPSOCKET */
          case 'G':
            opthlp[i] = "GET from server, send to standard output";
            arghlp[i] = "Remote file specification";
            optact[i] = 1;
            break;
          case 'H':
            opthlp[i] = "Suppress program startup Herald and greeting";
            arghlp[i] = NULL;
            break;
          case 'I':
            opthlp[i] = "Connection is reliable, streaming is allowed";
            arghlp[i] = NULL;
            break;
#ifdef TCPSOCKET
          case 'J':
            opthlp[i] = "'Be like Telnet'";
            arghlp[i] = "IP hostname/address optionally followed by service";
            break;
#endif /* TCPSOCKET */
          case 'L':
            opthlp[i] = "Recursive directory descent for files in -s option";
            arghlp[i] = NULL;
            break;
          case 'M':
            opthlp[i] = "My user name (for use with Telnet, Rlogin, etc)";
            arghlp[i] = "Username string";
            break;
#ifdef NETBIOS
          case 'N':
            opthlp[i] = "NETBIOS adapter number";
            arghlp[i] = "Number";
            break;
#endif /* NETBIOS */
          case 'O':                     /* Be a server for One command only */
            opthlp[i] = "Be a server for One command only";
            arghlp[i] = NULL;
            optact[i] = 1;
            break;
          case 'P':
            opthlp[i] = "Don't convert file (Path) names";
            arghlp[i] = NULL;
            break;
          case 'Q':
            opthlp[i] = "Quick (FAST) Kermit protocol settings";
            arghlp[i] = NULL;
            break;
          case 'R':                     /* Remote-Only */
            opthlp[i] = "Remote-only (makes IF REMOTE true)";
            arghlp[i] = NULL;
            break;
          case 'S':                     /* "Stay" - enter interactive */
            opthlp[i] = "Stay (enter command parser after action options)";
            arghlp[i] = NULL;
            break;
          case 'T':                     /* Text file transfer mode */
            opthlp[i] = "Transfer files in Text mode";
            arghlp[i] = NULL;
            break;
#ifdef ANYX25
          case 'U':                     /* X.25 call user data */
            opthlp[i] = "X.25 call User data";
            arghlp[i] = "Call-user-data string";
            break;
#endif /* ANYX25 */
          case 'V':                     /* No automatic filetype switching */
            opthlp[i] = "Disable automatic per-file text/binary switching";
            arghlp[i] = NULL;
            break;
#ifdef COMMENT
#ifdef OS2
          case 'W':                     /* Win32 Window Handle */
            opthlp[i] = "";
            arghlp[i] = NULL;
            break;
#endif /* OS2 */
#endif /* COMMENT */
#ifdef ANYX25
          case 'X':                     /* SET HOST to X.25 address */
            opthlp[i] = "Make an X.25 connection";
            arghlp[i] = "X.25 or X.121 address";
            break;
#endif /* ANYX25 */
          case 'Y':                     /* No initialization file */
            opthlp[i] = "Skip initialization file";
            arghlp[i] = NULL;
            break;
#ifdef ANYX25
          case 'Z':                     /* SET HOST to X.25 file descriptor */
            opthlp[i] = "Make an X.25 connection";
            arghlp[i] = "Numeric file descriptor of open X.25 connection";
            break;
#endif /* ANYX25 */
          case 'a':                     /* as-name */
            opthlp[i] = "As-name for file(s) in -s, -r, or -g";
            arghlp[i] = "As-name string (alternative filename)";
            break;
          case 'b':                     /* Set bits-per-second for serial */
            opthlp[i] = "Speed for serial device";
            arghlp[i] = "Numeric Bits per second";
            break;
          case 'c':                     /* Connect before */
            optact[i] = 1;
            opthlp[i] = "CONNECT before transferring files";
            arghlp[i] = NULL;
            break;
          case 'd':                     /* DEBUG */
            opthlp[i] = "Create debug.log file (a second -d adds timestamps)";
            arghlp[i] = NULL;
            break;
          case 'e':                     /* Extended packet length */
            opthlp[i] = "Maximum length for incoming file-transfer packets";
            arghlp[i] = "Length in bytes";
            break;
          case 'f':                     /* finish */
            optact[i] = 1;
            opthlp[i] = "Send Finish command to a Kermit server";
            arghlp[i] = NULL;
            break;
          case 'g':                     /* get */
            optact[i] = 1;
            opthlp[i] = "GET file(s) from a Kermit server";
            arghlp[i] = "Remote file specification";
            break;
          case 'h':                     /* help */
            optact[i] = 1;
#ifdef OS2ORUNIX
            opthlp[i] =
	      "Print this message (pipe thru 'more' to prevent scrolling)";
#else
	      "Print this message";
#endif /* OS2ORUNIX */
            arghlp[i] = NULL;
            break;
          case 'i':                     /* Treat files as binary */
            opthlp[i] ="Transfer files in binary mode";
            arghlp[i] = NULL;
            break;
#ifdef TCPSOCKET
          case 'j':                     /* SET HOST (TCP/IP socket) */
            opthlp[i] = "Make a TCP connection";
            arghlp[i] =
	      "TCP host name/address and optional service name or number";
            break;
#endif /* TCPSOCKET */
          case 'k':                     /* receive to stdout */
            optact[i] = 1;
            opthlp[i] = "RECEIVE file(s) to standard output";
            arghlp[i] = NULL;
            break;
          case 'l':                     /* SET LINE */
            opthlp[i] = "Make connection on serial communications device";
            arghlp[i] = "Serial device name";
            break;
          case 'm':                     /* Modem type */
            opthlp[i] = "Modem type for use with -l device";
            arghlp[i] = "Modem name as in SET MODEM TYPE command";
            break;
          case 'n':                     /* connect after */
            optact[i] = 1;
            opthlp[i] = "CONNECT after transferring files";
            arghlp[i] = NULL;
            break;
#ifdef ANYX25
          case 'o':                     /* X.25 closed user group */
            opthlp[i] = "X.25 closed user group";
            arghlp[i] = "User group string";
            break;
#endif /* ANYX25 */
          case 'p':                     /* SET PARITY */
            opthlp[i] = "Parity";
            arghlp[i] = "One of the following: even, odd, mark, none, space";
            break;
          case 'q':                     /* Quiet */
            opthlp[i] = "Quiet (suppress most messages)";
            arghlp[i] = NULL;
            break;
          case 'r':                     /* receive */
            optact[i] = 1;
            opthlp[i] = "RECEIVE file(s)";
            arghlp[i] = NULL;
            break;
          case 's':                     /* send */
            optact[i] = 1;
            opthlp[i] = "SEND file(s)";
            arghlp[i] = "One or more file specifications";
            break;
          case 't':                     /* Line turnaround handshake */
            opthlp[i] = "XON Turnaround character for half-duplex connections";
            arghlp[i] = NULL;
            break;
#ifdef ANYX25
          case 'u':                     /* X.25 reverse charge call */
            opthlp[i] = "X.25 reverse charge call";
            arghlp[i] = NULL;
            break;
#endif /* ANYX25 */
          case 'v':                     /* Vindow size */
            opthlp[i] = "Window size";
            arghlp[i] = "Number, 1 to 32";
            break;
          case 'w':                     /* Writeover */
            opthlp[i] = "Incoming files Write over existing files";
            arghlp[i] = NULL;
            break;
          case 'x':                     /* Server */
            optact[i] = 1;
            opthlp[i] = "Be a Kermit SERVER";
            arghlp[i] = NULL;
            break;
          case 'y':                     /* Alternate init-file name */
            opthlp[i] = "Alternative initialization file";
            arghlp[i] = "File specification";
            break;
          case 'z':                     /* Not background */
            opthlp[i] = "Force foreground behavior";
            arghlp[i] = NULL;
            break;
          default:
            opthlp[i] = NULL;
            arghlp[i] = NULL;
        }
    }
    inixopthlp();
}

int
doxarg(s,pre) char ** s; int pre; {
#ifdef IKSD
#ifdef CK_LOGIN
    extern int ckxsyslog, ckxwtmp, ckxanon;
#ifdef UNIX
    extern int ckxpriv;
#endif /* UNIX */
#ifdef CK_PERMS
    extern int ckxperms;
#endif /* CK_PERMS */
    extern char * anonfile, * userfile, * anonroot;
#endif /* CK_LOGIN */
#ifdef CKWTMP
    extern char * wtmpfile;
#endif /* CKWTMP */
#endif /* IKSD */
    extern int srvcdmsg;
    extern char * cdmsgfile[], * cdmsgstr;
    char tmpbuf[CKMAXPATH+1];

    int i, x, y, z, havearg = 0;
    char buf[XARGBUFL], c, * p;

    if (nxargs < 1)
      return(-1);

    c = *(*s + 1);                      /* Hyphen or Plus sign */

    p = *s + 2;
    for (i = 0; *p && i < XARGBUFL; i++) {
        buf[i] = *p++;
        if (buf[i] == '=' || buf[i] == ':') {
            havearg = 1;
            buf[i] = NUL;
            break;
        } else if (buf[i] < ' ') {
            buf[i] = NUL;
            break;
        }
    }
    if (i > XARGBUFL - 1)
      return(-1);
    buf[i] = NUL;

    x = lookup(xargtab,buf,nxargs,&z);  /* Lookup the option keyword */

    if (x < 0)                          /* On any kind of error */
      return(-1);                       /* fail. */

    /* Handle prescan versus post-initialization file */

    if (((xargtab[z].flgs & CM_PRE) || (c == '+')) && !pre)
      return(0);
    else if (pre && !(xargtab[z].flgs & CM_PRE) && (c != '+'))
      return(0);

    /* Ensure that argument is given if and only if required */

    p = havearg ? *s + i + 3 : NULL;

    if ((xargtab[z].flgs & CM_ARG) && !havearg)
      return(-1);
    else if ((!(xargtab[z].flgs & CM_ARG)) && havearg)
      return(-1);

    switch (x) {                        /* OK to process this option... */
#ifdef CKSYSLOG
      case XA_SYSL:                     /* IKS: Syslog level */
        y = 0;
        if (isdigit(*p)) {
            while (*p) {
                if (*p < '0' || *p > '9')
                  return(-1);
                y = y * 10 + (*p++ - '0');
            }
        } else {
            y = lookup(oktab,p,noktab,&z);
            if (y > 0) y = SYSLG_DF;    /* Yes = default logging level */
        }
#ifndef SYSLOGLEVEL
        /* If specified on cc command line, user can't change it. */
        if (!inserver)                  /* Don't allow voluminous syslogging */
          if (y > SYSLG_FA)             /* by ordinary users. */
            y = SYSLG_FA;
#endif /* SYSLOGLEVEL */
        if (y < 0) return(-1);
#ifdef DEBUG
        if (y >= SYSLG_DB)
          if (!deblog)
            deblog = debopn("debug.log",0);
#endif /* DEBUG */
#ifdef SYSLOGLEVEL
        /* If specified on cc command line, user can't change it. */
        y = SYSLOGLEVEL;
#endif /* SYSLOGLEVEL */
        ckxsyslog = y;
        /* printf("ckxsyslog=%d\n",ckxsyslog); */
        break;
#endif /* CKSYSLOG */

#ifdef CK_LOGIN
#ifdef CKWTMP
      case XA_WTMP:                     /* IKS: wtmp log */
        y = lookup(oktab,p,noktab,&z);
        if (y < 0) return(-1);
        ckxwtmp = y;
        /* printf("ckxwtmp=%d\n",ckxwtmp); */
        break;

      case XA_WTFI:                     /* IKS: wtmp logfile */
        if (zfnqfp(p,CKMAXPATH,tmpbuf))
          p = tmpbuf;
        makestr(&wtmpfile,p);
        /* printf("wtmpfile=%s\n",wtmpfile); */
        break;
#endif /* CKWTMP */

      case XA_ANON:                     /* IKS: Anonymous login allowed */
        y = lookup(oktab,p,noktab,&z);
        if (y < 0) return(-1);
        ckxanon = y;
        /* printf("ckxanon=%d\n",ckxanon); */
        break;

#ifdef UNIX
      case XA_PRIV:                     /* IKS: Priv'd login allowed */
        y = lookup(oktab,p,noktab,&z);
        if (y < 0) return(-1);
        ckxpriv = y;
        /* printf("ckxpriv=%d\n",ckxpriv); */
        break;
#endif /* UNIX */

#ifdef CK_PERMS
      case XA_PERM:                     /* IKS: Anonymous Upload Permissions */
        y = 0;
        while (*p) {
            if (*p < '0' || *p > '7')
              return(-1);
            y = y * 8 + (*p++ - '0');
        }
        ckxperms = y;
        /* printf("ckxperms=%04o\n",ckxperms); */
        break;
#endif /* CK_PERMS */

      case XA_ANFI:                     /* Anonymous init file */
	if (!isabsolute(p))
	  if (zfnqfp(p,CKMAXPATH,tmpbuf))
	    p = tmpbuf;
        makestr(&anonfile,p);
        /* printf("anonfile=%s\n",anonfile); */
        break;

      case XA_USFI:                     /* IKS: Forbidden user file */
	if (!isabsolute(p))
	  if (zfnqfp(p,CKMAXPATH,tmpbuf))
	    p = tmpbuf;
        makestr(&userfile,p);
        /* printf("userfile=%s\n",userfile); */
        break;

      case XA_ROOT:                     /* IKS: Anonymous root */
	if (!isabsolute(p))
	  if (zfnqfp(p,CKMAXPATH,tmpbuf))
	    p = tmpbuf;
        makestr(&anonroot,p);
        /* printf("anonroot=%s\n",anonroot); */
        break;
#endif /* CK_LOGIN */

      case XA_CDFI:                     /* CD filename */
#ifdef COMMENT
        /* Do NOT expand this one! */
        if (zfnqfp(p,CKMAXPATH,tmpbuf))
          p = tmpbuf;
#endif /* COMMENT */
        makelist(p,cdmsgfile,16);
        makestr(&cdmsgstr,p);
        /* printf("cdmsgstr=%s\n",cdmsgstr); */
        break;

      case XA_CDMS:                     /* CD messages */
        y = lookup(oktab,p,noktab,&z);
        if (y < 0) return(-1);
        srvcdmsg = y;
        /* printf("srvcdmsg=%d\n",srvcdmsg); */
        break;

#ifndef NOXFER
      case XA_IKLG:                     /* Transfer log on/off */
        y = lookup(oktab,p,noktab,&z);
        if (y < 0) return(-1);
        xferlog = y;
        /* printf("xferlog=%d\n",xferlog); */
        break;

      case XA_IKFI:                     /* Transfer log file */
	if (!isabsolute(p))
	  if (zfnqfp(p,CKMAXPATH,tmpbuf))
	    p = tmpbuf;
        makestr(&xferfile,p);
        xferlog = 1;
        /* printf("xferfile=%s\n",xferfile); */
        break;

      case XA_BAFI:                     /* IKS: banner (greeting) file */
	if (!isabsolute(p))
	  if (zfnqfp(p,CKMAXPATH,tmpbuf))
	    p = tmpbuf;
        makestr(&bannerfile,p);
        /* printf("bannerfile=%s\n",bannerfile); */
        break;
#endif /* NOXFER */

#ifndef NOHELP
      case XA_HELP:                     /* Help */
        /* printf("help\n"); */
        for (i = 0; i <= XA_MAX; i++)
          if (xopthlp[i])
            printf("%s\n   %s\n\n",xopthlp[i],xarghlp[i]);
        if (stayflg || what == W_COMMAND)
          break;
        else
          doexit(GOOD_EXIT,-1);
#endif /* NOHELP */

#ifndef NOHELP
      case XA_HEFI:                     /* IKS: custom help file */
	if (!isabsolute(p))
	  if (zfnqfp(p,CKMAXPATH,tmpbuf))
	    p = tmpbuf;
        makestr(&helpfile,p);
        /* printf("helpfile=%s\n",helpfile); */
        break;
#endif /* NOHELP */

#ifdef CK_LOGIN
      case XA_TIMO:
        if (!rdigits(p))
          return(-1);
        logintimo = atoi(p);
        /* printf("logintimo=%d\n",p); */
        break;
#endif /* CK_LOGIN */

      case XA_NOIN:                     /* No interrupts */
#ifndef NOICP
        cmdint = 0;
#endif /* NOICP */
	xsuspend = 0;
        break;

#ifdef UNIX
      case XA_UNBUF:			/* Unbuffered console i/o*/
	break;				/* This one is handled in ckcmai.c */
#endif	/* UNIX */

#ifdef IKSDB
      case XA_DBFI: {
          extern char * dbdir, * dbfile;
          extern int dbenabled;
          struct zfnfp * zz;
          if ((zz = zfnqfp(p,CKMAXPATH,tmpbuf))) {
	      char *s, *s2 = NULL;
              makestr(&dbdir,zz->fpath);
              makestr(&dbfile,zz->fpath);
	      for (s = dbdir; *s; s++) {
		  if (ISDIRSEP(*s))
		    s2 = s+1;
	      }
	      if (s2) *s2 = NUL;
	      debug(F110,"XA_DBFI dbdir",dbdir,0);
	      debug(F110,"XA_DBFI dbfile",dbfile,0);
              dbenabled = 1;
          }
          break;
      }
      case XA_DBAS: {
          extern int dbenabled;
          y = lookup(oktab,p,noktab,&z);
          if (y < 0) return(-1);
          dbenabled = y;
          break;
      }
#endif /* IKSDB */

      case XA_VERS: {
	  extern char * ck_s_ver, * ck_s_xver;
	  printf("%s",ck_s_ver);
	  if (*ck_s_xver)
	    printf(" [%s]\n",ck_s_xver);
	  printf("\n");
	  if (stayflg || what == W_COMMAND)
	    break;
	  else
	    doexit(GOOD_EXIT,-1);
      }
#ifndef NOXFER
#ifdef CK_PERMS
      case XA_NPRM: {
	  extern int atlpri, atlpro, atgpri, atgpro;
	  atlpri = 0;
	  atlpro = 0;
	  atgpri = 0;
	  atgpro = 0;
	  break;
      }
#endif /* CK_PERMS */
#endif /* NOXFER */

#ifdef KUI
      case XA_SCALE:
        kui_init.resizeMode = 1;
        break;
      case XA_CHGD:
        kui_init.resizeMode = 2;
        break;
      case XA_WMAX:
        kui_init.nCmdShow = SW_MAXIMIZE;
        break;
      case XA_WMIN:
        kui_init.nCmdShow = SW_MINIMIZE;
        break;

      case XA_XPOS:
        if (!rdigits(p))
          return(-1);
	kui_init.pos_init++;
	kui_init.pos_x = atoi(p);
        break;

      case XA_YPOS:
        if (!rdigits(p))
          return(-1);
	kui_init.pos_init++;
	kui_init.pos_y = atoi(p);
        break;

      case XA_FNAM: {
	  extern struct _kui_init kui_init;
	  extern struct keytab * term_font;
	  extern struct keytab * _term_font;
	  extern int tt_font, ntermfont;
	  int x, z;
	  if (ntermfont == 0)
	    BuildFontTable(&term_font, &_term_font, &ntermfont);
	  if (!(term_font && _term_font && ntermfont > 0)) {
            printf("?Unable to construct Font Facename Table\n");
	    return(0);
          }
	  x = lookup(term_font,p,ntermfont,&z);
	  if (x < 0) {
              x = lookup(_term_font,p,ntermfont,&z);
              if (x < 0) {
                  printf("?Invalid Font Facename: %s\n",p);
                  return(0);
              }
          }
	  tt_font = x;
	  kui_init.face_init++;
	  makestr(&kui_init.facename,term_font[z].kwd);
	  break;
      }
      case XA_FSIZ: {
	  extern struct _kui_init kui_init;
	  extern int tt_font_size;
          char * q;
          int halfpoint = 0;

	  kui_init.font_init++;
          for ( q=p ; *q ; q++ ) {
              if ( *q == '.') {
                  *q++ = '\0';
                  if (!rdigits(q))
                      return(-1);
                  if (!*q || atoi(q) == 0)
                      break;    /* no halfpoint */
                  halfpoint = 1;
                  if (atoi(q) != 5)
                printf("? Font sizes are treated in half-point increments\n");
                  break;
              }
          }
	  if (!rdigits(p))
	    return(-1);
	  tt_font_size = kui_init.font_size = 2 * atoi(p) + halfpoint;
	  break;
      }
      case XA_NOMN:
        kui_init.nomenubar = 1;
        break;
      case XA_NOTB:
        kui_init.notoolbar = 1;
        break;
      case XA_NOSB:
        kui_init.nostatusbar = 1;
        break;
      case XA_NOBAR:
        kui_init.nomenubar = 1;
        kui_init.notoolbar = 1;
        kui_init.nostatusbar = 1;
        break;
#endif /* KUI */

#ifndef NOPUSH
    case XA_NOPUSH:
        nopush = 1;
        break;
#endif /* NOPUSH */
#ifdef OS2
    case XA_LOCK:
        tt_scroll = 0;
        tt_escape = 0;
#ifndef NOPUSH
        nopush = 1;
#endif
#ifdef KUI
        kui_init.nomenubar = 1;
        kui_init.notoolbar = 1;
        kui_init.nostatusbar = 1;
#endif
        break;
#ifdef KUI
      case XA_NOCLOSE:
        kui_init.noclose = 1;
        break;
#endif /* KUI */
      case XA_NOSCROLL:
        tt_scroll = 0;
        break;
      case XA_NOESCAPE:
        tt_escape = 0;
        break;
#endif /* OS2 */

#ifndef NOLOCAL
      case XA_TERM: {			/* Terminal type */
          extern struct keytab ttyptab[];
          extern int nttyp;
#ifdef TNCODE
	  extern char * tn_term;
#endif /* TNCODE */
#ifdef OS2
	  int x, z;
	  extern int tt_type, tt_type_mode;
	  x = lookup(ttyptab,p,nttyp,&z);
	  if (x < 0)
	    return(-1);
	  tt_type_mode = tt_type = x;
#endif /* OS2 */
#ifdef TNCODE
	  makestr(&tn_term,p);
#endif /* TNCODE */
	  break;
      }
      case XA_CSET: {			/* Remote Character Set */
#ifndef NOCSETS
#ifdef CKOUNI
          extern struct keytab txrtab[];
          extern int ntxrtab;
          x = lookup(txrtab,p,ntxrtab,&z);
#else /* CKOUNI */
          extern struct keytab ttcstab[];
          extern int ntermc;
          x = lookup(ttcstab,p,ntermc,&z);
#endif /* CKOUNI */
	  if (x < 0)
	    return(-1);
          setremcharset(z,4 /* TT_GR_ALL (in ckuus7.c) */);
#else /* NOCSETS */
          return(-1);
#endif /* NOCSETS */
	  break;
      }
      case XA_ROWS: {			/* Screen rows (height) */
#ifdef OS2
          extern int row_init;
#else /* OS2 */
	  extern int tt_rows;
#endif /* OS2 */
	  if (!rdigits(p))
	    return(-1);
#ifdef OS2
	  if (!os2_settermheight(atoi(p)))
	    return(-1);
          row_init++;
#else  /* Not OS/2 */
	  tt_rows = atoi(p);
#endif /* OS2 */
	  break;
      }
      case XA_COLS: {			/* Screen columns (width) */
#ifdef OS2
          extern int col_init;
#else /* OS2 */
	  extern int tt_cols;
#endif /* OS2 */
	  if (!rdigits(p))
	    return(-1);
#ifdef OS2
	  if (!os2_settermwidth(atoi(p)))
	    return(-1);
          col_init++;
#else  /* Not OS/2 */
	  tt_cols = atoi(p);
#endif /* OS2 */
	  break;
      }
#ifdef OS2
    case XA_TITL: {
        extern char usertitle[];
        ckstrncpy(usertitle,p,64);
        os2settitle("",1);
        break;
    }
#endif /* OS2 */

#ifdef COMMENT				/* TO BE FILLED IN ... */
      case XA_TEL:			/* Make a Telnet connection */
      case XA_FTP:			/* Make an FTP connection */
      case XA_SSH:			/* Make an SSH connection */
#endif /* COMMENT */

#ifndef NOSPL
      case XA_USER:			/* Username for login */
#ifdef IKSD
	if (!inserver)
#endif /* IKSD */
	{
	    ckstrncpy(uidbuf,*xargv,UIDBUFLEN);
	    haveftpuid = 1;
	}
	break;
#endif /* NOSPL */
#endif /* NOLOCAL */

      default:
        return(-1);
    }
    return(0);
}

#ifdef IKSD
#ifdef IKSDCONF
#define IKS_ANON 0
#define IKS_BAFI 1
#define IKS_CDFI 2
#define IKS_CDMS 3
#define IKS_HEFI 4
#define IKS_ANFI 5
#define IKS_USFI 6
#define IKS_IKLG 7
#define IKS_IKFI 8
#define IKS_DBAS 9
#define IKS_DBFI 10
#define IKS_PERM 11
#define IKS_PRIV 12
#define IKS_ROOT 13
#define IKS_TIMO 14
#define IKS_WTFI 15
#define IKS_WTMP 16
#define IKS_SRVR 17
#define IKS_NOIN 18
#define IKS_INIT 19
#define IKS_ANLG 20
#define IKS_ACCT 21
#define IKS_NTDOM 22
#define IKS_SYSL 23

#ifdef CK_LOGIN
static struct keytab iksantab[] = {
#ifdef OS2
    { "account",     IKS_ACCT, 0 },
#endif /* OS2 */
    { "initfile",    IKS_ANFI, 0 },
    { "login",       IKS_ANLG, 0 },
#ifdef UNIX
    { "root",        IKS_ROOT, 0 },
#else
#ifdef CKROOT
    { "root",        IKS_ROOT, 0 },
#endif /* CKROOT */
#endif /* UNIX */
    { "", 0, 0 }
};
static int niksantab = sizeof(iksantab) / sizeof(struct keytab) - 1;
#endif /* CK_LOGIN */

static struct keytab ikstab[] = {
#ifdef CK_LOGIN
    { "anonymous",   IKS_ANON, 0 },
#endif /* CK_LOGIN */
    { "bannerfile",  IKS_BAFI, 0 },
    { "cdfile",      IKS_CDFI, 0 },
    { "cdmessage",   IKS_CDMS, 0 },
    { "cdmsg",       IKS_CDMS, CM_INV },
#ifdef IKSDB
    { "database",    IKS_DBAS, 0 },
    { "dbfile",      IKS_DBFI, 0 },
#endif /* IKSDB */
#ifdef CK_LOGIN
#ifdef NT
    { "default-domain", IKS_NTDOM, 0 },
#endif /* NT */
#endif /* CK_LOGIN */
#ifndef NOHELP
    { "helpfile",    IKS_HEFI, 0 },
#endif /* NOHELP */
    { "initfile",    IKS_INIT, 0 },
    { "no-initfile", IKS_NOIN, 0 },
#ifdef CK_LOGIN
#ifdef CK_PERM
    { "permissions", IKS_PERM, 0 },
    { "perms",       IKS_PERM, CM_INV },
#endif /* CK_PERM */
#ifdef UNIX
    { "privid",      IKS_PRIV, 0 },
#endif /* UNIX */
    { "server-only", IKS_SRVR, 0 },
#ifdef CKSYSLOG
    { "syslog",      IKS_SYSL, 0 },
#endif /* CKSYSLOG */
    { "timeout",     IKS_TIMO, 0 },
    { "userfile",    IKS_USFI, 0 },
#ifdef CKWTMP
    { "wtmpfile",    IKS_WTFI, 0 },
    { "wtmplog",     IKS_WTMP, 0 },
#endif /* CKWTMP */
#endif /* CK_LOGIN */
    { "xferfile",    IKS_IKFI, 0 },
    { "xferlog",     IKS_IKLG, 0 }
};
static int nikstab = sizeof(ikstab) / sizeof(struct keytab);
#endif /* IKSDCONF */

#ifndef NOICP
int
setiks() {				/* SET IKS */
#ifdef IKSDCONF
#ifdef CK_LOGIN
    extern int ckxsyslog, ckxwtmp, ckxanon;
#ifdef UNIX
    extern int ckxpriv;
#endif /* UNIX */
#ifdef CK_PERMS
    extern int ckxperms;
#endif /* CK_PERMS */
    extern char * anonfile, * userfile, * anonroot;
#ifdef OS2
    extern char * anonacct;
#endif /* OS2 */
#ifdef NT
    extern char * iks_domain;
#endif /* NT */
#endif /* CK_LOGIN */
#ifdef CKWTMP
    extern char * wtmpfile;
#endif /* CKWTMP */
    extern int srvcdmsg, success, iksdcf, rcflag, noinit, arg_x;
    extern char * cdmsgfile[], * cdmsgstr, *kermrc;
    extern xx_strp xxstring;
    int x, y, z;
    char *s;
    char tmpbuf[CKMAXPATH+1];

    if ((y = cmkey(ikstab,nikstab,"","",xxstring)) < 0)
      return(y);

#ifdef CK_LOGIN
    if (y == IKS_ANON) {
        if ((y = cmkey(iksantab,niksantab,"","",xxstring)) < 0)
	  return(y);
    }
#endif /* CK_LOGIN */

    switch (y) {
#ifdef CKSYSLOG
      case IKS_SYSL:                     /* IKS: Syslog level */
        if ((z = cmkey(oktab,noktab,"","",xxstring)) < 0)
	  return(z);
        if ((x = cmcfm()) < 0) return(x);
        if (iksdcf) return(success = 0);
#ifndef SYSLOGLEVEL
        /* If specified on cc command line, user can't change it. */
        if (!inserver)                  /* Don't allow voluminous syslogging */
          if (y > SYSLG_FA)             /* by ordinary users. */
            y = SYSLG_FA;
#endif /* SYSLOGLEVEL */
        if (y < 0) return(-1);
#ifdef DEBUG
        if (y >= SYSLG_DB)
          if (!deblog)
            deblog = debopn("debug.log",0);
#endif /* DEBUG */
#ifdef SYSLOGLEVEL
        /* If specified on cc command line, user can't change it. */
        y = SYSLOGLEVEL;
#endif /* SYSLOGLEVEL */
        ckxsyslog = y;
        /* printf("ckxsyslog=%d\n",ckxsyslog); */
        break;
#endif /* CKSYSLOG */

#ifdef CK_LOGIN
#ifdef NT
      case IKS_NTDOM:
        if ((z = cmtxt(
 "DOMAIN to be used for user authentication when none is specified",
                       "", &s,xxstring)) < 0)
	  return(z);
        if (iksdcf) return(success = 0);
        if (!*s) s= NULL;
          makestr(&iks_domain,s);
        break;
#endif /* NT */
#ifdef OS2
      case IKS_ACCT:
        if ((z = cmtxt("Name of local account to use for anonymous logins",
			"GUEST", &s,xxstring)) < 0)
	  return(z);
        if (iksdcf) return(success = 0);
        if (*s) {
            makestr(&anonacct,s);
        } else if ( anonacct ) {
	    free(anonacct);
	    anonacct = NULL;
	}
        break;
#endif /* OS2 */
      case IKS_ANLG:
        if ((z = cmkey(oktab,noktab,"","no",xxstring)) < 0)
	  return(z);
        if ((x = cmcfm()) < 0) return(x);
        if (iksdcf) return(success = 0);
        ckxanon = z;
#ifdef OS2
	if (ckxanon && !anonacct)
	  makestr(&anonacct,"GUEST");
#endif /* OS2 */
        break;
#endif /* CK_LOGIN */
      case IKS_BAFI:
        if ((z = cmifi("Filename","",&s,&x,xxstring)) < 0)
	  return(z);
        if (x) {
            printf("?Wildcards not allowed\n");
            return(-9);
        }
        debug(F110,"bannerfile before zfnqfp()",s,0);
        if (zfnqfp(s,CKMAXPATH,tmpbuf)) {
            debug(F110,"bannerfile after zfnqfp()",tmpbuf,0);
            s = tmpbuf;
        }
        if ((x = cmcfm()) < 0) return(x);
        if (iksdcf) return(success = 0);
        if (*s)
	  makestr(&bannerfile,s);
        break;
      case IKS_CDFI:
        if ((z = cmtxt("list of cd message file names","READ.ME",
		       &s,xxstring)) < 0)
	  return(z);
        if (iksdcf) return(success = 0);
        if (*s) {
            makelist(s,cdmsgfile,16);
            makestr(&cdmsgstr,s);
        }
        break;
      case IKS_CDMS:
        if ((z = cmkey(oktab,noktab,"","no",xxstring)) < 0)
	  return(z);
        if ((x = cmcfm()) < 0) return(x);
        if (iksdcf) return(success = 0);
        srvcdmsg = z;
        break;
      case IKS_HEFI:
        if ((z = cmifi("Filename","",&s,&x,xxstring)) < 0)
	  return(z);
        if (x) {
            printf("?Wildcards not allowed\n");
            return(-9);
        }
        if (zfnqfp(s,CKMAXPATH,tmpbuf))
          s = tmpbuf;
        if ((x = cmcfm()) < 0) return(x);
        if (iksdcf) return(success = 0);
        if (*s)
	  makestr(&helpfile,s);
        break;
      case IKS_ANFI:
        if ((z = cmifi("Filename","",&s,&x,xxstring)) < 0)
	  return(z);
        if (x) {
            printf("?Wildcards not allowed\n");
            return(-9);
        }
        if (zfnqfp(s,CKMAXPATH,tmpbuf))
          s = tmpbuf;
        if ((x = cmcfm()) < 0) return(x);
        if (iksdcf) return(success = 0);
        if (*s)
	  makestr(&anonfile,s);
        break;
      case IKS_USFI:
        if ((z = cmifi("Filename","",&s,&x,xxstring)) < 0)
	  return(z);
        if (x) {
            printf("?Wildcards not allowed\n");
            return(-9);
        }
        if (zfnqfp(s,CKMAXPATH,tmpbuf))
          s = tmpbuf;
        if ((x = cmcfm()) < 0) return(x);
        if (iksdcf) return(success = 0);
        if (*s)
	  makestr(&userfile,s);
        break;
      case IKS_IKFI:
        if ((z = cmifi("Filename","",&s,&x,xxstring)) < 0)
	  return(z);
        if (x) {
            printf("?Wildcards not allowed\n");
            return(-9);
        }
        if (zfnqfp(s,CKMAXPATH,tmpbuf))
          s = tmpbuf;
        if ((x = cmcfm()) < 0) return(x);
        if (iksdcf) return(success = 0);
        if (*s) {
            makestr(&xferfile,s);
            xferlog = 1;
        }
        break;
      case IKS_IKLG:
        if ((z = cmkey(oktab,noktab,"","no",xxstring)) < 0)
	  return(z);
        if ((x = cmcfm()) < 0) return(x);
        if (iksdcf) return(success = 0);
        xferlog = z;
        break;

#ifdef CK_LOGIN
#ifdef CK_PERM
      case IKS_PERM:
        if ((z = cmtxt("Octal file permssion code","000",
		       &s,xxstring)) < 0)
	  return(z);
	if (z < 0) return(z);
        if (iksdcf) return(success = 0);
        y = 0;
        while (*s) {
            if (*s < '0' || *s > '7')
              return(-9);
            y = y * 8 + (*s++ - '0');
        }
        ckxperms = y;
        break;
#endif /* CK_PERM */
#ifdef UNIX
      case IKS_PRIV:                     /* IKS: Priv'd login allowed */
        if ((z = cmkey(oktab,noktab,"","no",xxstring)) < 0)
	  return(z);
        if ((x = cmcfm()) < 0) return(x);
        if (iksdcf) return(success = 0);
        ckxpriv = z;
        break;
#endif /* UNIX */

      case IKS_ROOT:                     /* IKS: Anonymous root */
	if ((z = cmdir("Name of disk and/or directory","",&s,
		       xxstring)) < 0 ) {
	    if (z != -3)
	      return(z);
	}
        if (*s) {
	    if (zfnqfp(s,CKMAXPATH,tmpbuf))
	      s = tmpbuf;
        } else
	  s = "";
        if ((x = cmcfm()) < 0) return(x);
        if (iksdcf) return(success = 0);
        if (*s)
	  makestr(&anonroot,s);
        /* printf("anonroot=%s\n",anonroot); */
        break;

      case IKS_TIMO:
	z = cmnum("login timeout, seconds","0",10,&x,xxstring);
	if (z < 0) return(z);
        if (x < 0 || x > 7200) {
            printf("?Value must be between 0 and 7200\r\n");
            return(-9);
        }
        if ((z = cmcfm()) < 0) return(z);
        if (iksdcf) return(success = 0);
        logintimo = x;
        break;

#ifdef CKWTMP
      case IKS_WTMP:                     /* IKS: wtmp log */
        if ((z = cmkey(oktab,noktab,"","no",xxstring)) < 0)
	  return(z);
        if ((x = cmcfm()) < 0) return(x);
        if (iksdcf) return(success = 0);
        ckxwtmp = z;
        break;

      case IKS_WTFI:                     /* IKS: wtmp logfile */
        if ((z = cmifi("Filename","",&s,&x,xxstring)) < 0)
	  return(z);
        if (x) {
            printf("?Wildcards not allowed\n");
            return(-9);
        }
        if (zfnqfp(s,CKMAXPATH,tmpbuf))
          s = tmpbuf;
        if ((x = cmcfm()) < 0) return(x);
        if (iksdcf) return(success = 0);
        if (*s)
	  makestr(&wtmpfile,s);
        break;
#endif /* CKWTMP */
#endif /* CK_LOGIN */
#ifdef IKSDB
      case IKS_DBFI: {
          extern char * dbdir, * dbfile;
          extern int dbenabled;
          struct zfnfp * zz;
          if ((z = cmifi("Filename","",&s,&x,xxstring)) < 0)
	    return(z);
          if (x) {
              printf("?Wildcards not allowed\n");
              return(-9);
          }
          zz = zfnqfp(s,CKMAXPATH,tmpbuf);
          if ((x = cmcfm()) < 0) return(x);
          if (iksdcf) return(success = 0);
          if (zz) {
              makestr(&dbdir,zz->fpath);
              makestr(&dbfile,(char *)tmpbuf);
              dbenabled = 1;
          } else
	    return(success = 0);
          break;
      }
      case IKS_DBAS: {
          extern int dbenabled;
          if ((z = cmkey(oktab,noktab,"","no",xxstring)) < 0)
	    return(z);
          if ((x = cmcfm()) < 0) return(x);
          if (iksdcf) return(success = 0);
          dbenabled = z;
          break;
      }
#endif /* IKSDB */

      case IKS_INIT:
        if ((z = cmtxt("Alternate init file specification","",
		       &s,xxstring)) < 0)
	  return(z);
        if (z < 0) return(z);
        if (iksdcf) return(success = 0);
        ckstrncpy(kermrc,s,KERMRCL);
        rcflag = 1;			/* Flag that this has been done */
        break;

      case IKS_NOIN:
        if ((z = cmkey(oktab,noktab,"","no",xxstring)) < 0)
	  return(z);
        if ((x = cmcfm()) < 0) return(x);
        if (iksdcf) return(success = 0);
        noinit = z;
        break;

      case IKS_SRVR:
        if ((z = cmkey(oktab,noktab,"","no",xxstring)) < 0)
	  return(z);
        if ((x = cmcfm()) < 0) return(x);
        if (iksdcf) return(success = 0);
        arg_x = z;
        break;

      default:
        return(-9);
    }
    return(success = (inserver ? 1 : 0));
#else /* IKSDCONF */
    if ((x = cmcfm()) < 0)
      return(x);
    return(success = 0);
#endif /* IKSDCONF */
}
#endif /* NOICP */
#endif /* IKSD */

/*  D O A R G  --  Do a command-line argument.  */

int
#ifdef CK_ANSIC
doarg(char x)
#else
doarg(x) char x;
#endif /* CK_ANSIC */
/* doarg */ {
    int i, n, y, z, xx; long zz; char *xp;

#ifdef NETCONN
extern char *line, *tmpbuf;             /* Character buffers for anything */
#endif /* NETCONN */

#ifdef IKSD
    /* Internet Kermit Server set some way besides -A... */
    if (inserver)
      dofast();
#endif /* IKSD */

    xp = *xargv+1;                      /* Pointer for bundled args */
    debug(F111,"doarg entry",xp,xargc);
    while (x) {
        debug(F000,"doarg arg","",x);
        switch (x) {                    /* Big switch on arg */

#ifndef COMMENT
	  case '-':			/* Extended commands... */
	    if (doxarg(xargv,0) < 0) {
		XFATAL("Extended option error");
	    } /* Full thru... */
	  case '+':			/* Extended command for prescan() */
	    return(0);
#else  /* NOICP */
	  case '-':
	  case '+':
	    XFATAL("Extended options not configured");
#endif /* NOICP */

#ifndef NOSPL
	  case 'C': {			/* Commands for parser */
	      char * s;
	      xargv++, xargc--;
	      if ((xargc < 1) || (**xargv == '-')) {
		  XFATAL("No commands given for -C");
	      }
	      s = *xargv;		/* Get the argument (must be quoted) */
	      if (!*s)			/* If empty quotes */
		s = NULL;		/* ignore this option */
	      if (s) {
		  makestr(&clcmds,s);	/* Make pokeable copy */
		  s = clcmds;		/* Change tabs to spaces */
		  while (*s) {
		      if (*s == '\t') *s = ' ';
		      s++;
		  }
	      }
	      break;
	  }
#endif /* NOSPL */

#ifndef NOXFER
	  case 'D':			/* Delay */
	    if (*(xp+1)) {
		XFATAL("invalid argument bundling");
	    }
	    xargv++, xargc--;
	    if ((xargc < 1) || (**xargv == '-')) {
		XFATAL("missing delay value");
	    }
	    z = atoi(*xargv);		/* Convert to number */
	    if (z > -1)			/* If in range */
	      ckdelay = z;		/* set it */
	    else {
		XFATAL("bad delay value");
	    }
	    break;
#endif /* NOXFER */

	  case 'E':			/* Exit on close */
#ifdef NETCONN
	    tn_exit = 1;
#endif /* NETCONN */
	    exitonclose = 1;
	    break;

#ifndef NOICP
	  case 'S':			/* "Stay" - enter interactive */
	    stayflg = 1;		/* command parser after executing */
	    xfinish = 0;		/* command-line actions. */
	    break;
#endif /* NOICP */

	  case 'T':			/* File transfer mode = text */
	    binary = XYFT_T;
	    xfermode = XMODE_M;		/* Transfer mode manual */
	    filepeek = 0;
#ifdef PATTERNS
	    patterns = 0;
#endif /* PATTERNS */
	    break;

	  case '7':
	    break;

#ifdef IKSD
	  case 'A': {			/* Internet server */
	      /* Already done in prescan() */
	      /* but implies 'x' &&  'Q'   */
#ifdef OS2
	      char * p;
	      if (*(xp+1)) {
		  XFATAL("invalid argument bundling");
	      }
#ifdef NT
	      /* Support for Pragma Systems Telnet/Terminal Servers */
	      p = getenv("PRAGMASYS_INETD_SOCK");
	      if (!(p && atoi(p) != 0)) {
		  xargv++, xargc--;
		  if (xargc < 1 || **xargv == '-') {
		      XFATAL("missing socket handle");
		  }
	      }
#else /* NT */
	      xargv++, xargc--;
	      if (xargc < 1 || **xargv == '-') {
		  XFATAL("missing socket handle");
	      }
#endif /* NT */
#endif /* OS2 */
#ifdef NOICP                            /* If no Interactive Command Parser */
	      action = 'x';		/* -A implies -x. */
#endif /* NOICP */
#ifndef NOXFER
	      dofast();
#endif /* NOXFER */
	      break;
	  }
#endif /* IKSD */

#ifndef NOXFER
	  case 'Q':			/* Quick (i.e. FAST) */
	    dofast();
	    break;
#endif /* NOXFER */

	  case 'R':			/* Remote-Only */
	    break;			/* This is handled in prescan(). */

#ifndef NOSERVER
	  case 'x':			/* server */
	  case 'O':			/* (for One command only) */
	    if (action) {
		XFATAL("conflicting actions");
	    }
	    if (x == 'O') justone = 1;
	    xfinish = 1;
	    action = 'x';
	    break;
#endif /* NOSERVER */

#ifndef NOXFER
	  case 'f':			/* finish */
	    if (action) {
		XFATAL("conflicting actions");
	    }
	    action = setgen('F',"","","");
	    break;
#endif /* NOXFER */

	  case 'r': {			/* receive */
	      if (action) {
		  XFATAL("conflicting actions");
	      }
	      action = 'v';
	      break;
	  }

#ifndef NOXFER
	  case 'k':			/* receive to stdout */
	    if (action) {
		XFATAL("conflicting actions");
	    }
	    stdouf = 1;
	    action = 'v';
	    break;

	  case 's': {			/* send */
	      int fil2snd, rc;
	      if (!recursive)
	      nolinks = 0;		/* Follow links by default */

	      if (action) {
		  XFATAL("conflicting actions");
	      }
	      if (*(xp+1)) {
		  XFATAL("invalid argument bundling after -s");
	      }
	      nfils = 0;		/* Initialize file counter */
	      fil2snd = 0;		/* Assume nothing to send  */
	      z = 0;			/* Flag for stdin */
	      cmlist = xargv + 1;	/* Remember this pointer */
	      while (++xargv, --xargc > 0) { /* Traverse the list */
#ifdef PIPESEND
		  if (usepipes && protocol == PROTO_K && **xargv == '!') {
		      cmarg = *xargv;
		      cmarg++;
		      debug(F110,"doarg pipesend",cmarg,0);
		      nfils = -1;
		      z = 1;
		      pipesend = 1;
		  } else
#endif /* PIPESEND */
		    if (**xargv == '-') { /* Check for sending stdin */
			if (strcmp(*xargv,"-") != 0) /* next option? */
			  break;
			z++;		/* "-" alone means send from stdin. */
#ifdef RECURSIVE
		    } else if (!strcmp(*xargv,".")) {
			fil2snd = 1;
			nfils++;
			recursive = 1;
			nolinks = 2;
#endif /* RECURSIVE */
		    } else /* Check if file exists */
		      if ((rc = zchki(*xargv)) > -1 || (rc == -2)) {
			  if  (rc != -2)
			    fil2snd = 1;
			  nfils++;	/* Bump file counter */
		      } else if (iswild(*xargv) && nzxpand(*xargv,0) > 0) {
		      /* or contains wildcard characters matching real files */
			  fil2snd = 1;
			  nfils++;
		      } else {
			  if (!failmsg)
			    failmsg = (char *)malloc(2000);
			  if (failmsg) {
			      ckmakmsg(failmsg,2000,
#ifdef VMS
				       "%CKERMIT-E-SEARCHFAIL "
#else
				       "kermit -s "
#endif	/* VMS */
				       ,
				       *xargv,
				       ": ",
				       ck_errstr()
				       );
			  }
		      }
	      }
	      xargc++, xargv--;		/* Adjust argv/argc */
	      if (!fil2snd && z == 0) {
		  if (!failmsg) {
#ifdef VMS
		      failmsg = "%CKERMIT-E-SEARCHFAIL, no files for -s";
#else
		      failmsg = "No files for -s";
#endif /* VMS */
		  }
		  XFATAL(failmsg);
	      }
	      if (z > 1) {
		  XFATAL("kermit -s: too many -'s");
	      }
	      if (z == 1 && fil2snd) {
		  XFATAL("invalid mixture of filenames and '-' in -s");
	      }
	      debug(F101,"doarg s nfils","",nfils);
	      debug(F101,"doarg s z","",z);
	      if (nfils == 0) {		/* no file parameters were specified */
		  if (is_a_tty(0)) {	/* (used to be is_a_tty(1) - why?) */
		      XFATAL("sending from terminal not allowed");
		  } else stdinf = 1;
	      }
	      debug(F101,"doarg s stdinf","",stdinf);
	      debug(F111,"doarg",*xargv,nfils);
	      action = 's';
	      break;
	  }

	  case 'g':			/* get */
	  case 'G':			/* get to stdout */
	    if (action) {
		XFATAL("conflicting actions");
	    }
	    if (*(xp+1)) {
		XFATAL("invalid argument bundling after -g");
	    }
	    xargv++, xargc--;
	    if ((xargc == 0) || (**xargv == '-')) {
		XFATAL("missing filename for -g");
	    }
	    if (x == 'G') stdouf = 1;
	    cmarg = *xargv;
	    action = 'r';
	    break;
#endif /* NOXFER */

#ifndef NOLOCAL
	  case 'c':			/* connect before */
	    cflg = 1;
	    break;

	  case 'n':			/* connect after */
	    cnflg = 1;
	    break;
#endif /* NOLOCAL */

	  case 'h':			/* help */
	    usage();
#ifndef NOICP
	    if (stayflg || what == W_COMMAND)
	      break;
	    else
#endif /* NOICP */
	      doexit(GOOD_EXIT,-1);

#ifndef NOXFER
	  case 'a':			/* "as" */
	    if (*(xp+1)) {
		XFATAL("invalid argument bundling after -a");
	    }
	    xargv++, xargc--;
	    if ((xargc < 1) || (**xargv == '-')) {
		XFATAL("missing name in -a");
	    }
	    cmarg2 = *xargv;
	    debug(F111,"doarg a",cmarg2,xargc);
	    break;
#endif /* NOXFER */

#ifndef NOICP
	  case 'Y':			/* No initialization file */
	    noinit = 1;
	    break;

	  case 'y':			/* Alternate init-file name */
	    noinit = 0;
	    if (*(xp+1)) {
		XFATAL("invalid argument bundling after -y");
	    }
	    xargv++, xargc--;
	    if (xargc < 1) {
		XFATAL("missing filename in -y");
	    }
	    /* strcpy(kermrc,*xargv); ... already done in prescan()... */
	    break;
#endif /* NOICP */

#ifndef NOXFER
	  case 'I':			/* Assume we have an "Internet" */
	    reliable = 1;		/* or other reliable connection */
	    xreliable = 1;
	    setreliable = 1;

	    /* I'm not so sure about this -- what about VMS? (next comment) */
	    clearrq = 1;		/* therefore the channel is clear */

#ifndef VMS
/*
  Since this can trigger full control-character unprefixing, we need to
  ensure that our terminal or pty driver is not doing Xon/Xoff; otherwise
  we can become deadlocked the first time we receive a file that contains
  Xoff.
*/
	    flow = FLO_NONE;
#endif /* VMS */
	    break;
#endif /* NOXFER */

#ifndef NOLOCAL
	  case 'l':			/* SET LINE */
#ifdef NETCONN
#ifdef ANYX25
	  case 'X':			/* SET HOST to X.25 address */
#ifdef SUNX25
	  case 'Z':			/* SET HOST to X.25 file descriptor */
#endif /* SUNX25 */
#endif /* ANYX25 */
#ifdef TCPSOCKET
	  case 'J':
	  case 'j':			/* SET HOST (TCP/IP socket) */
#endif /* TCPSOCKET */
#endif /* NETCONN */
#ifndef NOXFER
	    if (x == 'j' || x == 'J' || x == 'X' || x == 'Z') {
		reliable = 1;		/* or other reliable connection */
		xreliable = 1;
		setreliable = 1;
	    }
#endif /* NOXFER */
	    network = 0;
	    if (*(xp+1)) {
		XFATAL("invalid argument bundling after -l or -j");
	    }
	    xargv++, xargc--;
	    if ((xargc < 1) || (**xargv == '-')) {
		XFATAL("communication line device name missing");
	    }

#ifdef NETCONN
	    if (x == 'J') {
		cflg    = 1;		/* Connect */
		stayflg = 1;		/* Stay */
		tn_exit = 1;		/* Telnet-like exit condition */
		exitonclose = 1;
	    }
#endif /* NETCONN */
	    ckstrncpy(ttname,*xargv,TTNAMLEN+1);
	    local = (strcmp(ttname,CTTNAM) != 0);
	    if (local && strcmp(ttname,"0") == 0)
	      local = 0;
/*
  NOTE: We really do not need to call ttopen here, since it should be called
  again later, automatically, when we first try to condition the device via
  ttpkt or ttvt.  Calling ttopen here has the bad side effect of making the
  order of the -b and -l options significant when the order of command-line
  options should not matter.  However, the network cases immediately below
  complicate matters a bit, so we'll settle this in a future edit.
*/
	    if (x == 'l') {
		if (ttopen(ttname,&local,mdmtyp,0) < 0) {
		    XFATAL("can't open device");
		}
#ifdef CKLOGDIAL
		dologline();
#endif /* CKLOGDIAL */
		debug(F101,"doarg speed","",speed);
		cxtype = (mdmtyp > 0) ? CXT_MODEM : CXT_DIRECT;
		speed = ttgspd();	/* Get the speed. */
		setflow();		/* Do something about flow control. */
#ifndef NOSPL
		if (local) {
		    if (nmac) {		/* Any macros defined? */
			int k;		/* Yes */
			k = mlook(mactab,"on_open",nmac); /* Look this up */
			if (k >= 0) {	/* If found, */
			    if (dodo(k,ttname,0) > -1) /* set it up, */
			      parser(1); /* and execute it */
			}
		    }
		}
#endif /* NOSPL */

#ifdef NETCONN
	    } else {
		if (x == 'j' || x == 'J') { /* IP network host name */
		    char * s = line;
		    char * service = tmpbuf;
		    if (xargc > 0) {	/* Check if it's followed by */
			/* A service name or number */
			if (*(xargv+1) && *(*(xargv+1)) != '-') {
			    xargv++, xargc--;
			    ckstrncat(ttname,":",TTNAMLEN+1);
			    ckstrncat(ttname,*xargv,TTNAMLEN+1);
			}
		    }
		    nettype = NET_TCPB;
		    mdmtyp = -nettype;	/* Perhaps already set in init file */
		    telnetfd = 1;	/* Or maybe an open file descriptor */
		    ckstrncpy(line, ttname, LINBUFSIZ); /* Working copy */
		    for (s = line; *s != NUL && *s != ':'; s++);
		    if (*s) {
			*s++ = NUL;
			ckstrncpy(service, s, TMPBUFSIZ);
		    } else *service = NUL;
		    s = line;
#ifndef NODIAL
#ifndef NOICP
		    /* Look up in network directory */
		    x = 0;
		    if (*s == '=') {	/* If number starts with = sign */
			s++;		/* strip it */
			while (*s == SP) /* and also any leading spaces */
			  s++;
			ckstrncpy(line,s,LINBUFSIZ); /* Do this again. */
			nhcount = 0;
		    } else if (!isdigit(line[0])) {
/*
  nnetdir will be greater than 0 if the init file has been processed and it
  contained a SET NETWORK DIRECTORY command.
*/
			xx = 0;		/* Initialize this */
			if (nnetdir > 0) /* If there is a directory... */
			  xx = lunet(line); /* Look up the name */
			else		/* If no directory */
			  nhcount = 0;	/* we didn't find anything there */
			if (xx < 0) {	/* Lookup error: */
			    ckmakmsg(tmpbuf,
				     TMPBUFSIZ,
				    "?Fatal network directory lookup error - ",
				     line,
				     "\n",
				     NULL
				     );
			    XFATAL(tmpbuf);
			}
		    }
#endif /* NOICP */
#endif /* NODIAL */
		    /* Add service to line specification for ttopen() */
		    if (*service) {	/* There is a service specified */
			ckstrncat(line, ":",LINBUFSIZ);
			ckstrncat(line, service,LINBUFSIZ);
			ttnproto = NP_DEFAULT;
		    } else {
			ckstrncat(line, ":telnet",LINBUFSIZ);
			ttnproto = NP_TELNET;
		    }

#ifndef NOICP
#ifndef NODIAL
		    if ((nhcount > 1) && !quiet && !backgrd) {
			printf("%d entr%s found for \"%s\"%s\n",
			       nhcount,
			       (nhcount == 1) ? "y" : "ies",
			       s,
			       (nhcount > 0) ? ":" : "."
			       );
			for (i = 0; i < nhcount; i++)
			  printf("%3d. %s %-12s => %s\n",
				 i+1, n_name, nh_p2[i], nh_p[i]
				 );
		    }
		    if (nhcount == 0)
		      n = 1;
		    else
		      n = nhcount;
#else
		    n = 1;
		    nhcount = 0;
#endif /* NODIAL */
		    for (i = 0; i < n; i++) {
#ifndef NODIAL
			if (nhcount >= 1) {
			    /* Copy the current entry to line */
			    ckstrncpy(line,nh_p[i],LINBUFSIZ);
                    /* Check to see if the network entry contains a service */
			    for (s = line ; (*s != NUL) && (*s != ':'); s++)
			      ;
			    /* If directory does not have a service ... */
			    /* and the user specified one */
			    if (!*s && *service) {
				ckstrncat(line, ":",LINBUFSIZ);
				ckstrncat(line, service,LINBUFSIZ);
			    }
			    if (lookup(netcmd,nh_p2[i],nnets,&z) > -1) {
				mdmtyp = 0 - netcmd[z].kwval;
			    } else {
				printf(
				 "Error - network type \"%s\" not supported\n",
				       nh_p2[i]
				       );
				continue;
			    }
			}
#endif /* NODIAL */
		    }
#endif /* NOICP */
		    ckstrncpy(ttname, line,TTNAMLEN+1);
		    cxtype = CXT_TCPIP;	/* Set connection type */
		    setflow();		/* Set appropriate flow control. */
#ifdef SUNX25
		} else if (x == 'X') {	/* X.25 address */
		    nettype = NET_SX25;
		    mdmtyp = -nettype;
		} else if (x == 'Z') {	/* Open X.25 file descriptor */
		    nettype = NET_SX25;
		    mdmtyp = -nettype;
		    x25fd = 1;
#endif /* SUNX25 */
#ifdef STRATUSX25
		} else if (x == 'X') {	/* X.25 address */
		    nettype = NET_VX25;
		    mdmtyp = -nettype;
#endif /* STRATUSX25 */
#ifdef IBMX25
		} else if (x == 'X') {	/* X.25 address */
		    nettype = NET_IX25;
		    mdmtyp = -nettype;
#endif /* IBMX25 */
#ifdef HPX25
		} else if (x == 'X') {	/* X.25 address */
		    nettype = NET_HX25;
		    mdmtyp = -nettype;
#endif /* HPX25 */
		}
		if (ttopen(ttname,&local,mdmtyp,0) < 0) {
		    XFATAL("can't open host connection");
		}
		network = 1;
#ifdef CKLOGDIAL
		dolognet();
#endif /* CKLOGDIAL */
		cxtype = CXT_X25;	/* Set connection type */
		setflow();		/* Set appropriate flow control. */
#ifndef NOSPL
		if (local) {
		    if (nmac) {		/* Any macros defined? */
			int k;		/* Yes */
			k = mlook(mactab,"on_open",nmac); /* Look this up */
			if (k >= 0) {	/* If found, */
			    if (dodo(k,ttname,0) > -1) /* set it up, */
			      parser(1);        /* and execute it */
			}
		    }
		}
#endif /* NOSPL */
#endif /* NETCONN */
	    }
	    /* add more here -- decnet, etc... */
	    haveline = 1;
	    break;

#ifdef ANYX25
	  case 'U':			/* X.25 call user data */
	    if (*(xp+1)) {
		XFATAL("invalid argument bundling");
	    }
	    xargv++, xargc--;
	    if ((xargc < 1) || (**xargv == '-')) {
		XFATAL("missing call user data string");
	    }
	    ckstrncpy(udata,*xargv,MAXCUDATA);
	    if ((int)strlen(udata) <= MAXCUDATA) {
		cudata = 1;
	    } else {
		XFATAL("Invalid call user data");
	    }
	    break;

	  case 'o':			/* X.25 closed user group */
	    if (*(xp+1)) {
		XFATAL("invalid argument bundling");
	    }
	    xargv++, xargc--;
	    if ((xargc < 1) || (**xargv == '-')) {
		XFATAL("missing closed user group index");
	    }
	    z = atoi(*xargv);		/* Convert to number */
	    if (z >= 0 && z <= 99) {
		closgr = z;
	    } else {
		XFATAL("Invalid closed user group index");
	    }
	    break;

	  case 'u':			/* X.25 reverse charge call */
	    revcall = 1;
	    break;
#endif /* ANYX25 */
#endif /* NOLOCAL */

	  case 'b':			/* Bits-per-second for serial device */
	    if (*(xp+1)) {
		XFATAL("invalid argument bundling");
	    }
	    xargv++, xargc--;
	    if ((xargc < 1) || (**xargv == '-')) {
		XFATAL("missing bps");
	    }
	    zz = atol(*xargv);		/* Convert to long int */
	    i = zz / 10L;
#ifndef NOLOCAL
	    if (ttsspd(i) > -1)		/* Check and set it */
#endif /* NOLOCAL */
	      speed = ttgspd();		/* and read it back. */
#ifndef NOLOCAL
	    else {
		XFATAL("unsupported transmission rate");
	    }
#endif /* NOLOCAL */
	    break;

#ifndef NODIAL
#ifndef NOICP
	  case 'm':			/* Modem type */
	    if (*(xp+1)) {
		XFATAL("invalid argument bundling after -m");
	    }
	    xargv++, xargc--;
	    if ((xargc < 1) || (**xargv == '-')) {
		XFATAL("modem type missing");
	    }
	    y = lookup(mdmtab,*xargv,nmdm,&z);
	    if (y < 0) {
		XFATAL("unknown modem type");
	    }
	    usermdm = 0;
	    usermdm = (y == dialudt) ? x : 0;
	    initmdm(y);
	    break;
#endif /* NOICP */
#endif /* NODIAL */

#ifndef NOXFER
	  case 'e':			/* Extended packet length */
	    if (*(xp+1)) {
		XFATAL("invalid argument bundling after -e");
	    }
	    xargv++, xargc--;
	    if ((xargc < 1) || (**xargv == '-')) {
		XFATAL("missing length");
	    }
	    z = atoi(*xargv);		/* Convert to number */
	    if (z > 10 && z <= maxrps) {
		rpsiz = urpsiz = z;
		if (z > 94) rpsiz = 94;	/* Fallback if other Kermit can't */
	    } else {
		XFATAL("Unsupported packet length");
	    }
	    break;

	  case 'v':			/* Vindow size */
	    if (*(xp+1)) {
		XFATAL("invalid argument bundling");
	    }
	    xargv++, xargc--;
	    if ((xargc < 1) || (**xargv == '-')) {
		XFATAL("missing or bad window size");
	    }
	    z = atoi(*xargv);		/* Convert to number */
	    if (z < 32) {		/* If in range */
		wslotr = z;		/* set it */
		if (z > 1) swcapr = 1;	/* Set capas bit if windowing */
	    } else {
		XFATAL("Unsupported packet length");
	    }
	    break;
#endif /* NOXFER */

	  case 'i':			/* Treat files as binary */
	    binary = XYFT_B;
	    xfermode = XMODE_M;		/* Transfer mode manual */
	    filepeek = 0;
#ifdef PATTERNS
	    patterns = 0;
#endif /* PATTERNS */
	    break;

#ifndef NOXFER
	  case 'w':			/* Writeover */
	    ckwarn = 0;
	    fncact = XYFX_X;
	    break;
#endif /* NOXFER */

	  case 'q':			/* Quiet */
	    quiet = 1;
	    break;

#ifdef DEBUG
	  case 'd':			/* DEBUG */
	    break;			/* Handled in prescan() */
#endif /* DEBUG */

	  case '0': {			/* In the middle */
	      extern int tt_escape, lscapr;
	      tt_escape = 0;		/* No escape character */
	      flow = 0;			/* No Xon/Xoff (what about hwfc?) */
#ifndef NOXFER
	      lscapr = 0;		/* No locking shifts */
#endif /* NOXFER */
#ifdef CK_APC
	      {
		  extern int apcstatus;	/* No APCs */
		  apcstatus = APC_OFF;
	      }
#endif /* CK_APC */
#ifndef NOLOCAL
#ifdef CK_AUTODL
              setautodl(0,0);		/* No autodownload */
#endif /* CK_AUTODL */
#endif /* NOLOCAL */
#ifndef NOCSETS
	      {
		  extern int tcsr, tcsl; /* No character-set translation */
		  tcsr = 0;
		  tcsl = tcsr;		/* Make these equal */
	      }
#endif /* NOCSETS */
#ifdef TNCODE
	      TELOPT_DEF_C_U_MODE(TELOPT_KERMIT) = TN_NG_RF;
	      TELOPT_DEF_C_ME_MODE(TELOPT_KERMIT) = TN_NG_RF;
	      TELOPT_DEF_S_U_MODE(TELOPT_KERMIT) = TN_NG_RF;
	      TELOPT_DEF_S_ME_MODE(TELOPT_KERMIT) = TN_NG_RF;
#endif /* TNCODE */
	  }
/* Fall thru... */

	  case '8':			/* 8-bit clean */
	    parity = 0;
	    cmdmsk = 0xff;
	    cmask = 0xff;
	    break;

	  case 'V': {
	      extern int xfermode;
#ifdef PATTERNS
	      extern int patterns;
	      patterns = 0;		/* No patterns */
#endif /* PATTERNS */
	      xfermode = XMODE_M;	/* Manual transfer mode */
	      filepeek = 0;
	      break;
	  }

	  case 'p':			/* SET PARITY */
	    if (*(xp+1)) {
		XFATAL("invalid argument bundling");
	    }
	    xargv++, xargc--;
	    if ((xargc < 1) || (**xargv == '-')) {
		XFATAL("missing parity");
	    }
	    switch(x = **xargv) {
	      case 'e':
	      case 'o':
	      case 'm':
	      case 's': parity = x; break;
	      case 'n': parity = 0; break;
	      default:  { XFATAL("invalid parity"); }
	    }
	    break;

	  case 't':			/* Line turnaround handshake */
	    turn = 1;
	    turnch = XON;		/* XON is turnaround character */
	    duplex = 1;			/* Half duplex */
	    flow = 0;			/* No flow control */
	    break;

	  case 'B':
	    bgset = 1;			/* Force background (batch) */
	    backgrd = 1;
	    break;

	  case 'z':			/* Force foreground */
	    bgset = 0;
	    backgrd = 0;
	    break;

#ifndef NOXFER
#ifdef RECURSIVE
	  case 'L':
	    recursive = 2;
	    nolinks = 2;
	    fnspath = PATH_REL;
	    break;
#endif /* RECURSIVE */
#endif /* NOXFER */

#ifndef NOSPL
	  case 'M':			/* My User Name */
	    if (*(xp+1)) {
		XFATAL("invalid argument bundling");
	    }
	    xargv++, xargc--;
	    if ((xargc < 1) || (**xargv == '-')) {
		XFATAL("missing username");
	    }
	    if ((int)strlen(*xargv) > 63) {
		XFATAL("username too long");
	    }
#ifdef IKSD
	    if (!inserver)
#endif /* IKSD */
	      {
		  ckstrncpy(uidbuf,*xargv,UIDBUFLEN);
		  haveftpuid = 1;
	      }
	    break;
#endif /* NOSPL */

#ifdef CK_NETBIOS
	  case 'N':			/* NetBios Adapter Number follows */
	    if (*(xp+1)) {
		XFATAL("invalid argument bundling after -N");
	    }
	    xargv++, xargc--;
	    if ((xargc < 1) || (**xargv == '-')) {
		XFATAL("missing NetBios Adapter number");
	    }
	    if ((strlen(*xargv) != 1) ||
		(*xargv)[0] != 'X' &&
		(atoi(*xargv) < 0) &&
		(atoi(*xargv) > 9)) {
		XFATAL("Invalid NetBios Adapter - Adapters 0 to 9 are valid");
	    }
	    break;
#endif /* CK_NETBIOS */

#ifdef NETCONN
	  case 'F':
	    network = 1;
	    if (*(xp+1)) {
		XFATAL("invalid argument bundling after -F");
	    }
	    xargv++, xargc--;
	    if ((xargc < 1) || (**xargv == '-')) {
		XFATAL("network file descriptor missing");
	    }
	    ckstrncpy(ttname,*xargv,TTNAMLEN+1);
	    nettype = NET_TCPB;
	    mdmtyp = -nettype;
	    telnetfd = 1;
	    local = 1;
	    break;
#endif /* NETCONN */

#ifdef COMMENT
#ifdef OS2PM
	  case 'P':			/* OS/2 Presentation Manager */
	    if (*(xp+1)) {
		XFATAL("invalid argument bundling after -P");
	    }
	    xargv++, xargc--;
	    if ((xargc < 1) || (**xargv == '-')) {
		XFATAL("pipe data missing");
	    }
	    pipedata = *xargv;
	    break;
#endif /* OS2PM */
#else
	  case 'P':			/* Filenames literal */
	    fncnv  = XYFN_L;
	    f_save = XYFN_L;
	    break;
#endif /* COMMENT */

#ifndef NOICP
	  case 'H':
	    noherald = 1;
	    break;
#endif /* NOICP */

#ifdef OS2
	  case 'W':
	    if (*(xp+1)) {
		XFATAL("invalid argument bundling after -W");
	    }
	    xargv++, xargc--;
	    if ((xargc < 1)) { /* could be negative */
		XFATAL("Window handle missing");
	    }
	    xargv++, xargc--;
	    if ((xargc < 1) || (**xargv == '-')) {
		XFATAL("Kermit Instance missing");
	    }
	    /* Action done in prescan */
	    break;

	  case '#':			/* K95 stdio threads */
	    xargv++, xargc--;		/* Skip past argument */
	    break;			/* Action done in prescan */
#endif /* OS2 */

#ifdef NEWFTP
	  case '9':			/* FTP */
	    if (*(xp+1)) {
		XFATAL("invalid argument bundling after -9");
	    }
	    xargv++, xargc--;
	    if ((xargc < 1) || (**xargv == '-')) {
		XFATAL("FTP server address missing");
	    }
	    makestr(&ftp_host,*xargv);
	    break;
#endif /* NEWFTP */

	  default:
	    fatal2(*xargv,
#ifdef NT
                   "invalid command-line option, type \"k95 -h\" for help"
#else
#ifdef OS2
                   "invalid command-line option, type \"k2 -h\" for help"
#else
                   "invalid command-line option, type \"kermit -h\" for help"
#endif /* OS2 */
#endif /* NT */
		   );
        }
	if (!xp) break;
	x = *++xp;			/* See if options are bundled */
    }
    return(0);
}

#ifdef TNCODE
/*  D O T N A R G  --  Do a telnet command-line argument.  */

static int
#ifdef CK_ANSIC
dotnarg(char x)
#else
dotnarg(x) char x;
#endif /* CK_ANSIC */
/* dotnarg */ {
    char *xp;

    xp = *xargv+1;                      /* Pointer for bundled args */
    debug(F111,"dotnarg entry",xp,xargc);
    while (x) {
        debug(F000,"dotnarg arg","",x);
        switch (x) {                    /* Big switch on arg */

#ifndef COMMENT
	  case '-':			/* Extended commands... */
            if (doxarg(xargv,0) < 0) {
                XFATAL("Extended option error");
            } /* Full thru... */
	  case '+':			/* Extended command for prescan() */
            return(0);
#else  /* COMMENT */
	  case '-':
	  case '+':
	    XFATAL("Extended options not configured");
#endif /* COMMENT */

/*
 * -#                Kermit 95 Startup Flags
 * -8                Negotiate Telnet Binary in both directions
 * -a                Require use of Telnet authentication
 * -c                Do not read the .telnetrc file
 * -d                Turn on debug mode
 * -E                No escape character
 * -f                Forward credentials to host
 * -K                Refuse use of authentication; do not send username
 * -k realm          Set default realm
 * -l user           Set username and request Telnet authentication
 * -L                Negotiate Telnet Binary Output only
 * -q                Quiet mode (suppress messages)
 * -S tos            Use the IP type-of-service tos
 * -x                Require Encryption
 * -D                Disable forward-X
 * -T cert=file      Use certificate in file
 * -T key=file       Use private key in file
 * -T crlfile=file   Use CRL in file
 * -T crldir=dir     Use CRLs in directory
 * -T cipher=string  Use only ciphers in string
 * -X atype          Disable use of atype authentication
 * -Y                Disable init file processing
 *
 */
	  case 'h':			/* help */
	    usage();
	    doexit(GOOD_EXIT,-1);
	    break;

	  case '8':			/* Telnet Binary in both directions */
	    TELOPT_DEF_C_U_MODE(TELOPT_BINARY) = TN_NG_MU;
	    TELOPT_DEF_C_ME_MODE(TELOPT_BINARY) = TN_NG_MU;
	    parity = 0;
	    cmdmsk = 0xff;
	    cmask = 0xff;
	    break;

	  case 'a':			/* Require Telnet Auth */
	    TELOPT_DEF_C_ME_MODE(TELOPT_AUTHENTICATION) = TN_NG_MU;
	    break;

	  case 'Y':
	    xargv++, xargc--;		/* Skip past argument */
	    break;			/* Action done in prescan */

#ifdef OS2
          case '#':			/* K95 stdio threads */
	    xargv++, xargc--;		/* Skip past argument */
	    break;			/* Action done in prescan */
#endif /* OS2 */

          case 'q':	                /* Quiet */
	    quiet = 1;
	    break;

	  case 'd':
#ifdef DEBUG
	    if (deblog) {
		debtim = 1;
	    } else {
		deblog = debopn("debug.log",0);
	    }
#endif /* DEBUG */
	    break;

	  case 'E': {			/* No Escape character */
	      extern int tt_escape;
	      tt_escape = 0;
	  }
	    break;

	  case 'K':
	    TELOPT_DEF_C_ME_MODE(TELOPT_AUTHENTICATION) = TN_NG_RF;
	    uidbuf[0] = NUL;
	    break;

	  case 'l': /* Set username and request telnet authentication */
	    if (*(xp+1)) {
		XFATAL("invalid argument bundling");
	    }
	    xargv++, xargc--;
	    if ((xargc < 1) || (**xargv == '-')) {
		XFATAL("missing username");
	    }
	    if ((int)strlen(*xargv) > 63) {
		XFATAL("username too long");
	    }
	    ckstrncpy(uidbuf,*xargv,UIDBUFLEN);
	    TELOPT_DEF_C_ME_MODE(TELOPT_AUTHENTICATION) = TN_NG_MU;
	    break;

	  case 'L':			/* Require BINARY mode outbound only */
	    TELOPT_DEF_C_ME_MODE(TELOPT_BINARY) = TN_NG_MU;
	    break;

	  case 'x':			/* Require Encryption */
	    TELOPT_DEF_C_U_MODE(TELOPT_ENCRYPTION) = TN_NG_MU;
	    TELOPT_DEF_C_ME_MODE(TELOPT_ENCRYPTION) = TN_NG_MU;
	    break;

	  case 'D':			/* Disable use of Forward X */
	    TELOPT_DEF_C_U_MODE(TELOPT_FORWARD_X) = TN_NG_RF;
	    break;

	  case 'f':			/* Forward credentials to host */
	    {
#ifdef CK_AUTHENTICATION
		extern int forward_flag;
		forward_flag = 1;
#endif
		break;
	    }

	  case 'k': {
#ifdef CK_KERBEROS
	      extern char * krb5_d_realm, * krb4_d_realm;
#endif /* CK_KERBEROS */
	      if (*(xp+1)) {
		  XFATAL("invalid argument bundling");
	      }
	      xargv++, xargc--;
	      if ((xargc < 1) || (**xargv == '-')) {
		  XFATAL("missing realm");
	      }
#ifdef CK_KERBEROS
	      if ((int)strlen(*xargv) > 63) {
		  XFATAL("realm too long");
	      }
	      makestr(&krb5_d_realm,*xargv);
	      makestr(&krb4_d_realm,*xargv);
#endif /* CK_KERBEROS */
	      break;
	  }

	  case 'T': {
	      if (*(xp+1)) {
		  XFATAL("invalid argument bundling");
	      }
	      xargv++, xargc--;
	      if ((xargc < 1) || (**xargv == '-')) {
		  XFATAL("missing cert=, key=, crlfile=, crldir=, or cipher=");
	      }
#ifdef CK_SSL
	      if (!strncmp(*xargv,"cert=",5)) {
		  extern char * ssl_rsa_cert_file;
		  makestr(&ssl_rsa_cert_file,&(*xargv[5]));
	      } else if ( !strncmp(*xargv,"key=",4) ) {
		  extern char * ssl_rsa_key_file;
		  makestr(&ssl_rsa_key_file,&(*xargv[4]));
	      } else if ( !strncmp(*xargv,"crlfile=",8) ) {
		  extern char * ssl_crl_file;
		  makestr(&ssl_crl_file,&(*xargv[8]));
	      } else if ( !strncmp(*xargv,"crldir=",7) ) {
		  extern char * ssl_crl_dir;
		  makestr(&ssl_crl_dir,&(*xargv[7]));
	      } else if ( !strncmp(*xargv,"cipher=",7) ) {
		  extern char * ssl_cipher_list;
		  makestr(&ssl_cipher_list,&(*xargv[7]));
	      } else {
		  XFATAL("invalid parameter");
	      }
#endif /* CK_SSL */
	      break;
	  }

	  default:
	    fatal2(*xargv,
		   "invalid command-line option, type \"telnet -h\" for help"
		   );
        }

	if (!xp) break;
	x = *++xp;			/* See if options are bundled */
    }
    return(0);
}
#endif /* TNCODE */

#ifdef RLOGCODE

/*  D O R L G A R G  --  Do a rlogin command-line argument.  */

static int
#ifdef CK_ANSIC
dorlgarg(char x)
#else
dorlgarg(x) char x;
#endif /* CK_ANSIC */
/* dorlgarg */ {
    char *xp;

    xp = *xargv+1;                      /* Pointer for bundled args */
    debug(F111,"dorlgarg entry",xp,xargc);
    while (x) {
        debug(F000,"dorlgarg arg","",x);
        switch (x) {                    /* Big switch on arg */

#ifndef COMMENT
	  case '-':			/* Extended commands... */
            if (doxarg(xargv,0) < 0) {
            XFATAL("Extended option error");
            } /* Full thru... */
	  case '+':			/* Extended command for prescan() */
            return(0);
#else  /* COMMENT */
	  case '-':
	  case '+':
	    XFATAL("Extended options not configured");
#endif /* COMMENT */

/*
 * -d                Debug
 * -l user           Set username
 *
 */
	  case 'h':			/* help */
	    usage();
	    doexit(GOOD_EXIT,-1);
	    break;

          case 'Y':
	    xargv++, xargc--;		/* Skip past argument */
	    break;			/* Action done in prescan */
#ifdef OS2
          case '#':			/* K95 stdio threads */
	    xargv++, xargc--;		/* Skip past argument */
	    break;			/* Action done in prescan */
#endif /* OS2 */
          case 'q':	                /* Quiet */
	    quiet = 1;
	    break;

	  case 'd':
#ifdef DEBUG
	    if (deblog) {
		debtim = 1;
	    } else {
		deblog = debopn("debug.log",0);
	    }
#endif /* DEBUG */
	    break;

	  case 'l': /* Set username and request telnet authentication */
	    if (*(xp+1)) {
		XFATAL("invalid argument bundling");
	    }
	    xargv++, xargc--;
	    if ((xargc < 1) || (**xargv == '-')) {
		XFATAL("missing username");
	    }
	    if ((int)strlen(*xargv) > 63) {
		XFATAL("username too long");
	    }
	    ckstrncpy(uidbuf,*xargv,UIDBUFLEN);
	    break;

	  default:
	    fatal2(*xargv,
		   "invalid command-line option, type \"rlogin -h\" for help"
		   );
        }

	if (!xp) break;
	x = *++xp;			/* See if options are bundled */
    }
    return(0);
}
#endif /* RLOGCODE */

#ifdef SSHBUILTIN

/*  D O S S H A R G  --  Do a ssh command-line argument.  */

static int
#ifdef CK_ANSIC
dossharg(char x)
#else
dossharg(x) char x;
#endif /* CK_ANSIC */
/* dossharg */ {
    char *xp;

    xp = *xargv+1;                      /* Pointer for bundled args */
    debug(F111,"dossharg entry",xp,xargc);
    while (x) {
        debug(F000,"dossharg arg","",x);
        switch (x) {                    /* Big switch on arg */

#ifndef COMMENT
	  case '-':			/* Extended commands... */
            if (doxarg(xargv,0) < 0) {
                XFATAL("Extended option error");
            } /* Full thru... */
	  case '+':			/* Extended command for prescan() */
            return(0);
#else  /* COMMENTP */
	  case '-':
	  case '+':
	    XFATAL("Extended options not configured");
#endif /* COMMENT */

/*
 * -d                Debug
 * -# args           Init
 * -Y                no init file
 * -l user           Set username
 *
 */
	  case 'h':			/* help */
	    usage();
	    doexit(GOOD_EXIT,-1);
	    break;

          case 'Y':
	    xargv++, xargc--;		/* Skip past argument */
	    break;			/* Action done in prescan */
#ifdef OS2
          case '#':			/* K95 stdio threads */
	    xargv++, xargc--;		/* Skip past argument */
	    break;			/* Action done in prescan */
#endif /* OS2 */
          case 'q':	                /* Quiet */
	    quiet = 1;
	    break;

	  case 'd':
#ifdef DEBUG
              if (deblog) {
                  debtim = 1;
              } else {
                  deblog = debopn("debug.log",0);
              }
#endif /* DEBUG */
	    break;

	  case 'l': /* Set username and request telnet authentication */
	    if (*(xp+1)) {
		XFATAL("invalid argument bundling");
	    }
	    xargv++, xargc--;
	    if ((xargc < 1) || (**xargv == '-')) {
		XFATAL("missing username");
	    }
	    if ((int)strlen(*xargv) > 63) {
		XFATAL("username too long");
	    }
	    ckstrncpy(uidbuf,*xargv,UIDBUFLEN);
	    break;

	  default:
	    fatal2(*xargv,
		   "invalid command-line option, type \"ssh -h\" for help"
		   );
        }

	if (!xp) break;
	x = *++xp;			/* See if options are bundled */
    }
    return(0);
}
#endif /* SSHBUILTIN */

#else /* No command-line interface... */

int
cmdlin() {
    extern int xargc;
    if (xargc > 1) {
        XFATAL("Sorry, command-line options disabled.");
    }
}
#endif /* NOCMDL */