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

📄 extract.c

📁 zip压缩
💻 C
📖 第 1 页 / 共 5 页
字号:
            }        }#ifdef DLL        if ((G.statreportcb != NULL) &&            (*G.statreportcb)(__G__ UZ_ST_FINISH_MEMBER, G.zipfn,                              G.filename, (zvoid *)&G.lrec.ucsize)) {            return IZ_CTRLC;        /* cancel operation by user request */        }#endif#ifdef MACOS  /* MacOS is no preemptive OS, thus call event-handling by hand */        UserStop();#endif    } /* end for-loop (i:  files in current block) */    return error_in_archive;} /* end function extract_or_test_entrylist() *//***************************************//*  Function extract_or_test_member()  *//***************************************/static int extract_or_test_member(__G)    /* return PK-type error code */     __GDEF{    char *nul="[empty] ", *txt="[text]  ", *bin="[binary]";#ifdef CMS_MVS    char *ebc="[ebcdic]";#endif    register int b;    int r, error=PK_COOL;#if (defined(DLL) && !defined(NO_SLIDE_REDIR))    ulg wsize;#else#   define wsize WSIZE#endif/*---------------------------------------------------------------------------    Initialize variables, buffers, etc.  ---------------------------------------------------------------------------*/    G.bits_left = 0;    G.bitbuf = 0L;       /* unreduce and unshrink only */    G.zipeof = 0;    G.newfile = TRUE;    G.crc32val = CRCVAL_INITIAL;#ifdef SYMLINKS    /* if file came from Unix and is a symbolic link and we are extracting     * to disk, prepare to restore the link */    if (S_ISLNK(G.pInfo->file_attr) &&        (G.pInfo->hostnum == UNIX_ || G.pInfo->hostnum == ATARI_ ||         G.pInfo->hostnum == BEOS_) &&        !uO.tflag && !uO.cflag && (G.lrec.ucsize > 0))        G.symlnk = TRUE;    else        G.symlnk = FALSE;#endif /* SYMLINKS */    if (uO.tflag) {        if (!uO.qflag)            Info(slide, 0, ((char *)slide, LoadFarString(ExtractMsg), "test",              FnFilter1(G.filename), "", ""));    } else {#ifdef DLL        if (uO.cflag && !G.redirect_data)#else        if (uO.cflag)#endif        {#if (defined(OS2) && defined(__IBMC__) && (__IBMC__ >= 200))            G.outfile = freopen("", "wb", stdout);   /* VAC++ ignores setmode */#else            G.outfile = stdout;#endif#ifdef DOS_FLX_NLM_OS2_W32#if (defined(__HIGHC__) && !defined(FLEXOS))            setmode(G.outfile, _BINARY);#else /* !(defined(__HIGHC__) && !defined(FLEXOS)) */            setmode(fileno(G.outfile), O_BINARY);#endif /* ?(defined(__HIGHC__) && !defined(FLEXOS)) */#           define NEWLINE "\r\n"#else /* !DOS_FLX_NLM_OS2_W32 */#           define NEWLINE "\n"#endif /* ?DOS_FLX_NLM_OS2_W32 */#ifdef VMS            if (open_outfile(__G))   /* VMS:  required even for stdout! */                return PK_DISK;#endif        } else if (open_outfile(__G))            return PK_DISK;    }/*---------------------------------------------------------------------------    Unpack the file.  ---------------------------------------------------------------------------*/    defer_leftover_input(__G);    /* so NEXTBYTE bounds check will work */    switch (G.lrec.compression_method) {        case STORED:            if (!uO.tflag && QCOND2) {#ifdef SYMLINKS                if (G.symlnk)   /* can also be deflated, but rarer... */                    Info(slide, 0, ((char *)slide, LoadFarString(ExtractMsg),                      "link", FnFilter1(G.filename), "", ""));                else#endif /* SYMLINKS */                Info(slide, 0, ((char *)slide, LoadFarString(ExtractMsg),                  "extract", FnFilter1(G.filename),                  (uO.aflag != 1 /* && G.pInfo->textfile==G.pInfo->textmode */)?                  "" : (G.lrec.ucsize == 0L? nul : (G.pInfo->textfile? txt :                  bin)), uO.cflag? NEWLINE : ""));            }#if (defined(DLL) && !defined(NO_SLIDE_REDIR))            if (G.redirect_slide) {                wsize = G.redirect_size; redirSlide = G.redirect_buffer;            } else {                wsize = WSIZE; redirSlide = slide;            }#endif            G.outptr = redirSlide;            G.outcnt = 0L;            while ((b = NEXTBYTE) != EOF) {                *G.outptr++ = (uch)b;                if (++G.outcnt == wsize) {                    error = flush(__G__ redirSlide, G.outcnt, 0);                    G.outptr = redirSlide;                    G.outcnt = 0L;                    if (error != PK_COOL || G.disk_full) break;                }            }            if (G.outcnt)          /* flush final (partial) buffer */                flush(__G__ redirSlide, G.outcnt, 0);            break;#ifndef SFX#ifndef LZW_CLEAN        case SHRUNK:            if (!uO.tflag && QCOND2) {                Info(slide, 0, ((char *)slide, LoadFarString(ExtractMsg),                  LoadFarStringSmall(Unshrink), FnFilter1(G.filename),                  (uO.aflag != 1 /* && G.pInfo->textfile==G.pInfo->textmode */)?                  "" : (G.pInfo->textfile? txt : bin), uO.cflag? NEWLINE : ""));            }            if ((r = unshrink(__G)) != PK_COOL) {                if (r < PK_DISK) {                    if ((uO.tflag && uO.qflag) || (!uO.tflag && !QCOND2))                        Info(slide, 0x401, ((char *)slide,                          LoadFarStringSmall(ErrUnzipFile),                          LoadFarString(NotEnoughMem),                          LoadFarStringSmall2(Unshrink),                          FnFilter1(G.filename)));                    else                        Info(slide, 0x401, ((char *)slide,                          LoadFarStringSmall(ErrUnzipNoFile),                          LoadFarString(NotEnoughMem),                          LoadFarStringSmall2(Unshrink)));                }                error = r;            }            break;#endif /* !LZW_CLEAN */#ifndef COPYRIGHT_CLEAN        case REDUCED1:        case REDUCED2:        case REDUCED3:        case REDUCED4:            if (!uO.tflag && QCOND2) {                Info(slide, 0, ((char *)slide, LoadFarString(ExtractMsg),                  "unreduc", FnFilter1(G.filename),                  (uO.aflag != 1 /* && G.pInfo->textfile==G.pInfo->textmode */)?                  "" : (G.pInfo->textfile? txt : bin), uO.cflag? NEWLINE : ""));            }            if ((r = unreduce(__G)) != PK_COOL) {                /* unreduce() returns only PK_COOL, PK_DISK, or IZ_CTRLC */                error = r;            }            break;#endif /* !COPYRIGHT_CLEAN */        case IMPLODED:            if (!uO.tflag && QCOND2) {                Info(slide, 0, ((char *)slide, LoadFarString(ExtractMsg),                  "explod", FnFilter1(G.filename),                  (uO.aflag != 1 /* && G.pInfo->textfile==G.pInfo->textmode */)?                  "" : (G.pInfo->textfile? txt : bin), uO.cflag? NEWLINE : ""));            }            if (((r = explode(__G)) != 0) && (r != 5)) { /* treat 5 specially */                if (r < PK_DISK) {                    if ((uO.tflag && uO.qflag) || (!uO.tflag && !QCOND2))                        Info(slide, 0x401, ((char *)slide,                          LoadFarStringSmall(ErrUnzipFile), r == 3?                          LoadFarString(NotEnoughMem) :                          LoadFarString(InvalidComprData),                          LoadFarStringSmall2(Explode),                          FnFilter1(G.filename)));                    else                        Info(slide, 0x401, ((char *)slide,                          LoadFarStringSmall(ErrUnzipNoFile), r == 3?                          LoadFarString(NotEnoughMem) :                          LoadFarString(InvalidComprData),                          LoadFarStringSmall2(Explode)));                    error = (r == 3)? PK_MEM3 : PK_ERR;                } else {                    error = r;                }            }            if (r == 5) {                int warning = ((ulg)G.used_csize <= G.lrec.csize);                if ((uO.tflag && uO.qflag) || (!uO.tflag && !QCOND2))                    Info(slide, 0x401, ((char *)slide, LoadFarString(LengthMsg),                      "", warning?  "warning" : "error", G.used_csize,                      G.lrec.ucsize, warning?  "  " : "", G.lrec.csize,                      " [", FnFilter1(G.filename), "]"));                else                    Info(slide, 0x401, ((char *)slide, LoadFarString(LengthMsg),                      "\n", warning? "warning" : "error", G.used_csize,                      G.lrec.ucsize, warning? "  ":"", G.lrec.csize,                      "", "", "."));                error = warning? PK_WARN : PK_ERR;            }            break;#endif /* !SFX */        case DEFLATED:#ifdef USE_DEFLATE64        case ENHDEFLATED:#endif            if (!uO.tflag && QCOND2) {                Info(slide, 0, ((char *)slide, LoadFarString(ExtractMsg),                  "inflat", FnFilter1(G.filename),                  (uO.aflag != 1 /* && G.pInfo->textfile==G.pInfo->textmode */)?                  "" : (G.pInfo->textfile? txt : bin), uO.cflag? NEWLINE : ""));            }#ifndef USE_ZLIB  /* zlib's function is called inflate(), too */#  define UZinflate inflate#endif            if ((r = UZinflate(__G__                               (G.lrec.compression_method == ENHDEFLATED)))                != 0) {                if (r < PK_DISK) {                    if ((uO.tflag && uO.qflag) || (!uO.tflag && !QCOND2))                        Info(slide, 0x401, ((char *)slide,                          LoadFarStringSmall(ErrUnzipFile), r == 3?                          LoadFarString(NotEnoughMem) :                          LoadFarString(InvalidComprData),                          LoadFarStringSmall2(Inflate),                          FnFilter1(G.filename)));                    else                        Info(slide, 0x401, ((char *)slide,                          LoadFarStringSmall(ErrUnzipNoFile), r == 3?                          LoadFarString(NotEnoughMem) :                          LoadFarString(InvalidComprData),                          LoadFarStringSmall2(Inflate)));                    error = (r == 3)? PK_MEM3 : PK_ERR;                } else {                    error = r;                }            }            break;        default:   /* should never get to this point */            Info(slide, 0x401, ((char *)slide,              LoadFarString(FileUnknownCompMethod), FnFilter1(G.filename)));            /* close and delete file before return? */            undefer_input(__G);            return PK_WARN;    } /* end switch (compression method) *//*---------------------------------------------------------------------------    Close the file and set its date and time (not necessarily in that order),    and make sure the CRC checked out OK.  Logical-AND the CRC for 64-bit    machines (redundant on 32-bit machines).  ---------------------------------------------------------------------------*/#ifdef VMS                  /* VMS:  required even for stdout! (final flush) */    if (!uO.tflag)           /* don't close NULL file */        close_outfile(__G);#else#ifdef DLL    if (!uO.tflag && (!uO.cflag || G.redirect_data)) {        if (G.redirect_data)            FINISH_REDIRECT();        else            close_outfile(__G);    }#else    if (!uO.tflag && !uO.cflag)   /* don't close NULL file or stdout */        close_outfile(__G);#endif#endif /* VMS */            /* GRR: CONVERT close_outfile() TO NON-VOID:  CHECK FOR ERRORS! */    if (G.disk_full) {            /* set by flush() */        if (G.disk_full > 1) {#if (defined(DELETE_IF_FULL) && defined(HAVE_UNLINK))            /* delete the incomplete file if we can */            if (unlink(G.filename) != 0)                Trace((stderr, "extract.c:  could not delete %s\n",                  FnFilter1(G.filename)));#else            /* warn user about the incomplete file */            Info(slide, 0x421, ((char *)slide, LoadFarString(FileTruncated),              FnFilter1(G.filename)));#endif            error = PK_DISK;        } else {            error = PK_WARN;        }    }    if (error > PK_WARN) {/* don't print redundant CRC error if error already */        undefer_input(__G);        return error;    }    if (G.crc32val != G.lrec.crc32) {        /* if quiet enough, we haven't output the filename yet:  do it */        if ((uO.tflag && uO.qflag) || (!uO.tflag && !QCOND2))            Info(slide, 0x401, ((char *)slide, "%-22s ",              FnFilter1(G.filename)));        Info(slide, 0x401, ((char *)slide, LoadFarString(BadCRC), G.crc32v

⌨️ 快捷键说明

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