?? unzip.c
字號(hào):
/* Copyright (c) 1990-2002 Info-ZIP. All rights reserved. See the accompanying file LICENSE, version 2000-Apr-09 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, send a *complete* description to Zip-Bugs@lists.wku.edu; include machine type, operating system and ver- sion, compiler and version, and reasonably detailed error messages or prob- lem 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. --------------------------------------------------------------------------- [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, 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 *//***************************/#ifdef REENTRANTtypedef struct _sign_info { struct _sign_info *previous; void (*sighandler)(int); int sigtype; } savsigs_info;#endif/*******************//* Local Functions *//*******************/#ifdef REENTRANTstatic int setsignalhandler OF((__GPRO__ savsigs_info **p_savedhandler_chain, int signal_type, void (*newhandler)(int)));#endif#ifndef SFXstatic 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 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 NoMemArguments[] = "envargs: cannot get memory for arguments";#endif#ifdef REENTRANT 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 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";#endifstatic 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\" => must quote uppercase options and filenames in VMS\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(DLL) && defined(API_DOC)) static ZCONST char Far local1[] = " -A print extended help for API functions";#else /* !(DLL && API_DOC) */ static ZCONST char Far local1[] = "";#endif /* ?(DLL && API_DOC) *//* 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/protection info";#ifdef MORE static ZCONST char Far local3[] = " \ \"-M\" pipe through \"more\" pager\n";#else static ZCONST char Far local3[] = "\n";#endif#else /* !VMS */#ifdef BEO_UNX static ZCONST char Far local2[] = " -X restore UID/GID info";#ifdef MORE static ZCONST char Far local3[] = "\ -M pipe through \"more\" pager\n";#else static ZCONST char Far local3[] = "\n";#endif#else /* !BEO_UNX */#ifdef TANDEM static ZCONST char Far local2[] = " -X restore Tandem User ID";#ifdef MORE static ZCONST char Far local3[] = "\ -b create 'C' (180) text files -M pipe through \"more\" pager\n";#else static ZCONST char Far local3[] = " -b create 'C' (180) text files\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 /* ?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\")";#endifstatic 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 %c-T%c print file times in sortable decimal format\\n %c-C%c be case-insensitive %s\ -x exclude filenames that follow from listing\n";#ifdef MORE#ifdef VMS static ZCONST char Far ZipInfoUsageLine4[] = " \"-M\" page output through built-in \"more\"\n";#else static ZCONST char Far ZipInfoUsageLine4[] = " -M page output through built-in \"more\"\n";#endif#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 (Zip-Bugs@lists.wku.edu).\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[] = "\t%s\n"; static ZCONST char Far EnvOptions[] = "\nUnZip and ZipInfo environment options:\n"; static ZCONST char Far EnvOptFormat[] = "%16s: %s\n"; 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
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -