📄 zipinfo.c
字号:
#endif /* CMS_MVS */static ZCONST char Far First20[] = ". The first\n 20 are: ";static ZCONST char Far ColonIndent[] = ":\n ";static ZCONST char Far efFormat[] = " %02x";static ZCONST char Far lExtraFieldType[] = "\n\ There %s a local extra field with ID 0x%04x (%s) and\n\ %u data bytes (%s).\n";static ZCONST char Far efIZuid[] = "GMT modification/access times and Unix UID/GID";static ZCONST char Far efIZnouid[] = "GMT modification/access times only";static ZCONST char Far NoFileComment[] = "\n There is no file comment.\n";static ZCONST char Far FileCommBegin[] = "\n\------------------------- file comment begins ----------------------------\n";static ZCONST char Far FileCommEnd[] = "\-------------------------- file comment ends -----------------------------\n";/* zi_time() strings */static ZCONST char Far BogusFmt[] = "%03d";static ZCONST char Far DMYHMTime[] = "%2u-%s-%02u %02u:%02u";static ZCONST char Far YMDHMSTime[] = "%u %s %u %02u:%02u:%02u";static ZCONST char Far DecimalTime[] = "%04u%02u%02u.%02u%02u%02u";static ZCONST char Far YMDHMSTimeError[] = "???? ??? ?? ??:??:??";#ifndef WINDLL/************************//* Function zi_opts() *//************************/int zi_opts(__G__ pargc, pargv) int *pargc; char ***pargv; __GDEF{ char **argv, *s; int argc, c, error=FALSE, negative=0; int hflag_slmv=TRUE, hflag_2=FALSE; /* diff options => diff defaults */ int tflag_slm=TRUE, tflag_2v=FALSE; int explicit_h=FALSE, explicit_t=FALSE;#ifdef MACOS uO.lflag = LFLAG; /* reset default on each call */#endif G.extract_flag = FALSE; /* zipinfo does not extract to disk */ argc = *pargc; argv = *pargv; while (--argc > 0 && (*++argv)[0] == '-') { s = argv[0] + 1; while ((c = *s++) != 0) { /* "!= 0": prevent Turbo C warning */ switch (c) { case '-': ++negative; break; case '1': /* shortest listing: JUST filenames */ if (negative) uO.lflag = -2, negative = 0; else uO.lflag = 1; break; case '2': /* just filenames, plus headers if specified */ if (negative) uO.lflag = -2, negative = 0; else uO.lflag = 2; break;#ifndef CMS_MVS case ('C'): /* -C: match filenames case-insensitively */ if (negative) uO.C_flag = FALSE, negative = 0; else uO.C_flag = TRUE; break;#endif /* !CMS_MVS */ case 'h': /* header line */ if (negative) hflag_2 = hflag_slmv = FALSE, negative = 0; else { hflag_2 = hflag_slmv = explicit_h = TRUE; if (uO.lflag == -1) uO.lflag = 0; } break; case 'l': /* longer form of "ls -l" type listing */ if (negative) uO.lflag = -2, negative = 0; else uO.lflag = 5; break; case 'm': /* medium form of "ls -l" type listing */ if (negative) uO.lflag = -2, negative = 0; else uO.lflag = 4; break;#ifdef MORE case 'M': /* send output through built-in "more" */ if (negative) G.M_flag = FALSE, negative = 0; else G.M_flag = TRUE; break;#endif case 's': /* default: shorter "ls -l" type listing */ if (negative) uO.lflag = -2, negative = 0; else uO.lflag = 3; break; case 't': /* totals line */ if (negative) tflag_2v = tflag_slm = FALSE, negative = 0; else { tflag_2v = tflag_slm = explicit_t = TRUE; if (uO.lflag == -1) uO.lflag = 0; } break; case ('T'): /* use (sortable) decimal time format */ if (negative) uO.T_flag = FALSE, negative = 0; else uO.T_flag = TRUE; break; case 'v': /* turbo-verbose listing */ if (negative) uO.lflag = -2, negative = 0; else uO.lflag = 10; break; case 'z': /* print zipfile comment */ if (negative) uO.zflag = negative = 0; else uO.zflag = 1; break; case 'Z': /* ZipInfo mode: ignore */ break; default: error = TRUE; break; } } } if ((argc-- == 0) || error) { *pargc = argc; *pargv = argv; return USAGE(error); }#ifdef MORE if (G.M_flag && !isatty(1)) /* stdout redirected: "more" func useless */ G.M_flag = 0;#endif /* if no listing options given (or all negated), or if only -h/-t given * with individual files specified, use default listing format */ if ((uO.lflag < 0) || ((argc > 0) && (uO.lflag == 0))) uO.lflag = LFLAG; /* set header and totals flags to default or specified values */ switch (uO.lflag) { case 0: /* 0: can only occur if either -t or -h explicitly given; */ case 2: /* therefore set both flags equal to normally false value */ uO.hflag = hflag_2; uO.tflag = tflag_2v; break; case 1: /* only filenames, *always* */ uO.hflag = FALSE; uO.tflag = FALSE; uO.zflag = FALSE; break; case 3: case 4: case 5: uO.hflag = ((argc > 0) && !explicit_h)? FALSE : hflag_slmv; uO.tflag = ((argc > 0) && !explicit_t)? FALSE : tflag_slm; break; case 10: uO.hflag = hflag_slmv; uO.tflag = tflag_2v; break; } *pargc = argc; *pargv = argv; return 0;} /* end function zi_opts() */#endif /* !WINDLL *//*******************************//* Function zi_end_central() *//*******************************/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 : "s")); /* 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; unsigned j, members=0; ulg tot_csize=0L, tot_ucsize=0L; ulg endprev; /* buffers end of previous entry for zi_long()'s check * of extra bytes */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -