home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / unzip52.zip / zipinfo.c < prev    next >
C/C++ Source or Header  |  1996-04-27  |  62KB  |  1,517 lines

  1. /*---------------------------------------------------------------------------
  2.  
  3.   zipinfo.c                                                    Greg Roelofs
  4.  
  5.   This file contains all of the ZipInfo-specific listing routines for UnZip.
  6.  
  7.   Contains:  zi_opts()
  8.              zi_end_central()
  9.              zipinfo()
  10.              zi_long()
  11.              zi_short()
  12.              zi_time()
  13.  
  14.   ---------------------------------------------------------------------------*/
  15.  
  16.  
  17. #define UNZIP_INTERNAL
  18. #include "unzip.h"
  19.  
  20.  
  21. #ifndef NO_ZIPINFO  /* strings use up too much space in small-memory systems */
  22.  
  23. /* Define OS-specific attributes for use on ALL platforms--the S_xxxx
  24.  * versions of these are defined differently (or not defined) by different
  25.  * compilers and operating systems. */
  26.  
  27. #define UNX_IFMT       0170000     /* Unix file type mask */
  28. #define UNX_IFDIR      0040000     /* Unix directory */
  29. #define UNX_IFREG      0100000     /* Unix regular file */
  30. #define UNX_IFSOCK     0140000     /* Unix socket (BSD, not SysV or Amiga) */
  31. #define UNX_IFLNK      0120000     /* Unix symbolic link (not SysV, Amiga) */
  32. #define UNX_IFBLK      0060000     /* Unix block special       (not Amiga) */
  33. #define UNX_IFCHR      0020000     /* Unix character special   (not Amiga) */
  34. #define UNX_IFIFO      0010000     /* Unix fifo    (BCC, not MSC or Amiga) */
  35. #define UNX_ISUID      04000       /* Unix set user id on execution */
  36. #define UNX_ISGID      02000       /* Unix set group id on execution */
  37. #define UNX_ISVTX      01000       /* Unix directory permissions control */
  38. #define UNX_ENFMT      UNX_ISGID   /* Unix record locking enforcement flag */
  39. #define UNX_IRWXU      00700       /* Unix read, write, execute: owner */
  40. #define UNX_IRUSR      00400       /* Unix read permission: owner */
  41. #define UNX_IWUSR      00200       /* Unix write permission: owner */
  42. #define UNX_IXUSR      00100       /* Unix execute permission: owner */
  43. #define UNX_IRWXG      00070       /* Unix read, write, execute: group */
  44. #define UNX_IRGRP      00040       /* Unix read permission: group */
  45. #define UNX_IWGRP      00020       /* Unix write permission: group */
  46. #define UNX_IXGRP      00010       /* Unix execute permission: group */
  47. #define UNX_IRWXO      00007       /* Unix read, write, execute: other */
  48. #define UNX_IROTH      00004       /* Unix read permission: other */
  49. #define UNX_IWOTH      00002       /* Unix write permission: other */
  50. #define UNX_IXOTH      00001       /* Unix execute permission: other */
  51.  
  52. #define VMS_IRUSR      UNX_IRUSR   /* VMS read/owner */
  53. #define VMS_IWUSR      UNX_IWUSR   /* VMS write/owner */
  54. #define VMS_IXUSR      UNX_IXUSR   /* VMS execute/owner */
  55. #define VMS_IRGRP      UNX_IRGRP   /* VMS read/group */
  56. #define VMS_IWGRP      UNX_IWGRP   /* VMS write/group */
  57. #define VMS_IXGRP      UNX_IXGRP   /* VMS execute/group */
  58. #define VMS_IROTH      UNX_IROTH   /* VMS read/other */
  59. #define VMS_IWOTH      UNX_IWOTH   /* VMS write/other */
  60. #define VMS_IXOTH      UNX_IXOTH   /* VMS execute/other */
  61.  
  62. #define AMI_IFMT       06000       /* Amiga file type mask */
  63. #define AMI_IFDIR      04000       /* Amiga directory */
  64. #define AMI_IFREG      02000       /* Amiga regular file */
  65. #define AMI_IHIDDEN    00200       /* to be supported in AmigaDOS 3.x */
  66. #define AMI_ISCRIPT    00100       /* executable script (text command file) */
  67. #define AMI_IPURE      00040       /* allow loading into resident memory */
  68. #define AMI_IARCHIVE   00020       /* not modified since bit was last set */
  69. #define AMI_IREAD      00010       /* can be opened for reading */
  70. #define AMI_IWRITE     00004       /* can be opened for writing */
  71. #define AMI_IEXECUTE   00002       /* executable image, a loadable runfile */
  72. #define AMI_IDELETE    00001       /* can be deleted */
  73.  
  74. #define LFLAG  3   /* short "ls -l" type listing */
  75.  
  76. static int   zi_long   OF((__GPRO__ ulg endprev));
  77. static int   zi_short  OF((__GPRO));
  78. static char *zi_time   OF((__GPRO__ const ush *datez, const ush *timez,
  79.                            const time_t *modtimez, char *d_t_str));
  80.  
  81.  
  82. /**********************************************/
  83. /*  Strings used in zipinfo.c (ZipInfo half)  */
  84. /**********************************************/
  85.  
  86. static char Far LongHeader[] = "Archive:  %s   %ld bytes   %d file%s\n";
  87. static char Far ShortHeader[] = "Archive:  %s   %ld   %d\n";
  88. static char Far EndCentDirRec[] = "\nEnd-of-central-directory record:\n";
  89. static char Far LineSeparators[] = "-------------------------------\n\n";
  90. static char Far ActOffsetCentDir[] = "\
  91.   Actual offset of end-of-central-dir record:   %9ld (%.8lXh)\n\
  92.   Expected offset of end-of-central-dir record: %9ld (%.8lXh)\n\
  93.   (based on the length of the central directory and its expected offset)\n\n";
  94. static char Far SinglePartArchive1[] = "\
  95.   This zipfile constitutes the sole disk of a single-part archive; its\n\
  96.   central directory contains %u %s.  The central directory is %lu\n\
  97.   (%.8lXh) bytes long, and its (expected) offset in bytes from the\n";
  98. static char Far SinglePartArchive2[] = "\
  99.   beginning of the zipfile is %lu (%.8lXh).\n\n";
  100. static char Far MultiPartArchive1[] = "\
  101.   This zipfile constitutes disk %u of a multi-part archive.  The central\n\
  102.   directory starts on disk %u; %u of its entries %s contained within\n";
  103. static char Far MultiPartArchive2[] = "\
  104.   this zipfile, out of a total of %u %s.  The entire central\n\
  105.   directory is %lu (%.8lXh) bytes long, and its offset in bytes from\n";
  106. static char Far MultiPartArchive3[] = "\
  107.   the beginning of the zipfile in which it begins is %lu (%.8lXh).\n\n";
  108. static char Far NoZipfileComment[] = "  There is no zipfile comment.\n";
  109. static char Far ZipfileCommentDesc[] =
  110.   "  The zipfile comment is %u bytes long and contains the following text:\n\n";
  111. static char Far ZipfileCommBegin[] =
  112.  "======================== zipfile comment begins ==========================\n";
  113. static char Far ZipfileCommEnd[] =
  114.  "========================= zipfile comment ends ===========================\n";
  115. static char Far ZipfileCommTrunc2[] = "\n  The zipfile comment is truncated.\n";
  116. static char Far ZipfileCommTruncMsg[] =
  117.   "\ncaution:  zipfile comment truncated\n";
  118.  
  119. static char Far CentralDirEntry[] =
  120.   "\nCentral directory entry #%d:\n---------------------------\n\n";
  121. static char Far ZipfileStats[] =
  122.   "%d file%s, %lu bytes uncompressed, %lu bytes compressed:  %s%d.%d%%\n";
  123.  
  124. /* zi_long() strings */
  125. static char Far OS_FAT[] = "MS-DOS, OS/2 or NT FAT";
  126. static char Far OS_Amiga[] = "Amiga";
  127. static char Far OS_VMS[] = "VMS";
  128. static char Far OS_Unix[] = "Unix";
  129. static char Far OS_VMCMS[] = "VM/CMS";
  130. static char Far OS_AtariST[] = "Atari ST";
  131. static char Far OS_HPFS[] = "OS/2 or NT HPFS";
  132. static char Far OS_Macintosh[] = "Macintosh";
  133. static char Far OS_ZSystem[] = "Z-System";
  134. static char Far OS_CPM[] = "CP/M";
  135. static char Far OS_TOPS20[] = "TOPS-20";
  136. static char Far OS_NTFS[] = "NT NTFS";
  137. static char Far OS_QDOS[] = "QDOS (maybe)";
  138. static char Far OS_Acorn[] = "Acorn RISCOS";
  139. static char Far OS_MVS[] = "MVS";
  140. static char Far OS_VFAT[] = "Win95 VFAT";
  141. static char Far OS_BeBox[] = "Be Box";
  142.  
  143. static char Far MthdNone[] = "none (stored)";
  144. static char Far MthdShrunk[] = "shrunk";
  145. static char Far MthdRedF1[] = "reduced (factor 1)";
  146. static char Far MthdRedF2[] = "reduced (factor 2)";
  147. static char Far MthdRedF3[] = "reduced (factor 3)";
  148. static char Far MthdRedF4[] = "reduced (factor 4)";
  149. static char Far MthdImplode[] = "imploded";
  150. static char Far MthdToken[] = "tokenized";
  151. static char Far MthdDeflate[] = "deflated";
  152.  
  153. static char Far DeflNorm[] = "normal";
  154. static char Far DeflMax[] = "maximum";
  155. static char Far DeflFast[] = "fast";
  156. static char Far DeflSFast[] = "superfast";
  157.  
  158. static char Far ExtraBytesPreceding[] =
  159.   "  There are an extra %ld bytes preceding this file.\n\n";
  160.  
  161. static char Far Unknown[] = "unknown (%d)";
  162.  
  163. static char Far HostOS[] =
  164.   "\n  file system or operating system of origin:        %s\n";
  165. static char Far EncodeSWVer[] =
  166.   "  version of encoding software:                     %d.%d\n";
  167. static char Far MinOSCompReq[] =
  168.   "  minimum file system compatibility required:       %s\n";
  169. static char Far MinSWVerReq[] =
  170.   "  minimum software version required to extract:     %d.%d\n";
  171. static char Far CompressMethod[] =
  172.   "  compression method:                               %s\n";
  173. static char Far SlideWindowSizeImplode[] =
  174.   "  size of sliding dictionary (implosion):           %cK\n";
  175. static char Far ShannonFanoTrees[] =
  176.   "  number of Shannon-Fano trees (implosion):         %c\n";
  177. static char Far CompressSubtype[] =
  178.   "  compression sub-type (deflation):                 %s\n";
  179. static char Far FileSecurity[] =
  180.   "  file security status:                             %sencrypted\n";
  181. static char Far ExtendedLocalHdr[] =
  182.   "  extended local header:                            %s\n";
  183. static char Far FileModDate[] =
  184.   "  file last modified on (DOS date/time):            %s\n";
  185. #ifdef USE_EF_UX_TIME
  186.   static char Far UX_FileModDate[] =
  187.     "  file last modified on (UX extra field modtime):   %s %s\n";
  188.   static char Far LocalTime[] = "local";
  189. #ifndef NO_GMTIME
  190.   static char Far GMTime[] = "UTC";
  191. #endif
  192. #endif /* USE_EF_UX_TIME */
  193. static char Far CRC32Value[] =
  194.   "  32-bit CRC value (hex):                           %.8lx\n";
  195. static char Far CompressedFileSize[] =
  196.   "  compressed size:                                  %lu bytes\n";
  197. static char Far UncompressedFileSize[] =
  198.   "  uncompressed size:                                %lu bytes\n";
  199. static char Far FilenameLength[] =
  200.   "  length of filename:                               %u characters\n";
  201. static char Far ExtraFieldLength[] =
  202.   "  length of extra field:                            %u bytes\n";
  203. static char Far FileCommentLength[] =
  204.   "  length of file comment:                           %u characters\n";
  205. static char Far FileDiskNum[] =
  206.   "  disk number on which file begins:                 disk %u\n";
  207. static char Far ApparentFileType[] =
  208.   "  apparent file type:                               %s\n";
  209. static char Far VMSFileAttributes[] =
  210.   "  VMS file attributes (%06o octal):               %s\n";
  211. static char Far AmigaFileAttributes[] =
  212.   "  Amiga file attributes (%06o octal):             %s\n";
  213. static char Far UnixFileAttributes[] =
  214.   "  Unix file attributes (%06o octal):              %s\n";
  215. static char Far NonMSDOSFileAttributes[] =
  216.   "  non-MSDOS external file attributes:               %06lX hex\n";
  217. static char Far MSDOSFileAttributes[] =
  218.   "  MS-DOS file attributes (%02X hex):                  none\n";
  219. static char Far MSDOSFileAttributesRO[] =
  220.   "  MS-DOS file attributes (%02X hex):                  read-only\n";
  221. static char Far MSDOSFileAttributesAlpha[] =
  222.   "  MS-DOS file attributes (%02X hex):                  %s%s%s%s%s%s\n";
  223. static char Far LocalHeaderOffset[] =
  224.   "  offset of local header from start of archive:     %lu (%.8lXh) bytes\n";
  225.  
  226. static char Far ExtraFieldTrunc[] = "\n\
  227.   error: EF data block size %u exceeds remaining extra field space %u;\n\
  228.          block length has been truncated.\n";
  229. static char Far ExtraFields[] = "\n\
  230.   The central-directory extra field contains:";
  231. static char Far ExtraFieldType[] = "\n\
  232.   - A subfield with ID 0x%04x (%s) and %u data bytes";
  233. static char Far OS2EAs[] = ".\n\
  234.     The local extra field has %lu bytes of OS/2 extended attributes.\n\
  235.     (May not match OS/2 \"dir\" amount due to storage method).";
  236. static char Far ACLData[] = ".\n\
  237.     The local extra field has %lu bytes of access control list information.";
  238. #ifdef CMS_MVS
  239.    static char Far VmMvsExtraField[] = ".\n\
  240.   The stored file open mode (FLDATA TYPE) is \"%s\".";
  241.    static char Far VmMvsInvalid[] = "[invalid]";
  242. #endif /* CMS_MVS */
  243. static char Far First16[] = ".  The first 16 are%s";
  244. static char Far ColonIndent[] = ":\n     ";
  245.  
  246. static char Far efFormat[] = " %02x";
  247. static char Far efAV[] = "PKWARE AV";
  248. static char Far efOS2[] = "OS/2";
  249. static char Far efACL[] = "ACL";
  250. static char Far efPKVMS[] = "PKWARE VMS";
  251. static char Far efASiUnix[] = "ASi Unix";
  252. static char Far efIZVMS[] = "Info-ZIP VMS";
  253. static char Far efIZUnix[] = "Info-ZIP Unix/OS2/NT";
  254. static char Far efVMCMS[] = "VM/CMS";
  255. static char Far efMVS[] = "MVS";
  256. static char Far efSpark[] = "Acorn SparkFS";
  257. static char Far efMD5[] = "Fred Kantor MD5";
  258. static char Far efUnknown[] = "unknown";
  259.  
  260. static char Far efIZuid[] = "GMT modification/access times and Unix UID/GID";
  261. static char Far efIZnouid[] = "GMT modification/access times only";
  262.  
  263. static char Far lExtraFieldType[] = "\n\
  264.   There %s a local extra field with ID 0x%04x (%s) and\n\
  265.   %u data bytes (%s).\n";
  266.  
  267. static char Far NoFileComment[] = "\n  There is no file comment.\n";
  268. static char Far FileCommBegin[] = "\n\
  269. ------------------------- file comment begins ----------------------------\n";
  270. static char Far FileCommEnd[] = "\
  271. -------------------------- file comment ends -----------------------------\n";
  272.  
  273. /* zi_time() strings */
  274. static char Far BogusFmt[] = "%03d";
  275. static char Far DMYHMTime[] = "%2u-%s-%02u %02u:%02u";
  276. static char Far YMDHMSTime[] = "%u %s %u %02u:%02u:%02u";
  277. static char Far DecimalTime[] = "%04u%02u%02u.%02u%02u%02u";
  278.  
  279.  
  280.  
  281.  
  282.  
  283. /************************/
  284. /*  Function zi_opts()  */
  285. /************************/
  286.  
  287. int zi_opts(__G__ pargc, pargv)
  288.     int *pargc;
  289.     char ***pargv;
  290.      __GDEF
  291. {
  292.     char   **argv, *s;
  293.     int    argc, c, error=FALSE, negative=0;
  294.     int    hflag_slmv=TRUE, hflag_2=FALSE;  /* diff options => diff defaults */
  295.     int    tflag_slm=TRUE, tflag_2v=FALSE;
  296.     int    explicit_h=FALSE, explicit_t=FALSE;
  297.  
  298.  
  299. #ifdef MACOS
  300.     G.lflag = LFLAG;   /* reset default on each call */
  301. #endif
  302.     argc = *pargc;
  303.     argv = *pargv;
  304.  
  305.     while (--argc > 0 && (*++argv)[0] == '-') {
  306.         s = argv[0] + 1;
  307.         while ((c = *s++) != 0) {    /* "!= 0":  prevent Turbo C warning */
  308.             switch (c) {
  309.                 case '-':
  310.                     ++negative;
  311.                     break;
  312.                 case '1':      /* shortest listing:  JUST filenames */
  313.                     if (negative)
  314.                         G.lflag = -2, negative = 0;
  315.                     else
  316.                         G.lflag = 1;
  317.                     break;
  318.                 case '2':      /* just filenames, plus headers if specified */
  319.                     if (negative)
  320.                         G.lflag = -2, negative = 0;
  321.                     else
  322.                         G.lflag = 2;
  323.                     break;
  324.                 case 'h':      /* header line */
  325.                     if (negative)
  326.                         hflag_2 = hflag_slmv = FALSE, negative = 0;
  327.                     else {
  328.                         hflag_2 = hflag_slmv = explicit_h = TRUE;
  329.                         if (G.lflag == -1)
  330.                             G.lflag = 0;
  331.                     }
  332.                     break;
  333.                 case 'l':      /* longer form of "ls -l" type listing */
  334.                     if (negative)
  335.                         G.lflag = -2, negative = 0;
  336.                     else
  337.                         G.lflag = 5;
  338.                     break;
  339.                 case 'm':      /* medium form of "ls -l" type listing */
  340.                     if (negative)
  341.                         G.lflag = -2, negative = 0;
  342.                     else
  343.                         G.lflag = 4;
  344.                     break;
  345. #ifdef MORE
  346.                 case 'M':      /* send output through built-in "more" */
  347.                     if (negative)
  348.                         G.M_flag = FALSE, negative = 0;
  349.                     else
  350.                         G.M_flag = TRUE;
  351.                     break;
  352. #endif
  353.                 case 's':      /* default:  shorter "ls -l" type listing */
  354.                     if (negative)
  355.                         G.lflag = -2, negative = 0;
  356.                     else
  357.                         G.lflag = 3;
  358.                     break;
  359.                 case 't':      /* totals line */
  360.                     if (negative)
  361.                         tflag_2v = tflag_slm = FALSE, negative = 0;
  362.                     else {
  363.                         tflag_2v = tflag_slm = explicit_t = TRUE;
  364.                         if (G.lflag == -1)
  365.                             G.lflag = 0;
  366.                     }
  367.                     break;
  368.                 case ('T'):    /* use (sortable) decimal time format */
  369.                     if (negative)
  370.                         G.T_flag = FALSE, negative = 0;
  371.                     else
  372.                         G.T_flag = TRUE;
  373.                     break;
  374.                 case 'v':      /* turbo-verbose listing */
  375.                     if (negative)
  376.                         G.lflag = -2, negative = 0;
  377.                     else
  378.                         G.lflag = 10;
  379.                     break;
  380.                 case 'z':      /* print zipfile comment */
  381.                     if (negative)
  382.                         G.zflag = negative = 0;
  383.                     else
  384.                         G.zflag = 1;
  385.                     break;
  386.                 case 'Z':      /* ZipInfo mode:  ignore */
  387.                     break;
  388.                 default:
  389.                     error = TRUE;
  390.                     break;
  391.             }
  392.         }
  393.     }
  394.     if ((argc-- == 0) || error) {
  395.         *pargc = argc;
  396.         *pargv = argv;
  397. #if (!defined(MSWIN) && !defined(CMS_MVS))
  398.         return usage(__G__ error);
  399. #else
  400.         return error;
  401. #endif
  402.     }
  403.  
  404.     /* if no listing options given (or all negated), or if only -h/-t given
  405.      * with individual files specified, use default listing format */
  406.     if ((G.lflag < 0) || ((argc > 0) && (G.lflag == 0)))
  407.         G.lflag = LFLAG;
  408.  
  409.     /* set header and totals flags to default or specified values */
  410.     switch (G.lflag) {
  411.         case 0:   /* 0:  can only occur if either -t or -h explicitly given; */
  412.         case 2:   /*  therefore set both flags equal to normally false value */
  413.             G.hflag = hflag_2;
  414.             G.tflag = tflag_2v;
  415.             break;
  416.         case 1:   /* only filenames, *always* */
  417.             G.hflag = FALSE;
  418.             G.tflag = FALSE;
  419.             G.zflag = FALSE;
  420.             break;
  421.         case 3:
  422.         case 4:
  423.         case 5:
  424.             G.hflag = ((argc > 0) && !explicit_h)? FALSE : hflag_slmv;
  425.             G.tflag = ((argc > 0) && !explicit_t)? FALSE : tflag_slm;
  426.             break;
  427.         case 10:
  428.             G.hflag = hflag_slmv;
  429.             G.tflag = tflag_2v;
  430.             break;
  431.     }
  432.  
  433.     *pargc = argc;
  434.     *pargv = argv;
  435.     return 0;
  436.  
  437. } /* end function zi_opts() */
  438.  
  439.  
  440.  
  441.  
  442.  
  443. /*******************************/
  444. /*  Function zi_end_central()  */
  445. /*******************************/
  446.  
  447. int zi_end_central(__G)   /* return PK-type error code */
  448.      __GDEF
  449. {
  450.     int  error = PK_COOL;
  451.  
  452.  
  453. /*---------------------------------------------------------------------------
  454.     Print out various interesting things about the zipfile.
  455.   ---------------------------------------------------------------------------*/
  456.  
  457.     /* header fits on one line, for anything up to 10GB and 10000 files: */
  458.     if (G.hflag)
  459.         Info(slide, 0, ((char *)slide, ((int)strlen(G.zipfn) < 39)?
  460.           LoadFarString(LongHeader) : LoadFarString(ShortHeader), G.zipfn,
  461.           (long)G.ziplen, G.ecrec.total_entries_central_dir,
  462.           (G.ecrec.total_entries_central_dir==1)? "" : "s"));
  463.  
  464.     /* verbose format */
  465.     if (G.lflag > 9) {
  466.         Info(slide, 0, ((char *)slide, LoadFarString(EndCentDirRec)));
  467.         Info(slide, 0, ((char *)slide, LoadFarString(LineSeparators)));
  468.  
  469.         Info(slide, 0, ((char *)slide, LoadFarString(ActOffsetCentDir),
  470.           (long)G.real_ecrec_offset, (long)G.real_ecrec_offset,
  471.           (long)G.expect_ecrec_offset, (long)G.expect_ecrec_offset));
  472.  
  473.         if (G.ecrec.number_this_disk == 0) {
  474.             Info(slide, 0, ((char *)slide, LoadFarString(SinglePartArchive1),
  475.               G.ecrec.total_entries_central_dir,
  476.               (G.ecrec.total_entries_central_dir == 1)? "entry" : "entries",
  477.               G.ecrec.size_central_directory,
  478.               G.ecrec.size_central_directory));
  479.             Info(slide, 0, ((char *)slide, LoadFarString(SinglePartArchive2),
  480.               G.ecrec.offset_start_central_directory,
  481.               G.ecrec.offset_start_central_directory));
  482.         } else {
  483.             Info(slide, 0, ((char *)slide, LoadFarString(MultiPartArchive1),
  484.               G.ecrec.number_this_disk,
  485.               G.ecrec.num_disk_start_cdir,
  486.               G.ecrec.num_entries_centrl_dir_ths_disk,
  487.               (G.ecrec.num_entries_centrl_dir_ths_disk == 1)? "is" : "are"));
  488.             Info(slide, 0, ((char *)slide, LoadFarString(MultiPartArchive2),
  489.               G.ecrec.total_entries_central_dir,
  490.               (G.ecrec.total_entries_central_dir == 1) ? "entry" : "entries",
  491.               G.ecrec.size_central_directory,
  492.               G.ecrec.size_central_directory));
  493.             Info(slide, 0, ((char *)slide, LoadFarString(MultiPartArchive3),
  494.               G.ecrec.offset_start_central_directory,
  495.               G.ecrec.offset_start_central_directory));
  496.         }
  497.  
  498.     /*-----------------------------------------------------------------------
  499.         Get the zipfile comment, if any, and print it out.  (Comment may be
  500.         up to 64KB long.  May the fleas of a thousand camels infest the arm-
  501.         pits of anyone who actually takes advantage of this fact.)
  502.       -----------------------------------------------------------------------*/
  503.  
  504.         if (!G.ecrec.zipfile_comment_length)
  505.             Info(slide, 0, ((char *)slide, LoadFarString(NoZipfileComment)));
  506.         else {
  507.             Info(slide, 0, ((char *)slide, LoadFarString(ZipfileCommentDesc),
  508.               G.ecrec.zipfile_comment_length));
  509.             Info(slide, 0, ((char *)slide, LoadFarString(ZipfileCommBegin)));
  510.             if (do_string(__G__ G.ecrec.zipfile_comment_length, DISPLAY))
  511.                 error = PK_WARN;
  512.             Info(slide, 0, ((char *)slide, LoadFarString(ZipfileCommEnd)));
  513.             if (error)
  514.                 Info(slide, 0, ((char *)slide,
  515.                   LoadFarString(ZipfileCommTrunc2)));
  516.         } /* endif (comment exists) */
  517.  
  518.     /* non-verbose mode:  print zipfile comment only if requested */
  519.     } else if (G.zflag && G.ecrec.zipfile_comment_length) {
  520.         if (do_string(__G__ G.ecrec.zipfile_comment_length,DISPLAY)) {
  521.             Info(slide, 0x401, ((char *)slide,
  522.               LoadFarString(ZipfileCommTruncMsg)));
  523.             error = PK_WARN;
  524.         }
  525.     } /* endif (verbose) */
  526.  
  527.     return error;
  528.  
  529. } /* end function zi_end_central() */
  530.  
  531.  
  532.  
  533.  
  534.  
  535. /************************/
  536. /*  Function zipinfo()  */
  537. /************************/
  538.  
  539. int zipinfo(__G)   /* return PK-type error code */
  540.      __GDEF
  541. {
  542.     int   j, do_this_file=FALSE, error, error_in_archive=PK_COOL;
  543.     int   *fn_matched=NULL, *xn_matched=NULL;
  544.     ush   members=0;
  545.     ulg   tot_csize=0L, tot_ucsize=0L;
  546.     ulg   endprev;   /* buffers end of previous entry for zi_long()'s check
  547.                       *  of extra bytes */
  548.  
  549.  
  550. /*---------------------------------------------------------------------------
  551.     Malloc space for check on unmatched filespecs (no big deal if one or both
  552.     are NULL).
  553.   ---------------------------------------------------------------------------*/
  554.  
  555.     if (G.filespecs > 0  &&
  556.         (fn_matched=(int *)malloc(G.filespecs*sizeof(int))) != NULL)
  557.         for (j = 0;  j < G.filespecs;  ++j)
  558.             fn_matched[j] = FALSE;
  559.  
  560.     if (G.xfilespecs > 0  &&
  561.         (xn_matched=(int *)malloc(G.xfilespecs*sizeof(int))) != NULL)
  562.         for (j = 0;  j < G.xfilespecs;  ++j)
  563.             xn_matched[j] = FALSE;
  564.  
  565. /*---------------------------------------------------------------------------
  566.     Set file pointer to start of central directory, then loop through cen-
  567.     tral directory entries.  Check that directory-entry signature bytes are
  568.     actually there (just a precaution), then process the entry.  We know
  569.     the entire central directory is on this disk:  we wouldn't have any of
  570.     this information unless the end-of-central-directory record was on this
  571.     disk, and we wouldn't have gotten to this routine unless this is also
  572.     the disk on which the central directory starts.  In practice, this had
  573.     better be the *only* disk in the archive, but maybe someday we'll add
  574.     multi-disk support.
  575.   ---------------------------------------------------------------------------*/
  576.  
  577.     G.pInfo->lcflag = 0;    /* used in do_string(): never TRUE in zipinfo mode */
  578.     G.pInfo->textmode = 0;  /* so one can read on screen (but is it ever used?) */
  579.  
  580.     /* reset endprev for new zipfile; account for multi-part archives (?) */
  581.     endprev = (G.crec.relative_offset_local_header == 4L)? 4L : 0L;
  582.  
  583.  
  584.     for (j = 0;  j < (int)G.ecrec.total_entries_central_dir;  ++j) {
  585.         if (readbuf(__G__ G.sig, 4) == 0)
  586.             return PK_EOF;
  587.         if (strncmp(G.sig, G.central_hdr_sig, 4)) {  /* just to make sure */
  588.             Info(slide, 0x401, ((char *)slide, LoadFarString(CentSigMsg), j));
  589.             return PK_BADERR;   /* sig not found */
  590.         }
  591.         if ((error = get_cdir_ent(__G)) != PK_COOL)
  592.             return error;       /* only PK_EOF defined */
  593.  
  594.         /* do Amigas (AMIGA_) also have volume labels? */
  595.         if (IS_VOLID(G.crec.external_file_attributes) &&
  596.             (G.pInfo->hostnum == FS_FAT_ || G.pInfo->hostnum == FS_HPFS_ ||
  597.              G.pInfo->hostnum == FS_NTFS_ || G.pInfo->hostnum == ATARI_))
  598.             G.pInfo->vollabel = TRUE;
  599.         else
  600.             G.pInfo->vollabel = FALSE;
  601.  
  602.         if ((error = do_string(__G__ G.crec.filename_length, DS_FN)) !=
  603.              PK_COOL)
  604.         {
  605.           error_in_archive = error;   /* might be warning */
  606.           if (error > PK_WARN)        /* fatal */
  607.               return error;
  608.         }
  609.  
  610.         if (!G.process_all_files) {    /* check if specified on command line */
  611.             char  **pfn = G.pfnames-1;
  612.  
  613.             do_this_file = FALSE;
  614.             while (*++pfn)
  615.                 if (match(G.filename, *pfn, 0)) {
  616.                     do_this_file = TRUE;
  617.                     if (fn_matched)
  618.                         fn_matched[(int)(pfn-G.pfnames)] = TRUE;
  619.                     break;       /* found match, so stop looping */
  620.                 }
  621.             if (do_this_file) {  /* check if this is an excluded file */
  622.                 char  **pxn = G.pxnames-1;
  623.  
  624.                 while (*++pxn)
  625.                     if (match(G.filename, *pxn, 0)) {
  626.                         do_this_file = FALSE;
  627.                         if (xn_matched)
  628.                             xn_matched[(int)(pxn-G.pxnames)] = TRUE;
  629.                         break;
  630.                     }
  631.             }
  632.         }
  633.  
  634.     /*-----------------------------------------------------------------------
  635.         If current file was specified on command line, or if no names were
  636.         specified, do the listing for this file.  Otherwise, get rid of the
  637.         file comment and go back for the next file.
  638.       -----------------------------------------------------------------------*/
  639.  
  640.         if (G.process_all_files || do_this_file) {
  641.  
  642.             switch (G.lflag) {
  643.                 case 1:
  644.                 case 2:
  645.                     fnprint(__G);
  646.                     SKIP_(G.crec.extra_field_length)
  647.                     SKIP_(G.crec.file_comment_length)
  648.                     break;
  649.  
  650.                 case 3:
  651.                 case 4:
  652.                 case 5:
  653.                     if ((error = zi_short(__G)) != PK_COOL) {
  654.                         error_in_archive = error;   /* might be warning */
  655.                         if (error > PK_WARN)        /* fatal */
  656.                             return error;
  657.                     }
  658.                     break;
  659.  
  660.                 case 10:
  661.                     Info(slide, 0, ((char *)slide,
  662.                       LoadFarString(CentralDirEntry), j));
  663.                     if ((error = zi_long(__G__ endprev)) != PK_COOL) {
  664.                         error_in_archive = error;   /* might be warning */
  665.                         if (error > PK_WARN)        /* fatal */
  666.                             return error;
  667.                     }
  668.                     break;
  669.  
  670.                 default:
  671.                     SKIP_(G.crec.extra_field_length)
  672.                     SKIP_(G.crec.file_comment_length)
  673.                     break;
  674.  
  675.             } /* end switch (lflag) */
  676.  
  677.             tot_csize += G.crec.csize;
  678.             tot_ucsize += G.crec.ucsize;
  679.             if (G.crec.general_purpose_bit_flag & 1)
  680.                 tot_csize -= 12;   /* don't count encryption header */
  681.             ++members;
  682.  
  683.         } else {   /* not listing */
  684.             SKIP_(G.crec.extra_field_length)
  685.             SKIP_(G.crec.file_comment_length)
  686.  
  687.         } /* end if (list member?) */
  688.  
  689.     } /* end for-loop (j: member files) */
  690.  
  691. /*---------------------------------------------------------------------------
  692.     Double check that we're back at the end-of-central-directory record.
  693.   ---------------------------------------------------------------------------*/
  694.  
  695.     if (readbuf(__G__ G.sig, 4) == 0)  /* disk error? */
  696.         return PK_EOF;
  697.     if (strncmp(G.sig, G.end_central_sig, 4)) {   /* just to make sure again */
  698.         Info(slide, 0x401, ((char *)slide, LoadFarString(EndSigMsg)));
  699.         error_in_archive = PK_WARN;   /* didn't find sig */
  700.     }
  701.  
  702. /*---------------------------------------------------------------------------
  703.     Check that we actually found requested files; if so, print totals.
  704.   ---------------------------------------------------------------------------*/
  705.  
  706.     if (G.tflag) {
  707.         char *sgn = "";
  708.         int cfactor = ratio(tot_ucsize, tot_csize);
  709.  
  710.         if (cfactor < 0) {
  711.             sgn = "-";
  712.             cfactor = -cfactor;
  713.         }
  714.         Info(slide, 0, ((char *)slide, LoadFarString(ZipfileStats),
  715.           members, (members==1)? "":"s", tot_ucsize, tot_csize, sgn, cfactor/10,
  716.           cfactor%10));
  717.     }
  718.  
  719. /*---------------------------------------------------------------------------
  720.     Check for unmatched filespecs on command line and print warning if any
  721.     found.
  722.   ---------------------------------------------------------------------------*/
  723.  
  724.     if (fn_matched) {
  725.         for (j = 0;  j < G.filespecs;  ++j)
  726.             if (!fn_matched[j])
  727.                 Info(slide, 0x401, ((char *)slide,
  728.                   LoadFarString(FilenameNotMatched), G.pfnames[j]));
  729.         free((zvoid *)fn_matched);
  730.     }
  731.     if (xn_matched) {
  732.         for (j = 0;  j < G.xfilespecs;  ++j)
  733.             if (!xn_matched[j])
  734.                 Info(slide, 0x401, ((char *)slide,
  735.                   LoadFarString(ExclFilenameNotMatched), G.pxnames[j]));
  736.         free((zvoid *)xn_matched);
  737.     }
  738.     if (members == 0 && error_in_archive <= PK_WARN)
  739.         error_in_archive = PK_FIND;
  740.  
  741.     return error_in_archive;
  742.  
  743. } /* end function zipinfo() */
  744.  
  745.  
  746.  
  747.  
  748.  
  749. /************************/
  750. /*  Function zi_long()  */
  751. /************************/
  752.  
  753. static int zi_long(__G__ endprev)   /* return PK-type error code */
  754.      __GDEF
  755.     ulg endprev;                    /* for zi_long() check of extra bytes */
  756. {
  757. #ifdef USE_EF_UX_TIME
  758.     ztimbuf z_utime;
  759. #endif
  760.     int  error, error_in_archive=PK_COOL;
  761.     ush  hostnum, hostver, extnum, extver, methnum, xattr;
  762.     char workspace[12], attribs[22];
  763.     char *varmsg_str;
  764.     char unkn[16];
  765.     static char Far *os[NUM_HOSTS] = {
  766.         OS_FAT, OS_Amiga, OS_VMS, OS_Unix, OS_VMCMS, OS_AtariST, OS_HPFS,
  767.         OS_Macintosh, OS_ZSystem, OS_CPM, OS_TOPS20, OS_NTFS, OS_QDOS,
  768.         OS_Acorn, OS_VFAT, OS_MVS, OS_BeBox
  769.     };
  770.     static char Far *method[NUM_METHODS] = {
  771.         MthdNone, MthdShrunk, MthdRedF1, MthdRedF2, MthdRedF3, MthdRedF4,
  772.         MthdImplode, MthdToken, MthdDeflate
  773.     };
  774.     static char Far *dtype[4] = {
  775.         DeflNorm, DeflMax, DeflFast, DeflSFast
  776.     };
  777.  
  778.  
  779. /*---------------------------------------------------------------------------
  780.     Check whether there's any extra space inside the zipfile.
  781.   ---------------------------------------------------------------------------*/
  782.  
  783.     if (G.crec.relative_offset_local_header != endprev)
  784.         Info(slide, 0, ((char *)slide, LoadFarString(ExtraBytesPreceding),
  785.           (long)G.crec.relative_offset_local_header - (long)endprev));
  786.  
  787.     /* calculate endprev for next time around */
  788.     endprev = G.crec.relative_offset_local_header + 4L + LREC_SIZE +
  789.       G.crec.filename_length + G.crec.extra_field_length + G.crec.file_comment_length
  790.       + G.crec.csize;
  791.  
  792. /*---------------------------------------------------------------------------
  793.     Read the extra field, if any. It may be used to get UNIX style modtime.
  794.   ---------------------------------------------------------------------------*/
  795.  
  796.     if ((error = do_string(__G__ G.crec.extra_field_length, EXTRA_FIELD))
  797.         != 0) {
  798.         if (G.extra_field != NULL) {
  799.             free(G.extra_field);
  800.             G.extra_field = NULL;
  801.         }
  802.         error_in_archive = error;
  803.         /* The premature return in case of a "fatal" error (PK_EOF) is
  804.          * delayed until we analyse the extra field contents.
  805.          * This allows to display all the other info that has been
  806.          * successfully read in.
  807.          */
  808.     }
  809.  
  810. /*---------------------------------------------------------------------------
  811.     Print out various interesting things about the compressed file.
  812.   ---------------------------------------------------------------------------*/
  813.  
  814.     hostnum = (ush)MIN(G.crec.version_made_by[1], NUM_HOSTS);
  815.     hostver = G.crec.version_made_by[0];
  816.     extnum = (ush)MIN(G.crec.version_needed_to_extract[1], NUM_HOSTS);
  817.     extver = G.crec.version_needed_to_extract[0];
  818.     methnum = (ush)MIN(G.crec.compression_method, NUM_METHODS);
  819.  
  820.     (*G.message)((zvoid *)&G, (uch *)"  ", 2L, 0);  fnprint(__G);
  821.  
  822.     if (hostnum >= NUM_HOSTS) {
  823.         sprintf(unkn, LoadFarString(Unknown),
  824.                 (int)G.crec.version_made_by[1]);
  825.         varmsg_str = unkn;
  826.     } else {
  827.         varmsg_str = LoadFarStringSmall(os[hostnum]);
  828.     }
  829.     Info(slide, 0, ((char *)slide, LoadFarString(HostOS), varmsg_str));
  830.     Info(slide, 0, ((char *)slide, LoadFarString(EncodeSWVer), hostver/10,
  831.       hostver%10));
  832.  
  833.     if (extnum >= NUM_HOSTS) {
  834.         sprintf(unkn, LoadFarString(Unknown),
  835.                 (int)G.crec.version_needed_to_extract[1]);
  836.         varmsg_str = unkn;
  837.     } else {
  838.         varmsg_str = LoadFarStringSmall(os[extnum]);
  839.     }
  840.     Info(slide, 0, ((char *)slide, LoadFarString(MinOSCompReq), varmsg_str));
  841.     Info(slide, 0, ((char *)slide, LoadFarString(MinSWVerReq), extver/10,
  842.       extver%10));
  843.  
  844.     if (methnum >= NUM_METHODS) {
  845.         sprintf(unkn, LoadFarString(Unknown), G.crec.compression_method);
  846.         varmsg_str = unkn;
  847.     } else {
  848.         varmsg_str = LoadFarStringSmall(method[methnum]);
  849.     }
  850.     Info(slide, 0, ((char *)slide, LoadFarString(CompressMethod), varmsg_str));
  851.     if (methnum == IMPLODED) {
  852.         Info(slide, 0, ((char *)slide, LoadFarString(SlideWindowSizeImplode),
  853.           (G.crec.general_purpose_bit_flag & 2)? '8' : '4'));
  854.         Info(slide, 0, ((char *)slide, LoadFarString(ShannonFanoTrees),
  855.           (G.crec.general_purpose_bit_flag & 4)? '3' : '2'));
  856.     } else if (methnum == DEFLATED) {
  857.         ush  dnum=(ush)((G.crec.general_purpose_bit_flag>>1) & 3);
  858.         Info(slide, 0, ((char *)slide, LoadFarString(CompressSubtype),
  859.           LoadFarStringSmall(dtype[dnum])));
  860.     }
  861.     Info(slide, 0, ((char *)slide, LoadFarString(FileSecurity),
  862.       (G.crec.general_purpose_bit_flag & 1)? "" : "not "));
  863.     Info(slide, 0, ((char *)slide, LoadFarString(ExtendedLocalHdr),
  864.       (G.crec.general_purpose_bit_flag & 8)? "yes" : "no"));
  865.     /* print upper 3 bits for amusement? */
  866.  
  867.     /* For printing of date & time, a "char d_t_buf[21]" is required.
  868.      * To save stack space, we reuse the "char attribs[22]" buffer which
  869.      * is not used yet.
  870.      */
  871. #   define d_t_buf attribs
  872.     zi_time(__G__ &G.crec.last_mod_file_date, &G.crec.last_mod_file_time,
  873.       NULL, d_t_buf);
  874.     Info(slide, 0, ((char *)slide, LoadFarString(FileModDate), d_t_buf));
  875. #ifdef USE_EF_UX_TIME
  876.     if (G.extra_field  &&  ef_scan_for_izux(G.extra_field,
  877.         G.crec.extra_field_length, &z_utime, NULL) > 0)
  878.     {
  879.         d_t_buf[0] = (char)0;           /* signal "show local time" */
  880.         zi_time(__G__ &G.crec.last_mod_file_date, &G.crec.last_mod_file_time,
  881.           &(z_utime.modtime), d_t_buf);
  882.         Info(slide, 0, ((char *)slide, LoadFarString(UX_FileModDate),
  883.           d_t_buf, LoadFarStringSmall(LocalTime)));
  884. #ifndef NO_GMTIME
  885.         d_t_buf[0] = (char)1;           /* signal "show UTC (GMT) time" */
  886.         zi_time(__G__ &G.crec.last_mod_file_date, &G.crec.last_mod_file_time,
  887.           &(z_utime.modtime), d_t_buf);
  888.         Info(slide, 0, ((char *)slide, LoadFarString(UX_FileModDate),
  889.           d_t_buf, LoadFarStringSmall(GMTime)));
  890. #endif /* !NO_GMTIME */
  891.     }
  892. #endif /* USE_EF_UX_TIME */
  893.  
  894.     Info(slide, 0, ((char *)slide, LoadFarString(CRC32Value), G.crec.crc32));
  895.     Info(slide, 0, ((char *)slide, LoadFarString(CompressedFileSize),
  896.       G.crec.csize));
  897.     Info(slide, 0, ((char *)slide, LoadFarString(UncompressedFileSize),
  898.       G.crec.ucsize));
  899.     Info(slide, 0, ((char *)slide, LoadFarString(FilenameLength),
  900.       G.crec.filename_length));
  901.     Info(slide, 0, ((char *)slide, LoadFarString(ExtraFieldLength),
  902.       G.crec.extra_field_length));
  903.     Info(slide, 0, ((char *)slide, LoadFarString(FileCommentLength),
  904.       G.crec.file_comment_length));
  905.     Info(slide, 0, ((char *)slide, LoadFarString(FileDiskNum),
  906.       G.crec.disk_number_start));
  907.     Info(slide, 0, ((char *)slide, LoadFarString(ApparentFileType),
  908.       (G.crec.internal_file_attributes & 1)? "text"
  909.          : (G.crec.internal_file_attributes & 2)? "ebcdic"
  910.               : "binary"));             /* changed to accept EBCDIC */
  911. #ifdef ATARI
  912.     printf("  external file attributes (hex):                   %.8lx\n",
  913.       G.crec.external_file_attributes);
  914. #endif
  915.     xattr = (ush)((G.crec.external_file_attributes >> 16) & 0xFFFF);
  916.     if (hostnum == VMS_) {
  917.         char   *p=attribs, *q=attribs+1;
  918.         int    i, j, k;
  919.  
  920.         for (k = 0;  k < 12;  ++k)
  921.             workspace[k] = 0;
  922.         if (xattr & VMS_IRUSR)
  923.             workspace[0] = 'R';
  924.         if (xattr & VMS_IWUSR) {
  925.             workspace[1] = 'W';
  926.             workspace[3] = 'D';
  927.         }
  928.         if (xattr & VMS_IXUSR)
  929.             workspace[2] = 'E';
  930.         if (xattr & VMS_IRGRP)
  931.             workspace[4] = 'R';
  932.         if (xattr & VMS_IWGRP) {
  933.             workspace[5] = 'W';
  934.             workspace[7] = 'D';
  935.         }
  936.         if (xattr & VMS_IXGRP)
  937.             workspace[6] = 'E';
  938.         if (xattr & VMS_IROTH)
  939.             workspace[8] = 'R';
  940.         if (xattr & VMS_IWOTH) {
  941.             workspace[9] = 'W';
  942.             workspace[11] = 'D';
  943.         }
  944.         if (xattr & VMS_IXOTH)
  945.             workspace[10] = 'E';
  946.  
  947.         *p++ = '(';
  948.         for (k = j = 0;  j < 3;  ++j) {    /* loop over groups of permissions */
  949.             for (i = 0;  i < 4;  ++i, ++k)  /* loop over perms within a group */
  950.                 if (workspace[k])
  951.                     *p++ = workspace[k];
  952.             *p++ = ',';                       /* group separator */
  953.             if (j == 0)
  954.                 while ((*p++ = *q++) != ','); /* system, owner perms are same */
  955.         }
  956.         *p-- = 0;
  957.         *p = ')';   /* overwrite last comma */
  958.         Info(slide, 0, ((char *)slide, LoadFarString(VMSFileAttributes), xattr,
  959.           attribs));
  960.  
  961.     } else if (hostnum == AMIGA_) {
  962.         switch (xattr & AMI_IFMT) {
  963.             case AMI_IFDIR:  attribs[0] = 'd';  break;
  964.             case AMI_IFREG:  attribs[0] = '-';  break;
  965.             default:         attribs[0] = '?';  break;
  966.         }
  967.         attribs[1] = (xattr & AMI_IHIDDEN)?   'h' : '-';
  968.         attribs[2] = (xattr & AMI_ISCRIPT)?   's' : '-';
  969.         attribs[3] = (xattr & AMI_IPURE)?     'p' : '-';
  970.         attribs[4] = (xattr & AMI_IARCHIVE)?  'a' : '-';
  971.         attribs[5] = (xattr & AMI_IREAD)?     'r' : '-';
  972.         attribs[6] = (xattr & AMI_IWRITE)?    'w' : '-';
  973.         attribs[7] = (xattr & AMI_IEXECUTE)?  'e' : '-';
  974.         attribs[8] = (xattr & AMI_IDELETE)?   'd' : '-';
  975.         attribs[9] = 0;   /* better dlm the string */
  976.         Info(slide, 0, ((char *)slide, LoadFarString(AmigaFileAttributes),
  977.           xattr, attribs));
  978.  
  979.     } else if ((hostnum != FS_FAT_) && (hostnum != FS_HPFS_) &&
  980.                (hostnum != FS_NTFS_) && (hostnum != FS_VFAT_) &&
  981.                (hostnum != ACORN_) &&   /*  (hostnum != BEBOX_) &&   Be Box? */
  982.                (hostnum != VM_CMS_) && (hostnum != MVS_))
  983.     {                                 /* assume Unix-like */
  984.         switch (xattr & UNX_IFMT) {
  985.             case UNX_IFDIR:   attribs[0] = 'd';  break;
  986.             case UNX_IFREG:   attribs[0] = '-';  break;
  987.             case UNX_IFLNK:   attribs[0] = 'l';  break;
  988.             case UNX_IFBLK:   attribs[0] = 'b';  break;
  989.             case UNX_IFCHR:   attribs[0] = 'c';  break;
  990.             case UNX_IFIFO:   attribs[0] = 'p';  break;
  991.             case UNX_IFSOCK:  attribs[0] = 's';  break;
  992.             default:          attribs[0] = '?';  break;
  993.         }
  994.         attribs[1] = (xattr & UNX_IRUSR)? 'r' : '-';
  995.         attribs[4] = (xattr & UNX_IRGRP)? 'r' : '-';
  996.         attribs[7] = (xattr & UNX_IROTH)? 'r' : '-';
  997.  
  998.         attribs[2] = (xattr & UNX_IWUSR)? 'w' : '-';
  999.         attribs[5] = (xattr & UNX_IWGRP)? 'w' : '-';
  1000.         attribs[8] = (xattr & UNX_IWOTH)? 'w' : '-';
  1001.  
  1002.         if (xattr & UNX_IXUSR)
  1003.             attribs[3] = (xattr & UNX_ISUID)? 's' : 'x';
  1004.         else
  1005.             attribs[3] = (xattr & UNX_ISUID)? 'S' : '-';   /* S = undefined */
  1006.         if (xattr & UNX_IXGRP)
  1007.             attribs[6] = (xattr & UNX_ISGID)? 's' : 'x';   /* == UNX_ENFMT */
  1008.         else
  1009.             attribs[6] = (xattr & UNX_ISGID)? 'l' : '-';
  1010.         if (xattr & UNX_IXOTH)
  1011.             attribs[9] = (xattr & UNX_ISVTX)? 't' : 'x';   /* "sticky bit" */
  1012.         else
  1013.             attribs[9] = (xattr & UNX_ISVTX)? 'T' : '-';   /* T = undefined */
  1014.         attribs[10] = 0;
  1015.  
  1016.         Info(slide, 0, ((char *)slide, LoadFarString(UnixFileAttributes), xattr,
  1017.           attribs));
  1018.  
  1019.     } else {
  1020.         Info(slide, 0, ((char *)slide, LoadFarString(NonMSDOSFileAttributes),
  1021.             G.crec.external_file_attributes >> 8));
  1022.  
  1023.     } /* endif (hostnum: external attributes format) */
  1024.  
  1025.     if ((xattr=(ush)(G.crec.external_file_attributes & 0xFF)) == 0)
  1026.         Info(slide, 0, ((char *)slide, LoadFarString(MSDOSFileAttributes),
  1027.           xattr));
  1028.     else if (xattr == 1)
  1029.         Info(slide, 0, ((char *)slide, LoadFarString(MSDOSFileAttributesRO),
  1030.           xattr));
  1031.     else
  1032.         Info(slide, 0, ((char *)slide, LoadFarString(MSDOSFileAttributesAlpha),
  1033.           xattr, (xattr&1)?"rdo ":"", (xattr&2)?"hid ":"", (xattr&4)?"sys ":"",
  1034.           (xattr&8)?"lab ":"", (xattr&16)?"dir ":"", (xattr&32)?"arc":""));
  1035.     Info(slide, 0, ((char *)slide, LoadFarString(LocalHeaderOffset),
  1036.       G.crec.relative_offset_local_header, G.crec.relative_offset_local_header));
  1037.  
  1038. /*---------------------------------------------------------------------------
  1039.     Analyse the extra field, if any, and print the file comment, if any (the
  1040.     filename has already been printed, above).  That finishes up this file
  1041.     entry...
  1042.   ---------------------------------------------------------------------------*/
  1043.  
  1044.     if (G.crec.extra_field_length > 0) {
  1045.         uch *ef_ptr = G.extra_field;
  1046.         ush ef_len = G.crec.extra_field_length;
  1047.         ush ef_id, ef_datalen;
  1048.  
  1049.         if (error_in_archive > PK_WARN)   /* fatal:  can't continue */
  1050.             /* delayed "fatal error" return from extra field reading */
  1051.             return error;
  1052.         if (G.extra_field == (uch *)NULL)
  1053.             return PK_ERR;   /* not consistent with crec length */
  1054.  
  1055.         Info(slide, 0, ((char *)slide, LoadFarString(ExtraFields)));
  1056.  
  1057.         while (ef_len >= EB_HEADSIZE) {
  1058.             ef_id = makeword(&ef_ptr[EB_ID]);
  1059.             ef_datalen = makeword(&ef_ptr[EB_LEN]);
  1060.  
  1061.             if (ef_datalen > (ush)(ef_len - EB_HEADSIZE)) {
  1062.                 Info(slide, 0, ((char *)slide, LoadFarString(ExtraFieldTrunc),
  1063.                   ef_datalen, (ef_len - EB_HEADSIZE)));
  1064.                 ef_datalen = (ef_len - EB_HEADSIZE);
  1065.             }
  1066.  
  1067.             switch (ef_id) {
  1068.                 case EF_AV:
  1069.                     Info(slide, 0, ((char *)slide, LoadFarString(ExtraFieldType),
  1070.                       ef_id, LoadFarStringSmall(efAV), ef_datalen));
  1071.                     break;
  1072.                 case EF_OS2:
  1073.                     Info(slide, 0, ((char *)slide, LoadFarString(ExtraFieldType),
  1074.                       ef_id, LoadFarStringSmall(efOS2), ef_datalen));
  1075.                     if (ef_datalen >= 4)
  1076.                         Info(slide, 0, ((char *)slide, LoadFarString(OS2EAs),
  1077.                           makelong(&ef_ptr[EB_HEADSIZE])));
  1078.                     break;
  1079.                 case EF_ACL:
  1080.                     Info(slide, 0, ((char *)slide, LoadFarString(ExtraFieldType),
  1081.                       ef_id, LoadFarStringSmall(efACL), ef_datalen));
  1082.                     if (ef_datalen >= 4)
  1083.                         Info(slide, 0, ((char *)slide, LoadFarString(ACLData),
  1084.                           makelong(&ef_ptr[EB_HEADSIZE])));
  1085.                     break;
  1086.                 case EF_PKVMS:
  1087.                     Info(slide, 0, ((char *)slide, LoadFarString(ExtraFieldType),
  1088.                       ef_id, LoadFarStringSmall(efPKVMS), ef_datalen));
  1089.                     break;
  1090.                 case EF_ASIUNIX:
  1091.                     Info(slide, 0, ((char *)slide, LoadFarString(ExtraFieldType),
  1092.                       ef_id, LoadFarStringSmall(efASiUnix), ef_datalen));
  1093.                     break;
  1094.                 case EF_IZVMS:
  1095.                     Info(slide, 0, ((char *)slide, LoadFarString(ExtraFieldType),
  1096.                       ef_id, LoadFarStringSmall(efIZVMS), ef_datalen));
  1097.                     break;
  1098.                 case EF_IZUNIX:
  1099.                     Info(slide, 0, ((char *)slide, LoadFarString(ExtraFieldType),
  1100.                       ef_id, LoadFarStringSmall(efIZUnix), ef_datalen));
  1101.                     break;
  1102.                 case EF_VMCMS:
  1103.                     Info(slide, 0, ((char *)slide, LoadFarString(ExtraFieldType),
  1104.                       ef_id, LoadFarStringSmall(efVMCMS), ef_datalen));
  1105.                     break;
  1106.                 case EF_MVS:
  1107.                     Info(slide, 0, ((char *)slide, LoadFarString(ExtraFieldType),
  1108.                       ef_id, LoadFarStringSmall(efMVS), ef_datalen));
  1109.                     break;
  1110.                 case EF_SPARK:   /* from RISCOS */
  1111.                     Info(slide, 0, ((char *)slide, LoadFarString(ExtraFieldType),
  1112.                       ef_id, LoadFarStringSmall(efSpark), ef_datalen));
  1113.                     break;
  1114.                 case EF_MD5:
  1115.                     Info(slide, 0, ((char *)slide, LoadFarString(ExtraFieldType),
  1116.                       ef_id, LoadFarStringSmall(efMD5), ef_datalen));
  1117.                     break;
  1118.                 default:
  1119.                     Info(slide, 0, ((char *)slide, LoadFarString(ExtraFieldType),
  1120.                       ef_id, LoadFarStringSmall(efUnknown), ef_datalen));
  1121.                     break;
  1122.             }
  1123. #ifdef CMS_MVS
  1124.             if (ef_id == EF_VMCMS || ef_id == EF_MVS) {
  1125.                char type[100];
  1126.  
  1127.                Info(slide, 0, ((char *)slide, LoadFarString(VmMvsExtraField),
  1128.                     (getVMMVSexfield(type, ef_ptr, (unsigned)ef_datalen) > 0)
  1129.                     ? type : LoadFarStringSmall(VmMvsInvalid)));
  1130.             } else
  1131. #endif /* CMS_MVS */
  1132.             if (ef_id != EF_OS2 && ef_id != EF_ACL) {
  1133.                 ush i, n;
  1134.  
  1135.                 if (ef_datalen <= 16) {
  1136.                     Info(slide, 0, ((char *)slide, LoadFarString(ColonIndent)));
  1137.                     n = ef_datalen;
  1138.                 } else {
  1139.                     Info(slide, 0, ((char *)slide, LoadFarString(First16),
  1140.                       LoadFarStringSmall(ColonIndent)));
  1141.                     n = 16;
  1142.                 }
  1143.                 for (i = 0;  i < n;  ++i)
  1144.                     Info(slide, 0, ((char *)slide, LoadFarString(efFormat),
  1145.                       ef_ptr[i+EB_HEADSIZE]));
  1146.             }
  1147.  
  1148.             ef_ptr += (ef_datalen + EB_HEADSIZE);
  1149.             ef_len -= (ef_datalen + EB_HEADSIZE);
  1150.         }
  1151.         (*G.message)((zvoid *)&G, (uch *)"\n", 1L, 0);
  1152.     }
  1153.  
  1154.     /* high bit == Unix/OS2/NT GMT times (mtime, atime); next bit == UID/GID */
  1155.     if ((xattr = (ush)((G.crec.external_file_attributes & 0xC000) >> 12)) & 8)
  1156.         if (hostnum == UNIX_ && xattr == 12)
  1157.             Info(slide, 0, ((char *)slide, LoadFarString(lExtraFieldType),
  1158.               "is", EF_IZUNIX, LoadFarStringSmall(efIZUnix), xattr, efIZuid));
  1159.         else if (hostnum == UNIX_ || hostnum == FS_HPFS_ || hostnum == FS_NTFS_)
  1160.             Info(slide, 0, ((char *)slide, LoadFarString(lExtraFieldType),
  1161.               "is", EF_IZUNIX, LoadFarStringSmall(efIZUnix), xattr,
  1162.               (xattr&4)? efIZuid : efIZnouid));
  1163.         else if (hostnum == FS_FAT_ && !(xattr&4))
  1164.             Info(slide, 0, ((char *)slide, LoadFarString(lExtraFieldType),
  1165.               "may be", EF_IZUNIX, LoadFarStringSmall(efIZUnix), xattr,
  1166.               (xattr&4)? efIZuid : efIZnouid));
  1167.  
  1168.     if (!G.crec.file_comment_length)
  1169.         Info(slide, 0, ((char *)slide, LoadFarString(NoFileComment)));
  1170.     else {
  1171.         Info(slide, 0, ((char *)slide, LoadFarString(FileCommBegin)));
  1172.         if ((error = do_string(__G__ G.crec.file_comment_length, DISPLAY)) != PK_COOL) {
  1173.             error_in_archive = error;   /* might be warning */
  1174.             if (error > PK_WARN)   /* fatal */
  1175.                 return error;
  1176.         }
  1177.         Info(slide, 0, ((char *)slide, LoadFarString(FileCommEnd)));
  1178.     }
  1179.  
  1180.     return error_in_archive;
  1181.  
  1182. } /* end function zi_long() */
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188. /*************************/
  1189. /*  Function zi_short()  */
  1190. /*************************/
  1191.  
  1192. static int zi_short(__G)   /* return PK-type error code */
  1193.      __GDEF
  1194. {
  1195. #ifdef USE_EF_UX_TIME
  1196.     ztimbuf     z_utime;
  1197.     time_t      *z_modtim;
  1198. #endif
  1199.     int         k, error, error_in_archive=PK_COOL;
  1200.     ush         methnum, hostnum, hostver, xattr;
  1201.     char        *p, workspace[12], attribs[16];
  1202.     char        methbuf[5];
  1203.     static char dtype[5]="NXFS";  /* normal, maximum, fast, superfast */
  1204.     static char Far os[NUM_HOSTS+1][4] = {
  1205.         "fat", "ami", "vms", "unx", "cms", "atr", "hpf", "mac", "zzz",
  1206.         "cpm", "t20", "ntf", "qds", "aco", "vft", "mvs", "be ", "???"
  1207.     };
  1208.     static char Far method[NUM_METHODS+1][5] = {
  1209.         "stor", "shrk", "re:1", "re:2", "re:3", "re:4", "i#:#", "tokn",
  1210.         "def#", "u###"
  1211.     };
  1212.  
  1213.  
  1214. /*---------------------------------------------------------------------------
  1215.     Print out various interesting things about the compressed file.
  1216.   ---------------------------------------------------------------------------*/
  1217.  
  1218.     methnum = (ush)MIN(G.crec.compression_method, NUM_METHODS);
  1219.     hostnum = (ush)MIN(G.crec.version_made_by[1], NUM_HOSTS);
  1220.     hostver = G.crec.version_made_by[0];
  1221. /*
  1222.     extnum = MIN(G.crec.version_needed_to_extract[1], NUM_HOSTS);
  1223.     extver = G.crec.version_needed_to_extract[0];
  1224.  */
  1225.  
  1226.     zfstrcpy(methbuf, method[methnum]);
  1227.     if (methnum == IMPLODED) {
  1228.         methbuf[1] = (char)((G.crec.general_purpose_bit_flag & 2)? '8' : '4');
  1229.         methbuf[3] = (char)((G.crec.general_purpose_bit_flag & 4)? '3' : '2');
  1230.     } else if (methnum == DEFLATED) {
  1231.         ush  dnum=(ush)((G.crec.general_purpose_bit_flag>>1) & 3);
  1232.         methbuf[3] = dtype[dnum];
  1233.     } else if (methnum >= NUM_METHODS) {   /* unknown */
  1234.         sprintf(&methbuf[1], "%03u", G.crec.compression_method);
  1235.     }
  1236.  
  1237.     for (k = 0;  k < 15;  ++k)
  1238.         attribs[k] = ' ';
  1239.     attribs[15] = 0;
  1240.  
  1241.     xattr = (ush)((G.crec.external_file_attributes >> 16) & 0xFFFF);
  1242.     switch (hostnum) {
  1243.         case VMS_:
  1244.             {   int    i, j;
  1245.  
  1246.                 for (k = 0;  k < 12;  ++k)
  1247.                     workspace[k] = 0;
  1248.                 if (xattr & VMS_IRUSR)
  1249.                     workspace[0] = 'R';
  1250.                 if (xattr & VMS_IWUSR) {
  1251.                     workspace[1] = 'W';
  1252.                     workspace[3] = 'D';
  1253.                 }
  1254.                 if (xattr & VMS_IXUSR)
  1255.                     workspace[2] = 'E';
  1256.                 if (xattr & VMS_IRGRP)
  1257.                     workspace[4] = 'R';
  1258.                 if (xattr & VMS_IWGRP) {
  1259.                     workspace[5] = 'W';
  1260.                     workspace[7] = 'D';
  1261.                 }
  1262.                 if (xattr & VMS_IXGRP)
  1263.                   workspace[6] = 'E';
  1264.                 if (xattr & VMS_IROTH)
  1265.                     workspace[8] = 'R';
  1266.                 if (xattr & VMS_IWOTH) {
  1267.                     workspace[9] = 'W';
  1268.                     workspace[11] = 'D';
  1269.                 }
  1270.                 if (xattr & VMS_IXOTH)
  1271.                     workspace[10] = 'E';
  1272.  
  1273.                 p = attribs;
  1274.                 for (k = j = 0;  j < 3;  ++j) {     /* groups of permissions */
  1275.                     for (i = 0;  i < 4;  ++i, ++k)  /* perms within a group */
  1276.                         if (workspace[k])
  1277.                             *p++ = workspace[k];
  1278.                     *p++ = ',';                     /* group separator */
  1279.                 }
  1280.                 *--p = ' ';   /* overwrite last comma */
  1281.                 if ((p - attribs) < 12)
  1282.                     sprintf(&attribs[12], "%d.%d", hostver/10, hostver%10);
  1283.             }
  1284.             break;
  1285.  
  1286.         case FS_FAT_:
  1287.         case FS_HPFS_:
  1288.         case FS_NTFS_:
  1289.         case VM_CMS_:
  1290.         case FS_VFAT_:
  1291.         case MVS_:
  1292.         case BEBOX_:      /* GRR:  guessing */
  1293.         case ACORN_:
  1294.             xattr = (ush)(G.crec.external_file_attributes & 0xFF);
  1295.             sprintf(attribs, ".r.-...     %d.%d", hostver/10, hostver%10);
  1296.             attribs[2] = (xattr & 0x01)? '-' : 'w';
  1297.             attribs[5] = (xattr & 0x02)? 'h' : '-';
  1298.             attribs[6] = (xattr & 0x04)? 's' : '-';
  1299.             attribs[4] = (xattr & 0x20)? 'a' : '-';
  1300.             if (xattr & 0x10) {
  1301.                 attribs[0] = 'd';
  1302.                 attribs[3] = 'x';
  1303.             } else
  1304.                 attribs[0] = '-';
  1305.             if (IS_VOLID(xattr))
  1306.                 attribs[0] = 'V';
  1307.             else if ((p = strrchr(G.filename, '.')) != (char *)NULL) {
  1308.                 ++p;
  1309.                 if (STRNICMP(p, "com", 3) == 0 || STRNICMP(p, "exe", 3) == 0 ||
  1310.                     STRNICMP(p, "btm", 3) == 0 || STRNICMP(p, "cmd", 3) == 0 ||
  1311.                     STRNICMP(p, "bat", 3) == 0)
  1312.                     attribs[3] = 'x';
  1313.             }
  1314.             break;
  1315.  
  1316.         case AMIGA_:
  1317.             switch (xattr & AMI_IFMT) {
  1318.                 case AMI_IFDIR:  attribs[0] = 'd';  break;
  1319.                 case AMI_IFREG:  attribs[0] = '-';  break;
  1320.                 default:         attribs[0] = '?';  break;
  1321.             }
  1322.             attribs[1] = (xattr & AMI_IHIDDEN)?   'h' : '-';
  1323.             attribs[2] = (xattr & AMI_ISCRIPT)?   's' : '-';
  1324.             attribs[3] = (xattr & AMI_IPURE)?     'p' : '-';
  1325.             attribs[4] = (xattr & AMI_IARCHIVE)?  'a' : '-';
  1326.             attribs[5] = (xattr & AMI_IREAD)?     'r' : '-';
  1327.             attribs[6] = (xattr & AMI_IWRITE)?    'w' : '-';
  1328.             attribs[7] = (xattr & AMI_IEXECUTE)?  'e' : '-';
  1329.             attribs[8] = (xattr & AMI_IDELETE)?   'd' : '-';
  1330.             sprintf(&attribs[12], "%d.%d", hostver/10, hostver%10);
  1331.             break;
  1332.  
  1333.         default:   /* assume Unix-like */
  1334.             switch (xattr & UNX_IFMT) {
  1335.                 case UNX_IFDIR:   attribs[0] = 'd';  break;
  1336.                 case UNX_IFREG:   attribs[0] = '-';  break;
  1337.                 case UNX_IFLNK:   attribs[0] = 'l';  break;
  1338.                 case UNX_IFBLK:   attribs[0] = 'b';  break;
  1339.                 case UNX_IFCHR:   attribs[0] = 'c';  break;
  1340.                 case UNX_IFIFO:   attribs[0] = 'p';  break;
  1341.                 case UNX_IFSOCK:  attribs[0] = 's';  break;
  1342.                 default:          attribs[0] = '?';  break;
  1343.             }
  1344.             attribs[1] = (xattr & UNX_IRUSR)? 'r' : '-';
  1345.             attribs[4] = (xattr & UNX_IRGRP)? 'r' : '-';
  1346.             attribs[7] = (xattr & UNX_IROTH)? 'r' : '-';
  1347.             attribs[2] = (xattr & UNX_IWUSR)? 'w' : '-';
  1348.             attribs[5] = (xattr & UNX_IWGRP)? 'w' : '-';
  1349.             attribs[8] = (xattr & UNX_IWOTH)? 'w' : '-';
  1350.  
  1351.             if (xattr & UNX_IXUSR)
  1352.                 attribs[3] = (xattr & UNX_ISUID)? 's' : 'x';
  1353.             else
  1354.                 attribs[3] = (xattr & UNX_ISUID)? 'S' : '-';  /* S==undefined */
  1355.             if (xattr & UNX_IXGRP)
  1356.                 attribs[6] = (xattr & UNX_ISGID)? 's' : 'x';  /* == UNX_ENFMT */
  1357.             else
  1358.                 /* attribs[6] = (xattr & UNX_ISGID)? 'l' : '-';  real 4.3BSD */
  1359.                 attribs[6] = (xattr & UNX_ISGID)? 'S' : '-';  /* SunOS 4.1.x */
  1360.             if (xattr & UNX_IXOTH)
  1361.                 attribs[9] = (xattr & UNX_ISVTX)? 't' : 'x';  /* "sticky bit" */
  1362.             else
  1363.                 attribs[9] = (xattr & UNX_ISVTX)? 'T' : '-';  /* T==undefined */
  1364.  
  1365.             sprintf(&attribs[12], "%d.%d", hostver/10, hostver%10);
  1366.             break;
  1367.  
  1368.     } /* end switch (hostnum: external attributes format) */
  1369.  
  1370.     Info(slide, 0, ((char *)slide, "%s %s %7lu ", attribs,
  1371.       LoadFarStringSmall(os[hostnum]), G.crec.ucsize));
  1372.     Info(slide, 0, ((char *)slide, "%c",
  1373.       (G.crec.general_purpose_bit_flag & 1)?
  1374.       ((G.crec.internal_file_attributes & 1)? 'T' : 'B') :  /* encrypted */
  1375.       ((G.crec.internal_file_attributes & 1)? 't' : 'b'))); /* plaintext */
  1376.     Info(slide, 0, ((char *)slide, "%c",
  1377.       (G.crec.extra_field_length || G.crec.external_file_attributes & 0xC000)?
  1378.       ((G.crec.general_purpose_bit_flag & 8)? 'X' : 'x') :  /* extra field */
  1379.       ((G.crec.general_purpose_bit_flag & 8)? 'l' : '-'))); /* no extra field */
  1380.       /* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ extended local header or not */
  1381.  
  1382.     if (G.lflag == 4) {
  1383.         ulg csiz = G.crec.csize;
  1384.  
  1385.         if (G.crec.general_purpose_bit_flag & 1)
  1386.             csiz -= 12;    /* if encrypted, don't count encryption header */
  1387.         Info(slide, 0, ((char *)slide, "%3d%%",
  1388.           (ratio(G.crec.ucsize,csiz)+5)/10));
  1389.     } else if (G.lflag == 5)
  1390.         Info(slide, 0, ((char *)slide, " %7lu", G.crec.csize));
  1391.  
  1392.     /* Read the extra field, if any.  The extra field info may be used
  1393.      * in the file modification time section, below.
  1394.      */
  1395.     if ((error = do_string(__G__ G.crec.extra_field_length, EXTRA_FIELD)) != 0)
  1396.     {
  1397.         if (G.extra_field != NULL) {
  1398.             free(G.extra_field);
  1399.             G.extra_field = NULL;
  1400.         }
  1401.         error_in_archive = error;
  1402.         /* We do not return prematurely in case of a "fatal" error (PK_EOF).
  1403.          * This does not hurt here, because we do not need to read from the
  1404.          * zipfile again before the end of this function.
  1405.          */
  1406.     }
  1407.  
  1408.     /* For printing of date & time, a "char d_t_buf[16]" is required.
  1409.      * To save stack space, we reuse the "char attribs[16]" buffer whose
  1410.      * content is no longer needed.
  1411.      */
  1412. #   define d_t_buf attribs
  1413. #ifdef USE_EF_UX_TIME
  1414.     z_modtim = (G.extra_field && ef_scan_for_izux(G.extra_field,
  1415.       G.crec.extra_field_length, &z_utime, NULL) > 0)? &z_utime.modtime : NULL;
  1416.     d_t_buf[0] = (char)0;   /* signal "show local time" */
  1417. #else
  1418. #   define z_modtim NULL
  1419. #endif
  1420.     Info(slide, 0, ((char *)slide, " %s %s ", methbuf,
  1421.       zi_time(__G__ &G.crec.last_mod_file_date, &G.crec.last_mod_file_time,
  1422.       z_modtim, d_t_buf)));
  1423.     fnprint(__G);
  1424.  
  1425. /*---------------------------------------------------------------------------
  1426.     Skip the file comment, if any (the filename has already been printed,
  1427.     above).  That finishes up this file entry...
  1428.   ---------------------------------------------------------------------------*/
  1429.  
  1430.     SKIP_(G.crec.file_comment_length)
  1431.  
  1432.     return error_in_archive;
  1433.  
  1434. } /* end function zi_short() */
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440. /************************/
  1441. /*  Function zi_time()  */
  1442. /************************/
  1443.  
  1444. static char *zi_time(__G__ datez, timez, modtimez, d_t_str)
  1445.     __GDEF
  1446.     const ush *datez, *timez;
  1447.     const time_t *modtimez;
  1448.     char *d_t_str;
  1449. {
  1450.     ush yr, mo, dy, hh, mm, ss;
  1451.     char monthbuf[4];
  1452.     char *monthstr;
  1453.     static char Far month[12][4] = {
  1454.         "Jan", "Feb", "Mar", "Apr", "May", "Jun",
  1455.         "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
  1456.     };
  1457.  
  1458.  
  1459.  
  1460. /*---------------------------------------------------------------------------
  1461.     Convert the file-modification date and time info to a string of the form
  1462.     "1991 Feb 23 17:15:00", "23-Feb-91 17:15" or "19910223.171500", depending
  1463.     on values of lflag and T_flag.  If using Unix-time extra fields, convert
  1464.     to local time or not, depending on value of first character in d_t_str[].
  1465.   ---------------------------------------------------------------------------*/
  1466.  
  1467. #ifdef USE_EF_UX_TIME
  1468.     if (modtimez != NULL) {
  1469.         struct tm *t;
  1470.  
  1471. #ifndef NO_GMTIME
  1472.         /* check for our secret message from above... */
  1473.         t = (d_t_str[0] == (char)1)? gmtime(modtimez) : localtime(modtimez);
  1474. #else
  1475.         t = localtime(modtimez);
  1476. #endif
  1477.         mo = (ush)(t->tm_mon + 1);
  1478.         dy = (ush)(t->tm_mday);
  1479.         yr = (ush)(t->tm_year);
  1480.  
  1481.         hh = (ush)(t->tm_hour);
  1482.         mm = (ush)(t->tm_min);
  1483.         ss = (ush)(t->tm_sec);
  1484.     } else
  1485. #endif /* USE_EF_UX_TIME */
  1486.     {
  1487.         yr = (ush)(((*datez >> 9) & 0x7f) + 80);
  1488.         mo = (ush)((*datez >> 5) & 0x0f);
  1489.         dy = (ush)(*datez & 0x1f);
  1490.  
  1491.         hh = (ush)((*timez >> 11) & 0x1f);
  1492.         mm = (ush)((*timez >> 5) & 0x3f);
  1493.         ss = (ush)((*timez & 0x1f) * 2);
  1494.     }
  1495.  
  1496.     if (mo == 0 || mo > 12) {
  1497.         sprintf(monthbuf, LoadFarString(BogusFmt), mo);
  1498.         monthstr = monthbuf;
  1499.     } else
  1500.         monthstr = LoadFarStringSmall(month[mo-1]);
  1501.  
  1502.     if (G.lflag > 9)  /* verbose listing format */
  1503.         sprintf(d_t_str, LoadFarString(YMDHMSTime), yr+1900, monthstr, dy, hh,
  1504.           mm, ss);
  1505.     else if (G.T_flag)
  1506.         sprintf(d_t_str, LoadFarString(DecimalTime), yr+1900, mo, dy, hh, mm,
  1507.           ss);
  1508.     else   /* was:  if ((lflag >= 3) && (lflag <= 5)) */
  1509.         sprintf(d_t_str, LoadFarString(DMYHMTime), dy, monthstr, yr%100, hh,
  1510.           mm);
  1511.  
  1512.     return d_t_str;
  1513.  
  1514. } /* end function zi_time() */
  1515.  
  1516. #endif /* !NO_ZIPINFO */
  1517.