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

📄 extract.c

📁 压缩解压,是unzip540的升级,这个外国网站摘来的源码,是evb编写.
💻 C
📖 第 1 页 / 共 5 页
字号:
                        do {                            Info(slide, 0x81, ((char *)slide,                              LoadFarString(NewNameQuery)));                            fgets(G.filename, FILNAMSIZ, stdin);                            /* usually get \n here:  better check for it */                            fnlen = strlen(G.filename);                            if (lastchar(G.filename, fnlen) == '\n')                                G.filename[--fnlen] = '\0';                        } while (fnlen == 0);#ifdef WIN32  /* WIN32 fgets( ... , stdin) returns OEM coded strings */                        _OEM_INTERN(G.filename);#endif                        renamed = TRUE;                        goto startover;   /* sorry for a goto */                    case 'A':   /* dangerous option:  force caps */                        G.overwrite_mode = OVERWRT_ALWAYS;                        /* FALL THROUGH, extract */                    case 'y':                    case 'Y':                        break;                    case 'N':                        G.overwrite_mode = OVERWRT_NEVER;                        /* FALL THROUGH, skip */                    case 'n':                        /* skip file */                        skip_entry = SKIP_Y_EXISTING;                        break;                    default:                        Info(slide, 1, ((char *)slide,                          LoadFarString(InvalidResponse), *G.answerbuf));                        goto reprompt;   /* yet another goto? */                } /* end switch (*answerbuf) */#endif /* ?WINDLL */            } /* end if (query) */            if (skip_entry != SKIP_NO) {#ifdef WINDLL                if (skip_entry == SKIP_Y_EXISTING) {                    /* report skipping of an existing entry */                    Info(slide, 0, ((char *)slide,                      ((IS_OVERWRT_NONE || !uO.uflag || renamed) ?                       "Target file exists.\nSkipping %s\n" :                       "Target file newer.\nSkipping %s\n"),                      FnFilter1(G.filename)));                }#endif /* WINDLL */                continue;            }        } /* end if (extracting to disk) */#ifdef DLL        if ((G.statreportcb != NULL) &&            (*G.statreportcb)(__G__ UZ_ST_START_EXTRACT, G.zipfn,                              G.filename, NULL)) {            return IZ_CTRLC;        /* cancel operation by user request */        }#endif#ifdef MACOS  /* MacOS is no preemptive OS, thus call event-handling by hand */        UserStop();#endif#ifdef AMIGA        G.filenote_slot = i;#endif        G.disk_full = 0;        if ((error = extract_or_test_member(__G)) != PK_COOL) {            if (error > error_in_archive)                error_in_archive = error;       /* ...and keep going */#ifdef DLL            if (G.disk_full > 1 || error_in_archive == IZ_CTRLC) {#else            if (G.disk_full > 1) {#endif                return error_in_archive;        /* (unless disk full) */            }        }#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 == ATHEOS_ || 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, ((

⌨️ 快捷键说明

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