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

📄 zipinfo.c

📁 压缩解压,是unzip540的升级,这个外国网站摘来的源码,是evb编写.
💻 C
📖 第 1 页 / 共 5 页
字号:
/*******************************/int zi_end_central(__G)   /* return PK-type error code */    __GDEF{    int  error = PK_COOL;/*---------------------------------------------------------------------------    Print out various interesting things about the zipfile.  ---------------------------------------------------------------------------*/    /* header fits on one line, for anything up to 10GB and 10000 files: */    if (uO.hflag)        Info(slide, 0, ((char *)slide, ((int)strlen(G.zipfn) < 39)?          LoadFarString(LongHeader) : LoadFarString(ShortHeader), G.zipfn,          (long)G.ziplen, G.ecrec.total_entries_central_dir,          (G.ecrec.total_entries_central_dir==1)?          nullStr : PlurSufx));    /* verbose format */    if (uO.lflag > 9) {        Info(slide, 0, ((char *)slide, LoadFarString(EndCentDirRec)));        Info(slide, 0, ((char *)slide, LoadFarString(LineSeparators)));        Info(slide, 0, ((char *)slide, LoadFarString(ActOffsetCentDir),          (long)G.real_ecrec_offset, (long)G.real_ecrec_offset,          (long)G.expect_ecrec_offset, (long)G.expect_ecrec_offset));        if (G.ecrec.number_this_disk == 0) {            Info(slide, 0, ((char *)slide, LoadFarString(SinglePartArchive1),              G.ecrec.total_entries_central_dir,              (G.ecrec.total_entries_central_dir == 1)? "entry" : "entries",              G.ecrec.size_central_directory,              G.ecrec.size_central_directory));            Info(slide, 0, ((char *)slide, LoadFarString(SinglePartArchive2),              G.ecrec.offset_start_central_directory,              G.ecrec.offset_start_central_directory));        } else {            Info(slide, 0, ((char *)slide, LoadFarString(MultiPartArchive1),              G.ecrec.number_this_disk + 1,              G.ecrec.num_disk_start_cdir + 1,              G.ecrec.num_entries_centrl_dir_ths_disk,              (G.ecrec.num_entries_centrl_dir_ths_disk == 1)? "is" : "are"));            Info(slide, 0, ((char *)slide, LoadFarString(MultiPartArchive2),              G.ecrec.total_entries_central_dir,              (G.ecrec.total_entries_central_dir == 1) ? "entry" : "entries",              G.ecrec.size_central_directory,              G.ecrec.size_central_directory));            Info(slide, 0, ((char *)slide, LoadFarString(MultiPartArchive3),              G.ecrec.offset_start_central_directory,              G.ecrec.offset_start_central_directory));        }    /*-----------------------------------------------------------------------        Get the zipfile comment, if any, and print it out.  (Comment may be        up to 64KB long.  May the fleas of a thousand camels infest the arm-        pits of anyone who actually takes advantage of this fact.)      -----------------------------------------------------------------------*/        if (!G.ecrec.zipfile_comment_length)            Info(slide, 0, ((char *)slide, LoadFarString(NoZipfileComment)));        else {            Info(slide, 0, ((char *)slide, LoadFarString(ZipfileCommentDesc),              G.ecrec.zipfile_comment_length));            Info(slide, 0, ((char *)slide, LoadFarString(ZipfileCommBegin)));            if (do_string(__G__ G.ecrec.zipfile_comment_length, DISPLAY))                error = PK_WARN;            Info(slide, 0, ((char *)slide, LoadFarString(ZipfileCommEnd)));            if (error)                Info(slide, 0, ((char *)slide,                  LoadFarString(ZipfileCommTrunc2)));        } /* endif (comment exists) */    /* non-verbose mode:  print zipfile comment only if requested */    } else if (uO.zflag && G.ecrec.zipfile_comment_length) {        if (do_string(__G__ G.ecrec.zipfile_comment_length, DISPLAY)) {            Info(slide, 0x401, ((char *)slide,              LoadFarString(ZipfileCommTruncMsg)));            error = PK_WARN;        }    } /* endif (verbose) */    return error;} /* end function zi_end_central() *//************************//*  Function zipinfo()  *//************************/int zipinfo(__G)   /* return PK-type error code */    __GDEF{    int do_this_file=FALSE, error, error_in_archive=PK_COOL;    int *fn_matched=NULL, *xn_matched=NULL;    ulg j, members=0L;    ulg tot_csize=0L, tot_ucsize=0L;    ulg endprev;   /* buffers end of previous entry for zi_long()'s check                    *  of extra bytes *//*---------------------------------------------------------------------------    Malloc space for check on unmatched filespecs (no big deal if one or both    are NULL).  ---------------------------------------------------------------------------*/    if (G.filespecs > 0  &&        (fn_matched=(int *)malloc(G.filespecs*sizeof(int))) != NULL)        for (j = 0;  j < G.filespecs;  ++j)            fn_matched[j] = FALSE;    if (G.xfilespecs > 0  &&        (xn_matched=(int *)malloc(G.xfilespecs*sizeof(int))) != NULL)        for (j = 0;  j < G.xfilespecs;  ++j)            xn_matched[j] = FALSE;/*---------------------------------------------------------------------------    Set file pointer to start of central directory, then loop through cen-    tral directory entries.  Check that directory-entry signature bytes are    actually there (just a precaution), then process the entry.  We know    the entire central directory is on this disk:  we wouldn't have any of    this information unless the end-of-central-directory record was on this    disk, and we wouldn't have gotten to this routine unless this is also    the disk on which the central directory starts.  In practice, this had    better be the *only* disk in the archive, but maybe someday we'll add    multi-disk support.  ---------------------------------------------------------------------------*/    uO.L_flag = FALSE;      /* zipinfo mode: never convert name to lowercase */    G.pInfo = G.info;       /* (re-)initialize, (just to make sure) */    G.pInfo->textmode = 0;  /* so one can read on screen (is this ever used?) */    /* reset endprev for new zipfile; account for multi-part archives (?) */    endprev = (G.crec.relative_offset_local_header == 4L)? 4L : 0L;    for (j = 1L;; j++) {        if (readbuf(__G__ G.sig, 4) == 0)            return PK_EOF;        if (strncmp(G.sig, central_hdr_sig, 4)) {  /* is it a CentDir entry? */            if (((unsigned)(j - 1) & (unsigned)0xFFFF) ==                (unsigned)G.ecrec.total_entries_central_dir) {                /* "j modulus 64k" matches the reported 16-bit-unsigned                 * number of directory entries -> probably, the regular                 * end of the central directory has been reached                 */                break;            } else {                Info(slide, 0x401,                     ((char *)slide, LoadFarString(CentSigMsg), j));                Info(slide, 0x401,                     ((char *)slide, LoadFarString(ReportMsg)));                return PK_BADERR;   /* sig not found */            }        }        /* process_cdir_file_hdr() sets pInfo->hostnum, pInfo->lcflag, ...: */        if ((error = process_cdir_file_hdr(__G)) != PK_COOL)            return error;       /* only PK_EOF defined */        if ((error = do_string(__G__ G.crec.filename_length, DS_FN)) !=             PK_COOL)        {          error_in_archive = error;   /* might be warning */          if (error > PK_WARN)        /* fatal */              return error;        }        if (!G.process_all_files) {   /* check if specified on command line */            unsigned i;            if (G.filespecs == 0)                do_this_file = TRUE;            else {  /* check if this entry matches an `include' argument */                do_this_file = FALSE;                for (i = 0; i < G.filespecs; i++)                    if (match(G.filename, G.pfnames[i], uO.C_flag WISEP)) {                        do_this_file = TRUE;                        if (fn_matched)                            fn_matched[i] = TRUE;                        break;       /* found match, so stop looping */                    }            }            if (do_this_file) {  /* check if this is an excluded file */                for (i = 0; i < G.xfilespecs; i++)                    if (match(G.filename, G.pxnames[i], uO.C_flag WISEP)) {                        do_this_file = FALSE;  /* ^-- ignore case in match */                        if (xn_matched)                            xn_matched[i] = TRUE;                        break;                    }            }        }    /*-----------------------------------------------------------------------        If current file was specified on command line, or if no names were        specified, do the listing for this file.  Otherwise, get rid of the        file comment and go back for the next file.      -----------------------------------------------------------------------*/        if (G.process_all_files || do_this_file) {            switch (uO.lflag) {                case 1:                case 2:                    fnprint(__G);                    SKIP_(G.crec.extra_field_length)                    SKIP_(G.crec.file_comment_length)                    break;                case 3:                case 4:                case 5:                    if ((error = zi_short(__G)) != PK_COOL) {                        error_in_archive = error;   /* might be warning */                        if (error > PK_WARN)        /* fatal */                            return error;                    }                    break;                case 10:                    Info(slide, 0, ((char *)slide,                      LoadFarString(CentralDirEntry), j));                    if ((error = zi_long(__G__ &endprev)) != PK_COOL) {                        error_in_archive = error;   /* might be warning */                        if (error > PK_WARN)        /* fatal */                            return error;                    }                    break;                default:                    SKIP_(G.crec.extra_field_length)                    SKIP_(G.crec.file_comment_length)                    break;            } /* end switch (lflag) */            tot_csize += G.crec.csize;            tot_ucsize += G.crec.ucsize;            if (G.crec.general_purpose_bit_flag & 1)                tot_csize -= 12;   /* don't count encryption header */            ++members;#ifdef DLL            if ((G.statreportcb != NULL) &&                (*G.statreportcb)(__G__ UZ_ST_FINISH_MEMBER, G.zipfn,                                  G.filename, (zvoid *)&G.crec.ucsize)) {                if (fn_matched)                    free((zvoid *)fn_matched);                if (xn_matched)                    free((zvoid *)xn_matched);                return IZ_CTRLC;        /* cancel operation by user request */            }#endif#ifdef MACOS  /* MacOS is no preemptive OS, thus call event-handling by hand */            UserStop();#endif        } else {        /* not listing this file */            SKIP_(G.crec.extra_field_length)            SKIP_(G.crec.file_comment_length)        } /* end if (list member?) */    } /* end for-loop (j: member files) *//*---------------------------------------------------------------------------    Check that we actually found requested files; if so, print totals.  ---------------------------------------------------------------------------*/    if (uO.tflag) {        char *sgn = "";        int cfactor = ratio(tot_ucsize, tot_csize);        if (cfactor < 0) {            sgn = "-";            cfactor = -cfactor;        }        Info(slide, 0, ((char *)slide, LoadFarString(ZipfileStats),          members, (members==1L)? nullStr:PlurSufx, tot_ucsize,          tot_csize, sgn, cfactor/10, cfactor%10));    }/*---------------------------------------------------------------------------    Check for unmatched filespecs on command line and print warning if any    found.  ---------------------------------------------------------------------------*/    if (fn_matched) {        for (j = 0;  j < G.filespecs;  ++j)            if (!fn_matched[j])                Info(slide, 0x401, ((char *)slide,                  LoadFarString(FilenameNotMatched), G.pfnames[j]));        free((zvoid *)fn_matched);    }    if (xn_matched) {        for (j = 0;  j < G.xfilespecs;  ++j)            if (!xn_matched[j])                Info(slide, 0x401, ((char *)slide,                  LoadFarString(ExclFilenameNotMatched), G.pxnames[j]));        free((zvoid *)xn_matched);    }/*---------------------------------------------------------------------------

⌨️ 快捷键说明

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