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

📄 process.c

📁 压缩解压,是unzip540的升级,这个外国网站摘来的源码,是evb编写.
💻 C
📖 第 1 页 / 共 5 页
字号:
        if (error != IZ_DIR && error > error_in_archive)            error_in_archive = error;#ifdef WINDLL        if (error == IZ_CTRLC) {            free_G_buffers(__G);            return error;        }#endif    } /* end while-loop (wildcard zipfiles) */    if ((NumWinFiles + NumWarnFiles + NumLoseFiles) == 0  &&        (NumMissDirs + NumMissFiles) == 1  &&  lastzipfn != (char *)NULL)    {#if (!defined(UNIX) && !defined(AMIGA)) /* filenames with wildcard characters */        if (iswild(G.wildzipfn)) {            if (iswild(lastzipfn)) {                NumMissDirs = NumMissFiles = 0;                error_in_archive = PK_COOL;                Info(slide, 0x401, ((char *)slide,                  LoadFarString(CannotFindWildcardMatch), uO.zipinfo_mode?                  LoadFarStringSmall(Zipnfo) : LoadFarStringSmall(Unzip),                  G.wildzipfn));            }        } else#endif        {            char *p = lastzipfn + strlen(lastzipfn);            G.zipfn = lastzipfn;            strcpy(p, ZSUFX);            NumMissDirs = NumMissFiles = 0;            error_in_archive = PK_COOL;#if defined(UNIX) || defined(QDOS)   /* only Unix has case-sensitive filesystems */   /* Well FlexOS (sometimes) also has them,  but support is per media */   /* and a pig to code for,  so treat as case insensitive for now */   /* we do this under QDOS to check for .zip as well as _zip */            if ((error = do_seekable(__G__ 0)) == PK_NOZIP || error == IZ_DIR) {                if (error == IZ_DIR)                    ++NumMissDirs;                strcpy(p, ALT_ZSUFX);                error = do_seekable(__G__ 1);            }#else            error = do_seekable(__G__ 1);#endif            Trace((stderr, "do_seekable(1) returns %d\n", error));            switch (error) {              case PK_WARN:                ++NumWarnFiles;                break;              case IZ_DIR:                ++NumMissDirs;                error = PK_NOZIP;                break;              case PK_NOZIP:                /* increment again => bug:                   "1 file had no zipfile directory." */                /* ++NumMissFiles */ ;                break;              default:                if (error)                    ++NumLoseFiles;                else                    ++NumWinFiles;                break;            }            if (error > error_in_archive)                error_in_archive = error;#ifdef WINDLL            if (error == IZ_CTRLC) {                free_G_buffers(__G);                return error;            }#endif        }    }#endif /* ?SFX *//*---------------------------------------------------------------------------    Print summary of all zipfiles, assuming zipfile spec was a wildcard (no    need for a summary if just one zipfile).  ---------------------------------------------------------------------------*/#ifndef SFX    if (iswild(G.wildzipfn) && uO.qflag < 3#ifdef TIMESTAMP        && !(uO.T_flag && uO.qflag && !uO.zipinfo_mode)#endif                                                    )    {        if ((NumMissFiles + NumLoseFiles + NumWarnFiles > 0 || NumWinFiles != 1)#ifdef TIMESTAMP            && !(uO.T_flag && !uO.zipinfo_mode)#endif            && !(uO.tflag && uO.qflag > 1))            (*G.message)((zvoid *)&G, (uch *)"\n", 1L, 0x401);        if ((NumWinFiles > 1) || (NumWinFiles == 1 &&            NumMissDirs + NumMissFiles + NumLoseFiles + NumWarnFiles > 0))            Info(slide, 0x401, ((char *)slide, LoadFarString(FilesProcessOK),              NumWinFiles, (NumWinFiles == 1)? " was" : "s were"));        if (NumWarnFiles > 0)            Info(slide, 0x401, ((char *)slide, LoadFarString(ArchiveWarning),              NumWarnFiles, (NumWarnFiles == 1)? "" : "s"));        if (NumLoseFiles > 0)            Info(slide, 0x401, ((char *)slide, LoadFarString(ArchiveFatalError),              NumLoseFiles, (NumLoseFiles == 1)? "" : "s"));        if (NumMissFiles > 0)            Info(slide, 0x401, ((char *)slide,              LoadFarString(FileHadNoZipfileDir), NumMissFiles,              (NumMissFiles == 1)? "" : "s"));        if (NumMissDirs == 1)            Info(slide, 0x401, ((char *)slide, LoadFarString(ZipfileWasDir)));        else if (NumMissDirs > 0)            Info(slide, 0x401, ((char *)slide,              LoadFarString(ManyZipfilesWereDir), NumMissDirs));        if (NumWinFiles + NumLoseFiles + NumWarnFiles == 0)            Info(slide, 0x401, ((char *)slide, LoadFarString(NoZipfileFound)));    }#endif /* !SFX */    /* free allocated memory */    free_G_buffers(__G);    return error_in_archive;} /* end function process_zipfiles() *//*****************************//* Function free_G_buffers() *//*****************************/void free_G_buffers(__G)     /* releases all memory allocated in global vars */    __GDEF{#ifndef SFX    unsigned i;#endif#ifdef SYSTEM_SPECIFIC_DTOR    SYSTEM_SPECIFIC_DTOR(__G);#endif    inflate_free(__G);    checkdir(__G__ (char *)NULL, END);#ifdef DYNALLOC_CRCTAB    if (CRC_32_TAB) {        free_crc_table();        CRC_32_TAB = NULL;    }#endif   if (G.key != (char *)NULL) {        free(G.key);        G.key = (char *)NULL;   }   if (G.extra_field != (uch *)NULL) {        free(G.extra_field);        G.extra_field = (uch *)NULL;   }#if (!defined(VMS) && !defined(SMALL_MEM))    /* VMS uses its own buffer scheme for textmode flush() */    if (G.outbuf2) {        free(G.outbuf2);   /* malloc'd ONLY if unshrink and -a */        G.outbuf2 = (uch *)NULL;    }#endif    if (G.outbuf)        free(G.outbuf);    if (G.inbuf)        free(G.inbuf);    G.inbuf = G.outbuf = (uch *)NULL;#ifndef SFX    for (i = 0; i < DIR_BLKSIZ; i++) {        if (G.info[i].cfilname != (char Far *)NULL) {            zffree(G.info[i].cfilname);            G.info[i].cfilname = (char Far *)NULL;        }    }#endif#ifdef MALLOC_WORK    if (G.area.Slide) {        free(G.area.Slide);        G.area.Slide = (uch *)NULL;    }#endif} /* end function free_G_buffers() *//**************************//* Function do_seekable() *//**************************/static int do_seekable(__G__ lastchance)        /* return PK-type error code */    __GDEF    int lastchance;{#ifndef SFX    /* static int no_ecrec = FALSE;  SKM: moved to globals.h */    int maybe_exe=FALSE;    int too_weird_to_continue=FALSE;#ifdef TIMESTAMP    time_t uxstamp;    ulg nmember = 0L;#endif#endif    int error=0, error_in_archive;/*---------------------------------------------------------------------------    Open the zipfile for reading in BINARY mode to prevent CR/LF translation,    which would corrupt the bit streams.  ---------------------------------------------------------------------------*/    if (SSTAT(G.zipfn, &G.statbuf) ||#ifdef THEOS        (error = S_ISLIB(G.statbuf.st_mode)) != 0 ||#endif        (error = S_ISDIR(G.statbuf.st_mode)) != 0)    {#ifndef SFX        if (lastchance && (uO.qflag < 3)) {#if defined(UNIX) || defined(QDOS)            if (G.no_ecrec)                Info(slide, 1, ((char *)slide,                  LoadFarString(CannotFindZipfileDirMsg), uO.zipinfo_mode?                  LoadFarStringSmall(Zipnfo) : LoadFarStringSmall(Unzip),                  G.wildzipfn, uO.zipinfo_mode? "  " : "", G.wildzipfn,                  G.zipfn));            else                Info(slide, 1, ((char *)slide,                  LoadFarString(CannotFindEitherZipfile), uO.zipinfo_mode?                  LoadFarStringSmall(Zipnfo) : LoadFarStringSmall(Unzip),                  G.wildzipfn, G.wildzipfn, G.zipfn));#else /* !(UNIX || QDOS) */            if (G.no_ecrec)                Info(slide, 0x401, ((char *)slide,                  LoadFarString(CannotFindZipfileDirMsg), uO.zipinfo_mode?                  LoadFarStringSmall(Zipnfo) : LoadFarStringSmall(Unzip),                  G.wildzipfn, uO.zipinfo_mode? "  " : "", G.zipfn));            else                Info(slide, 0x401, ((char *)slide,                  LoadFarString(CannotFindEitherZipfile), uO.zipinfo_mode?                  LoadFarStringSmall(Zipnfo) : LoadFarStringSmall(Unzip),                  G.wildzipfn, G.zipfn));#endif /* ?(UNIX || QDOS) */        }#endif /* !SFX */        return error? IZ_DIR : PK_NOZIP;    }    G.ziplen = G.statbuf.st_size;#ifndef SFX#if defined(UNIX) || defined(DOS_OS2_W32) || defined(THEOS)    if (G.statbuf.st_mode & S_IEXEC)   /* no extension on Unix exes:  might */        maybe_exe = TRUE;               /*  find unzip, not unzip.zip; etc. */#endif#endif /* !SFX */#ifdef VMS    if (check_format(__G))              /* check for variable-length format */        return PK_ERR;#endif    if (open_input_file(__G))   /* this should never happen, given */        return PK_NOZIP;        /*  the stat() test above, but... *//*---------------------------------------------------------------------------    Find and process the end-of-central-directory header.  UnZip need only    check last 65557 bytes of zipfile:  comment may be up to 65535, end-of-    central-directory record is 18 bytes, and signature itself is 4 bytes;    add some to allow for appended garbage.  Since ZipInfo is often used as    a debugging tool, search the whole zipfile if zipinfo_mode is true.  ---------------------------------------------------------------------------*/    /* initialize the CRC table pointer (once) */    if (CRC_32_TAB == NULL) {        if ((CRC_32_TAB = get_crc_table()) == NULL) {            CLOSE_INFILE();            return PK_MEM;        }    }#if (!defined(SFX) || defined(SFX_EXDIR))    /* check out if specified extraction root directory exists */    if (uO.exdir != (char *)NULL && G.extract_flag) {        G.create_dirs = !uO.fflag;        if ((error = checkdir(__G__ uO.exdir, ROOT)) > MPN_INF_SKIP) {            /* out of memory, or file in way */            CLOSE_INFILE();            return (error == MPN_NOMEM ? PK_MEM : PK_ERR);        }    }#endif /* !SFX || SFX_EXDIR */    G.cur_zipfile_bufstart = 0;    G.inptr = G.inbuf;#if (!defined(WINDLL) && !defined(SFX))#ifdef TIMESTAMP    if (!uO.zipinfo_mode && !uO.qflag && !uO.T_flag)#else    if (!uO.zipinfo_mode && !uO.qflag)#endif#ifdef WIN32    /* Win32 console may require codepage conversion for G.zipfn */        Info(slide, 0, ((char *)slide, "Archive:  %s\n", FnFilter1(G.zipfn)));#else        Info(slide, 0, ((char *)slide, "Archive:  %s\n", G.zipfn));#endif#endif /* !WINDLL && !SFX */    if ((#ifndef NO_ZIPINFO         uO.zipinfo_mode &&          ((error_in_archive = find_ecrec(__G__ G.ziplen)) != 0 ||          (error_in_archive = zi_end_central(__G)) > PK_WARN))        || (!uO.zipinfo_mode &&#endif

⌨️ 快捷键说明

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