⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unzip.c

📁 压缩解压,是unzip540的升级,这个外国网站摘来的源码,是evb编写.
💻 C
📖 第 1 页 / 共 5 页
字号:
/*  Copyright (c) 1990-2005 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, 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.  ---------------------------------------------------------------------------  [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 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#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 NoMemArguments[] =    "envargs:  cannot get memory for arguments";#endif /* !_WIN32_WCE */#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 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\"\ (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(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 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\")";#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 (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[] = "\t%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:  %s\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[] =

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -