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
|
/*
Copyright (c) 1990-2009 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2009-Jan-02 or later
(the contents of which are also included in unzip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/*---------------------------------------------------------------------------
unzip.c
UnZip - a zipfile extraction utility. See below for make instructions, or
read the comments in Makefile and the various Contents files for more de-
tailed explanations. To report a bug, submit a *complete* description via
//www.info-zip.org/zip-bug.html; include machine type, operating system and
version, compiler and version, and reasonably detailed error messages or
problem report. To join Info-ZIP, see the instructions in README.
UnZip 5.x is a greatly expanded and partially rewritten successor to 4.x,
which in turn was almost a complete rewrite of version 3.x. For a detailed
revision history, see UnzpHist.zip at quest.jpl.nasa.gov. For a list of
the many (near infinite) contributors, see "CONTRIBS" in the UnZip source
distribution.
UnZip 6.0 adds support for archives larger than 4 GiB using the Zip64
extensions as well as support for Unicode information embedded per the
latest zip standard additions.
---------------------------------------------------------------------------
[from original zipinfo.c]
This program reads great gobs of totally nifty information, including the
central directory stuff, from ZIP archives ("zipfiles" for short). It
started as just a testbed for fooling with zipfiles, but at this point it
is actually a useful utility. It also became the basis for the rewrite of
UnZip (3.16 -> 4.0), using the central directory for processing rather than
the individual (local) file headers.
As of ZipInfo v2.0 and UnZip v5.1, the two programs are combined into one.
If the executable is named "unzip" (or "unzip.exe", depending), it behaves
like UnZip by default; if it is named "zipinfo" or "ii", it behaves like
ZipInfo. The ZipInfo behavior may also be triggered by use of unzip's -Z
option; for example, "unzip -Z [zipinfo_options] archive.zip".
Another dandy product from your buddies at Newtware!
Author: Greg Roelofs, newt@pobox.com, http://pobox.com/~newt/
23 August 1990 -> April 1997
---------------------------------------------------------------------------
Version: unzip5??.{tar.Z | tar.gz | zip} for Unix, VMS, OS/2, MS-DOS, Amiga,
Atari, Windows 3.x/95/NT/CE, Macintosh, Human68K, Acorn RISC OS,
AtheOS, BeOS, SMS/QDOS, VM/CMS, MVS, AOS/VS, Tandem NSK, Theos
and TOPS-20.
Copyrights: see accompanying file "LICENSE" in UnZip source distribution.
(This software is free but NOT IN THE PUBLIC DOMAIN.)
---------------------------------------------------------------------------*/
#define __UNZIP_C /* identifies this source module */
#define UNZIP_INTERNAL
#include "unzip.h" /* includes, typedefs, macros, prototypes, etc. */
#include "crypt.h"
#include "unzvers.h"
#ifndef WINDLL /* The WINDLL port uses windll/windll.c instead... */
/***************************/
/* Local type declarations */
/***************************/
#if (defined(REENTRANT) && !defined(NO_EXCEPT_SIGNALS))
typedef struct _sign_info
{
struct _sign_info *previous;
void (*sighandler)(int);
int sigtype;
} savsigs_info;
#endif
/*******************/
/* Local Functions */
/*******************/
#if (defined(REENTRANT) && !defined(NO_EXCEPT_SIGNALS))
static int setsignalhandler OF((__GPRO__ savsigs_info **p_savedhandler_chain,
int signal_type, void (*newhandler)(int)));
#endif
#ifndef SFX
static void help_extended OF((__GPRO));
static void show_version_info OF((__GPRO));
#endif
/*************/
/* Constants */
/*************/
#include "consts.h" /* all constant global variables are in here */
/* (non-constant globals were moved to globals.c) */
/* constant local variables: */
#ifndef SFX
#ifndef _WIN32_WCE /* Win CE does not support environment variables */
static ZCONST char Far EnvUnZip[] = ENV_UNZIP;
static ZCONST char Far EnvUnZip2[] = ENV_UNZIP2;
static ZCONST char Far EnvZipInfo[] = ENV_ZIPINFO;
static ZCONST char Far EnvZipInfo2[] = ENV_ZIPINFO2;
#ifdef RISCOS
static ZCONST char Far EnvUnZipExts[] = ENV_UNZIPEXTS;
#endif /* RISCOS */
static ZCONST char Far NoMemEnvArguments[] =
"envargs: cannot get memory for arguments";
#endif /* !_WIN32_WCE */
static ZCONST char Far CmdLineParamTooLong[] =
"error: command line parameter #%d exceeds internal size limit\n";
#endif /* !SFX */
#if (defined(REENTRANT) && !defined(NO_EXCEPT_SIGNALS))
static ZCONST char Far CantSaveSigHandler[] =
"error: cannot save signal handler settings\n";
#endif
#if (!defined(SFX) || defined(SFX_EXDIR))
static ZCONST char Far NotExtracting[] =
"caution: not extracting; -d ignored\n";
static ZCONST char Far MustGiveExdir[] =
"error: must specify directory to which to extract with -d option\n";
static ZCONST char Far OnlyOneExdir[] =
"error: -d option used more than once (only one exdir allowed)\n";
#endif
#if (defined(UNICODE_SUPPORT) && !defined(UNICODE_WCHAR))
static ZCONST char Far UTF8EscapeUnSupp[] =
"warning: -U \"escape all non-ASCII UTF-8 chars\" is not supported\n";
#endif
#if CRYPT
static ZCONST char Far MustGivePasswd[] =
"error: must give decryption password with -P option\n";
#endif
#ifndef SFX
static ZCONST char Far Zfirst[] =
"error: -Z must be first option for ZipInfo mode (check UNZIP variable?)\n";
#endif
static ZCONST char Far InvalidOptionsMsg[] = "error:\
-fn or any combination of -c, -l, -p, -t, -u and -v options invalid\n";
static ZCONST char Far IgnoreOOptionMsg[] =
"caution: both -n and -o specified; ignoring -o\n";
/* usage() strings */
#ifndef SFX
#ifdef VMS
static ZCONST char Far Example3[] = "vms.c";
static ZCONST char Far Example2[] = " unzip \"-V\" foo \"Bar\"\
(Quote names to preserve case, unless SET PROC/PARS=EXT)\n";
#else /* !VMS */
static ZCONST char Far Example3[] = "ReadMe";
#ifdef RISCOS
static ZCONST char Far Example2[] =
" unzip foo -d RAM:$ => extract all files from foo into RAMDisc\n";
#else /* !RISCOS */
#if (defined(OS2) || (defined(DOS_FLX_OS2_W32) && defined(MORE)))
static ZCONST char Far Example2[] =
""; /* no room: too many local3[] items */
#else /* !OS2 */
#ifdef MACOS
static ZCONST char Far Example2[] = ""; /* not needed */
#else /* !MACOS */
static ZCONST char Far Example2[] = " \
unzip -p foo | more => send contents of foo.zip via pipe into program more\n";
#endif /* ?MACOS */
#endif /* ?OS2 */
#endif /* ?RISCOS */
#endif /* ?VMS */
/* local1[]: command options */
#if defined(TIMESTAMP)
static ZCONST char Far local1[] =
" -T timestamp archive to latest";
#else /* !TIMESTAMP */
static ZCONST char Far local1[] = "";
#endif /* ?TIMESTAMP */
/* local2[] and local3[]: modifier options */
#ifdef DOS_FLX_H68_OS2_W32
#ifdef FLEXOS
static ZCONST char Far local2[] = "";
#else
static ZCONST char Far local2[] =
" -$ label removables (-$$ => fixed disks)";
#endif
#ifdef OS2
#ifdef MORE
static ZCONST char Far local3[] = "\
-X restore ACLs if supported -s spaces in filenames => '_'\n\
-M pipe through \"more\" pager\n";
#else
static ZCONST char Far local3[] = " \
-X restore ACLs if supported -s spaces in filenames => '_'\n\n";
#endif /* ?MORE */
#else /* !OS2 */
#ifdef WIN32
#ifdef NTSD_EAS
#ifdef MORE
static ZCONST char Far local3[] = "\
-X restore ACLs (-XX => use privileges) -s spaces in filenames => '_'\n\
-M pipe through \"more\" pager\n";
#else
static ZCONST char Far local3[] = " \
-X restore ACLs (-XX => use privileges) -s spaces in filenames => '_'\n\n";
#endif /* ?MORE */
#else /* !NTSD_EAS */
#ifdef MORE
static ZCONST char Far local3[] = "\
-M pipe through \"more\" pager \
-s spaces in filenames => '_'\n\n";
#else
static ZCONST char Far local3[] = " \
-s spaces in filenames => '_'\n\n";
#endif /* ?MORE */
#endif /* ?NTSD_EAS */
#else /* !WIN32 */
#ifdef MORE
static ZCONST char Far local3[] = " -\
M pipe through \"more\" pager -s spaces in filenames => '_'\n\n";
#else
static ZCONST char Far local3[] = "\
-s spaces in filenames => '_'\n";
#endif
#endif /* ?WIN32 */
#endif /* ?OS2 || ?WIN32 */
#else /* !DOS_FLX_OS2_W32 */
#ifdef VMS
static ZCONST char Far local2[] = " -X restore owner/ACL protection info";
#ifdef MORE
static ZCONST char Far local3[] = "\
-Y treat \".nnn\" as \";nnn\" version -2 force ODS2 names\n\
--D restore dir (-D: no) timestamps -M pipe through \"more\" pager\n\
(Must quote upper-case options, like \"-V\", unless SET PROC/PARSE=EXTEND.)\
\n\n";
#else
static ZCONST char Far local3[] = "\n\
-Y treat \".nnn\" as \";nnn\" version -2 force ODS2 names\n\
--D restore dir (-D: no) timestamps\n\
(Must quote upper-case options, like \"-V\", unless SET PROC/PARSE=EXTEND.)\
\n\n";
#endif
#else /* !VMS */
#ifdef ATH_BEO_UNX
static ZCONST char Far local2[] = " -X restore UID/GID info";
#ifdef MORE
static ZCONST char Far local3[] = "\
-K keep setuid/setgid/tacky permissions -M pipe through \"more\" pager\n";
#else
static ZCONST char Far local3[] = "\
-K keep setuid/setgid/tacky permissions\n";
#endif
#else /* !ATH_BEO_UNX */
#ifdef TANDEM
static ZCONST char Far local2[] = "\
-X restore Tandem User ID -r remove file extensions\n\
-b create 'C' (180) text files ";
#ifdef MORE
static ZCONST char Far local3[] = " \
-M pipe through \"more\" pager\n";
#else
static ZCONST char Far local3[] = "\n";
#endif
#else /* !TANDEM */
#ifdef AMIGA
static ZCONST char Far local2[] = " -N restore comments as filenotes";
#ifdef MORE
static ZCONST char Far local3[] = " \
-M pipe through \"more\" pager\n";
#else
static ZCONST char Far local3[] = "\n";
#endif
#else /* !AMIGA */
#ifdef MACOS
static ZCONST char Far local2[] = " -E show Mac info during extraction";
static ZCONST char Far local3[] = " \
-i ignore filenames in mac extra info -J junk (ignore) Mac extra info\n\
\n";
#else /* !MACOS */
#ifdef MORE
static ZCONST char Far local2[] = " -M pipe through \"more\" pager";
static ZCONST char Far local3[] = "\n";
#else
static ZCONST char Far local2[] = ""; /* Atari, Mac, CMS/MVS etc. */
static ZCONST char Far local3[] = "";
#endif
#endif /* ?MACOS */
#endif /* ?AMIGA */
#endif /* ?TANDEM */
#endif /* ?ATH_BEO_UNX */
#endif /* ?VMS */
#endif /* ?DOS_FLX_OS2_W32 */
#endif /* !SFX */
#ifndef NO_ZIPINFO
#ifdef VMS
static ZCONST char Far ZipInfoExample[] = "* or % (e.g., \"*font-%.zip\")";
#else
static ZCONST char Far ZipInfoExample[] = "*, ?, [] (e.g., \"[a-j]*.zip\")";
#endif
static ZCONST char Far ZipInfoUsageLine1[] = "\
ZipInfo %d.%d%d%s of %s, by Greg Roelofs and the Info-ZIP group.\n\
\n\
List name, date/time, attribute, size, compression method, etc., about files\n\
in list (excluding those in xlist) contained in the specified .zip archive(s).\
\n\"file[.zip]\" may be a wildcard name containing %s.\n\n\
usage: zipinfo [-12smlvChMtTz] file[.zip] [list...] [-x xlist...]\n\
or: unzip %s-Z%s [-12smlvChMtTz] file[.zip] [list...] [-x xlist...]\n";
static ZCONST char Far ZipInfoUsageLine2[] = "\nmain\
listing-format options: -s short Unix \"ls -l\" format (def.)\n\
-1 filenames ONLY, one per line -m medium Unix \"ls -l\" format\n\
-2 just filenames but allow -h/-t/-z -l long Unix \"ls -l\" format\n\
-v verbose, multi-page format\n";
static ZCONST char Far ZipInfoUsageLine3[] = "miscellaneous options:\n\
-h print header line -t print totals for listed files or for all\n\
-z print zipfile comment -T print file times in sortable decimal format\
\n -C be case-insensitive %s\
-x exclude filenames that follow from listing\n";
#ifdef MORE
static ZCONST char Far ZipInfoUsageLine4[] =
" -M page output through built-in \"more\"\n";
#else /* !MORE */
static ZCONST char Far ZipInfoUsageLine4[] = "";
#endif /* ?MORE */
#endif /* !NO_ZIPINFO */
#ifdef BETA
# ifdef VMSCLI
/* BetaVersion[] is also used in vms/cmdline.c: do not make it static */
ZCONST char Far BetaVersion[] = "%s\
THIS IS STILL A BETA VERSION OF UNZIP%s -- DO NOT DISTRIBUTE.\n\n";
# else
static ZCONST char Far BetaVersion[] = "%s\
THIS IS STILL A BETA VERSION OF UNZIP%s -- DO NOT DISTRIBUTE.\n\n";
# endif
#endif
#ifdef SFX
# ifdef VMSCLI
/* UnzipSFXBanner[] is also used in vms/cmdline.c: do not make it static */
ZCONST char Far UnzipSFXBanner[] =
# else
static ZCONST char Far UnzipSFXBanner[] =
# endif
"UnZipSFX %d.%d%d%s of %s, by Info-ZIP (http://www.info-zip.org).\n";
# ifdef SFX_EXDIR
static ZCONST char Far UnzipSFXOpts[] =
"Valid options are -tfupcz and -d <exdir>; modifiers are -abjnoqCL%sV%s.\n";
# else
static ZCONST char Far UnzipSFXOpts[] =
"Valid options are -tfupcz; modifiers are -abjnoqCL%sV%s.\n";
# endif
#else /* !SFX */
static ZCONST char Far CompileOptions[] =
"UnZip special compilation options:\n";
static ZCONST char Far CompileOptFormat[] = " %s\n";
#ifndef _WIN32_WCE /* Win CE does not support environment variables */
static ZCONST char Far EnvOptions[] =
"\nUnZip and ZipInfo environment options:\n";
static ZCONST char Far EnvOptFormat[] = "%16s: %.1024s\n";
#endif
static ZCONST char Far None[] = "[none]";
# ifdef ACORN_FTYPE_NFS
static ZCONST char Far AcornFtypeNFS[] = "ACORN_FTYPE_NFS";
# endif
# ifdef ASM_CRC
static ZCONST char Far AsmCRC[] = "ASM_CRC";
# endif
# ifdef ASM_INFLATECODES
static ZCONST char Far AsmInflateCodes[] = "ASM_INFLATECODES";
# endif
# ifdef CHECK_VERSIONS
static ZCONST char Far Check_Versions[] = "CHECK_VERSIONS";
# endif
# ifdef COPYRIGHT_CLEAN
static ZCONST char Far Copyright_Clean[] =
"COPYRIGHT_CLEAN (PKZIP 0.9x unreducing method not supported)";
# endif
# ifdef DEBUG
static ZCONST char Far UDebug[] = "DEBUG";
# endif
# ifdef DEBUG_TIME
static ZCONST char Far DebugTime[] = "DEBUG_TIME";
# endif
# ifdef DLL
static ZCONST char Far Dll[] = "DLL";
# endif
# ifdef DOSWILD
static ZCONST char Far DosWild[] = "DOSWILD";
# endif
# ifdef LZW_CLEAN
static ZCONST char Far LZW_Clean[] =
"LZW_CLEAN (PKZIP/Zip 1.x unshrinking method not supported)";
# endif
# ifndef MORE
static ZCONST char Far No_More[] = "NO_MORE";
# endif
# ifdef NO_ZIPINFO
static ZCONST char Far No_ZipInfo[] = "NO_ZIPINFO";
# endif
# ifdef NTSD_EAS
static ZCONST char Far NTSDExtAttrib[] = "NTSD_EAS";
# endif
# if defined(WIN32) && defined(NO_W32TIMES_IZFIX)
static ZCONST char Far W32NoIZTimeFix[] = "NO_W32TIMES_IZFIX";
# endif
# ifdef OLD_THEOS_EXTRA
static ZCONST char Far OldTheosExtra[] =
"OLD_THEOS_EXTRA (handle also old Theos port extra field)";
# endif
# ifdef OS2_EAS
static ZCONST char Far OS2ExtAttrib[] = "OS2_EAS";
# endif
# ifdef QLZIP
static ZCONST char Far SMSExFldOnUnix[] = "QLZIP";
# endif
# ifdef REENTRANT
static ZCONST char Far Reentrant[] = "REENTRANT";
# endif
# ifdef REGARGS
static ZCONST char Far RegArgs[] = "REGARGS";
# endif
# ifdef RETURN_CODES
static ZCONST char Far Return_Codes[] = "RETURN_CODES";
# endif
# ifdef SET_DIR_ATTRIB
static ZCONST char Far SetDirAttrib[] = "SET_DIR_ATTRIB";
# endif
# ifdef SYMLINKS
static ZCONST char Far SymLinkSupport[] =
"SYMLINKS (symbolic links supported, if RTL and file system permit)";
# endif
# ifdef TIMESTAMP
static ZCONST char Far TimeStamp[] = "TIMESTAMP";
# endif
# ifdef UNIXBACKUP
static ZCONST char Far UnixBackup[] = "UNIXBACKUP";
# endif
# ifdef USE_EF_UT_TIME
static ZCONST char Far Use_EF_UT_time[] = "USE_EF_UT_TIME";
# endif
# ifndef LZW_CLEAN
static ZCONST char Far Use_Unshrink[] =
"USE_UNSHRINK (PKZIP/Zip 1.x unshrinking method supported)";
# endif
# ifndef COPYRIGHT_CLEAN
static ZCONST char Far Use_Smith_Code[] =
"USE_SMITH_CODE (PKZIP 0.9x unreducing method supported)";
# endif
# ifdef USE_DEFLATE64
static ZCONST char Far Use_Deflate64[] =
"USE_DEFLATE64 (PKZIP 4.x Deflate64(tm) supported)";
# endif
# ifdef UNICODE_SUPPORT
# ifdef UTF8_MAYBE_NATIVE
# ifdef UNICODE_WCHAR
/* direct native UTF-8 check AND charset transform via wchar_t */
static ZCONST char Far Use_Unicode[] =
"UNICODE_SUPPORT [wide-chars, char coding: %s] (handle UTF-8 paths)";
# else
/* direct native UTF-8 check, only */
static ZCONST char Far Use_Unicode[] =
"UNICODE_SUPPORT [char coding: %s] (handle UTF-8 paths)";
# endif
static ZCONST char Far SysChUTF8[] = "UTF-8";
static ZCONST char Far SysChOther[] = "other";
# else /* !UTF8_MAYBE_NATIVE */
/* charset transform via wchar_t, no native UTF-8 support */
static ZCONST char Far Use_Unicode[] =
"UNICODE_SUPPORT [wide-chars] (handle UTF-8 paths)";
# endif /* ?UTF8_MAYBE_NATIVE */
# endif /* UNICODE_SUPPORT */
# ifdef _MBCS
static ZCONST char Far Have_MBCS_Support[] =
"MBCS-support (multibyte character support, MB_CUR_MAX = %u)";
# endif
# ifdef MULT_VOLUME
static ZCONST char Far Use_MultiVol[] =
"MULT_VOLUME (multi-volume archives supported)";
# endif
# ifdef LARGE_FILE_SUPPORT
static ZCONST char Far Use_LFS[] =
"LARGE_FILE_SUPPORT (large files over 2 GiB supported)";
# endif
# ifdef ZIP64_SUPPORT
static ZCONST char Far Use_Zip64[] =
"ZIP64_SUPPORT (archives using Zip64 for large files supported)";
# endif
# if (defined(__DJGPP__) && (__DJGPP__ >= 2))
# ifdef USE_DJGPP_ENV
static ZCONST char Far Use_DJGPP_Env[] = "USE_DJGPP_ENV";
# endif
# ifdef USE_DJGPP_GLOB
static ZCONST char Far Use_DJGPP_Glob[] = "USE_DJGPP_GLOB";
# endif
# endif /* __DJGPP__ && (__DJGPP__ >= 2) */
# ifdef USE_VFAT
static ZCONST char Far Use_VFAT_support[] = "USE_VFAT";
# endif
# ifdef USE_ZLIB
static ZCONST char Far UseZlib[] =
"USE_ZLIB (compiled with version %s; using version %s)";
# endif
# ifdef USE_BZIP2
static ZCONST char Far UseBZip2[] =
"USE_BZIP2 (PKZIP 4.6+, using bzip2 lib version %s)";
# endif
# ifdef VMS_TEXT_CONV
static ZCONST char Far VmsTextConv[] = "VMS_TEXT_CONV";
# endif
# ifdef VMSCLI
static ZCONST char Far VmsCLI[] = "VMSCLI";
# endif
# ifdef VMSWILD
static ZCONST char Far VmsWild[] = "VMSWILD";
# endif
# ifdef WILD_STOP_AT_DIR
static ZCONST char Far WildStopAtDir[] = "WILD_STOP_AT_DIR";
# endif
# if CRYPT
# ifdef PASSWD_FROM_STDIN
static ZCONST char Far PasswdStdin[] = "PASSWD_FROM_STDIN";
# endif
static ZCONST char Far Decryption[] =
" [decryption, version %d.%d%s of %s]\n";
static ZCONST char Far CryptDate[] = CR_VERSION_DATE;
# endif
# ifndef __RSXNT__
# ifdef __EMX__
static ZCONST char Far EnvEMX[] = "EMX";
static ZCONST char Far EnvEMXOPT[] = "EMXOPT";
# endif
# if (defined(__GO32__) && (!defined(__DJGPP__) || (__DJGPP__ < 2)))
static ZCONST char Far EnvGO32[] = "GO32";
static ZCONST char Far EnvGO32TMP[] = "GO32TMP";
# endif
# endif /* !__RSXNT__ */
#ifdef VMS
/* UnzipUsageLine1[] is also used in vms/cmdline.c: do not make it static */
ZCONST char Far UnzipUsageLine1[] = "\
UnZip %d.%d%d%s of %s, by Info-ZIP. For more details see: unzip -v.\n\n";
# ifdef COPYRIGHT_CLEAN
static ZCONST char Far UnzipUsageLine1v[] = "\
UnZip %d.%d%d%s of %s, by Info-ZIP. Maintained by C. Spieler. Send\n\
bug reports using http://www.info-zip.org/zip-bug.html; see README for details.\
\n\n";
# else
static ZCONST char Far UnzipUsageLine1v[] = "\
UnZip %d.%d%d%s of %s, by Info-ZIP. UnReduce (c) 1989 by S. H. Smith.\n\
Send bug reports using //www.info-zip.org/zip-bug.html; see README for details.\
\n\n";
# endif /* ?COPYRIGHT_CLEAN */
#else /* !VMS */
# ifdef COPYRIGHT_CLEAN
static ZCONST char Far UnzipUsageLine1[] = "\
UnZip %d.%d%d%s of %s, by Debian. Original by Info-ZIP.\
\n\n";
# else
static ZCONST char Far UnzipUsageLine1[] = "\
UnZip %d.%d%d%s of %s, by Info-ZIP. UnReduce (c) 1989 by S. H. Smith.\n\
Send bug reports using //www.info-zip.org/zip-bug.html; see README for details.\
\n\n";
# endif /* ?COPYRIGHT_CLEAN */
# define UnzipUsageLine1v UnzipUsageLine1
#endif /* ?VMS */
static ZCONST char Far UnzipUsageLine2v[] = "\
Latest sources and executables are at ftp://ftp.info-zip.org/pub/infozip/ ;\
\nsee ftp://ftp.info-zip.org/pub/infozip/UnZip.html for other sites.\
\n\n";
#ifdef MACOS
static ZCONST char Far UnzipUsageLine2[] = "\
Usage: unzip %s[-opts[modifiers]] file[.zip] [list] [-d exdir]\n \
Default action is to extract files in list, to exdir;\n\
file[.zip] may be a wildcard. %s\n";
#else /* !MACOS */
#ifdef VM_CMS
static ZCONST char Far UnzipUsageLine2[] = "\
Usage: unzip %s[-opts[modifiers]] file[.zip] [list] [-x xlist] [-d fm]\n \
Default action is to extract files in list, except those in xlist, to disk fm;\
\n file[.zip] may be a wildcard. %s\n";
#else /* !VM_CMS */
static ZCONST char Far UnzipUsageLine2[] = "\
Usage: unzip %s[-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir]\n \
Default action is to extract files in list, except those in xlist, to exdir;\n\
file[.zip] may be a wildcard. %s\n";
#endif /* ?VM_CMS */
#endif /* ?MACOS */
#ifdef NO_ZIPINFO
# define ZIPINFO_MODE_OPTION ""
static ZCONST char Far ZipInfoMode[] =
"(ZipInfo mode is disabled in this version.)";
#else
# define ZIPINFO_MODE_OPTION "[-Z] "
static ZCONST char Far ZipInfoMode[] =
"-Z => ZipInfo mode (\"unzip -Z\" for usage).";
#endif /* ?NO_ZIPINFO */
#ifdef VMS
static ZCONST char Far VMSusageLine2b[] = "\
=> define foreign command symbol in LOGIN.COM: $ unzip :== $dev:[dir]unzip.exe\
\n";
#endif
#ifdef MACOS
static ZCONST char Far UnzipUsageLine3[] = "\n\
-d extract files into exdir -l list files (short format)\n\
-f freshen existing files, create none -t test compressed archive data\n\
-u update files, create if necessary -z display archive comment only\n\
-v list verbosely/show version info %s\n";
#else /* !MACOS */
#ifdef VM_CMS
static ZCONST char Far UnzipUsageLine3[] = "\n\
-p extract files to pipe, no messages -l list files (short format)\n\
-f freshen existing files, create none -t test compressed archive data\n\
-u update files, create if necessary -z display archive comment only\n\
-v list verbosely/show version info %s\n\
-x exclude files that follow (in xlist) -d extract files onto disk fm\n";
#else /* !VM_CMS */
static ZCONST char Far UnzipUsageLine3[] = "\n\
-p extract files to pipe, no messages -l list files (short format)\n\
-f freshen existing files, create none -t test compressed archive data\n\
-u update files, create if necessary -z display archive comment only\n\
-v list verbosely/show version info %s\n\
-x exclude files that follow (in xlist) -d extract files into exdir\n";
#endif /* ?VM_CMS */
#endif /* ?MACOS */
/* There is not enough space on a standard 80x25 Windows console screen for
* the additional line advertising the UTF-8 debugging options. This may
* eventually also be the case for other ports. Probably, the -U option need
* not be shown on the introductory screen at all. [Chr. Spieler, 2008-02-09]
*
* Likely, other advanced options should be moved to an extended help page and
* the option to list that page put here. [E. Gordon, 2008-3-16]
*/
#if (defined(UNICODE_SUPPORT) && !defined(WIN32))
#ifdef VMS
static ZCONST char Far UnzipUsageLine4[] = "\
modifiers:\n\
-n never overwrite or make a new version of an existing file\n\
-o always make a new version (-oo: overwrite original) of an existing file\n\
-q quiet mode (-qq => quieter) -a auto-convert any text files\n\
-j junk paths (do not make directories) -aa treat ALL files as text\n\
-U use escapes for all non-ASCII Unicode -UU ignore any Unicode fields\n\
-C match filenames case-insensitively -L make (some) names \
lowercase\n %-42s -V retain VMS version numbers\n%s";
#else /* !VMS */
static ZCONST char Far UnzipUsageLine4[] = "\
modifiers:\n\
-n never overwrite existing files -q quiet mode (-qq => quieter)\n\
-o overwrite files WITHOUT prompting -a auto-convert any text files\n\
-j junk paths (do not make directories) -aa treat ALL files as text\n\
-U use escapes for all non-ASCII Unicode -UU ignore any Unicode fields\n\
-C match filenames case-insensitively -L make (some) names \
lowercase\n %-42s -V retain VMS version numbers\n%s";
#endif /* ?VMS */
#else /* !UNICODE_SUPPORT */
#ifdef VMS
static ZCONST char Far UnzipUsageLine4[] = "\
modifiers:\n\
-n never overwrite or make a new version of an existing file\n\
-o always make a new version (-oo: overwrite original) of an existing file\n\
-q quiet mode (-qq => quieter) -a auto-convert any text files\n\
-j junk paths (do not make directories) -aa treat ALL files as text\n\
-C match filenames case-insensitively -L make (some) names \
lowercase\n %-42s -V retain VMS version numbers\n%s";
#else /* !VMS */
static ZCONST char Far UnzipUsageLine4[] = "\
modifiers:\n\
-n never overwrite existing files -q quiet mode (-qq => quieter)\n\
-o overwrite files WITHOUT prompting -a auto-convert any text files\n\
-j junk paths (do not make directories) -aa treat ALL files as text\n\
-C match filenames case-insensitively -L make (some) names \
lowercase\n %-42s -V retain VMS version numbers\n%s";
#endif /* ?VMS */
#endif /* ?UNICODE_SUPPORT */
static ZCONST char Far UnzipUsageLine5[] = "\
See \"unzip -hh\" or unzip.txt for more help. Examples:\n\
unzip data1 -x joe => extract all files except joe from zipfile data1.zip\n\
%s\
unzip -fo foo %-6s => quietly replace existing %s if archive file newer\n";
#endif /* ?SFX */
/*****************************/
/* main() / UzpMain() stub */
/*****************************/
int MAIN(argc, argv) /* return PK-type error code (except under VMS) */
int argc;
char *argv[];
{
int r;
CONSTRUCTGLOBALS();
r = unzip(__G__ argc, argv);
DESTROYGLOBALS();
RETURN(r);
}
/*******************************/
/* Primary UnZip entry point */
/*******************************/
int unzip(__G__ argc, argv)
__GDEF
int argc;
char *argv[];
{
#ifndef NO_ZIPINFO
char *p;
#endif
#if (defined(DOS_FLX_H68_NLM_OS2_W32) || !defined(SFX))
int i;
#endif
int retcode, error=FALSE;
#ifndef NO_EXCEPT_SIGNALS
#ifdef REENTRANT
savsigs_info *oldsighandlers = NULL;
# define SET_SIGHANDLER(sigtype, newsighandler) \
if ((retcode = setsignalhandler(__G__ &oldsighandlers, (sigtype), \
(newsighandler))) > PK_WARN) \
goto cleanup_and_exit
#else
# define SET_SIGHANDLER(sigtype, newsighandler) \
signal((sigtype), (newsighandler))
#endif
#endif /* NO_EXCEPT_SIGNALS */
/* initialize international char support to the current environment */
SETLOCALE(LC_CTYPE, "");
#ifdef UNICODE_SUPPORT
/* see if can use UTF-8 Unicode locale */
# ifdef UTF8_MAYBE_NATIVE
{
char *codeset;
# if !(defined(NO_NL_LANGINFO) || defined(NO_LANGINFO_H))
/* get the codeset (character set encoding) currently used */
# include <langinfo.h>
codeset = nl_langinfo(CODESET);
# else /* NO_NL_LANGINFO || NO_LANGINFO_H */
/* query the current locale setting for character classification */
codeset = setlocale(LC_CTYPE, NULL);
if (codeset != NULL) {
/* extract the codeset portion of the locale name */
codeset = strchr(codeset, '.');
if (codeset != NULL) ++codeset;
}
# endif /* ?(NO_NL_LANGINFO || NO_LANGINFO_H) */
/* is the current codeset UTF-8 ? */
if ((codeset != NULL) && (strcmp(codeset, "UTF-8") == 0)) {
/* successfully found UTF-8 char coding */
G.native_is_utf8 = TRUE;
} else {
/* Current codeset is not UTF-8 or cannot be determined. */
G.native_is_utf8 = FALSE;
}
/* Note: At least for UnZip, trying to change the process codeset to
* UTF-8 does not work. For the example Linux setup of the
* UnZip maintainer, a successful switch to "en-US.UTF-8"
* resulted in garbage display of all non-basic ASCII characters.
*/
}
# endif /* UTF8_MAYBE_NATIVE */
/* initialize Unicode */
G.unicode_escape_all = 0;
G.unicode_mismatch = 0;
G.unipath_version = 0;
G.unipath_checksum = 0;
G.unipath_filename = NULL;
#endif /* UNICODE_SUPPORT */
#if (defined(__IBMC__) && defined(__DEBUG_ALLOC__))
extern void DebugMalloc(void);
atexit(DebugMalloc);
#endif
#ifdef MALLOC_WORK
/* The following (rather complex) expression determines the allocation
size of the decompression work area. It simulates what the
combined "union" and "struct" declaration of the "static" work
area reservation achieves automatically at compile time.
Any decent compiler should evaluate this expression completely at
compile time and provide constants to the zcalloc() call.
(For better readability, some subexpressions are encapsulated
in temporarly defined macros.)
*/
# define UZ_SLIDE_CHUNK (sizeof(shrint)+sizeof(uch)+sizeof(uch))
# define UZ_NUMOF_CHUNKS \
(unsigned)(((WSIZE+UZ_SLIDE_CHUNK-1)/UZ_SLIDE_CHUNK > HSIZE) ? \
(WSIZE+UZ_SLIDE_CHUNK-1)/UZ_SLIDE_CHUNK : HSIZE)
G.area.Slide = (uch *)zcalloc(UZ_NUMOF_CHUNKS, UZ_SLIDE_CHUNK);
# undef UZ_SLIDE_CHUNK
# undef UZ_NUMOF_CHUNKS
G.area.shrink.Parent = (shrint *)G.area.Slide;
G.area.shrink.value = G.area.Slide + (sizeof(shrint)*(HSIZE));
G.area.shrink.Stack = G.area.Slide +
(sizeof(shrint) + sizeof(uch))*(HSIZE);
#endif
/*---------------------------------------------------------------------------
Set signal handler for restoring echo, warn of zipfile corruption, etc.
---------------------------------------------------------------------------*/
#ifndef NO_EXCEPT_SIGNALS
#ifdef SIGINT
SET_SIGHANDLER(SIGINT, handler);
#endif
#ifdef SIGTERM /* some systems really have no SIGTERM */
SET_SIGHANDLER(SIGTERM, handler);
#endif
#if defined(SIGABRT) && !(defined(AMIGA) && defined(__SASC))
SET_SIGHANDLER(SIGABRT, handler);
#endif
#ifdef SIGBREAK
SET_SIGHANDLER(SIGBREAK, handler);
#endif
#ifdef SIGBUS
SET_SIGHANDLER(SIGBUS, handler);
#endif
#ifdef SIGILL
SET_SIGHANDLER(SIGILL, handler);
#endif
#ifdef SIGSEGV
SET_SIGHANDLER(SIGSEGV, handler);
#endif
#endif /* NO_EXCEPT_SIGNALS */
#if (defined(WIN32) && defined(__RSXNT__))
for (i = 0 ; i < argc; i++) {
_ISO_INTERN(argv[i]);
}
#endif
/*---------------------------------------------------------------------------
Macintosh initialization code.
---------------------------------------------------------------------------*/
#ifdef MACOS
{
int a;
for (a = 0; a < 4; ++a)
G.rghCursor[a] = GetCursor(a+128);
G.giCursor = 0;
}
#endif
/*---------------------------------------------------------------------------
NetWare initialization code.
---------------------------------------------------------------------------*/
#ifdef NLM
InitUnZipConsole();
#endif
/*---------------------------------------------------------------------------
Acorn RISC OS initialization code.
---------------------------------------------------------------------------*/
#ifdef RISCOS
set_prefix();
#endif
/*---------------------------------------------------------------------------
Theos initialization code.
---------------------------------------------------------------------------*/
#ifdef THEOS
/* The easiest way found to force creation of libraries when selected
* members are to be unzipped. Explicitly add libraries names to the
* arguments list before the first member of the library.
*/
if (! _setargv(&argc, &argv)) {
Info(slide, 0x401, ((char *)slide, "cannot process argv\n"));
retcode = PK_MEM;
goto cleanup_and_exit;
}
#endif
/*---------------------------------------------------------------------------
Sanity checks. Commentary by Otis B. Driftwood and Fiorello:
D: It's all right. That's in every contract. That's what they
call a sanity clause.
F: Ha-ha-ha-ha-ha. You can't fool me. There ain't no Sanity
Claus.
---------------------------------------------------------------------------*/
#ifdef DEBUG
# ifdef LARGE_FILE_SUPPORT
/* test if we can support large files - 10/6/04 EG */
if (sizeof(zoff_t) < 8) {
Info(slide, 0x401, ((char *)slide, "LARGE_FILE_SUPPORT set but not supported\n"));
retcode = PK_BADERR;
goto cleanup_and_exit;
}
/* test if we can show 64-bit values */
{
zoff_t z = ~(zoff_t)0; /* z should be all 1s now */
char *sz;
sz = FmZofft(z, FZOFFT_HEX_DOT_WID, "X");
if ((sz[0] != 'F') || (strlen(sz) != 16))
{
z = 0;
}
/* shift z so only MSB is set */
z <<= 63;
sz = FmZofft(z, FZOFFT_HEX_DOT_WID, "X");
if ((sz[0] != '8') || (strlen(sz) != 16))
{
Info(slide, 0x401, ((char *)slide,
"Can't show 64-bit values correctly\n"));
retcode = PK_BADERR;
goto cleanup_and_exit;
}
}
# endif /* LARGE_FILE_SUPPORT */
/* 2004-11-30 SMS.
Test the NEXTBYTE macro for proper operation.
*/
{
int test_char;
static uch test_buf[2] = { 'a', 'b' };
G.inptr = test_buf;
G.incnt = 1;
test_char = NEXTBYTE; /* Should get 'a'. */
if (test_char == 'a')
{
test_char = NEXTBYTE; /* Should get EOF, not 'b'. */
}
if (test_char != EOF)
{
Info(slide, 0x401, ((char *)slide,
"NEXTBYTE macro failed. Try compiling with ALT_NEXTBYTE defined?"));
retcode = PK_BADERR;
goto cleanup_and_exit;
}
}
#endif /* DEBUG */
/*---------------------------------------------------------------------------
First figure out if we're running in UnZip mode or ZipInfo mode, and put
the appropriate environment-variable options into the queue. Then rip
through any command-line options lurking about...
---------------------------------------------------------------------------*/
#ifdef SFX
G.argv0 = argv[0];
#if (defined(OS2) || defined(WIN32))
G.zipfn = GetLoadPath(__G);/* non-MSC NT puts path into G.filename[] */
#else
G.zipfn = G.argv0;
#endif
#ifdef VMSCLI
{
ulg status = vms_unzip_cmdline(&argc, &argv);
if (!(status & 1)) {
retcode = (int)status;
goto cleanup_and_exit;
}
}
#endif /* VMSCLI */
uO.zipinfo_mode = FALSE;
error = uz_opts(__G__ &argc, &argv); /* UnZipSFX call only */
#else /* !SFX */
#ifdef RISCOS
/* get the extensions to swap from environment */
getRISCOSexts(ENV_UNZIPEXTS);
#endif
#ifdef MSDOS
/* extract MKS extended argument list from environment (before envargs!) */
mksargs(&argc, &argv);
#endif
#ifdef VMSCLI
{
ulg status = vms_unzip_cmdline(&argc, &argv);
if (!(status & 1)) {
retcode = (int)status;
goto cleanup_and_exit;
}
}
#endif /* VMSCLI */
G.noargs = (argc == 1); /* no options, no zipfile, no anything */
#ifndef NO_ZIPINFO
for (p = argv[0] + strlen(argv[0]); p >= argv[0]; --p) {
if (*p == DIR_END
#ifdef DIR_END2
|| *p == DIR_END2
#endif
)
break;
}
++p;
#ifdef THEOS
if (strncmp(p, "ZIPINFO.",8) == 0 || strstr(p, ".ZIPINFO:") != NULL ||
strncmp(p, "II.",3) == 0 || strstr(p, ".II:") != NULL ||
#else
if (STRNICMP(p, LoadFarStringSmall(Zipnfo), 7) == 0 ||
STRNICMP(p, "ii", 2) == 0 ||
#endif
(argc > 1 && strncmp(argv[1], "-Z", 2) == 0))
{
uO.zipinfo_mode = TRUE;
#ifndef _WIN32_WCE /* Win CE does not support environment variables */
if ((error = envargs(&argc, &argv, LoadFarStringSmall(EnvZipInfo),
LoadFarStringSmall2(EnvZipInfo2))) != PK_OK)
perror(LoadFarString(NoMemEnvArguments));
#endif
} else
#endif /* !NO_ZIPINFO */
{
uO.zipinfo_mode = FALSE;
#ifndef _WIN32_WCE /* Win CE does not support environment variables */
if ((error = envargs(&argc, &argv, LoadFarStringSmall(EnvUnZip),
LoadFarStringSmall2(EnvUnZip2))) != PK_OK)
perror(LoadFarString(NoMemEnvArguments));
#endif
}
if (!error) {
/* Check the length of all passed command line parameters.
* Command arguments might get sent through the Info() message
* system, which uses the sliding window area as string buffer.
* As arguments may additionally get fed through one of the FnFilter
* macros, we require all command line arguments to be shorter than
* WSIZE/4 (and ca. 2 standard line widths for fixed message text).
*/
for (i = 1 ; i < argc; i++) {
if (strlen(argv[i]) > ((WSIZE>>2) - 160)) {
Info(slide, 0x401, ((char *)slide,
LoadFarString(CmdLineParamTooLong), i));
retcode = PK_PARAM;
goto cleanup_and_exit;
}
}
#ifndef NO_ZIPINFO
if (uO.zipinfo_mode)
error = zi_opts(__G__ &argc, &argv);
else
#endif /* !NO_ZIPINFO */
error = uz_opts(__G__ &argc, &argv);
}
#endif /* ?SFX */
if ((argc < 0) || error) {
retcode = error;
goto cleanup_and_exit;
}
/*---------------------------------------------------------------------------
Now get the zipfile name from the command line and then process any re-
maining options and file specifications.
---------------------------------------------------------------------------*/
#ifdef DOS_FLX_H68_NLM_OS2_W32
/* convert MSDOS-style 'backward slash' directory separators to Unix-style
* 'forward slashes' for user's convenience (include zipfile name itself)
*/
#ifdef SFX
for (G.pfnames = argv, i = argc; i > 0; --i) {
#else
/* argc does not include the zipfile specification */
for (G.pfnames = argv, i = argc+1; i > 0; --i) {
#endif
#ifdef __human68k__
extern char *_toslash(char *);
_toslash(*G.pfnames);
#else /* !__human68k__ */
char *q = *G.pfnames;
while (*q != '\0') {
if (*q == '\\')
*q = '/';
INCSTR(q);
}
#endif /* ?__human68k__ */
++G.pfnames;
}
#endif /* DOS_FLX_H68_NLM_OS2_W32 */
#ifndef SFX
G.wildzipfn = *argv++;
#endif
#if (defined(SFX) && !defined(SFX_EXDIR)) /* only check for -x */
G.filespecs = argc;
G.xfilespecs = 0;
if (argc > 0) {
char **pp = argv-1;
G.pfnames = argv;
while (*++pp)
if (strcmp(*pp, "-x") == 0) {
if (pp > argv) {
*pp = 0; /* terminate G.pfnames */
G.filespecs = pp - G.pfnames;
} else {
G.pfnames = (char **)fnames; /* defaults */
G.filespecs = 0;
}
G.pxnames = pp + 1; /* excluded-names ptr: _after_ -x */
G.xfilespecs = argc - G.filespecs - 1;
break; /* skip rest of args */
}
G.process_all_files = FALSE;
} else
G.process_all_files = TRUE; /* for speed */
#else /* !SFX || SFX_EXDIR */ /* check for -x or -d */
G.filespecs = argc;
G.xfilespecs = 0;
if (argc > 0) {
int in_files=FALSE, in_xfiles=FALSE;
char **pp = argv-1;
G.process_all_files = FALSE;
G.pfnames = argv;
while (*++pp) {
Trace((stderr, "pp - argv = %d\n", pp-argv));
#ifdef CMS_MVS
if (!uO.exdir && STRNICMP(*pp, "-d", 2) == 0) {
#else
if (!uO.exdir && strncmp(*pp, "-d", 2) == 0) {
#endif
int firstarg = (pp == argv);
uO.exdir = (*pp) + 2;
if (in_files) { /* ... zipfile ... -d exdir ... */
*pp = (char *)NULL; /* terminate G.pfnames */
G.filespecs = pp - G.pfnames;
in_files = FALSE;
} else if (in_xfiles) {
*pp = (char *)NULL; /* terminate G.pxnames */
G.xfilespecs = pp - G.pxnames;
/* "... -x xlist -d exdir": nothing left */
}
/* first check for "-dexdir", then for "-d exdir" */
if (*uO.exdir == '\0') {
if (*++pp)
uO.exdir = *pp;
else {
Info(slide, 0x401, ((char *)slide,
LoadFarString(MustGiveExdir)));
/* don't extract here by accident */
retcode = PK_PARAM;
goto cleanup_and_exit;
}
}
if (firstarg) { /* ... zipfile -d exdir ... */
if (pp[1]) {
G.pfnames = pp + 1; /* argv+2 */
G.filespecs = argc - (G.pfnames-argv); /* for now... */
} else {
G.process_all_files = TRUE;
G.pfnames = (char **)fnames; /* GRR: necessary? */
G.filespecs = 0; /* GRR: necessary? */
break;
}
}
} else if (!in_xfiles) {
if (strcmp(*pp, "-x") == 0) {
in_xfiles = TRUE;
if (pp == G.pfnames) {
G.pfnames = (char **)fnames; /* defaults */
G.filespecs = 0;
} else if (in_files) {
*pp = 0; /* terminate G.pfnames */
G.filespecs = pp - G.pfnames; /* adjust count */
in_files = FALSE;
}
G.pxnames = pp + 1; /* excluded-names ptr starts after -x */
G.xfilespecs = argc - (G.pxnames-argv); /* anything left */
} else
in_files = TRUE;
}
}
} else
G.process_all_files = TRUE; /* for speed */
if (uO.exdir != (char *)NULL && !G.extract_flag) /* -d ignored */
Info(slide, 0x401, ((char *)slide, LoadFarString(NotExtracting)));
#endif /* ?(SFX && !SFX_EXDIR) */
#ifdef UNICODE_SUPPORT
/* set Unicode-escape-all if option -U used */
if (uO.U_flag == 1)
# ifdef UNICODE_WCHAR
G.unicode_escape_all = TRUE;
# else
Info(slide, 0x401, ((char *)slide, LoadFarString(UTF8EscapeUnSupp)));
# endif
#endif
/*---------------------------------------------------------------------------
Okey dokey, we have everything we need to get started. Let's roll.
---------------------------------------------------------------------------*/
retcode = process_zipfiles(__G);
cleanup_and_exit:
#if (defined(REENTRANT) && !defined(NO_EXCEPT_SIGNALS))
/* restore all signal handlers back to their state at function entry */
while (oldsighandlers != NULL) {
savsigs_info *thissigsav = oldsighandlers;
signal(thissigsav->sigtype, thissigsav->sighandler);
oldsighandlers = thissigsav->previous;
free(thissigsav);
}
#endif
#if (defined(MALLOC_WORK) && !defined(REENTRANT))
if (G.area.Slide != (uch *)NULL) {
free(G.area.Slide);
G.area.Slide = (uch *)NULL;
}
#endif
#if (defined(MSDOS) && !defined(SFX) && !defined(WINDLL))
if (retcode != PK_OK)
check_for_windows("UnZip");
#endif
return(retcode);
} /* end main()/unzip() */
#if (defined(REENTRANT) && !defined(NO_EXCEPT_SIGNALS))
/*******************************/
/* Function setsignalhandler() */
/*******************************/
static int setsignalhandler(__G__ p_savedhandler_chain, signal_type,
newhandler)
__GDEF
savsigs_info **p_savedhandler_chain;
int signal_type;
void (*newhandler)(int);
{
savsigs_info *savsig;
savsig = malloc(sizeof(savsigs_info));
if (savsig == NULL) {
/* error message and break */
Info(slide, 0x401, ((char *)slide, LoadFarString(CantSaveSigHandler)));
return PK_MEM;
}
savsig->sigtype = signal_type;
savsig->sighandler = signal(SIGINT, newhandler);
if (savsig->sighandler == SIG_ERR) {
free(savsig);
} else {
savsig->previous = *p_savedhandler_chain;
*p_savedhandler_chain = savsig;
}
return PK_OK;
} /* end function setsignalhandler() */
#endif /* REENTRANT && !NO_EXCEPT_SIGNALS */
/**********************/
/* Function uz_opts() */
/**********************/
int uz_opts(__G__ pargc, pargv)
__GDEF
int *pargc;
char ***pargv;
{
char **argv, *s;
int argc, c, error=FALSE, negative=0, showhelp=0;
argc = *pargc;
argv = *pargv;
while (++argv, (--argc > 0 && *argv != NULL && **argv == '-')) {
s = *argv + 1;
while ((c = *s++) != 0) { /* "!= 0": prevent Turbo C warning */
#ifdef CMS_MVS
switch (tolower(c))
#else
switch (c)
#endif
{
case ('-'):
++negative;
break;
#ifdef RISCOS
case ('/'):
if (negative) { /* negative not allowed with -/ swap */
Info(slide, 0x401, ((char *)slide,
"error: must give extensions list"));
return(PK_PARAM); /* don't extract here by accident */
}
exts2swap = s; /* override Unzip$Exts */
s += strlen(s);
break;
#endif
case ('a'):
if (negative) {
uO.aflag = MAX(uO.aflag-negative,0);
negative = 0;
} else
++uO.aflag;
break;
#if (defined(DLL) && defined(API_DOC))
case ('A'): /* extended help for API */
APIhelp(__G__ argc, argv);
*pargc = -1; /* signal to exit successfully */
return 0;
#endif
case ('b'):
if (negative) {
#if (defined(TANDEM) || defined(VMS))
uO.bflag = MAX(uO.bflag-negative,0);
#endif
negative = 0; /* do nothing: "-b" is default */
} else {
#ifdef VMS
if (uO.aflag == 0)
++uO.bflag;
#endif
#ifdef TANDEM
++uO.bflag;
#endif
uO.aflag = 0;
}
break;
#ifdef UNIXBACKUP
case ('B'): /* -B: back up existing files */
if (negative)
uO.B_flag = FALSE, negative = 0;
else
uO.B_flag = TRUE;
break;
#endif
case ('c'):
if (negative) {
uO.cflag = FALSE, negative = 0;
#ifdef NATIVE
uO.aflag = 0;
#endif
} else {
uO.cflag = TRUE;
#ifdef NATIVE
uO.aflag = 2; /* so you can read it on the screen */
#endif
#ifdef DLL
if (G.redirect_text)
G.redirect_data = 2;
#endif
}
break;
#ifndef CMS_MVS
case ('C'): /* -C: match filenames case-insensitively */
if (negative)
uO.C_flag = FALSE, negative = 0;
else
uO.C_flag = TRUE;
break;
#endif /* !CMS_MVS */
#if (!defined(SFX) || defined(SFX_EXDIR))
case ('d'):
if (negative) { /* negative not allowed with -d exdir */
Info(slide, 0x401, ((char *)slide,
LoadFarString(MustGiveExdir)));
return(PK_PARAM); /* don't extract here by accident */
}
if (uO.exdir != (char *)NULL) {
Info(slide, 0x401, ((char *)slide,
LoadFarString(OnlyOneExdir)));
return(PK_PARAM); /* GRR: stupid restriction? */
} else {
/* first check for "-dexdir", then for "-d exdir" */
uO.exdir = s;
if (*uO.exdir == '\0') {
if (argc > 1) {
--argc;
uO.exdir = *++argv;
if (*uO.exdir == '-') {
Info(slide, 0x401, ((char *)slide,
LoadFarString(MustGiveExdir)));
return(PK_PARAM);
}
/* else uO.exdir points at extraction dir */
} else {
Info(slide, 0x401, ((char *)slide,
LoadFarString(MustGiveExdir)));
return(PK_PARAM);
}
}
/* uO.exdir now points at extraction dir (-dexdir or
* -d exdir); point s at end of exdir to avoid mis-
* interpretation of exdir characters as more options
*/
if (*s != 0)
while (*++s != 0)
;
}
break;
#endif /* !SFX || SFX_EXDIR */
#if (!defined(NO_TIMESTAMPS))
case ('D'): /* -D: Skip restoring dir (or any) timestamp. */
if (negative) {
uO.D_flag = MAX(uO.D_flag-negative,0);
negative = 0;
} else
uO.D_flag++;
break;
#endif /* (!NO_TIMESTAMPS) */
case ('e'): /* just ignore -e, -x options (extract) */
break;
#ifdef MACOS
case ('E'): /* -E [MacOS] display Mac e.f. when restoring */
if( negative ) {
uO.E_flag = FALSE, negative = 0;
} else {
uO.E_flag = TRUE;
}
break;
#endif /* MACOS */
case ('f'): /* "freshen" (extract only newer files) */
if (negative)
uO.fflag = uO.uflag = FALSE, negative = 0;
else
uO.fflag = uO.uflag = TRUE;
break;
#if (defined(RISCOS) || defined(ACORN_FTYPE_NFS))
case ('F'): /* Acorn filetype & NFS extension handling */
if (negative)
uO.acorn_nfs_ext = FALSE, negative = 0;
else
uO.acorn_nfs_ext = TRUE;
break;
#endif /* RISCOS || ACORN_FTYPE_NFS */
case ('h'): /* just print help message and quit */
if (showhelp == 0) {
#ifndef SFX
if (*s == 'h')
showhelp = 2;
else
#endif /* !SFX */
{
showhelp = 1;
}
}
break;
#ifdef MACOS
case ('i'): /* -i [MacOS] ignore filenames stored in Mac ef */
if( negative ) {
uO.i_flag = FALSE, negative = 0;
} else {
uO.i_flag = TRUE;
}
break;
#endif /* MACOS */
case ('j'): /* junk pathnames/directory structure */
if (negative)
uO.jflag = FALSE, negative = 0;
else
uO.jflag = TRUE;
break;
#if (defined(ATH_BEO) || defined(MACOS))
case ('J'): /* Junk AtheOS, BeOS or MacOS file attributes */
if( negative ) {
uO.J_flag = FALSE, negative = 0;
} else {
uO.J_flag = TRUE;
}
break;
#endif /* ATH_BEO || MACOS */
#ifdef ATH_BEO_UNX
case ('K'):
if (negative) {
uO.K_flag = FALSE, negative = 0;
} else {
uO.K_flag = TRUE;
}
break;
#endif /* ATH_BEO_UNX */
#ifndef SFX
case ('l'):
if (negative) {
uO.vflag = MAX(uO.vflag-negative,0);
negative = 0;
} else
++uO.vflag;
break;
#endif /* !SFX */
#ifndef CMS_MVS
case ('L'): /* convert (some) filenames to lowercase */
if (negative) {
uO.L_flag = MAX(uO.L_flag-negative,0);
negative = 0;
} else
++uO.L_flag;
break;
#endif /* !CMS_MVS */
#ifdef MORE
#ifdef CMS_MVS
case ('m'):
#endif
case ('M'): /* send all screen output through "more" fn. */
/* GRR: eventually check for numerical argument => height */
if (negative)
G.M_flag = FALSE, negative = 0;
else
G.M_flag = TRUE;
break;
#endif /* MORE */
case ('n'): /* don't overwrite any files */
if (negative)
uO.overwrite_none = FALSE, negative = 0;
else
uO.overwrite_none = TRUE;
break;
#ifdef AMIGA
case ('N'): /* restore comments as filenotes */
if (negative)
uO.N_flag = FALSE, negative = 0;
else
uO.N_flag = TRUE;
break;
#endif /* AMIGA */
case ('o'): /* OK to overwrite files without prompting */
if (negative) {
uO.overwrite_all = MAX(uO.overwrite_all-negative,0);
negative = 0;
} else
++uO.overwrite_all;
break;
case ('p'): /* pipes: extract to stdout, no messages */
if (negative) {
uO.cflag = FALSE;
uO.qflag = MAX(uO.qflag-999,0);
negative = 0;
} else {
uO.cflag = TRUE;
uO.qflag += 999;
}
break;
#if CRYPT
/* GRR: yes, this is highly insecure, but dozens of people
* have pestered us for this, so here we go... */
case ('P'):
if (negative) { /* negative not allowed with -P passwd */
Info(slide, 0x401, ((char *)slide,
LoadFarString(MustGivePasswd)));
return(PK_PARAM); /* don't extract here by accident */
}
if (uO.pwdarg != (char *)NULL) {
/*
GRR: eventually support multiple passwords?
Info(slide, 0x401, ((char *)slide,
LoadFarString(OnlyOnePasswd)));
return(PK_PARAM);
*/
} else {
/* first check for "-Ppasswd", then for "-P passwd" */
uO.pwdarg = s;
if (*uO.pwdarg == '\0') {
if (argc > 1) {
--argc;
uO.pwdarg = *++argv;
if (*uO.pwdarg == '-') {
Info(slide, 0x401, ((char *)slide,
LoadFarString(MustGivePasswd)));
return(PK_PARAM);
}
/* else pwdarg points at decryption password */
} else {
Info(slide, 0x401, ((char *)slide,
LoadFarString(MustGivePasswd)));
return(PK_PARAM);
}
}
/* pwdarg now points at decryption password (-Ppasswd or
* -P passwd); point s at end of passwd to avoid mis-
* interpretation of passwd characters as more options
*/
if (*s != 0)
while (*++s != 0)
;
}
break;
#endif /* CRYPT */
case ('q'): /* quiet: fewer comments/messages */
if (negative) {
uO.qflag = MAX(uO.qflag-negative,0);
negative = 0;
} else
++uO.qflag;
break;
#ifdef QDOS
case ('Q'): /* QDOS flags */
qlflag ^= strtol(s, &s, 10);
break; /* we XOR this as we can config qlflags */
#endif
#ifdef TANDEM
case ('r'): /* remove file extensions */
if (negative)
uO.rflag = FALSE, negative = 0;
else
uO.rflag = TRUE;
break;
#endif /* TANDEM */
#ifdef DOS_FLX_NLM_OS2_W32
case ('s'): /* spaces in filenames: allow by default */
if (negative)
uO.sflag = FALSE, negative = 0;
else
uO.sflag = TRUE;
break;
#endif /* DOS_FLX_NLM_OS2_W32 */
#ifdef VMS
/* VMS: extract "text" files in Stream_LF format (-a[a]) */
case ('S'):
if (negative)
uO.S_flag = FALSE, negative = 0;
else
uO.S_flag = TRUE;
break;
#endif /* VMS */
case ('t'):
if (negative)
uO.tflag = FALSE, negative = 0;
else
uO.tflag = TRUE;
break;
#ifdef TIMESTAMP
case ('T'):
if (negative)
uO.T_flag = FALSE, negative = 0;
else
uO.T_flag = TRUE;
break;
#endif
case ('u'): /* update (extract only new and newer files) */
if (negative)
uO.uflag = FALSE, negative = 0;
else
uO.uflag = TRUE;
break;
#ifdef UNICODE_SUPPORT
case ('U'): /* escape UTF-8, or disable UTF-8 support */
if (negative) {
uO.U_flag = MAX(uO.U_flag-negative,0);
negative = 0;
} else
uO.U_flag++;
break;
#else /* !UNICODE_SUPPORT */
#ifndef CMS_MVS
case ('U'): /* obsolete; to be removed in version 6.0 */
if (negative)
uO.L_flag = TRUE, negative = 0;
else
uO.L_flag = FALSE;
break;
#endif /* !CMS_MVS */
#endif /* ?UNICODE_SUPPORT */
#ifndef SFX
case ('v'): /* verbose */
if (negative) {
uO.vflag = MAX(uO.vflag-negative,0);
negative = 0;
} else if (uO.vflag)
++uO.vflag;
else
uO.vflag = 2;
break;
#endif /* !SFX */
#ifndef CMS_MVS
case ('V'): /* Version (retain VMS/DEC-20 file versions) */
if (negative)
uO.V_flag = FALSE, negative = 0;
else
uO.V_flag = TRUE;
break;
#endif /* !CMS_MVS */
#ifdef WILD_STOP_AT_DIR
case ('W'): /* Wildcard interpretation (stop at '/'?) */
if (negative)
uO.W_flag = FALSE, negative = 0;
else
uO.W_flag = TRUE;
break;
#endif /* WILD_STOP_AT_DIR */
case ('x'): /* extract: default */
#ifdef SFX
/* when 'x' is the only option in this argument, and the
* next arg is not an option, assume this initiates an
* exclusion list (-x xlist): terminate option-scanning
* and leave uz_opts with argv still pointing to "-x";
* the xlist is processed later
*/
if (s - argv[0] == 2 && *s == '\0' &&
argc > 1 && argv[1][0] != '-') {
/* break out of nested loops without "++argv;--argc" */
goto opts_done;
}
#endif /* SFX */
break;
#if (defined(RESTORE_UIDGID) || defined(RESTORE_ACL))
case ('X'): /* restore owner/protection info (need privs?) */
if (negative) {
uO.X_flag = MAX(uO.X_flag-negative,0);
negative = 0;
} else
++uO.X_flag;
break;
#endif /* RESTORE_UIDGID || RESTORE_ACL */
#ifdef VMS
case ('Y'): /* Treat ".nnn" as ";nnn" version. */
if (negative)
uO.Y_flag = FALSE, negative = 0;
else
uO.Y_flag = TRUE;
break;
#endif /* VMS */
case ('z'): /* display only the archive comment */
if (negative) {
uO.zflag = MAX(uO.zflag-negative,0);
negative = 0;
} else
++uO.zflag;
break;
#ifndef SFX
case ('Z'): /* should have been first option (ZipInfo) */
Info(slide, 0x401, ((char *)slide, LoadFarString(Zfirst)));
error = TRUE;
break;
#endif /* !SFX */
#ifdef VMS
case ('2'): /* Force ODS2-compliant names. */
if (negative)
uO.ods2_flag = FALSE, negative = 0;
else
uO.ods2_flag = TRUE;
break;
#endif /* VMS */
#ifdef DOS_H68_OS2_W32
case ('$'):
if (negative) {
uO.volflag = MAX(uO.volflag-negative,0);
negative = 0;
} else
++uO.volflag;
break;
#endif /* DOS_H68_OS2_W32 */
#if (!defined(RISCOS) && !defined(CMS_MVS) && !defined(TANDEM))
case (':'): /* allow "parent dir" path components */
if (negative) {
uO.ddotflag = MAX(uO.ddotflag-negative,0);
negative = 0;
} else
++uO.ddotflag;
break;
#endif /* !RISCOS && !CMS_MVS && !TANDEM */
#ifdef UNIX
case ('^'): /* allow control chars in filenames */
if (negative) {
uO.cflxflag = MAX(uO.cflxflag-negative,0);
negative = 0;
} else
++uO.cflxflag;
break;
#endif /* UNIX */
default:
error = TRUE;
break;
} /* end switch */
} /* end while (not end of argument string) */
} /* end while (not done with switches) */
/*---------------------------------------------------------------------------
Check for nonsensical combinations of options.
---------------------------------------------------------------------------*/
#ifdef SFX
opts_done: /* yes, very ugly...but only used by UnZipSFX with -x xlist */
#endif
if (showhelp > 0) { /* just print help message and quit */
*pargc = -1;
#ifndef SFX
if (showhelp == 2) {
help_extended(__G);
return PK_OK;
} else
#endif /* !SFX */
{
return USAGE(PK_OK);
}
}
if ((uO.cflag && (uO.tflag || uO.uflag)) ||
(uO.tflag && uO.uflag) || (uO.fflag && uO.overwrite_none))
{
Info(slide, 0x401, ((char *)slide, LoadFarString(InvalidOptionsMsg)));
error = TRUE;
}
if (uO.aflag > 2)
uO.aflag = 2;
#ifdef VMS
if (uO.bflag > 2)
uO.bflag = 2;
/* Clear -s flag when converting text files. */
if (uO.aflag <= 0)
uO.S_flag = 0;
#endif /* VMS */
if (uO.overwrite_all && uO.overwrite_none) {
Info(slide, 0x401, ((char *)slide, LoadFarString(IgnoreOOptionMsg)));
uO.overwrite_all = FALSE;
}
#ifdef MORE
if (G.M_flag && !isatty(1)) /* stdout redirected: "more" func. useless */
G.M_flag = 0;
#endif
#ifdef SFX
if (error)
#else
if ((argc-- == 0) || error)
#endif
{
*pargc = argc;
*pargv = argv;
#ifndef SFX
if (uO.vflag >= 2 && argc == -1) { /* "unzip -v" */
show_version_info(__G);
return PK_OK;
}
if (!G.noargs && !error)
error = TRUE; /* had options (not -h or -v) but no zipfile */
#endif /* !SFX */
return USAGE(error);
}
#ifdef SFX
/* print our banner unless we're being fairly quiet */
if (uO.qflag < 2)
Info(slide, error? 1 : 0, ((char *)slide, LoadFarString(UnzipSFXBanner),
UZ_MAJORVER, UZ_MINORVER, UZ_PATCHLEVEL, UZ_BETALEVEL,
LoadFarStringSmall(VersionDate)));
#ifdef BETA
/* always print the beta warning: no unauthorized distribution!! */
Info(slide, error? 1 : 0, ((char *)slide, LoadFarString(BetaVersion), "\n",
"SFX"));
#endif
#endif /* SFX */
if (uO.cflag || uO.tflag || uO.vflag || uO.zflag
#ifdef TIMESTAMP
|| uO.T_flag
#endif
)
G.extract_flag = FALSE;
else
G.extract_flag = TRUE;
*pargc = argc;
*pargv = argv;
return PK_OK;
} /* end function uz_opts() */
/********************/
/* Function usage() */
/********************/
#ifdef SFX
# ifdef VMS
# define LOCAL "X.\n\
(Must quote upper-case options, like \"-V\", unless SET PROC/PARSE=EXTEND.)"
# endif
# ifdef UNIX
# define LOCAL "X"
# endif
# ifdef DOS_OS2_W32
# define LOCAL "s$"
# endif
# if (defined(FLEXOS) || defined(NLM))
# define LOCAL "s"
# endif
# ifdef AMIGA
# define LOCAL "N"
# endif
/* Default for all other systems: */
# ifndef LOCAL
# define LOCAL ""
# endif
# ifndef NO_TIMESTAMP
# ifdef MORE
# define SFXOPT1 "DM"
# else
# define SFXOPT1 "D"
# endif
# else
# ifdef MORE
# define SFXOPT1 "M"
# else
# define SFXOPT1 ""
# endif
# endif
int usage(__G__ error) /* return PK-type error code */
__GDEF
int error;
{
Info(slide, error? 1 : 0, ((char *)slide, LoadFarString(UnzipSFXBanner),
UZ_MAJORVER, UZ_MINORVER, UZ_PATCHLEVEL, UZ_BETALEVEL,
LoadFarStringSmall(VersionDate)));
Info(slide, error? 1 : 0, ((char *)slide, LoadFarString(UnzipSFXOpts),
SFXOPT1, LOCAL));
#ifdef BETA
Info(slide, error? 1 : 0, ((char *)slide, LoadFarString(BetaVersion), "\n",
"SFX"));
#endif
if (error)
return PK_PARAM;
else
return PK_COOL; /* just wanted usage screen: no error */
} /* end function usage() */
#else /* !SFX */
# ifdef VMS
# define QUOT '\"'
# define QUOTS "\""
# else
# define QUOT ' '
# define QUOTS ""
# endif
int usage(__G__ error) /* return PK-type error code */
__GDEF
int error;
{
int flag = (error? 1 : 0);
/*---------------------------------------------------------------------------
Print either ZipInfo usage or UnZip usage, depending on incantation.
(Strings must be no longer than 512 bytes for Turbo C, apparently.)
---------------------------------------------------------------------------*/
if (uO.zipinfo_mode) {
#ifndef NO_ZIPINFO
Info(slide, flag, ((char *)slide, LoadFarString(ZipInfoUsageLine1),
ZI_MAJORVER, ZI_MINORVER, UZ_PATCHLEVEL, UZ_BETALEVEL,
LoadFarStringSmall(VersionDate),
LoadFarStringSmall2(ZipInfoExample), QUOTS,QUOTS));
Info(slide, flag, ((char *)slide, LoadFarString(ZipInfoUsageLine2)));
Info(slide, flag, ((char *)slide, LoadFarString(ZipInfoUsageLine3),
LoadFarStringSmall(ZipInfoUsageLine4)));
#ifdef VMS
Info(slide, flag, ((char *)slide, "\n\
You must quote non-lowercase options and filespecs, unless SET PROC/PARSE=EXT.\
\n"));
#endif
#endif /* !NO_ZIPINFO */
} else { /* UnZip mode */
Info(slide, flag, ((char *)slide, LoadFarString(UnzipUsageLine1),
UZ_MAJORVER, UZ_MINORVER, UZ_PATCHLEVEL, UZ_BETALEVEL,
LoadFarStringSmall(VersionDate)));
#ifdef BETA
Info(slide, flag, ((char *)slide, LoadFarString(BetaVersion), "", ""));
#endif
Info(slide, flag, ((char *)slide, LoadFarString(UnzipUsageLine2),
ZIPINFO_MODE_OPTION, LoadFarStringSmall(ZipInfoMode)));
#ifdef VMS
if (!error) /* maybe no command-line tail found; show extra help */
Info(slide, flag, ((char *)slide, LoadFarString(VMSusageLine2b)));
#endif
Info(slide, flag, ((char *)slide, LoadFarString(UnzipUsageLine3),
LoadFarStringSmall(local1)));
Info(slide, flag, ((char *)slide, LoadFarString(UnzipUsageLine4),
LoadFarStringSmall(local2), LoadFarStringSmall2(local3)));
/* This is extra work for SMALL_MEM, but it will work since
* LoadFarStringSmall2 uses the same buffer. Remember, this
* is a hack. */
Info(slide, flag, ((char *)slide, LoadFarString(UnzipUsageLine5),
LoadFarStringSmall(Example2), LoadFarStringSmall2(Example3),
LoadFarStringSmall2(Example3)));
} /* end if (uO.zipinfo_mode) */
if (error)
return PK_PARAM;
else
return PK_COOL; /* just wanted usage screen: no error */
} /* end function usage() */
#endif /* ?SFX */
#ifndef SFX
/* Print extended help to stdout. */
static void help_extended(__G)
__GDEF
{
extent i; /* counter for help array */
/* help array */
static ZCONST char *text[] = {
"",
"Extended Help for UnZip",
"",
"See the UnZip Manual for more detailed help",
"",
"",
"UnZip lists and extracts files in zip archives. The default action is to",
"extract zipfile entries to the current directory, creating directories as",
"needed. With appropriate options, UnZip lists the contents of archives",
"instead.",
"",
"Basic unzip command line:",
" unzip [-Z] options archive[.zip] [file ...] [-x xfile ...] [-d exdir]",
"",
"Some examples:",
" unzip -l foo.zip - list files in short format in archive foo.zip",
"",
" unzip -t foo - test the files in archive foo",
"",
" unzip -Z foo - list files using more detailed zipinfo format",
"",
" unzip foo - unzip the contents of foo in current dir",
"",
" unzip -a foo - unzip foo and convert text files to local OS",
"",
"If unzip is run in zipinfo mode, a more detailed list of archive contents",
"is provided. The -Z option sets zipinfo mode and changes the available",
"options.",
"",
"Basic zipinfo command line:",
" zipinfo options archive[.zip] [file ...] [-x xfile ...]",
" unzip -Z options archive[.zip] [file ...] [-x xfile ...]",
"",
"Below, Mac OS refers to Mac OS before Mac OS X. Mac OS X is a Unix based",
"port and is referred to as Unix Apple.",
"",
"",
"unzip options:",
" -Z Switch to zipinfo mode. Must be first option.",
" -hh Display extended help.",
" -A [OS/2, Unix DLL] Print extended help for DLL.",
" -c Extract files to stdout/screen. As -p but include names. Also,",
" -a allowed and EBCDIC conversions done if needed.",
" -f Freshen by extracting only if older file on disk.",
" -l List files using short form.",
" -p Extract files to pipe (stdout). Only file data is output and all",
" files extracted in binary mode (as stored).",
" -t Test archive files.",
" -T Set timestamp on archive(s) to that of newest file. Similar to",
" zip -o but faster.",
" -u Update existing older files on disk as -f and extract new files.",
" -v Use verbose list format. If given alone as unzip -v show version",
" information. Also can be added to other list commands for more",
" verbose output.",
" -z Display only archive comment.",
"",
"unzip modifiers:",
" -a Convert text files to local OS format. Convert line ends, EOF",
" marker, and from or to EBCDIC character set as needed.",
" -b Treat all files as binary. [Tandem] Force filecode 180 ('C').",
" [VMS] Autoconvert binary files. -bb forces convert of all files.",
" -B [UNIXBACKUP compile option enabled] Save a backup copy of each",
" overwritten file in foo~ or foo~99999 format.",
" -C Use case-insensitive matching.",
" -D Skip restoration of timestamps for extracted directories. On VMS this",
" is on by default and -D essentially becames -DD.",
" -DD Skip restoration of timestamps for all entries.",
" -E [MacOS (not Unix Apple)] Display contents of MacOS extra field during",
" restore.",
" -F [Acorn] Suppress removal of NFS filetype extension. [Non-Acorn if",
" ACORN_FTYPE_NFS] Translate filetype and append to name.",
" -i [MacOS] Ignore filenames in MacOS extra field. Instead, use name in",
" standard header.",
" -j Junk paths and deposit all files in extraction directory.",
" -J [BeOS] Junk file attributes. [MacOS] Ignore MacOS specific info.",
" -K [AtheOS, BeOS, Unix] Restore SUID/SGID/Tacky file attributes.",
" -L Convert to lowercase any names from uppercase only file system.",
" -LL Convert all files to lowercase.",
" -M Pipe all output through internal pager similar to Unix more(1).",
" -n Never overwrite existing files. Skip extracting that file, no prompt.",
" -N [Amiga] Extract file comments as Amiga filenotes.",
" -o Overwrite existing files without prompting. Useful with -f. Use with",
" care.",
" -P p Use password p to decrypt files. THIS IS INSECURE! Some OS show",
" command line to other users.",
" -q Perform operations quietly. The more q (as in -qq) the quieter.",
" -s [OS/2, NT, MS-DOS] Convert spaces in filenames to underscores.",
" -S [VMS] Convert text files (-a, -aa) into Stream_LF format.",
" -U [UNICODE enabled] Show non-local characters as #Uxxxx or #Lxxxxxx ASCII",
" text escapes where x is hex digit. [Old] -U used to leave names",
" uppercase if created on MS-DOS, VMS, etc. See -L.",
" -UU [UNICODE enabled] Disable use of stored UTF-8 paths. Note that UTF-8",
" paths stored as native local paths are still processed as Unicode.",
" -V Retain VMS file version numbers.",
" -W [Only if WILD_STOP_AT_DIR] Modify pattern matching so ? and * do not",
" match directory separator /, but ** does. Allows matching at specific",
" directory levels.",
" -X [VMS, Unix, OS/2, NT, Tandem] Restore UICs and ACL entries under VMS,",
" or UIDs/GIDs under Unix, or ACLs under certain network-enabled",
" versions of OS/2, or security ACLs under Windows NT. Can require",
" user privileges.",
" -XX [NT] Extract NT security ACLs after trying to enable additional",
" system privileges.",
" -Y [VMS] Treat archived name endings of .nnn as VMS version numbers.",
" -$ [MS-DOS, OS/2, NT] Restore volume label if extraction medium is",
" removable. -$$ allows fixed media (hard drives) to be labeled.",
" -/ e [Acorn] Use e as extension list.",
" -: [All but Acorn, VM/CMS, MVS, Tandem] Allow extract archive members into",
" locations outside of current extraction root folder. This allows",
" paths such as ../foo to be extracted above the current extraction",
" directory, which can be a security problem.",
" -^ [Unix] Allow control characters in names of extracted entries. Usually",
" this is not a good thing and should be avoided.",
" -2 [VMS] Force unconditional conversion of names to ODS-compatible names.",
" Default is to exploit destination file system, preserving cases and",
" extended name characters on ODS5 and applying ODS2 filtering on ODS2.",
"",
"",
"Wildcards:",
" Internally unzip supports the following wildcards:",
" ? (or %% or #, depending on OS) matches any single character",
" * matches any number of characters, including zero",
" [list] matches char in list (regex), can do range [ac-f], all but [!bf]",
" If port supports [], must escape [ as [[]",
" For shells that expand wildcards, escape (\\* or \"*\") so unzip can recurse.",
"",
"Include and Exclude:",
" -i pattern pattern ... include files that match a pattern",
" -x pattern pattern ... exclude files that match a pattern",
" Patterns are paths with optional wildcards and match paths as stored in",
" archive. Exclude and include lists end at next option or end of line.",
" unzip archive -x pattern pattern ...",
"",
"Multi-part (split) archives (archives created as a set of split files):",
" Currently split archives are not readable by unzip. A workaround is",
" to use zip to convert the split archive to a single-file archive and",
" use unzip on that. See the manual page for Zip 3.0 or later.",
"",
"Streaming (piping into unzip):",
" Currently unzip does not support streaming. The funzip utility can be",
" used to process the first entry in a stream.",
" cat archive | funzip",
"",
"Testing archives:",
" -t test contents of archive",
" This can be modified using -q for quieter operation, and -qq for even",
" quieter operation.",
"",
"Unicode:",
" If compiled with Unicode support, unzip automatically handles archives",
" with Unicode entries. Currently Unicode on Win32 systems is limited.",
" Characters not in the current character set are shown as ASCII escapes",
" in the form #Uxxxx where the Unicode character number fits in 16 bits,",
" or #Lxxxxxx where it doesn't, where x is the ASCII character for a hex",
" digit.",
"",
"",
"zipinfo options (these are used in zipinfo mode (unzip -Z ...)):",
" -1 List names only, one per line. No headers/trailers. Good for scripts.",
" -2 List names only as -1, but include headers, trailers, and comments.",
" -s List archive entries in short Unix ls -l format. Default list format.",
" -m List in long Unix ls -l format. As -s, but includes compression %.",
" -l List in long Unix ls -l format. As -m, but compression in bytes.",
" -v List zipfile information in verbose, multi-page format.",
" -h List header line. Includes archive name, actual size, total files.",
" -M Pipe all output through internal pager similar to Unix more(1) command.",
" -t List totals for files listed or for all files. Includes uncompressed",
" and compressed sizes, and compression factors.",
" -T Print file dates and times in a sortable decimal format (yymmdd.hhmmss)",
" Default date and time format is a more human-readable version.",
" -U [UNICODE] If entry has a UTF-8 Unicode path, display any characters",
" not in current character set as text #Uxxxx and #Lxxxxxx escapes",
" representing the Unicode character number of the character in hex.",
" -UU [UNICODE] Disable use of any UTF-8 path information.",
" -z Include archive comment if any in listing.",
"",
"",
"funzip stream extractor:",
" funzip extracts the first member in an archive to stdout. Typically",
" used to unzip the first member of a stream or pipe. If a file argument",
" is given, read from that file instead of stdin.",
"",
"funzip command line:",
" funzip [-password] [input[.zip|.gz]]",
"",
"",
"unzipsfx self extractor:",
" Self-extracting archives made with unzipsfx are no more (or less)",
" portable across different operating systems than unzip executables.",
" In general, a self-extracting archive made on a particular Unix system,",
" for example, will only self-extract under the same flavor of Unix.",
" Regular unzip may still be used to extract embedded archive however.",
"",
"unzipsfx command line:",
" <unzipsfx+archive_filename> [-options] [file(s) ... [-x xfile(s) ...]]",
"",
"unzipsfx options:",
" -c, -p - Output to pipe. (See above for unzip.)",
" -f, -u - Freshen and Update, as for unzip.",
" -t - Test embedded archive. (Can be used to list contents.)",
" -z - Print archive comment. (See unzip above.)",
"",
"unzipsfx modifiers:",
" Most unzip modifiers are supported. These include",
" -a - Convert text files.",
" -n - Never overwrite.",
" -o - Overwrite without prompting.",
" -q - Quiet operation.",
" -C - Match names case-insensitively.",
" -j - Junk paths.",
" -V - Keep version numbers.",
" -s - Convert spaces to underscores.",
" -$ - Restore volume label.",
"",
"If unzipsfx compiled with SFX_EXDIR defined, -d option also available:",
" -d exd - Extract to directory exd.",
"By default, all files extracted to current directory. This option",
"forces extraction to specified directory.",
"",
"See unzipsfx manual page for more information.",
""
};
for (i = 0; i < sizeof(text)/sizeof(char *); i++)
{
Info(slide, 0, ((char *)slide, "%s\n", text[i]));
}
} /* end function help_extended() */
#ifndef _WIN32_WCE /* Win CE does not support environment variables */
#if (!defined(MODERN) || defined(NO_STDLIB_H))
/* Declare getenv() to be sure (might be missing in some environments) */
extern char *getenv();
#endif
#endif
/********************************/
/* Function show_version_info() */
/********************************/
static void show_version_info(__G)
__GDEF
{
if (uO.qflag > 3) /* "unzip -vqqqq" */
Info(slide, 0, ((char *)slide, "%d\n",
(UZ_MAJORVER*100 + UZ_MINORVER*10 + UZ_PATCHLEVEL)));
else {
#ifndef _WIN32_WCE /* Win CE does not support environment variables */
char *envptr;
#endif
int numopts = 0;
Info(slide, 0, ((char *)slide, LoadFarString(UnzipUsageLine1v),
UZ_MAJORVER, UZ_MINORVER, UZ_PATCHLEVEL, UZ_BETALEVEL,
LoadFarStringSmall(VersionDate)));
Info(slide, 0, ((char *)slide,
LoadFarString(UnzipUsageLine2v)));
version(__G);
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptions)));
#ifdef ACORN_FTYPE_NFS
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(AcornFtypeNFS)));
++numopts;
#endif
#ifdef ASM_CRC
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(AsmCRC)));
++numopts;
#endif
#ifdef ASM_INFLATECODES
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(AsmInflateCodes)));
++numopts;
#endif
#ifdef CHECK_VERSIONS
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(Check_Versions)));
++numopts;
#endif
#ifdef COPYRIGHT_CLEAN
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(Copyright_Clean)));
++numopts;
#endif
#ifdef DEBUG
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(UDebug)));
++numopts;
#endif
#ifdef DEBUG_TIME
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(DebugTime)));
++numopts;
#endif
#ifdef DLL
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(Dll)));
++numopts;
#endif
#ifdef DOSWILD
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(DosWild)));
++numopts;
#endif
#ifdef LZW_CLEAN
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(LZW_Clean)));
++numopts;
#endif
#ifndef MORE
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(No_More)));
++numopts;
#endif
#ifdef NO_ZIPINFO
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(No_ZipInfo)));
++numopts;
#endif
#ifdef NTSD_EAS
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(NTSDExtAttrib)));
++numopts;
#endif
#if defined(WIN32) && defined(NO_W32TIMES_IZFIX)
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(W32NoIZTimeFix)));
++numopts;
#endif
#ifdef OLD_THEOS_EXTRA
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(OldTheosExtra)));
++numopts;
#endif
#ifdef OS2_EAS
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(OS2ExtAttrib)));
++numopts;
#endif
#ifdef QLZIP
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(SMSExFldOnUnix)));
++numopts;
#endif
#ifdef REENTRANT
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(Reentrant)));
++numopts;
#endif
#ifdef REGARGS
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(RegArgs)));
++numopts;
#endif
#ifdef RETURN_CODES
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(Return_Codes)));
++numopts;
#endif
#ifdef SET_DIR_ATTRIB
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(SetDirAttrib)));
++numopts;
#endif
#ifdef SYMLINKS
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(SymLinkSupport)));
++numopts;
#endif
#ifdef TIMESTAMP
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(TimeStamp)));
++numopts;
#endif
#ifdef UNIXBACKUP
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(UnixBackup)));
++numopts;
#endif
#ifdef USE_EF_UT_TIME
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(Use_EF_UT_time)));
++numopts;
#endif
#ifndef COPYRIGHT_CLEAN
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(Use_Smith_Code)));
++numopts;
#endif
#ifndef LZW_CLEAN
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(Use_Unshrink)));
++numopts;
#endif
#ifdef USE_DEFLATE64
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(Use_Deflate64)));
++numopts;
#endif
#ifdef UNICODE_SUPPORT
# ifdef UTF8_MAYBE_NATIVE
sprintf((char *)(slide+256), LoadFarStringSmall(Use_Unicode),
LoadFarStringSmall2(G.native_is_utf8 ? SysChUTF8 : SysChOther));
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
(char *)(slide+256)));
# else
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(Use_Unicode)));
# endif
++numopts;
#endif
#ifdef _MBCS
sprintf((char *)(slide+256), LoadFarStringSmall(Have_MBCS_Support),
(unsigned int)MB_CUR_MAX);
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
(char *)(slide+256)));
++numopts;
#endif
#ifdef MULT_VOLUME
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(Use_MultiVol)));
++numopts;
#endif
#ifdef LARGE_FILE_SUPPORT
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(Use_LFS)));
++numopts;
#endif
#ifdef ZIP64_SUPPORT
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(Use_Zip64)));
++numopts;
#endif
#if (defined(__DJGPP__) && (__DJGPP__ >= 2))
# ifdef USE_DJGPP_ENV
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(Use_DJGPP_Env)));
++numopts;
# endif
# ifdef USE_DJGPP_GLOB
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(Use_DJGPP_Glob)));
++numopts;
# endif
#endif /* __DJGPP__ && (__DJGPP__ >= 2) */
#ifdef USE_VFAT
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(Use_VFAT_support)));
++numopts;
#endif
#ifdef USE_ZLIB
sprintf((char *)(slide+256), LoadFarStringSmall(UseZlib),
ZLIB_VERSION, zlibVersion());
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
(char *)(slide+256)));
++numopts;
#endif
#ifdef USE_BZIP2
sprintf((char *)(slide+256), LoadFarStringSmall(UseBZip2),
BZ2_bzlibVersion());
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
(char *)(slide+256)));
++numopts;
#endif
#ifdef VMS_TEXT_CONV
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(VmsTextConv)));
++numopts;
#endif
#ifdef VMSCLI
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(VmsCLI)));
++numopts;
#endif
#ifdef VMSWILD
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(VmsWild)));
++numopts;
#endif
#ifdef WILD_STOP_AT_DIR
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(WildStopAtDir)));
++numopts;
#endif
#if CRYPT
# ifdef PASSWD_FROM_STDIN
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
LoadFarStringSmall(PasswdStdin)));
# endif
Info(slide, 0, ((char *)slide, LoadFarString(Decryption),
CR_MAJORVER, CR_MINORVER, CR_BETA_VER,
LoadFarStringSmall(CryptDate)));
++numopts;
#endif /* CRYPT */
if (numopts == 0)
Info(slide, 0, ((char *)slide,
LoadFarString(CompileOptFormat),
LoadFarStringSmall(None)));
#ifndef _WIN32_WCE /* Win CE does not support environment variables */
Info(slide, 0, ((char *)slide, LoadFarString(EnvOptions)));
envptr = getenv(LoadFarStringSmall(EnvUnZip));
Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
LoadFarStringSmall(EnvUnZip),
(envptr == (char *)NULL || *envptr == 0)?
LoadFarStringSmall2(None) : envptr));
envptr = getenv(LoadFarStringSmall(EnvUnZip2));
Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
LoadFarStringSmall(EnvUnZip2),
(envptr == (char *)NULL || *envptr == 0)?
LoadFarStringSmall2(None) : envptr));
envptr = getenv(LoadFarStringSmall(EnvZipInfo));
Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
LoadFarStringSmall(EnvZipInfo),
(envptr == (char *)NULL || *envptr == 0)?
LoadFarStringSmall2(None) : envptr));
envptr = getenv(LoadFarStringSmall(EnvZipInfo2));
Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
LoadFarStringSmall(EnvZipInfo2),
(envptr == (char *)NULL || *envptr == 0)?
LoadFarStringSmall2(None) : envptr));
#ifndef __RSXNT__
#ifdef __EMX__
envptr = getenv(LoadFarStringSmall(EnvEMX));
Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
LoadFarStringSmall(EnvEMX),
(envptr == (char *)NULL || *envptr == 0)?
LoadFarStringSmall2(None) : envptr));
envptr = getenv(LoadFarStringSmall(EnvEMXOPT));
Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
LoadFarStringSmall(EnvEMXOPT),
(envptr == (char *)NULL || *envptr == 0)?
LoadFarStringSmall2(None) : envptr));
#endif /* __EMX__ */
#if (defined(__GO32__) && (!defined(__DJGPP__) || (__DJGPP__ < 2)))
envptr = getenv(LoadFarStringSmall(EnvGO32));
Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
LoadFarStringSmall(EnvGO32),
(envptr == (char *)NULL || *envptr == 0)?
LoadFarStringSmall2(None) : envptr));
envptr = getenv(LoadFarStringSmall(EnvGO32TMP));
Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
LoadFarStringSmall(EnvGO32TMP),
(envptr == (char *)NULL || *envptr == 0)?
LoadFarStringSmall2(None) : envptr));
#endif /* __GO32__ && !(__DJGPP__ >= 2) */
#endif /* !__RSXNT__ */
#ifdef RISCOS
envptr = getenv(LoadFarStringSmall(EnvUnZipExts));
Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
LoadFarStringSmall(EnvUnZipExts),
(envptr == (char *)NULL || *envptr == 0)?
LoadFarStringSmall2(None) : envptr));
#endif /* RISCOS */
#endif /* !_WIN32_WCE */
}
} /* end function show_version() */
#endif /* !SFX */
#endif /* !WINDLL */
|