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
|
/*
ckcsym.h is used for for defining symbols that normally would be defined
using -D or -d on the cc command line, for use with compilers that don't
support this feature. Must be before any tests for preprocessor symbols.
*/
#include "ckcsym.h"
/*
Consolidated program version information (for UNIX also see ckuver.h).
See makever() below for how they are used.
*/
#ifndef OS2 /* Remove this for release */
#ifndef BETATEST
#define BETATEST
#endif /* BETATEST */
#endif /* OS2 */
#ifdef BETATEST
#ifdef OS2
#ifdef __DATE__
#define BETADATE
#endif /* __DATE__ */
#endif /* OS2 */
#endif /* BETATEST */
#ifndef MAC
/*
Note: initialize ck_s_test to "" if this is not a test version.
(*ck_s_test != '\0') can be used to decide whether to print
test-related messages.
*/
#ifdef BETATEST
char *ck_s_test = "Beta"; /* "Alpha", "Beta", or "" */
char *ck_s_tver = "05"; /* Test version number or "" */
#else
char *ck_s_test = ""; /* Not a test */
char *ck_s_tver = "";
#endif /* BETATEST */
#else /* MAC */
char *ck_s_test = "Pre-Alpha"; /* Mac Kermit is always a test... */
char *ck_s_tver = "";
#endif /* MAC */
#ifdef BETADATE /* Date of this version or edit */
char *ck_s_date = __DATE__; /* Compilation date */
#else
char *ck_s_date = "7 May 1998"; /* Hand-crafted date */
#endif /* BETADATE */
#ifdef UNIX
static char sccsid[] = "@(#)C-Kermit 6.1.193";
#endif /* UNIX */
char *ck_s_ver = "6.1.193"; /* C-Kermit version string */
long ck_l_ver = 601193L; /* C-Kermit version number */
#ifdef OS2
char *ck_s_xver = "1.1.17"; /* Product-specific version string */
long ck_l_xver = 1117L; /* Product-specific version number */
#else
#ifdef MAC
char *ck_s_xver = "0.994"; /* Product-specific version string */
long ck_l_xver = 994L; /* Product-specific version number */
#else
char *ck_s_xver = ""; /* Don't touch these... */
long ck_l_xver = 0L; /* they are filled in at runtime */
#endif /* MAC */
#endif /* OS2 */
#ifdef OS2
char *ck_s_name = "Kermit 95"; /* Program name */
#else
#ifdef MAC
char *ck_s_name = "Mac Kermit";
#else
char *ck_s_name = "C-Kermit";
#endif /* MAC */
#endif /* OS2 */
char *ck_s_who = ""; /* Where customized, "" = not. */
char *ck_patch = ""; /* Patch info, if any. */
#define CKVERLEN 128
char versiox[CKVERLEN]; /* Version string buffer */
char *versio = versiox; /* These are filled in at */
long vernum, xvernum; /* runtime from above. */
#define CKCMAI
#include "ckcasc.h" /* ASCII character symbols */
#include "ckcdeb.h" /* Debug & other symbols */
char * myname = NULL; /* The name I am called by */
/* C K C M A I -- C-Kermit Main program */
/*
Author: Frank da Cruz (fdc@columbia.edu),
Columbia University Academic Information Systems, New York City.
COPYRIGHT NOTICE:
*/
char *copyright[] = {
#ifdef pdp11
"Copyright (C) 1985, 1998, Trustees of Columbia University, NYC.",
"All rights reserved.",
" ",
#else
#ifdef OS2
"Copyright (C) 1985, 1998, Trustees of Columbia University in the City of New",
"York. All rights reserved. This software is furnished under license",
"and may not be reproduced without license to do so. This copyright notice",
"must not be removed, altered, or obscured.",
" ",
#else
"Copyright (C) 1985, 1998, Trustees of Columbia University in the City of New",
"York. The C-Kermit software may not be, in whole or in part, licensed or",
"sold for profit as a software product itself, nor may it be included in or",
"distributed with commercial products or otherwise distributed by commercial",
"concerns to their clients or customers without written permission of the",
"Kermit Project, Columbia University. This copyright notice must not be",
"removed, altered, or obscured.",
" ",
#endif /* OS2 */
#endif /* pdp11 */
#ifdef OS2
"Portions Copyright (C) 1995, Oy Online Solutions Ltd., Jyvaskyla, Finland.",
#endif /* OS2 */
#ifdef CK_AUTHENTICATION
"Portions Copyright (C) 1990, Massachusetts Institute of Technology.",
#ifdef CK_ENCRYPTION
"Portions Copyright (C) 1991, 1993 Regents of the University of California.",
"Portions Copyright (C) 1991, 1992, 1993, 1994, 1995 by AT&T.",
"Portions Copyright (C) 1995, 1997, Eric Young <eay@cryptosoft.com>.",
#endif /* CK_ENCRYPTION */
#ifdef CK_SRP
"Portions Copyright (C) 1997, Stanford University.",
#endif /* CK_SRP */
#endif /* CK_AUTHENTICATION */
#ifndef pdp11
" ",
"For further information, contact the Kermit Project, Columbia University,",
"612 West 115th Street, New York NY 10025-7799, USA; phone +1 (212) 854 3703,",
"fax +1 (212) 663 8202 or +1 (212) 662 6442, email kermit@columbia.edu,",
"Web http://www.columbia.edu/kermit/ or http://www.kermit-project.org/.",
#endif /* pdp11 */
""};
/*
DOCUMENTATION:
"Using C-Kermit" by Frank da Cruz and Christine M. Gianone,
Digital Press / Butterworth-Heinemann, Woburn MA, USA.
Second edition (1997), ISBN 1-55558-164-1.
Order from Digital Press: +1 (800) 366-2665
Or from Columbia University: +1 (212) 854-3703
For Kermit 95, also:
"Kermit 95" by Christine M. Gianone and Frank da Cruz,
Manning Publications, Greenwich CT, USA (1996)
Order from Manning: +1 (203) 629 2078
Or from Columbia University: +1 (212) 854-3703
DISCLAIMER:
The C-Kermit software is provided in source code and/or binary form by
the Kermit Project, Academic Information Systems, Columbia University.
The software is provided "as is;" no other warranty is provided, express
or implied, including without limitations, any implied warranty of
merchantability or implied warranty of fitness for a particular purpose.
Neither Columbia University nor any of the contributors to C-Kermit's
development, including, but not limited to, Manning Software, Digital Press,
AT&T, Digital Equipment Corporation, Data General Corporation, or
International Business Machines Corporation, or any individuals affiliated
with those or other institutions, warrant C-Kermit software or documentation
in any way. In addition, neither the authors of any Kermit programs,
publications or documentation, nor Columbia University nor any contributing
institutions or individuals acknowledge any liability resulting from program
or documentation errors.
Contributions made to C-Kermit by programmers outside of Columbia University
fall within the provisions of the foregoing copyrights, terms and
conditions, and disclaimers, and grant to the Kermit Project at Columbia
University a nonexclusive license to use the contributed code in any and
all Kermit software without restriction or obligation.
ACKNOWLEDGMENTS:
The Kermit file transfer protocol was developed at the Columbia University
Center for Computing Activities (CUCCA), which was since renamed to Columbia
University Academic Information Systems (AcIS). Kermit is named after
Kermit the Frog, star of the television series THE MUPPET SHOW; the name is
used by permission of Henson Associates, Inc.
Thanks to at least the following people for their contributions to this
program over the years, and apologies to anyone who was inadvertantly
omitted:
Chris Adie, Edinburgh U, Scotland (OS/2)
Robert Adsett, University of Waterloo, Canada
Larry Afrin, Clemson U
Jeffrey Altman, Columbia University
Greg Andrews, Telebit Corp
Barry Archer, U of Missouri
Robert Andersson, International Systems A/S, Oslo, Norway
Chris Armstrong, Brookhaven National Lab (OS/2)
William Bader, Software Consulting Services, Nazareth, PA
Fuat Baran, Columbia U
Stan Barber, Rice U
Jim Barbour, U of Colorado
Donn Baumgartner, Dell
Nelson Beebe, U of Utah
Karl Berry, UMB
Mark Berryman, SAIC
Dean W Bettinger, SUNY
Gary Bilkus
Peter Binderup, Denmark
David Bolen, Advanced Networks and Services, Inc.
Marc Boucher, U of Montreal
Charles Brooks, EDN
Bob Brown
Mike Brown, Purdue U
Jack Bryans, California State U at Long Beach
Mark Buda, DEC (VMS)
Fernando Cabral, Padrao iX, Brasilia
Bjorn Carlsson, Stockholm University Computer Centre QZ, Sweden
Bill Catchings, (formerly of) Columbia U
Bob Cattani, Columbia U CS Dept
Davide Cervone, Rochester U
Seth Chaiklin, Denmark
John Chandler, Harvard U / Smithsonian Astronomical Observatory
Bernard Chen, UCLA
Andrew A Chernov, RELCOM Team, Moscow
John L Chmielewski, AT&T, Lisle, IL
Howard Chu, U of Michigan
Bill Coalson, McDonnell Douglas
Bertie Coopersmith, London
Chet Creider, U of Western Ontario
Alan Crosswell, Columbia U
Jeff Damens, (formerly of) Columbia U
Mark Davies, Bath U, UK
Sin-itirou Dezawa, Fujifilm, Japan
Joe R. Doupnik, Utah State U
Frank Dreano, Honeywell
John Dunlap, U of Washington
Alex Dupuy, SMART.COM
David Dyck, John Fluke Mfg Co.
Stefaan A. Eeckels, Eurokom, Luxembourg
Paul Eggert, Twin Sun, Inc., El Segundo, CA
Bernie Eiben, DEC
Peter Eichhorn, Assyst International
Kristoffer Eriksson, Peridot Konsult AB, Oerebro, Sweden
John R. Evans, IRS, Kansas City
Glenn Everhart, RCA Labs
Charlie Finan, Cray Research
Herm Fischer, Encino, CA (extensive contributions to version 4.0)
Carl Fongheiser, CWRU
Mike Freeman, Bonneville Power Authority
Marcello Frutig, Catholic University, Sao Paulo, Brazil (X.25 support)
Hirofumi Fujii, Japan Nat'l Lab for High Energy Physics, Tokyo (Kanji)
Chuck Fuller, Westinghouse Corporate Computer Services
Andy Fyfe, Caltech
Christine M. Gianone, Columbia U
John Gilmore, UC Berkeley
Madhusudan Giyyarpuram, HP
Rainer Glaschick, Siemens AG, Paderborn
William H. Glass
German Goldszmidt, IBM
Chuck Goodhart, NASA
Alistair Gorman, New Zealand
Richard Gration, ADFA, Australia
Chris Green, Essex U, UK
Alan Grieg, Dundee Tech, Scotland
Yekta Gursel, MIT
Jim Guyton, Rand Corp
Michael Haertel
Bob Hain, UMN
Marion Hakanson, ORST
Richard Hamilton
John Hamilston, Iowa State U
Simon Hania, Netherlands
Stan Hanks, Rice U.
Ken Harrenstein, SRI
Eugenia Harris, Data General (AOS/VS)
David Harrison, Kingston Warren Corp
James Harvey, Indiana/Purdue U (VMS)
Rob Healey
Chuck Hedrick, Rutgers U
Ron Heiby, Technical Systems Division, Motorola Computer Group
Steve Hemminger, Tektronix
Christian Hemsing, RWTH Aachen, Germany (OS-9)
Randolph Herber, US DOE,
Andrew Herbert, Monash Univ, Australia
Mike Hickey, ITI
Dan Hildebrand, QNX Software Systems Inc, Kanata, ON (QNX)
R E Hill
Stephan Hoffman-Emden
Bill Homer, Cray Research
Ray Hunter, The Wollongong Group
Randy Huntziger, National Library of Medicine
Larry Jacobs, Transarc
Steve Jenkins, Lancaster University, UK
Dave Johnson, Gradient Technologies
Mark B Johnson, Apple Computer
Jyke Jokinen, Tampere University of Technology, Finland (QNX)
Eric F Jones, AT&T
Luke Jones, AT&T
Peter Jones, U of Quebec Montreal
Phil Julian, SAS Institute
Peter Kabal, U of Quebec
Mic Kaczmarczik, U of Texas at Austin
Sergey Kartashoff, Inst. of Precise Mechanics & Computer Equipment, Moscow
Howie Kaye, Columbia U
Rob Kedoin, Linotype Co, Hauppauge, NY (OS/2)
Phil Keegstra
Mark Kennedy, IBM
Terry Kennedy, St Peter's College, Jersey City, NJ (VMS and more)
"Carlo Kid", Technical University of Delft, Netherlands
Tim Kientzle
Paul Kimoto, Cornell U
Douglas Kingston, morgan.com
Lawrence Kirby, Wiltshire, UK
Tom Kloos, Sequent Computer Systems
Jim Knutson, U of Texas at Austin
John T. Kohl (BSDI)
Scott Kramer, SRI International, Menlo Park, CA
John Kraynack, US Postal Service
David Kricker, Encore Computer
Thomas Krueger, UWM
Bo Kullmar, ABC Klubben, Stockholm, and Central Bank of Sweden, Kista
R. Brad Kummer, AT&T Bell Labs, Atlanta, GA
John Kunze, UC Berkeley
David Lane, BSSI / BellSouth (Stratus VOS, X.25)
Bob Larson, USC (OS-9)
Bert Laverman, Groningen U, Netherlands
Steve Layton
David Lawyer, UC Irvine
David LeVine, National Semiconductor Corporation
Daniel S. Lewart, UIUC
S.O. Lidie, Lehigh U
Tor Lillqvist, Helsinki U, Finland
David-Michael Lincke, U of St Gallen, Switzerland
Robert Lipe
Dean Long
Mike Long, Analog Devices, Norwood MA
Kevin Lowey, U of Saskatchewan (OS/2)
Andy Lowry, Columbia U
James Lummel, Caprica Telecomputing Resources (QNX)
David MacKenzie, Environmental Defense Fund, U of Maryland
John Mackin, University of Sidney, Australia
Martin Maclaren, Bath U, UK
Chris Maio, Columbia U CS Dept
Montserrat Mane, HP, Grenoble, France
Fulvio Marino, Olivetti, Ivrea, Italy
Arthur Marsh, dircsa.org.au
Peter Mauzey, AT&T
Tye McQueen, Utah State U
Ted Medin
Hellmuth Michaelis, Hanseatischer Computerservice GmbH, Hamburg, Germany
Leslie Mikesell, American Farm Bureau
Todd Miller, Courtesan Consulting
Martin Minow, DEC (VMS)
Pawan Misra, Bellcore
Ken Mizialko, IBM, Manassas, VA
Wolfgang Moeller, DECUS Germany
Ray Moody, Purdue U
Bruce J Moore, Allen-Bradley Co, Highland Heights, OH (Atari ST)
Steve Morley, Convex
Peter Mossel, Columbia U
Tony Movshon, NYU
Lou Muccioli, Swanson Analysis Systems
Dan Murphy
Neal P. Murphy, Harsof Systems, Wonder Lake IL
Gary Mussar
John Nall, FSU
Jack Nelson, U of Pittsburgh
Jim Noble, Planning Research Corporation (Macintosh)
Ian O'Brien, Bath U, UK
Melissa O'Neill, SFU
John Owens
Michael Pins, Iowa Computer Aided Engineering Network
Andre' Pirard, University of Liege, Belgium
Paul Placeway, Ohio State U
Piet W. Plomp, ICCE, Groningen University, Netherlands
Ken Poulton, HP Labs
Manfred Prange, Oakland U
Christopher Pratt, APV Baker, UK
Frank Prindle, NADC
Tony Querubin, U of Hawaii
Anton Rang
Scott Ribe
Alan Robiette, Oxford University, UK
Michel Robitaille, U of Montreal (Mac)
Huw Rogers, Schweizerische Kreditanstalt, Zuerich
Nigel Roles, Cambridge, England
Kai Uwe Rommel, Technische Universitaet Muenchen (OS/2)
Larry Rosenman (Amiga)
Jay Rouman, U of Michigan
Jack Rouse, SAS Institute (Data General and/or Apollo)
Stew Rubenstein, Harvard U (VMS)
Gerhard Rueckle, FH Darmstadt, Fb. E/Automatisierungstechnik
John Santos, EG&H
Bill Schilit, Columbia U
Ulli Schlueter, RWTH Aachen, Germany (OS-9, etc)
Michael Schmidt, U of Paderborn, Germany
Eric Schnoebelen, Convex
Benn Schreiber, DEC
Dan Schullman, DEC (modems, DIAL command, etc)
John Schultz, 3M
Steven Schultz, Contel (PDP-11)
APPP Scorer, Leeds Polytechnic, UK
Gordon Scott, Micro Focus, Newbury UK
Gisbert W. Selke, WIdO, Bonn, Germany
David Singer, IBM Almaden Research Labs
David Sizeland, U of London Medical School
Fridrik Skulason, Iceland
Rick Sladkey (Linux)
Dave Slate
Bradley Smith, UCLA
Fred Smith, Merk / Computrition
Richard S Smith, Cal State
Ryan Stanisfer, UNT
Bertil Stenstroem, Stockholm University Computer Centre (QZ), Sweden
James Sturdevant, CAP GEMENI AMERICA, Minneapolis
Peter Svanberg, Royal Techn. HS, Sweden
James R. Swenson, Accu-Weather, Inc.
Ted T'so, MIT
Andy Tanenbaum, Vrije U, Amsterdam, Netherlands
Glen Thobe
Markku Toijala, Helsinki U of Technology
Teemu Torma, Helsinki U of Technology
Linus Torvalds, Helsinki
Rick Troxel, NIH
Warren Tucker, Tridom Corp, Mountain Park, GA
Dave Tweten, AMES-NAS
G Uddeborg, Sweden
Walter Underwood, Ford Aerospace
Pieter Van Der Linden, Centre Mondial, Paris
Ge van Geldorp, Netherlands
Fred van Kempen, MINIX User Group, Voorhout, Netherlands
Wayne Van Pelt, GE/CRD
Mark Vasoll, Oklahoma State U (V7 UNIX)
Konstantin Vinogradov, ICSTI, Moscow
Paul Vixie, DEC
Bernie Volz, Process Software
Eduard Vopicka, Prague University of Economics, Czech Republic
Dimitri Vulis, CUNY
Roger Wallace, Raytheon
Stephen Walton, Calif State U, Northridge (Amiga)
Jamie Watson, Adasoft, Switzerland (RS/6000)
Rick Watson, U of Texas (Macintosh)
Robert Weiner, Programming Plus, New York City
Lauren Weinstein, Vortex Technlogy
David Wexelblat, AT&T
Clark Wierda, Illuminati Online
Joachim Wiesel, U of Karlsruhe
Lon Willett, U of Utah
Michael Williams, UCLA
Nate Williams, U of Montana
David Wilson
Joellen Windsor, U of Arizona
Patrick Wolfe, Kuck & Associates, Inc.
Gregg Wonderly, Oklahoma State U (V7 UNIX)
Farrell Woods, Concurrent (formerly Masscomp)
Dave Woolley, CAP Communication Systems, London
Jack Woolley, SCT Corp
Frank Wortner
Ken Yap, formerly of U of Rochester
John Zeeff, Ann Arbor, MI
*/
#include "ckcker.h" /* Kermit symbols */
#include "ckcnet.h" /* Network symbols */
#ifndef NOSPL
#include "ckuusr.h"
#endif /* NOSPL */
#ifdef OS2ONLY
#define INCL_VIO /* Needed for ckocon.h */
#include <os2.h>
#undef COMMENT
#endif /* OS2ONLY */
#ifdef NT
#include <windows.h>
#include <tapi.h>
#include "ckntap.h"
#endif /* NT */
#ifndef NOSERVER
/* Text message definitions.. each should be 256 chars long, or less. */
#ifdef MINIX
char *srvtxt = "\r\n\
Entering server mode.\r\n\0";
#else
#ifdef OLDMSG
/*
It seems there was a large installation that was using C-Kermit 5A(165)
or thereabouts, which had deployed thousands of MS-DOS Kermit scripts in
scattered locations that looked for strings in the old server message,
which changed in 5A(183), August 1992.
*/
char *srvtxt = "\r\n\
C-Kermit server starting. Return to your local machine by typing\r\n\
its escape sequence for closing the connection, and issue further\r\n\
commands from there. To shut down the C-Kermit server, issue the\r\n\
FINISH or BYE command and then reconnect.\n\
\r\n\0";
#else
#ifdef OSK
char *srvtxt = "\r\012\
Entering server mode. If your local Kermit software is menu driven, use\r\012\
the menus to send commands to the server. Otherwise, enter the escape\r\012\
sequence to return to your local Kermit prompt and issue commands from\r\012\
there. Use SEND and GET for file transfer. Use REMOTE HELP for a list of\r\012\
other available services. Use BYE or FINISH to end server mode.\r\012\0";
#else /* UNIX, VMS, AOS/VS, and all others */
char *srvtxt = "\r\n\
Entering server mode. If your local Kermit software is menu driven, use\r\n\
the menus to send commands to the server. Otherwise, enter the escape\r\n\
sequence to return to your local Kermit prompt and issue commands from\r\n\
there. Use SEND and GET for file transfer. Use REMOTE HELP for a list of\r\n\
other available services. Use BYE or FINISH to end server mode.\r\n\0";
#endif /* OSK */
#endif /* OLDMSG */
#endif /* MINIX */
#else /* server mode disabled */
char *srvtxt = "";
#endif /* NOSERVER */
int initflg = 0; /* sysinit() has executed... */
int howcalled = I_AM_KERMIT; /* How I was called */
/* Multi-protocol support */
/* Command to put other Kermit into server mode */
char *srvstring = NULL;
struct ck_p ptab[NPROTOS] = { /* Initialize the Kermit part ... */
{ "Kermit",
DRPSIZ, /* Receive packet size */
DSPSIZ, /* Send packet size */
0, /* Send-packet-size-set flag */
DFWSIZ, /* Window size */
#ifdef NEWDEFAULTS
PX_CAU, /* Control char unprefixing... */
#else
PX_ALL,
#endif /* NEWDEFAULTS */
#ifdef VMS /* Default filename collision action */
XYFX_X, /* REPLACE for VAX/VMS */
#else
XYFX_B, /* BACKUP for everybody else */
#endif /* VMS */
#ifdef OS2 /* Flag for file name conversion */
XYFN_L, /* Literal for OS2 */
#else
XYFN_C, /* Converted for others */
#endif /* OS2 */
PATH_OFF, /* Send pathnames OFF */
PATH_OFF, /* Receive pathnames OFF */
NULL, /* Host receive initiation string (binary) */
NULL, /* Host receive initiation string (text) */
NULL, /* External protocol send command (binary) */
NULL, /* External protocol send command (text) */
NULL, /* External protocol receive command (bin) */
NULL } /* External protocol receive command (txt) */
#ifdef CK_XYZ
,
{ "XMODEM", 128,128,-1,-1, 1,-1,-1,0,0,NULL,NULL,NULL,NULL,NULL,NULL },
{ "XMODEM-CRC",128,128,-1,-1, -1,-1,-1,0,0,NULL,NULL,NULL,NULL,NULL,NULL },
{ "YMODEM", -1, -1,-1,-1, -1,-1,-1,0,0,NULL,NULL,NULL,NULL,NULL,NULL },
{ "YMODEM-g", -1, -1,-1,-1, -1,-1,-1,0,0,NULL,NULL,NULL,NULL,NULL,NULL },
{ "ZMODEM", -1, -1,-1,-1,PX_WIL,-1,-1,0,0,NULL,NULL,NULL,NULL,NULL,NULL },
{ "Other", -1, -1,-1,-1, -1,-1,-1,0,0,NULL,NULL,NULL,NULL,NULL,NULL }
#endif /* CK_XYZ */
};
/* Declarations for Send-Init Parameters */
int spsiz = DSPSIZ, /* Current packet size to send */
spmax = DSPSIZ, /* Biggest packet size we can send */
lastspmax = DSPSIZ, /* Send-packet size last used */
spsizr = DSPSIZ, /* Send-packet size requested */
spsizf = 0, /* Flag to override size negotiation */
rpsiz = DRPSIZ, /* Biggest we want to receive */
urpsiz = DRPSIZ, /* User-requested receive pkt size */
maxrps = MAXRP, /* Maximum incoming long packet size */
maxsps = MAXSP, /* Maximum outbound l.p. size */
maxtry = MAXTRY, /* Maximum retries per packet */
wslots = 1, /* Window size currently in use */
wslotr = DFWSIZ, /* Window size from SET WINDOW */
wslotn = 1, /* Window size negotiated in S-pkt */
timeouts = 0, /* For statistics reporting */
spackets = 0, /* ... */
rpackets = 0, /* ... */
retrans = 0, /* ... */
crunched = 0, /* ... */
wmax = 0, /* ... */
wcur = 0, /* ... */
#ifdef OS2
srvidl = 0, /* Server idle timeout */
#endif /* OS2 */
srvdis = 1, /* Server file xfer display */
srvtim = DSRVTIM, /* Server command wait timeout */
/*
timint is the timeout interval I use when waiting for a packet.
pkttim is the SET RECEIVE TIMEOUT value, sent to the other Kermit.
rtimo is the SET SEND TIMEOUT value. rtimo is the initial value of
timint. timint is changed by the value in the incoming negotiation
packet unless a SET SEND TIMEOUT command was given.
*/
timint = DMYTIM, /* Timeout interval I use */
pkttim = URTIME, /* Timeout I want you to use */
rtimo = DMYTIM, /* Normal packet wait timeout */
timef = 0, /* Flag to override what you ask */
#ifdef CK_TIMERS
rttflg = 1, /* Use dynamic round-trip timers */
#else
rttflg = 0, /* Use fixed timer */
#endif /* CK_TIMERS */
mintime = 1, /* Minimum timeout */
maxtime = 0, /* Maximum timeout */
npad = MYPADN, /* How much padding to send */
mypadn = MYPADN, /* How much padding to ask for */
bctr = DFBCT, /* Block check type requested */
bctu = 1, /* Block check type used */
bctl = 1, /* Block check length */
c_save = -1, /* Block check saving and restoring */
ss_save = -1, /* Slow-start saving and restoring */
ebq = MYEBQ, /* 8th bit prefix */
ebqflg = 0, /* 8th-bit quoting flag */
rqf = -1, /* Flag used in 8bq negotiation */
rq = 0, /* Received 8bq bid */
sq = 'Y', /* Sent 8bq bid */
rpt = 0, /* Repeat count */
rptq = MYRPTQ, /* Repeat prefix */
rptflg = 0, /* Repeat processing flag */
rptena = 1, /* Repeat processing enabled */
xfrcan = 1, /* Transfer cancellation enabled */
xfrchr = 3, /* Transfer cancel char = Ctrl-C */
xfrnum = 3; /* Need three of them. */
int epktflg = 0; /* E-PACKET command active */
int capas = 9, /* Position of Capabilities */
lpcapb = 2, /* Long Packet capability */
lpcapr = 1, /* requested */
lpcapu = 0, /* used */
swcapb = 4, /* Sliding Window capability */
swcapr = 1, /* requested (allowed) */
swcapu = 0, /* used */
atcapb = 8, /* Attribute capability */
atcapr = 1, /* requested */
atcapu = 0, /* used */
rscapb = 16, /* RESEND capability */
rscapr = 1, /* requested by default */
rscapu = 0, /* used */
lscapb = 32, /* Locking Shift capability */
lscapr = 1, /* requested by default */
lscapu = 0; /* used */
/* Flags for whether to use particular attributes */
int atenci = 1, /* Encoding in */
atenco = 1, /* Encoding out */
atdati = 1, /* Date in */
atdato = 1, /* Date out */
atdisi = 1, /* Disposition in/out */
atdiso = 1,
atleni = 1, /* Length in/out (both kinds) */
atleno = 1,
atblki = 1, /* Blocksize in/out */
atblko = 1,
attypi = 1, /* File type in/out */
attypo = 1,
atsidi = 1, /* System ID in/out */
atsido = 1,
atsysi = 1, /* System-dependent parameters in/out */
atsyso = 1;
#ifdef CK_PERMS
int atlpri = 1,
atlpro = 1,
atgpri = 1,
atgpro = 1;
#endif /* CK_PERMS */
#ifdef STRATUS
int atfrmi = 1, /* Format in/out */
atfrmo = 1,
atcrei = 1, /* Creator ID in/out */
atcreo = 1,
atacti = 1, /* Account in/out */
atacto = 1;
#endif /* STRATUS */
int sprmlen = -1; /* Send/Recieve protocol parameter */
int rprmlen = -1; /* string length limits */
CHAR padch = MYPADC, /* Padding character to send */
mypadc = MYPADC, /* Padding character to ask for */
seol = MYEOL, /* End-Of-Line character to send */
eol = MYEOL, /* End-Of-Line character to look for */
ctlq = CTLQ, /* Control prefix in incoming data */
myctlq = CTLQ, /* Outbound control character prefix */
myrptq = MYRPTQ; /* Repeat prefix I want to use */
int rptmin = 3; /* Repeat-count minimum */
int dironly = 0; /* Directories only, not files */
int fileonly = 0; /* Files only, not directories */
int usepipes = 0; /* Used for xfer to/from pipes */
char * filefile = NULL; /* File containing list of filenames */
char whoareu[16] = { NUL, NUL }; /* System ID of other Kermit */
int sysindex = -1; /* and index to its system ID struct */
int myindex = -1;
char * cksysid = /* My system ID */
#ifdef UNIX
"U1"
#else
#ifdef VMS
"D7"
#else
#ifdef OSK
"UD"
#else
#ifdef AMIGA
"L3"
#else
#ifdef MAC
"A3"
#else
#ifdef OS2
#ifdef NT
"UN"
#else /* NT */
"UO"
#endif /* NT */
#else /* OS2 */
#ifdef datageneral
"F3"
#else
#ifdef GEMDOS
"K2"
#else
#ifdef STRATUS
"MV"
#else
""
#endif /* STRATUS */
#endif /* GEMDOS */
#endif /* datageneral */
#endif /* OS2 */
#endif /* MAC */
#endif /* AMIGA */
#endif /* OSK */
#endif /* VMS */
#endif /* UNIX */
;
char uidbuf[64] = { NUL, NUL };
struct zattr iattr; /* Incoming file attributes */
/* File related variables, mainly for the benefit of (Open)VMS */
#ifdef NLCHAR /* Text-file line terminator */
CHAR feol = NLCHAR;
#else
CHAR feol = 0;
#endif
int fblksiz = DBLKSIZ; /* File blocksize */
int frecl = DLRECL; /* File record length */
int frecfm = XYFF_S; /* File record format (default = stream) */
int forg = XYFO_S; /* File organization (sequential) */
int fcctrl = XYFP_N; /* File carriage control (ctrl chars) */
#ifdef VMS
/* VMS labeled file default options - name only. */
int lf_opts = LBL_NAM;
#else
#ifdef OS2
/* OS/2 labeled file default options, all attributes but archived. */
unsigned long int lf_opts = LBL_EXT|LBL_HID|LBL_RO|LBL_SYS;
#else
int lf_opts = 0;
#endif /* OS2 */
#endif /* VMS */
/* Packet-related variables */
int pktnum = 0, /* Current packet number */
sndtyp = 0, /* Type of packet just sent */
rcvtyp = 0, /* Type of packet just received */
rsn, /* Received packet sequence number */
rln, /* Received packet length */
size, /* Current size of output pkt data */
osize, /* Previous output packet data size */
maxsize, /* Max size for building data field */
spktl = 0, /* Length packet being sent */
rpktl = 0, /* Length of packet just received */
pktpaus = 0, /* Interpacket pause interval, msec */
rprintf, /* REMOTE PRINT flag */
rmailf, /* MAIL flag */
xferstat = -1, /* Status of last transaction */
filestatus = 0; /* Status of last file transfer */
CHAR pktmsgbuf[PKTMSGLEN+1];
CHAR *epktmsg = pktmsgbuf;
CHAR
#ifdef pdp11
srvcmdbuf[MAXRP+4],
*srvcmd = srvcmdbuf,
#else
#ifdef DYNAMIC
*srvcmd = (CHAR *)0, /* Where to decode server command */
#else
srvcmdbuf[MAXRP+4],
*srvcmd = srvcmdbuf,
#endif /* DYNAMIC */
#endif /* pdp11 */
padbuf[96], /* Buffer for send-padding */
*recpkt,
*rdatap, /* Pointer to received packet data */
*data = (CHAR *)0, /* Pointer to send-packet data */
*srvptr, /* Pointer to srvcmd */
mystch = SOH, /* Outbound packet-start character */
stchr = SOH; /* Incoming packet-start character */
/* File-related variables */
#ifndef NOMSEND /* Multiple SEND */
struct filelist * filehead = NULL; /* SEND list */
struct filelist * filetail = NULL;
struct filelist * filenext = NULL;
int addlist = 0;
#endif /* NOMSEND */
char filnam[CKMAXPATH + 1]; /* Name of current file. */
int cfilef = 0; /* Application file flag. */
char cmdfil[CKMAXPATH + 1]; /* Application file name. */
#ifdef PIPESEND
char * sndfilter = NULL;
char * rcvfilter = NULL;
#endif /* PIPESEND */
#ifndef NOSERVER
int ngetpath = 0; /* GET search path */
int fromgetpath = 0;
char * getpath[MAXGETPATH];
char * x_user = NULL; /* Server login information */
char * x_passwd = NULL;
char * x_acct = NULL;
int x_login = 0; /* Login required */
int x_logged = 0; /* User is logged in */
#endif /* NOSERVER */
int nfils = 0; /* Number of files in file group */
long fsize; /* Size of current file */
int wildxpand = 0; /* Who expands wildcards */
int matchdot = 0; /* Whether to match dot files */
int clfils = 0; /* Flag for command-line files */
int stayflg = 0; /* Flag for "stay", i.e. "-S" */
/* Communication device / connection variables */
#ifdef BIGBUFOK
char ttname[512]; /* Name of communication device */
#else
#ifdef MAC
char ttname[256];
#else
#ifndef CK_SMALL
char ttname[128];
#else
char ttname[80];
#endif /* CK_SMALL */
#endif /* MAC */
#endif /* BIGBUFOK */
#ifdef MAC
int connected = 0; /* True if connected */
int startconnected; /* initial state of connected */
#endif /* MAC */
long speed = -1L; /* Communication device speed */
int parity = DEFPAR, /* Parity specified, 0,'e','o',etc */
autopar = 0, /* Automatic parity change flag */
sosi = 0, /* Shift-In/Out flag */
flow = FLO_XONX, /* Flow control */
autoflow = 1, /* Automatic flow control */
turn = 0, /* Line turnaround handshake flag */
turnch = XON, /* Line turnaround character */
duplex = 0, /* Duplex, full by default */
escape = DFESC, /* Escape character for connect */
ckdelay = DDELAY, /* Initial delay before sending */
tnlm = 0, /* Terminal newline mode */
mdmtyp = 0; /* Modem type (initially none) */
/* Networks for SET HOST */
#ifdef BIGBUFOK
#define MYHOSTL 1024
#else
#define MYHOSTL 100
#endif /* BIGBUFOK */
char myhost[MYHOSTL]; /* Local host name */
int network = 0; /* Network vs serial connection */
#ifdef NETCONN
#ifdef TCPSOCKET
int nettype = NET_TCPB; /* Assume TCP/IP (BSD sockets) */
#else
#ifdef SUNX25
int nettype = NET_SX25;
#else
#ifdef IBMX25
int nettype = NET_IX25;
#else
#ifdef HPX25
int nettype = NET_HX25;
#else
#ifdef STRATUSX25
int nettype = NET_VX25;
#else
#ifdef DECNET
int nettype = NET_DEC;
#else
#ifdef SUPERLAT
int nettype = NET_SLAT;
#else
int nettype = NET_NONE;
#endif /* SUPERLAT */
#endif /* DECNET */
#endif /* STRATUSX25 */
#endif /* HPX25 */
#endif /* IBMX25 */
#endif /* SUNX25 */
#endif /* TCPSOCKET */
#else /* NETCONN */
int nettype = NET_NONE;
#endif /* NETCONN */
#ifdef ANYX25
int revcall = 0; /* X.25 reverse call not selected */
int closgr = -1; /* X.25 closed user group not selected */
int cudata = 0; /* X.25 call user data not specified */
char udata[MAXCUDATA]; /* X.25 call user data */
#ifdef IBMX25
/*
I was unable to find any pre-defined MAX values for x25 addresses the
addresses that I've seen have been around 10-12 characters 32 is probably
enough, 64 is hopefully safe for everyone.
*/
x25addr_t local_nua = {'\0'}; /* local x.25 address */
x25addr_t remote_nua = {'\0'}; /* remote x.25 address */
char x25name[32] = {'\0'}; /* x25 device name, sx25a0 or sx25a1 */
char x25dev[64] = "/dev/x25pkt"; /* x25 device in /dev */
int x25port = 0; /* port used for X.25 - AIX only */
#endif /* IBMX25 */
#ifndef IBMX25
/*
This condition is unrelated to the above IBMX25 condition.
IBM X.25 doesn't have PAD support.
*/
CHAR padparms[MAXPADPARMS+1]; /* X.3 parameters */
#endif /* !IBMX25 */
#endif /* ANYX25 */
/* Other items */
int isinterrupted = 0; /* Used in exception handling */
extern int what;
#ifdef NT
extern int StartedFromDialer;
#ifdef NTSIG
extern int TlsIndex;
#endif /* NTSIG */
#ifdef NTASM
unsigned long ESPToRestore ; /* Ditto */
#endif /* NTASM */
#endif /* NT */
#ifdef OS2PM
int os2pm = 0; /* OS/2 Presentation Manager flag */
#endif /* OS2PM */
/* Terminal screen size, if known, -1 means unknown. */
#ifdef OS2
#include "ckocon.h"
int tt_rows[VNUM] = {25,24,25,1}; /* Rows (height) */
int tt_cols[VNUM] = {80,80,80,80}; /* Columns (width) */
int k95stdio = 0; /* Stdio threads */
#else /* OS2 */
int tt_rows = -1; /* Rows (height) */
int tt_cols = -1; /* Columns (width) */
#endif /* OS2 */
int tt_escape = 1; /* Escaping back is enabled */
int cmd_rows = 24, cmd_cols = 80; /* Command/console screen dimensions */
#ifdef NETCONN
extern int tn_exit;
#endif /* NETCONN */
int exitonclose = 0; /* Exit on close */
int haveline = 0; /* SET LINE or SET HOST in effect */
int tlevel = -1; /* Take-file command level */
#ifdef NOLOCAL
int remonly = 1; /* Remote-mode-only advisory (-R) */
#else
int remonly = 0;
#endif /* NOLOCAL */
#ifndef NOSPL
extern int cmdlvl; /* Command level */
extern int maclvl; /* Macro invocation level */
#endif /* NOSPL */
int protocol = PROTO_K; /* File transfer protocol = Kermit */
#ifdef NEWDEFAULTS
int prefixing = PX_CAU;
#else
int prefixing = PX_ALL;
#endif /* NEWDEFAULTS */
extern short ctlp[]; /* Control-prefix table */
int carrier = CAR_AUT; /* Pay attention to carrier signal */
int cdtimo = 0; /* Carrier wait timeout */
int xitsta = GOOD_EXIT; /* Program exit status */
#ifdef VMS /* Default filename collision action */
int fncact = XYFX_X; /* REPLACE for VAX/VMS */
#else
int fncact = XYFX_B; /* BACKUP for everybody else */
#endif /* VMS */
int fncsav = -1; /* For saving & restoring the above */
int bgset = -1; /* BACKGROUND mode set explicitly */
#ifdef UNIX
int suspend = DFSUSP; /* Whether SUSPEND command, etc, */
#else /* is to be allowed. */
int suspend = 0;
#endif /* UNIX */
/* Statistics variables */
long filcnt, /* Number of files in transaction */
filrej, /* Number of files rejected in transaction */
flci, /* Characters from line, current file */
flco, /* Chars to line, current file */
tlci, /* Chars from line in transaction */
tlco, /* Chars to line in transaction */
ffc, /* Chars to/from current file */
tfc, /* Chars to/from files in transaction */
cps = 0L, /* Chars/sec last transfer */
peakcps = 0L, /* Peak chars/sec last transfer */
ccu, /* Control chars unprefixed in transaction */
ccp, /* Control chars prefixed in transaction */
rptn; /* Repeated characters compressed */
int tsecs = 0; /* Seconds for transaction */
int fsecs = 0; /* Per-file timer */
#ifdef GFTIMER
CKFLOAT
fpfsecs = 0.0, /* Floating point per-file timer */
fptsecs = 0.0; /* and per-transaction timer */
#endif /* GFTIMER */
/* Flags */
int deblog = 0, /* Flag for debug logging */
debses = 0, /* Flag for DEBUG SESSION */
pktlog = 0, /* Flag for packet logging */
seslog = 0, /* Session logging */
tralog = 0, /* Transaction logging */
tlogfmt = 1, /* Transaction log format (verbose) */
tlogsep = (int)',', /* Transaction log field separator */
displa = 0, /* File transfer display on/off */
stdouf = 0, /* Flag for output to stdout */
stdinf = 0, /* Flag for input from stdin */
xflg = 0, /* Flag for X instead of F packet */
hcflg = 0, /* Doing Host command */
dest = DEST_D, /* Destination for packet data */
/* If you change this, also see struct ptab above... */
#ifdef OS2 /* Flag for file name conversion */
fncnv = XYFN_L, /* Default is Literal in OS/2, */
f_save = XYFN_L, /* (saved copy of same) */
#else
fncnv = XYFN_C, /* elsewhere Convert them */
f_save = XYFN_C, /* (ditto) */
#endif /* OS2 */
fnspath = PATH_OFF, /* Send file path */
fnrpath = PATH_OFF, /* Receive file path */
#ifdef NEWDEFAULTS
binary = XYFT_B, /* Default file transfer mode */
b_save = XYFT_B, /* Saved file mode */
#else
binary = XYFT_T, /* Default file transfer mode */
b_save = XYFT_T, /* Saved file mode */
#endif /* NEWDEFAULTS */
eofmethod = 0, /* EOF detection method (length) */
#ifdef OS2
cursor_save = -1, /* Cursor state */
#endif /* OS2 */
xfermode = XMODE_A, /* Transfer mode, manual or auto */
recursive = 0, /* Recursive directory traversal */
sendmode = SM_SEND, /* Which type of SEND operation */
slostart = 1, /* Slow start (grow packet lengths) */
cmask = 0177, /* CONNECT (terminal) byte mask */
fmask = 0377, /* File byte mask */
ckwarn = 0, /* Flag for file warning */
quiet = 0, /* Be quiet during file transfer */
local = 0, /* 1 = local mode, 0 = remote mode */
server = 0, /* Flag for I Am Server */
urserver = 0, /* Flag for You Are Server */
bye_active = 0, /* Flag for BYE command active */
cflg = 0, /* Connect before transaction */
cnflg = 0, /* Connect after transaction */
cxseen = 0, /* Flag for cancelling a file */
czseen = 0, /* Flag for cancelling file group */
discard = 0, /* Flag for file to be discarded */
keep = 1, /* Keep incomplete files */
unkcs = 1, /* Keep file w/unknown character set */
nakstate = 0, /* In a state where we can send NAKs */
dblchar = -1, /* Character to double when sending */
moving = 0, /* MOVE = send, then delete */
reliable = 0, /* Nonzero if transport is reliable */
xreliable = -1,
urclear = 0, /* Nonzero for clear channel to you */
clearrq = SET_AUTO, /* SET CLEARCHANEL value */
cleared = 0,
streaming = 0, /* Nonzero if streaming is active */
streamok = 0, /* Nonzero if streaming negotiated */
streamrq = SET_AUTO, /* SET STREAMING value */
streamed = -1; /* Whether we streamed last time */
#ifdef UNIXOROSK
int alphacase = 1; /* Case matters in filenames */
#else
int alphacase = 0; /* Case doesn't matter in filenames */
#endif /* UNIXOROSK */
char * snd_move = NULL; /* Move file after sending it */
char * snd_rename = NULL; /* Rename file after sending it */
long sendstart = 0L; /* SEND start position */
long calibrate = 0L; /* Nonzero if calibration run */
#ifdef CK_TRIGGER
char *tt_trigger[TRIGGERS] = { NULL, NULL };
CHAR *tt_trmatch[TRIGGERS] = { NULL, NULL };
char *triggerval = NULL;
#endif /* CK_TRIGGER */
#ifndef NOHELP
#ifndef NOCMDL
_PROTOTYP( VOID iniopthlp, (void) ); /* Command-line help initializer */
#endif /* NOCMDL */
#endif /* NOHELP */
/* Variables passed from command parser to protocol module */
#ifndef NOSPL
#ifndef NOICP
_PROTOTYP( int parser, (int) ); /* The parser itself */
#ifdef CK_APC
_PROTOTYP( VOID apconect, (void) );
#endif /* CK_APC */
#endif /* NOICP */
#endif /* NOSPL */
char *clcmds = NULL; /* Pointer to command-line commands */
#ifdef CK_CURSES
#ifndef OS2
#ifndef COHERENT
_PROTOTYP( VOID fxdinit, (void) );
#endif /* COHERENT */
#endif /* OS2 */
#endif /* CK_CURSES */
CHAR sstate = (CHAR) 0; /* Starting state for automaton */
CHAR zstate = (CHAR) 0; /* For remembering sstate */
char *cmarg = ""; /* Pointer to command data */
char *cmarg2 = ""; /* Pointer to 2nd command data */
char **cmlist; /* Pointer to file list in argv */
#ifdef CK_AUTODL /* Autodownload */
#ifdef OS2
int autodl = 1; /* Enabled by default only in */
#else /* terminal-emulating versions, */
int autodl = 0; /* disabled by default for others */
#endif /* OS2 */
#else /* CK_AUTODL */
int autodl = 0; /* (or if not implemented). */
#endif /* CK_AUTODL */
#ifdef OS2 /* AUTODOWNLOAD parameters */
int adl_kmode = ADL_PACK, /* Match Packet to signal download */
adl_zmode = ADL_PACK;
char * adl_kstr = NULL; /* KERMIT Download String */
char * adl_zstr = NULL; /* ZMODEM Download String */
#endif /* OS2 */
int remfile = 0, rempipe = 0, remappd = 0; /* REMOTE output redirection */
char * remdest = NULL;
char * printername = NULL; /* NULL if printer not redirected */
int printpipe = 0; /* For SET PRINTER */
/*
Server services:
0 = disabled
1 = enabled in local mode
2 = enabled in remote mode
3 = enabled in both local and remote modes
only as initial (default) values.
*/
int en_cwd = 3; /* CD/CWD */
int en_cpy = 3; /* COPY */
int en_del = 2; /* DELETE */
int en_mkd = 3; /* MKDIR */
int en_rmd = 2; /* RMDIR */
int en_dir = 3; /* DIRECTORY */
int en_fin = 3; /* FINISH */
int en_get = 3; /* GET */
int nopush = 0; /* PUSH enabled */
#ifndef NOPUSH
int en_hos = 2; /* HOST enabled */
#else
int en_hos = 0; /* HOST disabled */
#endif /* NOPUSH */
int en_ren = 3; /* RENAME */
int en_sen = 3; /* SEND */
int en_set = 3; /* SET */
int en_spa = 3; /* SPACE */
int en_typ = 3; /* TYPE */
int en_who = 3; /* WHO */
#ifdef datageneral
/* Data General AOS/VS can't do this */
int en_bye = 0; /* BYE */
#else
int en_bye = 2; /* PCs in local mode... */
#endif /* datageneral */
int en_asg = 3; /* ASSIGN */
int en_que = 3; /* QUERY */
int en_ret = 2; /* RETRIEVE */
int en_mai = 3; /* MAIL */
int en_pri = 3; /* PRINT */
/* Miscellaneous */
char **xargv; /* Global copies of argv */
int xargc; /* and argc */
int xargs; /* an immutable copy of argc */
char *xarg0; /* and of argv[0] */
char *pipedata; /* Pointer to -P (pipe) data */
extern char *dftty; /* Default tty name from ck?tio.c */
extern int dfloc; /* Default location: remote/local */
extern int dfprty; /* Default parity */
extern int dfflow; /* Default flow control */
/*
Buffered file input and output buffers. See getpkt() in ckcfns.c
and zoutdump() in the system-dependent file i/o module (usually ck?fio.c).
*/
#ifndef DYNAMIC
/* Now we allocate them dynamically, see getiobs() below. */
char zinbuffer[INBUFSIZE], zoutbuffer[OBUFSIZE];
#endif /* DYNAMIC */
char *zinptr, *zoutptr;
int zincnt, zoutcnt;
int zobufsize = OBUFSIZE;
int zofbuffer = 1;
int zofblock = 1;
#ifdef SESLIMIT
int seslimit = 0;
#endif /* SESLIMIT */
_PROTOTYP( int getiobs, (VOID) );
/* M A I N -- C-Kermit main program */
#include <signal.h>
#ifndef NOCCTRAP
#include <setjmp.h>
#include "ckcsig.h"
ckjmpbuf cmjbuf;
#ifdef GEMDOS /* Special for Atari ST */
cc_clean(); /* This can't be right? */
#endif /* GEMDOS */
#endif /* NOCCTRAP */
/* C K I N D E X -- C-Kermit's index function */
/*
We can't depend on C libraries to have one, so here is our own.
Call with:
s1 - String to look for.
s2 - String to look in.
t - Starting position in s2, 0 based, or -1 for rightmost char in s2.
r - 0 for left-to-right search, non-0 for right-to-left.
icase 0 for case independence, non-0 if alphabetic case matters.
Returns 0 if string not found, otherwise a 1-based result.
*/
int
ckindex(s1,s2,t,r,icase) char *s1, *s2; int t, r, icase; {
int len1, len2, i, j, x;
char * s;
if (!s1 || !s2) return(0);
len1 = (int)strlen(s1); /* length of string to look for */
len2 = (int)strlen(s = s2); /* length of string to look in */
if (t < 0) t = len2 - 1;
if (len1 < 0) return(0); /* paranoia */
if (len2 < 0) return(0);
j = len2 - len1; /* length difference */
if (j < 0 || t > j) { /* search string is longer */
return(0);
} else { /* Args are OK */
s = s2 + t; /* Point to beginning of target */
if (r == 0) { /* Index */
for (i = 0; i <= (j - t); i++) { /* Now compare */
x = icase ? strncmp(s1,s++,len1) : xxstrcmp(s1,s++,len1);
if (!x)
return(i+1+t);
}
} else { /* Reverse Index */
for (i = t; i > -1 && s >= s1; i--) { /* Compare */
x = icase ? strncmp(s1,s--,len1) : xxstrcmp(s1,s--,len1);
if (!x)
return(i+1);
}
}
return(0);
}
}
/* C K S T R C H R -- Pointer to first occurrence of char in string */
char *
#ifdef CK_ANSIC
ckstrchr(char * s, char c)
#else /* CK_ANSIC */
ckstrchr(s,c) char * s; char c;
#endif /* CK_ANSIC */
/* ckstrchr */ {
while (*s) {
if (*s == c)
return(s);
s++;
}
return(NULL);
}
/* Tell if a pathname is absolute (vs relative) */
/* This should be parceled out to each of the ck*fio.c modules... */
int
isabsolute(path) char * path; {
int rc = 0;
int x;
if (!path)
return(0);
if (!*path)
return(0);
x = (int) strlen(path);
debug(F111,"isabsolute",path,x);
#ifdef VMS
rc = 0;
x = ckindex("[",path,0,0,0); /* 1-based */
debug(F111,"isabsolute left bracket",path,x);
if (x > 0)
if (path[x] != '.') /* 0-based */
rc = 1;
#else
#ifdef UNIX
if (*path == '/'
#ifdef DTILDE
|| *path == '~'
#endif /* DTILDE */
)
rc = 1;
#else
#ifdef OS2
if (*path == '/' || *path == '\\')
rc = 1;
else if (isalpha(*path) && x > 1)
if (*(path+1) == ':')
rc = 1;
#else
#ifdef AMIGA
if (*path == '/'
#ifdef DTILDE
|| *path == '~'
#endif /* DTILDE */
)
rc = 1;
#else
#ifdef OSK
if (*path == '/'
#ifdef DTILDE
|| *path == '~'
#endif /* DTILDE */
)
rc = 1;
#else
#ifdef datageneral
if (*path == ':')
rc = 1;
#else
#ifdef MAC
rc = 0; /* Fill in later... */
#else
#ifdef STRATUS
rc = 0; /* Fill in later... */
#else
#ifdef GEMDOS
if (*path == '/' || *path == '\\')
rc = 1;
else if (isalpha(*path) && x > 1)
if (*(path+1) == ':')
rc = 1;
#endif /* GEMDOS */
#endif /* STRATUS */
#endif /* MAC */
#endif /* datageneral */
#endif /* OSK */
#endif /* AMIGA */
#endif /* OS2 */
#endif /* UNIX */
#endif /* VMS */
debug(F101,"isabsolute rc","",rc);
return(rc);
}
/* See if I have direct access to the keyboard */
int
is_a_tty(n) int n; {
#ifdef KUI
return 1;
#else /* KUI */
#ifdef NT
if (isWin95())
return(1);
else
return(_isatty(n));
#else
return(isatty(n));
#endif /* NT */
#endif /* KUI */
}
/* Info associated with a system ID */
struct sysdata sysidlist[] = { /* Add others as needed... */
{ "0", "anonymous", 0, NUL, 0, 0, 0 },
{ "A1", "Apple II", 0, NUL, 0, 0, 3 }, /* fix this */
{ "A3", "Macintosh", 1, ':', 0, 2, 1 },
{ "D7", "VMS", 0, ']', 1, 0, 0 },
{ "DA", "RSTS/E", 0, ']', 1, 0, 3 }, /* (i think...) */
{ "DB", "RT11", 0, NUL, 1, 0, 3 }, /* (maybe...) */
{ "F3", "AOS/VS", 1, ':', 0, 0, 2 },
{ "I1", "VM/CMS", 0, NUL, 0, 0, 0 },
{ "I2", "MVS/TSO", 0, NUL, 0, 0, 0 },
{ "I4", "MUSIC", 0, NUL, 0, 0, 0 },
{ "I7", "CICS", 0, NUL, 0, 0, 0 },
{ "I9", "MVS/ROSCOE", 0, NUL, 0, 0, 0 },
{ "K2", "Atari ST", 1, '\\', 1, 0, 3 },
{ "L3", "Amiga", 1, '/', 1, 0, 2 },
{ "MV", "Stratus VOS", 1, '>', 0, 1, 0 },
{ "N3", "Apollo Aegis", 1, '/', 0, 3, 2 },
{ "U1", "UNIX", 1, '/', 0, 3, 2 },
{ "U8", "MS-DOS", 1, '\\', 1, 0, 3 },
{ "UD", "OS-9", 1, '/', 0, 3, 2 },
{ "UN", "Windows-32", 1, '\\', 1, 2, 3 },
{ "UO", "OS/2", 1, '\\', 1, 2, 3 }
};
static int nxxsysids = (sizeof(sysidlist) / sizeof(struct sysdata));
/* Given a Kermit system ID code, return the associated name string */
/* and some properties of the filenames... */
char *
getsysid(s) char * s; { /* Get system-type name */
int i;
if (!s) return("");
for (i = 0; i < nxxsysids; i++)
if (!strcmp(sysidlist[i].sid_code,s))
return(sysidlist[i].sid_name);
return(s);
}
int
getsysix(s) char *s; { /* Get system-type index */
int i;
if (!s) return(-1);
for (i = 0; i < nxxsysids; i++)
if (!strcmp(sysidlist[i].sid_code,s))
return(i);
return(-1);
}
/* Initialize file transfer protocols */
VOID
initproto(y, upbstr, uptstr, sndbstr, sndtstr, rcvbstr, rcvtstr)
int y;
char * upbstr, * uptstr, * sndbstr, * sndtstr, * rcvbstr, * rcvtstr;
/* initproto */ {
char * p;
if (upbstr) /* Convert null strings */
if (!*upbstr) /* to null pointers */
upbstr = NULL;
if (uptstr) /* Convert null strings */
if (!*uptstr) /* to null pointers */
uptstr = NULL;
if (sndbstr)
if (!*sndbstr)
sndbstr = NULL;
if (sndtstr)
if (!*sndtstr)
sndtstr = NULL;
if (rcvbstr)
if (!*rcvbstr)
rcvbstr = NULL;
if (rcvtstr)
if (!*rcvtstr)
rcvtstr = NULL;
protocol = y; /* Set protocol */
if (protocol == PROTO_K && !srvstring) {
if (p = (char *) malloc(10)) {
strcpy(p,"kermit -x");
srvstring = p;
}
}
if (ptab[protocol].rpktlen > -1)
urpsiz = ptab[protocol].rpktlen;
if (ptab[protocol].spktflg > -1)
spsizf = ptab[protocol].spktflg;
if (ptab[protocol].spktlen > -1) {
spsiz = ptab[protocol].spktlen;
debug(F101,"initproto spsiz","",spsiz);
if (spsizf) {
spsizr = spmax = spsiz;
debug(F101,"initproto spsizr","",spsizr);
}
}
if (ptab[protocol].winsize > -1)
wslotr = ptab[protocol].winsize;
if (ptab[protocol].prefix > -1)
prefixing = ptab[protocol].prefix;
if (ptab[protocol].fnca > -1)
fncact = ptab[protocol].fnca;
if (ptab[protocol].fncn > -1)
fncnv = ptab[protocol].fncn;
if (ptab[protocol].fnsp > -1)
fnspath = ptab[protocol].fnsp;
if (ptab[protocol].fnrp > -1)
fnrpath = ptab[protocol].fnrp;
makestr(&(ptab[protocol].h_b_init),upbstr);
makestr(&(ptab[protocol].h_t_init),uptstr);
makestr(&(ptab[protocol].p_b_scmd),sndbstr);
makestr(&(ptab[protocol].p_t_scmd),sndtstr);
makestr(&(ptab[protocol].p_b_rcmd),rcvbstr);
makestr(&(ptab[protocol].p_t_rcmd),rcvtstr);
}
/*
M A K E S T R -- Creates a dynamically allocated string.
Makes a new copy of string s and sets pointer p to its address.
Handles degenerate cases, like when buffers overlap or are the same,
one or both arguments are NULL, etc.
*/
VOID
makestr(p,s) char **p, *s; {
int x;
char *q = NULL;
if (*p == s) /* The two pointers are the same. */
return; /* Don't do anything. */
if (!s) { /* New definition is null? */
if (*p) /* Free old storage. */
free(*p);
*p = NULL; /* Return null pointer. */
return;
}
if ((x = strlen(s)) >= 0) { /* Get length, even of empty string. */
q = malloc(x + 1); /* Get and point to temp storage. */
if (q)
strcpy(q,s);
} else
q = NULL; /* Length of string is zero */
if (*p) /* Now free the original storage. */
free(*p);
*p = NULL;
if (!q)
return;
if (x >= 0) { /* Get length. */
if (*p = malloc(x + 1))
strcpy(*p,q);
}
free(q); /* Free temporary buffer. */
}
/* X M A K E S T R - Non-destructive makestr() if s is NULL. */
VOID
xmakestr(p,s) char **p, *s; {
if (s) makestr(p,s);
}
/* C K M E M C P Y -- Portable memcpy() */
/* Copies n bytes from s to p, allowing for overlap. */
VOID
ckmemcpy(p,s,n) char *p, *s; int n; {
char * q = NULL;
register int i;
int x;
if (!s || !p || n <= 0 || p == s) /* Verify args */
return;
x = p - s; /* Check for overlap */
if (x < 0)
x = 0 - x;
if (x < n) { /* They overlap */
q = p;
if (!(p = (char *)malloc(n))) /* So use a temporary buffer */
return;
}
for (i = 0; i < n; i++) /* Copy n bytes */
p[i] = s[i];
if (q) { /* If we used a temporary buffer */
for (i = 0; i < n; i++) /* copy from it to destination */
q[i] = p[i];
if (p) free(p); /* and free the temporary buffer */
}
}
/* X X S T R C M P -- Caseless string comparison */
/*
Call with pointers to the two strings, s1 and s2, and a length, n.
Call with n == -1 to compare without a length limit.
Compares up to n characters of the two strings and returns:
1 if s1 > t1
0 if s1 = s2
-1 if s1 < t1
*/
int
xxstrcmp(s1,s2,n) char *s1, *s2; int n; { /* Caseless string comparison. */
CHAR t1, t2;
if (!s1) s1 = ""; /* Watch out for null pointers. */
if (!s2) s2 = "";
while (n--) {
t1 = (CHAR) *s1++; /* Get next character from each. */
t2 = (CHAR) *s2++;
if (!t1) return(t2 ? -1 : 0);
if (!t2) return(t1 ? -1 : 0);
if (isupper(t1)) t1 = tolower(t1);
if (isupper(t2)) t2 = tolower(t2);
if (t1 < t2) return(-1); /* s1 < s2 */
if (t1 > t2) return(1); /* s1 > s2 */
}
return(0); /* They're equal */
}
/* X X S T R P R E -- Caseless string prefix comparison */
/* Returns position of the first char in the 2 strings that doesn't match */
int
xxstrpre(s1,s2) char *s1, *s2; {
CHAR t1, t2;
int n = 0;
if (!s1) s1 = "";
if (!s2) s2 = "";
while (1) {
t1 = (CHAR) *s1++;
t2 = (CHAR) *s2++;
if (!t1 || !t2) return(n);
if (isupper(t1)) t1 = tolower(t1);
if (isupper(t2)) t2 = tolower(t2);
if (t1 != t2)
return(n);
n++;
}
}
/* C K M A T C H -- Match a string against a pattern */
/*
Call with a pattern containing * and/or ? metacharacters.
xx is 1 if case-sensitive, 0 otherwise
Returns:
0 if string does not match pattern,
1 if it does.
*/
int
ckmatch(pattern, string, xx) char *pattern,*string; int xx; {
char *psave, *ssave; /* Backup pointers for failure */
int q = 0; /* Quote flag */
char c1, c2;
debug(F110,"ckmatch string",string,0);
debug(F110,"ckmatch pattern",pattern,0);
psave = ssave = NULL;
while (1) {
#ifdef COMMENT
for (; *pattern == *string; pattern++,string++) /* skip first */
if (*string == '\0') /* End of strings, succeed */
return(1);
if (*pattern == '\\' && q == 0) { /* Watch out for quoted */
q = 1; /* metacharacters */
pattern++; /* advance past quote */
c1 = *pattern;
c2 = *string;
if (xx) {
if (isupper(c1)) c1 = tolower(c1);
if (isupper(c2)) c2 = tolower(c2);
}
if (c1 != c2) return(0);
continue;
} else q = 0;
if (q) {
return(0);
} else {
if (*string != '\0' && *pattern == '?') {
pattern++; /* '?', let it match */
string++;
} else if (*pattern == '*') { /* '*' ... */
psave = ++pattern; /* remember where we saw it */
ssave = string; /* let it match 0 chars */
} else if (ssave != NULL && *ssave != '\0') { /* if not at end */
/* ...have seen a star */
string = ++ssave; /* skip 1 char from string */
pattern = psave; /* and back up pattern */
} else /* otherwise fail */
return(0);
}
#else
if (xx) {
/* Case Sensitive comparision */
for (; *pattern == *string; pattern++,string++) /* skip first */
if (*string == '\0') /* End of strings, succeed */
return(1);
} else {
/* Ignore case */
/* convert each char to lower case before comparison */
while (1) {
c1 = *pattern;
c2 = *string;
if (isupper(c1)) c1 = tolower(c1);
if (isupper(c2)) c2 = tolower(c2);
if (c1 == c2) {
if (*string == '\0')
return(1);
pattern++;
string++;
} else
break;
}
}
if (*pattern == '\\' && q == 0) { /* Watch out for quoted */
q = 1; /* metacharacters */
pattern++; /* advance past quote */
c1 = *pattern;
c2 = *string;
if (!xx) {
if (isupper(c1)) c1 = tolower(c1);
if (isupper(c2)) c2 = tolower(c2);
}
if (c1 != c2) return(0);
continue;
} else
q = 0;
if (q)
return(0);
if (*string != '\0' && *pattern == '?') {
pattern++; /* '?', let it match */
string++;
} else if (*pattern == '*') { /* '*' ... */
psave = ++pattern; /* remember where we saw it */
ssave = string; /* let it match 0 chars */
} else if (ssave != NULL && *ssave != '\0') { /* if not at end */
/* ...have seen a star */
string = ++ssave; /* skip 1 char from string */
pattern = psave; /* and back up pattern */
} else /* otherwise fail */
return(0);
#endif /* COMMENT */
}
}
/* Filename pattern recognition lists for automatic text/binary switching */
#ifdef PATTERNS
int patterns = 1; /* Use patterns: 0 = no, 1 = yes */
char *txtpatterns[FTPATTERNS+1] = { NULL, NULL };
char *binpatterns[FTPATTERNS+1] = { NULL, NULL };
/*
Default pattern lists for each platform...
NOTE: We leave ".doc", ".hlp", ".ini", and ".scr" alone; although they are
traditionally text types, they are binary in Windows. So they are handled
by the prevailing SET FILE TYPE, rather than automatically. Similarly for
".dat", ".inf", and so on. Also ".ps" since PostScript files are not
always text.
*/
#ifdef UNIXOROSK
static char *txtp[FTPATTERNS] = {
"*.txt","*.c","*.h","*.r","*.w","*.cpp","*.ksc","*.bwr","*.upd",
"*.html","*.htm","*.mss","*.tex","*.nr","*akefile", "*.hex", "*.hqx",
"*.for","*.f77","*.f","*.F","*.s","*.pas","*.java","*.el",".lisp",
"*.sh","*.perl","*.awk","*.sno","*.spt","*.sed",
"*.TXT", "*read.me", "*READ.ME", ".*", "*/.*", NULL
};
static char *binp[FTPATTERNS] = {
"*.gz","*.Z","*.tgz","*.gif", "*.tar","*.zip","*.o","*.so","*.a","*.out",
"*.exe", "*.jpg", "*.jpeg", "*.tif","*.tiff", "*.pdf", "*.so.*", "*.class",
"*.rpm", "*.bmp", ".bz2", "*.BMP", "*.dll", NULL
};
#else
#ifdef OS2
static char *txtp[FTPATTERNS] = {
"*.txt","*.ksc","*.htm","*.html","*.bat","*.cmd","*.jav","*.asm", "*.hex",
"*.hqx", "*.c", "*.h", "*.w", "*.html", "*.java", "*.bwr", "*.upd",
"read.me", NULL
};
static char *binp[FTPATTERNS] = {
"*.exe", "*.zip", "*.obj", "*.com", "*.gif", "*.jpg", "*.wav", "*.ram",
"*.class", "*.cla", "*.dll", "*.drv", "*.ocx", "*.vbx", "*.lib", "*.ico",
"*.bmp", "*.tif", "*.tar", "*.gz", "*.tgz", "*.xl*", NULL
};
#else
#ifdef datageneral
static char *txtp[FTPATTERNS] = {
"*.txt", "*.c", "*.h", "*.w", "*.er", "*.bwr", "*.upd", "read.me",
"*.cli", "*.ksc", NULL
};
static char *binp[FTPATTERNS] = {
"*.ob", "*.pr", ".dmp", NULL
};
#else
/* Fill in others here if appropriate */
static char *binp[FTPATTERNS] = { NULL, NULL };
static char *txtp[FTPATTERNS] = { NULL, NULL };
#endif /* datageneral */
#endif /* OS2 */
#endif /* UNIXOROSK */
/*
Set up default pattern lists so they can be freed and re-malloc'd.
Each pattern list must terminated by a null element.
*/
VOID
initpat() {
int i;
for (i = 0; i < FTPATTERNS; i++) {
txtpatterns[i] = NULL;
binpatterns[i] = NULL;
}
for (i = 0; i < FTPATTERNS; i++) {
makestr(&(txtpatterns[i]),txtp[i]);
if (!txtp[i])
break;
}
for (i = 0; i < FTPATTERNS; i++) {
makestr(&(binpatterns[i]),binp[i]);
if (!binp[i])
break;
}
}
#endif /* PATTERNS */
#ifndef NOCMDL
VOID
#ifdef CK_ANSIC
docmdline(void * threadinfo)
#else /* CK_ANSIC */
docmdline(threadinfo) VOID * threadinfo;
#endif /* CK_ANSIC */
{
#ifdef NTSIG
setint();
if (threadinfo) { /* Thread local storage... */
TlsSetValue(TlsIndex,threadinfo);
debug( F100, "docmdline called with threadinfo block", "", 0 );
} else
debug( F100, "docmdline threadinfo is NULL","",0) ;
#endif /* NTSIG */
proto(); /* Take any requested action, then */
if (!quiet) /* put cursor back at left margin, */
conoll("");
#ifndef NOLOCAL
if (cnflg) doconect(0); /* connect if requested. */
#endif /* NOLOCAL */
#ifdef NTSIG
ckThreadEnd(threadinfo);
#endif /* NTSIG */
return;
}
VOID
#ifdef CK_ANSIC
failcmdline(void * foo)
#else /* CK_ANSIC */
failcmdline(foo) VOID * foo;
#endif /* CK_ANSIC */
{
#ifdef GEMDOS
cc_clean();
#endif /* GEMDOS */
#ifndef NOLOCAL
if (cnflg) doconect(0); /* connect again if requested. */
#endif /* NOLOCAL */
}
#endif /* NOCMDL */
#ifndef NOICP
VOID
#ifdef CK_ANSIC
dotakeini(void * threadinfo) /* Execute init file. */
#else /* CK_ANSIC */
dotakeini(threadinfo) VOID * threadinfo; /* Execute init file. */
#endif /* CK_ANSIC */
/* dotakeini */ {
#ifdef NTSIG
setint();
if (threadinfo) { /* Thread local storage... */
TlsSetValue(TlsIndex,threadinfo);
debug( F100, "dotakeini called with threadinfo block","", 0 ) ;
} else
debug( F100, "dotakeini - threadinfo is NULL", "", 0 ) ;
#endif /* NTSIG */
cmdini(); /* Sets tlevel */
doinit(); /* Initialization file */
debug(F101,"main executing init file","",tlevel);
while (tlevel > -1) {
sstate = (CHAR) parser(1); /* Execute one command at a time. */
if (sstate) proto(); /* Enter protocol if requested. */
#ifdef NTSIG
ck_ih();
#endif /* NTSIG */
}
debug(F101,"main exits init file","",tlevel);
#ifdef NTSIG
ckThreadEnd(threadinfo);
#endif /* NTSIG */
return;
}
VOID
#ifdef CK_ANSIC
failtakeini(void * threadinfo)
#else /* CK_ANSIC */
failtakeini(threadinfo) VOID * threadinfo;
#endif /* CK_ANSIC */
/* failtakeini */ {
#ifdef GEMDOS
cc_clean(); /* Atari: Clean up after ^C-trap. */
#endif /* GEMDOS */
conoll("Interrupt during initialization or command-line processing.");
conoll("C-Kermit quitting...");
doexit(BAD_EXIT,-1); /* Exit with bad status. */
}
VOID
#ifdef CK_ANSIC
doicp(void * threadinfo)
#else /* CK_ANSIC */
doicp(threadinfo) VOID * threadinfo;
#endif /* CK_ANSIC */
/* doicp */ {
#ifdef NTSIG
setint();
if (threadinfo) { /* Thread local storage... */
if (!TlsSetValue(TlsIndex,threadinfo))
debug(F101,"doicp TlsSetValue failed","",GetLastError() ) ;
debug( F101, "doicp a threadinfo block - TlsIndex", "", TlsIndex ) ;
} else {
debug( F100, "doicp received a null threadinfo", "", 0 ) ;
}
#endif /* NTSIG */
#ifdef MAC
while (1) {
extern char *lfiles; /* Fake pointer cast */
if (connected) {
debug(F100, "doicp: calling macparser", "", 0);
sstate = newparser(1, 1, 0L);
/* ignore null command state */
if (sstate == 'n')
sstate = '\0';
if (sstate)
proto();
} else {
/*
* process take files the finder gave us.
*/
if ((tlevel == -1) && lfiles)
startlfile();
debug(F100, "doicp: calling parser", "", 0);
sstate = (CHAR) parser(0);
if (sstate == 'c') /* if MAC connect */
sstate = 0;
if (sstate)
proto();
}
}
#else /* Not MAC */
#ifndef NOSPL
/*
If interactive commands were given on the command line (using the
-C "command, command, ..." option), assign them to a macro called
"cl_commands", then execute the macro and leave it defined for
subsequent re-execution if desired.
*/
if (clcmds) { /* Check for -C commands */
int x;
x = addmac("cl_commands",clcmds); /* Put macro in table */
if (x > -1) { /* If successful, */
dodo(x,NULL,CF_CMDL); /* set up for macro execution */
while (maclvl > -1) { /* Loop getting macro commands. */
sstate = (CHAR) parser(1);
if (sstate) proto(); /* Enter protocol if requested. */
#ifdef NTSIG
ck_ih();
#endif /* NTSIG */
}
}
herald();
}
#endif /* NOSPL */
while(1) { /* Loop getting commands. */
sstate = (CHAR) parser(0);
if (sstate) proto(); /* Enter protocol if requested. */
#ifdef NTSIG
ck_ih();
#endif /* NTSIG */
}
#ifdef NTSIG
ckThreadEnd(threadinfo);
#endif /* NTSIG */
#endif /* MAC */
}
VOID
#ifdef CK_ANSIC
failicp(void * threadinfo)
#else /* CK_ANSIC */
failicp(threadinfo) VOID * threadinfo;
#endif /* CK_ANSIC */
{
#ifdef GEMDOS
cc_clean();
#endif /* GEMDOS */
fixcmd(); /* Pop command stacks, etc. */
clcmds = NULL;
debug(F100,"ckcmai got interrupt","",0);
}
#endif /* NOICP */
#ifndef NOICP
VOID
#ifdef CK_ANSIC
docmdfile(void * threadinfo) /* Execute application file */
#else /* CK_ANSIC */
docmdfile(threadinfo) VOID * threadinfo;
#endif /* CK_ANSIC */
/* docmdfile */ {
#ifdef NTSIG
setint();
if (threadinfo) { /* Thread local storage... */
TlsSetValue(TlsIndex,threadinfo);
debug( F100, "docmdfile called with threadinfo block","", 0 ) ;
} else debug( F100, "docmdfile - threadinfo is NULL", "", 0 ) ;
#endif /* NTSIG */
debug(F110,"main cmdfil",cmdfil,0);
dotake(cmdfil); /* execute it */
while (tlevel > -1) { /* until it runs out. */
sstate = parser(1); /* Loop getting commands. */
if (sstate) proto(); /* Enter protocol if requested. */
#ifdef NTSIG
ck_ih();
#endif /* NTSIG */
}
cfilef = 1; /* Remember we did this */
#ifdef NTSIG
ckThreadEnd(threadinfo);
#endif /* NTSIG */
return;
}
VOID
#ifdef CK_ANSIC
failcmdfile(void * threadinfo)
#else /* CK_ANSIC */
failcmdfile(threadinfo) VOID * threadinfo;
#endif /* CK_ANSIC */
/* failcmdfile */ {
#ifdef GEMDOS
cc_clean(); /* Atari: Clean up after ^C-trap. */
#endif /* GEMDOS */
conoll("Interrupt during initialization or command-line processing.");
conoll("C-Kermit quitting...");
doexit(BAD_EXIT,-1); /* Exit with bad status. */
}
#endif /* NOICP */
VOID
setprefix(z) int z; { /* Initial control-char prefixing */
#ifdef CK_SPEED
int i, val;
prefixing = z;
ptab[protocol].prefix = prefixing;
debug(F101,"setprefix","",prefixing);
switch (z) {
case PX_ALL: /* All or None */
case PX_NON:
val = (z == PX_ALL) ? 1 : 0;
for (i =
#ifdef UNPREFIXZERO
0
#else
1
#endif /* UNPREFIXZERO */
; i < 32; i++)
ctlp[i] = val;
for (i = 127; i < 160; i++) ctlp[i] = val;
ctlp[255] = val;
if (z == PX_NON) { /* These are never safe */
ctlp[CR] = ctlp[255] = ctlp[mystch] = 1;
if (flow == FLO_XONX) /* Xon/Xoff forces prefixing */
ctlp[XON] = ctlp[XOFF] = ctlp[XON+128] = ctlp[XOFF+128] = 1;
}
break;
case PX_CAU: /* Cautious or Minimal */
case PX_WIL: /* Minimal ("wild") */
ctlp[0] = 1; /* Does not include 0 */
for (i = 1; i < 32; i++)
ctlp[i] = 0;
for (i = 127; i < 160; i++)
ctlp[i] = 0;
ctlp[mystch] = ctlp[mystch+128] = 1; /* Kermit start of packet */
if (seol != 13)
ctlp[seol] = ctlp[seol+128] = 1; /* Kermit end */
ctlp[13] = ctlp[141] = 1; /* In case of TELNET */
ctlp[(unsigned)255] = 1; /* Ditto */
if (flow == FLO_XONX || /* Xon/Xoff forces prefixing these */
prefixing == PX_CAU) /* So does CAUTIOUS */
ctlp[XON] = ctlp[XOFF] = ctlp[XON+128] = ctlp[XOFF+128] = 1;
if (prefixing == PX_CAU) { /* Cautious - add some more */
#ifdef UNPREFIXZERO
ctlp[0] = 1;
#endif /* UNPREFIXZERO */
ctlp[3] = ctlp[13] = ctlp[16] = 1; /* ^C, DLE */
ctlp[14] = ctlp[15] = 1; /* SO/SI */
ctlp[24] = ctlp[25] = 1; /* VMS needs these */
ctlp[28] = ctlp[29] = ctlp[30] = 1; /* Assorted esc chars */
ctlp[131] = ctlp[141] = ctlp[144] = 1; /* and 8-bit versions */
ctlp[(unsigned)255] = ctlp[156] = ctlp[157] = ctlp[158] = 1;
}
break;
}
#endif /* CK_SPEED */
}
VOID
makever() { /* Make version string from pieces */
int x, y;
#ifndef OS2
#ifndef MAC
ck_s_xver = ck_s_ver; /* Fill in C-Kermit version number */
ck_l_xver = ck_l_ver; /* for UNIX, VMS, etc. */
#endif /* MAC */
#endif /* OS2 */
x = strlen(ck_s_name);
y = strlen(ck_s_xver);
if (y + x + 1 < CKVERLEN) {
sprintf(versio,"%s %s",ck_s_name,ck_s_xver);
} else {
sprintf(versio,"C-Kermit");
return;
}
x += y + 1;
if (*ck_s_who) {
y = strlen(ck_s_who);
if (CKVERLEN < x + y + 1)
return;
strcat(versio,"-");
strcat(versio,ck_s_who);
}
x += y + 1;
y = strlen(ck_s_test);
if (y > 0 && y + x + 1 < CKVERLEN) {
strcat(versio," ");
strcat(versio,ck_s_test);
x += y + 1;
y = strlen(ck_s_tver);
if (y > 0 && y + x + 1 < CKVERLEN) {
strcat(versio,".");
strcat(versio,ck_s_tver);
x += y + 1;
}
}
y = strlen(ck_s_date);
if (y > 0 && y + x + 2 < CKVERLEN) {
strcat(versio,", ");
strcat(versio,ck_s_date);
}
vernum = ck_l_ver;
xvernum = ck_l_xver;
debug(F110,"Kermit version",versio,0);
}
#ifdef aegis
/* On the Apollo, intercept main to insert a cleanup handler */
int
ckcmai(argc,argv) int argc; char **argv;
#else
#ifdef MAC /* Macintosh */
int
main (void)
#else
#ifdef __GNUC__ /* GCC compiler */
int
main(argc,argv) int argc; char **argv;
#else
#ifdef __DECC /* DEC Alpha with DEC C compiler */
#ifdef __ALPHA
int
main(argc,argv) int argc; char **argv;
#else /* DEC C compiler, not Alpha */
VOID
main(argc,argv) int argc; char **argv;
#endif /* __ALPHA */
#else
#ifdef STRATUS /* Stratus VOS */
/* ANSI main returns int, and VOS compiler complains if not so. */
int
main(argc,argv) int argc; char **argv;
#else /* All others */
#ifdef OS2
#ifdef KUI
void
Main( int argc, char ** argv )
#else /* KUI */
VOID
main(argc,argv) int argc; char **argv;
#endif /* KUI */
#else /* OS2 */
#ifdef CK_SCOV5
int
main(argc,argv) int argc; char **argv;
#else
/*
The default case should be int, not VOID, but it's been this way for
years (no doubt for a reason) and who knows how many builds would break
if I changed it.
*/
VOID
main(argc,argv) int argc; char **argv;
#endif /* CK_SCOV5 */
#endif /* OS2 */
#endif /* STRATUS */
#endif /* __DECC */
#endif /* VMSGCC */
#endif /* MAC */
#endif /* aegis */
/* main */ {
char *p;
#ifdef datageneral
short *pfha = 016000000036; /* Get around LANG_RT problem -- */
*pfha = (short) 0; /* No user protection fault handler */
#endif /* datageneral */
/* Do some initialization */
#ifndef MAC
xargc = xargs = argc; /* Make global copies of argc */
xargv = argv; /* ...and argv. */
xarg0 = argv[0];
#ifndef NOICP
#ifdef NT
setOSVer();
#endif /* NT */
zstrip(argv[0],&p); /* Get name we were invoked with */
makestr(&myname,p);
if (!strncmp(myname,"telnet",6)) howcalled = I_AM_TELNET;
if (!strncmp(myname,"TELNET",6)) howcalled = I_AM_TELNET;
if (!strncmp(myname,"rlogin",6)) howcalled = I_AM_RLOGIN;
if (!strncmp(myname,"RLOGIN",6)) howcalled = I_AM_RLOGIN;
prescan(0); /* Pre-Check for debugging, etc */
#endif /* NOICP */
#endif /* MAC */
makever(); /* Put together version strings */
if (sysinit() < 0) /* System-dependent initialization. */
fatal("Can't initialize!");
else
initflg = 1; /* Remember we did. */
debug(F111,"ckcmai myname",myname,howcalled);
#ifdef CK_KERBEROS
ini_kerb(); /* Initialize Kerberos data */
#endif /* CK_KERBEROS */
#ifdef CK_TTGWSIZ
#ifdef OS2
ttgcwsz();
#else /* OS2 */
if (ttgwsiz() > 0) {
if (tt_rows > 0 && tt_cols > 0) {
cmd_rows = tt_rows;
cmd_cols = tt_cols;
}
}
#endif /* OS2 */
#endif /* CK_TTGWSIZ */
#ifdef CK_CURSES
#ifndef OS2
#ifndef COHERENT
fxdinit(); /* Init fullscreen package */
#endif /* COHERENT */
#endif /* OS2 */
#endif /* CK_CURSES */
#ifdef TCPSOCKET
#ifdef CK_SOCKS
SOCKSinit(argv[0]); /* Internet relay package... */
#endif /* CK_SOCKS */
#endif /* TCPSOCKET */
#ifdef CK_XYZ /* Initialize protocols... */
#ifdef XYZ_INTERNAL /* XYZMODEM are internal ... */
#ifdef COMMENT
initproto(PROTO_X, "rx %s","rx %s", NULL, NULL, NULL, NULL);
initproto(PROTO_XC,"rc %s","rc %s", NULL, NULL, NULL, NULL);
#else /* COMMENT */
initproto(PROTO_X, NULL, NULL, NULL, NULL, NULL, NULL);
initproto(PROTO_XC,NULL, NULL, NULL, NULL, NULL, NULL);
#endif /* COMMENT */
initproto(PROTO_Y, "rb","rb", NULL, NULL, NULL, NULL);
initproto(PROTO_G, "rb","rb", NULL, NULL, NULL, NULL);
initproto(PROTO_Z, "rz","rz", NULL, NULL, NULL, NULL);
initproto(PROTO_K, "kermit -ir","kermit -r", NULL, NULL, NULL, NULL);
/* Kermit Must be last */
#else /* XYZMODEM are external protocols ... */
/* s1 s2 s3 s4 s5 s6 */
initproto(PROTO_X, "rx %s","rx %s", "sx %s", "sx -a %s", "rx %s", "rx %s");
initproto(PROTO_XC,"rc %s","rc %s", "sx %s", "sx -a %s", "rc %s", "rc %s");
initproto(PROTO_Y, "rb", "rb", "sb %s", "sb -a %s", "rb", "rb" );
initproto(PROTO_G, "rb", "rb", "sb %s", "sb -a %s", "rb", "rb" );
initproto(PROTO_Z, "rz", "rz", "sz %s", "sz -a %s", "rz", "rz" );
initproto(PROTO_K, "kermit -ir", "kermit -r", NULL, NULL, NULL, NULL);
/* Kermit must be last */
#endif /* XYZ_INTERNAL */
#else /* No XYZMODEM support */
initproto(PROTO_K, "kermit -ir","kermit -r", NULL, NULL, NULL, NULL);
#endif /* CK_XYZ */
#ifdef OS2
/* Initialize Kermit and Zmodem Auto-Download Strings */
adl_kstr = strdup("KERMIT READY TO SEND...");
adl_zstr = strdup("rz\r");
#endif /* OS2 */
#ifdef PATTERNS
initpat();
#endif /* PATTERNS */
connoi(); /* Console interrupts off */
sstate = 0; /* No default start state. */
#ifdef DYNAMIC
if (getiobs() < 0)
fatal("Can't allocate i/o buffers!");
#endif /* DYNAMIC */
#ifndef NOSPL
#ifndef NORANDOM
srand((unsigned int)gtimer());
#endif /* NORANDOM */
#endif /* NOSPL */
ckhost(myhost,MYHOSTL); /* Name of local host */
debug(F110,"main ckhost",myhost,0);
strcpy(ttname,dftty); /* Set up default tty name. */
local = dfloc; /* And whether it's local or remote. */
parity = dfprty; /* Set initial parity, */
flow = dfflow; /* and flow control. */
myindex = getsysix(cksysid);
if (local) if (ttopen(ttname,&local,0,0) < 0) { /* If default tty line */
#ifndef OS2
conol("Can't open device: ");
conoll(ttname);
#endif /* OS2 */
local = 0;
strcpy(ttname,CTTNAM);
}
speed = ttgspd(); /* Get transmission speed. */
#ifdef ANYX25 /* All X.25 implementations */
#ifndef IBMX25 /* except IBM have PAD support */
initpad(); /* Initialize X.25 PAD */
#endif /* IBMX25 */
#endif /* ANYX25 */
if (inibufs(SBSIZ,RBSIZ) < 0) /* Allocate packet buffers */
fatal("Can't allocate packet buffers!");
#ifndef NOCKSPEED
setprefix(prefixing); /* Set up control char prefixing */
#endif /* NOCKSPEED */
#ifndef NOICP
#ifdef MAC
cmdini();
#else /* Not MAC */
/* Attempt to take ini file before doing command line */
*cmdfil = '\0'; /* Assume no command file. */
prescan(1); /* But first check for -y option */
debug(F101,"main argc after prescan()","",argc);
/* Now process any relevant environment variables */
#ifndef NODIAL
getdialenv(); /* Dialing */
#ifdef NETCONN
ndinit(); /* Initialize network directory info */
getnetenv(); /* Network directories */
#endif /* NETCONN */
#endif /* NODIAL */
#ifdef NOCCTRAP
dotakeini(0);
#else /* NOCCTRAP */
debug(F100,"main about to cc_execute","",0);
setint();
cc_execute( ckjaddr(cmjbuf), dotakeini, failtakeini );
#endif /* NOCCTRAP */
debug(F101,"main 2 cfilef","",cfilef);
if (*cmdfil) { /* If we got one (see prescan())... */
#ifdef NOCCTRAP
docmdfile(0); /* execute it. */
#else /* NOCCTRAP */
setint();
cc_execute( ckjaddr(cmjbuf), docmdfile, failcmdfile );
#endif /* NOCCTRAP */
}
#ifndef OS2 /* Preserve name so we can delete it */
*cmdfil = '\0'; /* Done, nullify the file name */
#endif /* OS2 */
#endif /* MAC */
#endif /* NOICP */
#ifndef NOCMDL
/* Look for a UNIX-style command line... */
what = W_NOTHING;
debug(F101,"main argc","",argc);
#ifndef NOHELP
iniopthlp(); /* Initialize cmdline arg help */
#endif /* NOHELP */
if (argc > 1) { /* Command line arguments? */
sstate = (CHAR) cmdlin(); /* Yes, parse. */
zstate = sstate; /* Remember sstate around protocol */
debug(F101,"main zstate","",zstate);
#ifndef NOLOCAL
if (cflg) /* Connect first if requested */
doconect(0);
#endif /* NOLOCAL */
if (sstate) {
#ifndef NOLOCAL
if (displa) concb((char)escape); /* (for console "interrupts") */
#endif /* NOLOCAL */
#ifdef NOCCTRAP
docmdline(1);
#else /* NOCCTRAP */
setint();
cc_execute( ckjaddr(cmjbuf), docmdline, failcmdline );
#endif /* NOCCTRAP */
}
#ifndef NOICP
/*
If a command-line action argument was given and -S ("stay") was not given,
exit now.
*/
if ((cflg || cnflg || zstate) && !stayflg)
#endif /* NOICP */
doexit(GOOD_EXIT,xitsta); /* Exit with good status */
#ifndef NOLOCAL
#ifndef NOICP
if (local) {
#ifdef NETCONN
if ((cflg || cnflg) && tn_exit && ttchk() < 0)
doexit(GOOD_EXIT,xitsta); /* Exit with good status */
#endif /* NETCONN */
if (exitonclose && !network &&
(carrier != CAR_OFF && (ttgmdm() & BM_DCD) == 0))
doexit(GOOD_EXIT,xitsta); /* Exit with good status */
if (exitonclose && network && ttchk() < 0)
doexit(GOOD_EXIT,xitsta); /* Exit with good status */
}
#endif /* NOICP */
#endif /* NOLOCAL */
}
#endif /* NOCMDL */
#ifdef NOICP /* No interactive command parser */
else {
#ifndef NOCMDL
/* Command-line-only version */
fatal("no command-line options given, type 'kermit -h' for help");
#else /* Neither one! */
sstate = 'x';
proto(); /* So go into server mode */
doexit(GOOD_EXIT,xitsta); /* exit with good status */
#endif /* NOCMDL */
}
#else /* not NOICP */
/*
If no action requested on command line, or if -S ("stay") was included,
enter the interactive command parser.
*/
if (!clcmds)
herald(); /* Display program herald. */
#ifdef NOCCTRAP
debug(F100,"main NOCCTRAP setting interrupt trap","",0);
setint(); /* Set up command interrupt traps */
doicp(NULL);
#else /* NOCCTRAP */
while (1) {
debug(F100,"main setting interrupt trap","",0);
setint(); /* Set up command interrupt traps */
if (!cc_execute(ckjaddr(cmjbuf), doicp, failicp))
break;
}
#endif /* NOCCTRAP */
#endif /* NOICP */
#ifdef MAC
return(1);
#endif /* MAC */
}
#ifdef DYNAMIC
/* Allocate file i/o buffers */
char *zinbuffer, *zoutbuffer;
int
getiobs() {
zinbuffer = (char *)malloc(INBUFSIZE);
if (!zinbuffer) return(-1);
zoutbuffer = (char *)malloc(zobufsize);
debug(F101,"zoutbuffer malloc","",zobufsize);
if (!zoutbuffer) return(-1);
debug(F100,"getiobs ok","",0);
return(0);
}
#endif /* DYNAMIC */
|