home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / unzip532.zip / list.c < prev    next >
C/C++ Source or Header  |  1997-10-12  |  23KB  |  628 lines

  1. /*---------------------------------------------------------------------------
  2.  
  3.   list.c
  4.  
  5.   This file contains the non-ZipInfo-specific listing routines for UnZip.
  6.  
  7.   Contains:  list_files()
  8.              get_time_stamp()   [optional feature]
  9.              ratio()
  10.              fnprint()
  11.  
  12.   ---------------------------------------------------------------------------*/
  13.  
  14.  
  15. #define UNZIP_INTERNAL
  16. #include "unzip.h"
  17. #ifdef WINDLL
  18. #  ifdef POCKET_UNZIP
  19. #    include "wince/intrface.h"
  20. #  else
  21. #    include "windll/windll.h"
  22. #  endif
  23. #endif
  24.  
  25.  
  26. #ifdef TIMESTAMP
  27.    static int  fn_is_dir   OF((__GPRO));
  28. #endif
  29.  
  30. #ifndef WINDLL
  31. static char Far CompFactorStr[] = "%c%d%%";
  32. static char Far CompFactor100[] = "100%%";
  33.  
  34. #ifdef OS2_EAS
  35.    static char Far HeadersS[]  =
  36.      " Length    EAs   ACLs    Date    Time    Name";
  37.    static char Far HeadersS1[] =
  38.      " ------    ---   ----    ----    ----    ----";
  39. #else
  40.    static char Far HeadersS[]  = " Length    Date    Time    Name";
  41.    static char Far HeadersS1[] = " ------    ----    ----    ----";
  42. #endif
  43.  
  44.    static char Far HeadersL[]  =
  45.      " Length  Method   Size  Ratio   Date    Time   CRC-32     Name";
  46.    static char Far HeadersL1[] =
  47.      " ------  ------   ----  -----   ----    ----   ------     ----";
  48.    static char Far *Headers[][2] =
  49.      { {HeadersS, HeadersS1}, {HeadersL, HeadersL1} };
  50.  
  51.    static char Far CaseConversion[] = "%s (\"^\" ==> case\n%s   conversion)\n";
  52.    static char Far LongHdrStats[] =
  53.      "%7lu  %-7s%7lu %4s  %02u-%02u-%02u  %02u:%02u  %08lx  %c";
  54.    static char Far LongFileTrailer[] =
  55.      " ------          ------  ---                         \
  56.      -------\n%7lu         %7lu %4s                              %u file%s\n";
  57. #ifdef OS2_EAS
  58.    static char Far ShortHdrStats[] =
  59.      "%7lu %6lu %6lu  %02u-%02u-%02u  %02u:%02u  %c";
  60.    static char Far ShortFileTrailer[] = " ------  -----  -----        \
  61.             -------\n%7lu %6lu %6lu                    %u file%s\n";
  62.    static char Far OS2ExtAttrTrailer[] =
  63.       "%ld file%s %ld bytes of OS/2 extended attributes attached.\n";
  64.    static char Far OS2ACLTrailer[] =
  65.       "%ld file%s %ld bytes of access control lists attached.\n";
  66. #else
  67.    static char Far ShortHdrStats[] = "%7lu  %02u-%02u-%02u  %02u:%02u  %c";
  68.    static char Far ShortFileTrailer[] =
  69.      " ------                    -------\n%7lu                    %u file%s\n";
  70. #endif /* ?OS2_EAS */
  71. #endif /* ?WINDLL */
  72.  
  73.  
  74.  
  75.  
  76.  
  77. /*************************/
  78. /* Function list_files() */
  79. /*************************/
  80.  
  81. int list_files(__G)    /* return PK-type error code */
  82.     __GDEF
  83. {
  84.     int do_this_file=FALSE, cfactor, error, error_in_archive=PK_COOL;
  85. #ifndef WINDLL
  86.     char sgn, cfactorstr[10];
  87.     int longhdr=(G.vflag>1);
  88. #endif
  89.     int date_format;
  90.     unsigned j, methnum, members=0;
  91. #ifdef USE_EF_UT_TIME
  92.     iztimes z_utime;
  93. #endif
  94.     ush yr, mo, dy, hh, mm;
  95.     ulg csiz, tot_csize=0L, tot_ucsize=0L;
  96. #ifdef OS2_EAS
  97.     ulg ea_size, tot_easize=0L, tot_eafiles=0L;
  98.     ulg acl_size, tot_aclsize=0L, tot_aclfiles=0L;
  99. #endif
  100.     min_info info;
  101.     char methbuf[8];
  102.     static char dtype[]="NXFS";   /* see zi_short() */
  103.     static char Far method[NUM_METHODS+1][8] =
  104.         {"Stored", "Shrunk", "Reduce1", "Reduce2", "Reduce3", "Reduce4",
  105.          "Implode", "Token", "Defl:#", "EnhDefl", "ImplDCL", "Unk:###"};
  106.  
  107.  
  108.  
  109. /*---------------------------------------------------------------------------
  110.     Unlike extract_or_test_files(), this routine confines itself to the cen-
  111.     tral directory.  Thus its structure is somewhat simpler, since we can do
  112.     just a single loop through the entire directory, listing files as we go.
  113.  
  114.     So to start off, print the heading line and then begin main loop through
  115.     the central directory.  The results will look vaguely like the following:
  116.  
  117.   Length  Method   Size  Ratio   Date    Time   CRC-32     Name ("^" ==> case
  118.   ------  ------   ----  -----   ----    ----   ------     ----   conversion)
  119.    44004  Implode  13041  71%  11-02-89  19:34  8b4207f7   Makefile.UNIX
  120.     3438  Shrunk    2209  36%  09-15-90  14:07  a2394fd8  ^dos-file.ext
  121.   ---------------------------------------------------------------------------*/
  122.  
  123.     G.pInfo = &info;
  124.     date_format = DATE_FORMAT;
  125.  
  126. #ifndef WINDLL
  127.     if (G.qflag < 2)
  128.         if (G.L_flag)
  129.             Info(slide, 0, ((char *)slide, LoadFarString(CaseConversion),
  130.               LoadFarStringSmall(Headers[longhdr][0]),
  131.               LoadFarStringSmall2(Headers[longhdr][1])));
  132.         else
  133.             Info(slide, 0, ((char *)slide, "%s\n%s\n",
  134.                LoadFarString(Headers[longhdr][0]),
  135.                LoadFarStringSmall(Headers[longhdr][1])));
  136. #endif /* !WINDLL */
  137.  
  138.     for (j = 0; j < (unsigned)G.ecrec.total_entries_central_dir; ++j) {
  139.  
  140.         if (readbuf(__G__ G.sig, 4) == 0)
  141.             return PK_EOF;
  142.         if (strncmp(G.sig, G.central_hdr_sig, 4)) {  /* just to make sure */
  143.             Info(slide, 0x401, ((char *)slide, LoadFarString(CentSigMsg), j));
  144.             Info(slide, 0x401, ((char *)slide, LoadFarString(ReportMsg)));
  145.             return PK_BADERR;
  146.         }
  147.         /* process_cdir_file_hdr() sets pInfo->lcflag: */
  148.         if ((error = process_cdir_file_hdr(__G)) != PK_COOL)
  149.             return error;       /* only PK_EOF defined */
  150.  
  151.         /*
  152.          * We could DISPLAY the filename instead of storing (and possibly trun-
  153.          * cating, in the case of a very long name) and printing it, but that
  154.          * has the disadvantage of not allowing case conversion--and it's nice
  155.          * to be able to see in the listing precisely how you have to type each
  156.          * filename in order for unzip to consider it a match.  Speaking of
  157.          * which, if member names were specified on the command line, check in
  158.          * with match() to see if the current file is one of them, and make a
  159.          * note of it if it is.
  160.          */
  161.  
  162.         if ((error = do_string(__G__ G.crec.filename_length, DS_FN)) !=
  163.              PK_COOL)   /*  ^--(uses pInfo->lcflag) */
  164.         {
  165.             error_in_archive = error;
  166.             if (error > PK_WARN)   /* fatal:  can't continue */
  167.                 return error;
  168.         }
  169.         if (G.extra_field != (uch *)NULL) {
  170.             free(G.extra_field);
  171.             G.extra_field = (uch *)NULL;
  172.         }
  173.         if ((error = do_string(__G__ G.crec.extra_field_length, EXTRA_FIELD))
  174.             != 0)
  175.         {
  176.             error_in_archive = error;
  177.             if (error > PK_WARN)      /* fatal */
  178.                 return error;
  179.         }
  180.         if (!G.process_all_files) {   /* check if specified on command line */
  181.             char **pfn = G.pfnames-1;
  182.  
  183.             do_this_file = FALSE;
  184.             while (*++pfn)
  185.                 if (match(G.filename, *pfn, G.C_flag)) {
  186.                     do_this_file = TRUE;
  187.                     break;       /* found match, so stop looping */
  188.                 }
  189.             if (do_this_file) {  /* check if this is an excluded file */
  190.                 char **pxn = G.pxnames-1;
  191.  
  192.                 while (*++pxn)
  193.                     if (match(G.filename, *pxn, G.C_flag)) {
  194.                         do_this_file = FALSE;  /* ^-- ignore case in match */
  195.                         break;
  196.                     }
  197.             }
  198.         }
  199.         /*
  200.          * If current file was specified on command line, or if no names were
  201.          * specified, do the listing for this file.  Otherwise, get rid of the
  202.          * file comment and go back for the next file.
  203.          */
  204.  
  205.         if (G.process_all_files || do_this_file) {
  206.  
  207. #ifdef OS2DLL
  208.             /* this is used by UzpFileTree() to allow easy processing of lists
  209.              * of zip directory contents */
  210.             if (G.processExternally)
  211.                 if ((G.processExternally)(G.filename, &G.crec))
  212.                     break;
  213.                 else
  214.                     continue;
  215. #endif
  216. #ifdef OS2_EAS
  217.             {
  218.                 uch *ef_ptr = G.extra_field;
  219.                 int ef_size, ef_len = G.crec.extra_field_length;
  220.                 ea_size = acl_size = 0;
  221.  
  222.                 while (ef_len >= EB_HEADSIZE) {
  223.                     ef_size = makeword(&ef_ptr[EB_LEN]);
  224.                     switch (makeword(&ef_ptr[EB_ID])) {
  225.                         case EF_OS2:
  226.                             ea_size = makelong(&ef_ptr[EB_HEADSIZE]);
  227.                             break;
  228.                         case EF_ACL:
  229.                             acl_size = makelong(&ef_ptr[EB_HEADSIZE]);
  230.                             break;
  231.                     }
  232.                     ef_ptr += (ef_size + EB_HEADSIZE);
  233.                     ef_len -= (ef_size + EB_HEADSIZE);
  234.                 }
  235.             }
  236. #endif
  237. #ifdef USE_EF_UT_TIME
  238.             if (G.extra_field &&
  239.                 (ef_scan_for_izux(G.extra_field, G.crec.extra_field_length, 1,
  240.                                   G.crec.last_mod_file_date, &z_utime, NULL)
  241.                  & EB_UT_FL_MTIME))
  242.             {
  243.                 struct tm *t;
  244.  
  245.                 TIMET_TO_NATIVE(z_utime.mtime)   /* NOP unless MSC 7.0, Mac */
  246.                 t = localtime(&(z_utime.mtime));
  247.                 mo = (ush)(t->tm_mon + 1);
  248.                 dy = (ush)(t->tm_mday);
  249.                 yr = (ush)(t->tm_year % 100);
  250.                 hh = (ush)(t->tm_hour);
  251.                 mm = (ush)(t->tm_min);
  252.             } else
  253. #endif /* USE_EF_UT_TIME */
  254.             {
  255.                 yr = (ush)((((G.crec.last_mod_file_date >> 9) & 0x7f) + 80) %
  256.                            (unsigned)100);
  257.                 mo = (ush)((G.crec.last_mod_file_date >> 5) & 0x0f);
  258.                 dy = (ush)(G.crec.last_mod_file_date & 0x1f);
  259.                 hh = (ush)((G.crec.last_mod_file_time >> 11) & 0x1f);
  260.                 mm = (ush)((G.crec.last_mod_file_time >> 5) & 0x3f);
  261.             }
  262.             /* permute date so it displays according to nat'l convention
  263.              * ('methnum' is not yet set, it is used as temporary buffer) */
  264.             switch (date_format) {
  265.                 case DF_YMD:
  266.                     methnum = (unsigned)mo;
  267.                     mo = yr; yr = dy; dy = (ush)methnum;
  268.                     break;
  269.                 case DF_DMY:
  270.                     methnum = (unsigned)mo;
  271.                     mo = dy; dy = (ush)methnum;
  272.             }
  273.  
  274.             csiz = G.crec.csize;
  275.             if (G.crec.general_purpose_bit_flag & 1)
  276.                 csiz -= 12;   /* if encrypted, don't count encryption header */
  277.             if ((cfactor = ratio(G.crec.ucsize, csiz)) < 0) {
  278. #ifndef WINDLL
  279.                 sgn = '-';
  280. #endif
  281.                 cfactor = (-cfactor + 5) / 10;
  282.             } else {
  283. #ifndef WINDLL
  284.                 sgn = ' ';
  285. #endif
  286.                 cfactor = (cfactor + 5) / 10;
  287.             }
  288.  
  289.             methnum = MIN(G.crec.compression_method, NUM_METHODS);
  290.             zfstrcpy(methbuf, method[methnum]);
  291.             if (methnum == DEFLATED) {
  292.                 methbuf[5] = dtype[(G.crec.general_purpose_bit_flag>>1) & 3];
  293.             } else if (methnum >= NUM_METHODS) {
  294.                 sprintf(&methbuf[4], "%03u", G.crec.compression_method);
  295.             }
  296.  
  297. #if 0       /* GRR/Euro:  add this? */
  298. #if defined(DOS_FLX_OS2_W32) || defined(UNIX)
  299.             for (p = G.filename;  *p;  ++p)
  300.                 if (!isprint(*p))
  301.                     *p = '?';  /* change non-printable chars to '?' */
  302. #endif /* DOS_FLX_OS2_W32 || UNIX */
  303. #endif /* 0 */
  304.  
  305. #ifdef WINDLL
  306.             /* send data to application for formatting and printing */
  307.             (*lpUserFunctions->SendApplicationMessage)(G.crec.ucsize, csiz,
  308.               (ush)cfactor, mo, dy, yr, hh, mm,
  309.               (char)(G.pInfo->lcflag ? '^' : ' '),
  310.               (LPSTR)fnfilter(G.filename, slide), (LPSTR)methbuf, G.crec.crc32,
  311.               (char)((G.crec.general_purpose_bit_flag & 1) ? 'E' : ' '));
  312. #else /* !WINDLL */
  313.             if (cfactor == 100)
  314.                 sprintf(cfactorstr, LoadFarString(CompFactor100));
  315.             else
  316.                 sprintf(cfactorstr, LoadFarString(CompFactorStr), sgn, cfactor);
  317.             if (longhdr)
  318.                 Info(slide, 0, ((char *)slide, LoadFarString(LongHdrStats),
  319.                   G.crec.ucsize, methbuf, csiz, cfactorstr, mo, dy,
  320.                   yr, hh, mm, G.crec.crc32, (G.pInfo->lcflag? '^':' ')));
  321.             else
  322. #ifdef OS2_EAS
  323.                 Info(slide, 0, ((char *)slide, LoadFarString(ShortHdrStats),
  324.                   G.crec.ucsize, ea_size, acl_size,
  325.                   mo, dy, yr, hh, mm, (G.pInfo->lcflag? '^':' ')));
  326. #else
  327.                 Info(slide, 0, ((char *)slide, LoadFarString(ShortHdrStats),
  328.                   G.crec.ucsize,
  329.                   mo, dy, yr, hh, mm, (G.pInfo->lcflag? '^':' ')));
  330. #endif
  331.             fnprint(__G);
  332. #endif /* ?WINDLL */
  333.  
  334.             if ((error = do_string(__G__ G.crec.file_comment_length,
  335.                                    QCOND? DISPL_8 : SKIP)) != 0)
  336.             {
  337.                 error_in_archive = error;  /* might be just warning */
  338.                 if (error > PK_WARN)       /* fatal */
  339.                     return error;
  340.             }
  341.             tot_ucsize += G.crec.ucsize;
  342.             tot_csize += csiz;
  343.             ++members;
  344. #ifdef OS2_EAS
  345.             if (ea_size) {
  346.                 tot_easize += ea_size;
  347.                 ++tot_eafiles;
  348.             }
  349.             if (acl_size) {
  350.                 tot_aclsize += acl_size;
  351.                 ++tot_aclfiles;
  352.             }
  353. #endif
  354.         } else {        /* not listing this file */
  355.             SKIP_(G.crec.file_comment_length)
  356.         }
  357.     } /* end for-loop (j: files in central directory) */
  358.  
  359. /*---------------------------------------------------------------------------
  360.     Print footer line and totals (compressed size, uncompressed size, number
  361.     of members in zipfile).
  362.   ---------------------------------------------------------------------------*/
  363.  
  364.     if (G.qflag < 2) {
  365.         if ((cfactor = ratio(tot_ucsize, tot_csize)) < 0) {
  366. #ifndef WINDLL
  367.             sgn = '-';
  368. #endif
  369.             cfactor = (-cfactor + 5) / 10;
  370.         } else {
  371. #ifndef WINDLL
  372.             sgn = ' ';
  373. #endif
  374.             cfactor = (cfactor + 5) / 10;
  375.         }
  376. #ifdef WINDLL
  377.         /* pass the totals back to the calling application */
  378.         lpUserFunctions->TotalSizeComp = tot_csize;
  379.         lpUserFunctions->TotalSize = tot_ucsize;
  380.         lpUserFunctions->CompFactor = cfactor;
  381.         lpUserFunctions->NumMembers = members;
  382.  
  383. #else /* !WINDLL */
  384.         if (cfactor == 100)
  385.             sprintf(cfactorstr, LoadFarString(CompFactor100));
  386.         else
  387.             sprintf(cfactorstr, LoadFarString(CompFactorStr), sgn, cfactor);
  388.         if (longhdr) {
  389.             Info(slide, 0, ((char *)slide, LoadFarString(LongFileTrailer),
  390.               tot_ucsize, tot_csize, cfactorstr, members, members==1? "":"s"));
  391. #ifdef OS2_EAS
  392.             if (tot_easize || tot_aclsize)
  393.                 Info(slide, 0, ((char *)slide, "\n"));
  394.             if (tot_eafiles && tot_easize)
  395.                 Info(slide, 0, ((char *)slide, LoadFarString(OS2ExtAttrTrailer),
  396.                   tot_eafiles, tot_eafiles == 1? " has" : "s have a total of",
  397.                   tot_easize));
  398.             if (tot_aclfiles && tot_aclsize)
  399.                 Info(slide, 0, ((char *)slide, LoadFarString(OS2ACLTrailer),
  400.                   tot_aclfiles, tot_aclfiles == 1? " has" : "s have a total of",
  401.                   tot_aclsize));
  402. #endif /* OS2_EAS */
  403.         } else
  404. #ifdef OS2_EAS
  405.             Info(slide, 0, ((char *)slide, LoadFarString(ShortFileTrailer),
  406.               tot_ucsize, tot_easize, tot_aclsize, members, members == 1?
  407.               "" : "s"));
  408. #else
  409.             Info(slide, 0, ((char *)slide, LoadFarString(ShortFileTrailer),
  410.               tot_ucsize, members, members == 1? "" : "s"));
  411. #endif /* OS2_EAS */
  412. #endif /* ?WINDLL */
  413.     }
  414. /*---------------------------------------------------------------------------
  415.     Double check that we're back at the end-of-central-directory record.
  416.   ---------------------------------------------------------------------------*/
  417.  
  418.     if (readbuf(__G__ G.sig, 4) == 0)
  419.         return PK_EOF;
  420.     if (strncmp(G.sig, G.end_central_sig, 4)) {   /* just to make sure again */
  421.         Info(slide, 0x401, ((char *)slide, LoadFarString(EndSigMsg)));
  422.         error_in_archive = PK_WARN;
  423.     }
  424.     if (members == 0 && error_in_archive <= PK_WARN)
  425.         error_in_archive = PK_FIND;
  426.  
  427.     return error_in_archive;
  428.  
  429. } /* end function list_files() */
  430.  
  431.  
  432.  
  433.  
  434.  
  435. #ifdef TIMESTAMP
  436.  
  437. /************************/
  438. /* Function fn_is_dir() */
  439. /************************/
  440.  
  441. static int fn_is_dir(__G)    /* returns TRUE if G.filename is directory */
  442.     __GDEF
  443. {
  444.     extent fn_len = strlen(G.filename);
  445.     register char   endc;
  446.  
  447.     return  fn_len > 0 &&
  448.             ((endc = G.filename[fn_len-1]) == '/' ||
  449.              (G.pInfo->hostnum == FS_FAT_ && !strchr(G.filename, '/') &&
  450.               endc == '\\'));
  451. }
  452.  
  453.  
  454.  
  455.  
  456.  
  457. /*****************************/
  458. /* Function get_time_stamp() */
  459. /*****************************/
  460.  
  461. int get_time_stamp(__G__ last_modtime, nmember)  /* return PK-type error code */
  462.     __GDEF
  463.     time_t *last_modtime;
  464.     unsigned *nmember;
  465. {
  466.     int do_this_file=FALSE, error, error_in_archive=PK_COOL;
  467.     unsigned j;
  468. #ifdef USE_EF_UT_TIME
  469.     iztimes z_utime;
  470. #endif
  471.     min_info info;
  472.  
  473.  
  474. /*---------------------------------------------------------------------------
  475.     Unlike extract_or_test_files() but like list_files(), this function works
  476.     on information in the central directory alone.  Thus we have a single,
  477.     large loop through the entire directory, searching for the latest time
  478.     stamp.
  479.   ---------------------------------------------------------------------------*/
  480.  
  481.     *last_modtime = 0L;         /* assuming no zipfile data older than 1970 */
  482.     *nmember = 0;
  483.     G.pInfo = &info;
  484.  
  485.     for (j = 0; j < (unsigned)G.ecrec.total_entries_central_dir; ++j) {
  486.  
  487.         if (readbuf(__G__ G.sig, 4) == 0)
  488.             return PK_EOF;
  489.         if (strncmp(G.sig, G.central_hdr_sig, 4)) {  /* just to make sure */
  490.             Info(slide, 0x401, ((char *)slide, LoadFarString(CentSigMsg), j));
  491.             Info(slide, 0x401, ((char *)slide, LoadFarString(ReportMsg)));
  492.             return PK_BADERR;
  493.         }
  494.         /* process_cdir_file_hdr() sets pInfo->lcflag: */
  495.         if ((error = process_cdir_file_hdr(__G)) != PK_COOL)
  496.             return error;       /* only PK_EOF defined */
  497.         if ((error = do_string(__G__ G.crec.filename_length, DS_FN)) != PK_OK)
  498.         {        /*  ^-- (uses pInfo->lcflag) */
  499.             error_in_archive = error;
  500.             if (error > PK_WARN)   /* fatal:  can't continue */
  501.                 return error;
  502.         }
  503.         if (G.extra_field != (uch *)NULL) {
  504.             free(G.extra_field);
  505.             G.extra_field = (uch *)NULL;
  506.         }
  507.         if ((error = do_string(__G__ G.crec.extra_field_length, EXTRA_FIELD))
  508.             != 0)
  509.         {
  510.             error_in_archive = error;
  511.             if (error > PK_WARN)      /* fatal */
  512.                 return error;
  513.         }
  514.         if (!G.process_all_files) {   /* check if specified on command line */
  515.             char **pfn = G.pfnames-1;
  516.  
  517.             do_this_file = FALSE;
  518.             while (*++pfn)
  519.                 if (match(G.filename, *pfn, G.C_flag)) {
  520.                     do_this_file = TRUE;
  521.                     break;       /* found match, so stop looping */
  522.                 }
  523.             if (do_this_file) {  /* check if this is an excluded file */
  524.                 char **pxn = G.pxnames-1;
  525.  
  526.                 while (*++pxn)
  527.                     if (match(G.filename, *pxn, G.C_flag)) {
  528.                         do_this_file = FALSE;  /* ^-- ignore case in match */
  529.                         break;
  530.                     }
  531.             }
  532.         }
  533.  
  534.         /* If current file was specified on command line, or if no names were
  535.          * specified, check the time for this file.  Either way, get rid of the
  536.          * file comment and go back for the next file.
  537.          * Directory entries are always ignored, to stay compatible with both
  538.          * Zip and PKZIP.
  539.          */
  540.         if ((G.process_all_files || do_this_file) && !fn_is_dir(__G)) {
  541. #ifdef USE_EF_UT_TIME
  542.             if (G.extra_field &&
  543.                 (ef_scan_for_izux(G.extra_field, G.crec.extra_field_length, 1,
  544.                                   G.crec.last_mod_file_date, &z_utime, NULL)
  545.                  & EB_UT_FL_MTIME))
  546.             {
  547.                 if (*last_modtime < z_utime.mtime)
  548.                     *last_modtime = z_utime.mtime;
  549.             } else
  550. #endif /* USE_EF_UT_TIME */
  551.             {
  552.                 time_t modtime = dos_to_unix_time(G.crec.last_mod_file_date,
  553.                                                   G.crec.last_mod_file_time);
  554.  
  555.                 if (*last_modtime < modtime)
  556.                     *last_modtime = modtime;
  557.             }
  558.             ++*nmember;
  559.         }
  560.         SKIP_(G.crec.file_comment_length)
  561.  
  562.     } /* end for-loop (j: files in central directory) */
  563.  
  564. /*---------------------------------------------------------------------------
  565.     Double check that we're back at the end-of-central-directory record.
  566.   ---------------------------------------------------------------------------*/
  567.  
  568.     if (readbuf(__G__ G.sig, 4) == 0)
  569.         return PK_EOF;
  570.     if (strncmp(G.sig, G.end_central_sig, 4)) {   /* just to make sure again */
  571.         Info(slide, 0x401, ((char *)slide, LoadFarString(EndSigMsg)));
  572.         error_in_archive = PK_WARN;
  573.     }
  574.     if (*nmember == 0 && error_in_archive <= PK_WARN)
  575.         error_in_archive = PK_FIND;
  576.  
  577.     return error_in_archive;
  578.  
  579. } /* end function get_time_stamp() */
  580.  
  581. #endif /* TIMESTAMP */
  582.  
  583.  
  584.  
  585.  
  586.  
  587. /********************/
  588. /* Function ratio() */    /* also used by ZipInfo routines */
  589. /********************/
  590.  
  591. int ratio(uc, c)
  592.     ulg uc, c;
  593. {
  594.     ulg denom;
  595.  
  596.     if (uc == 0)
  597.         return 0;
  598.     if (uc > 2000000L) {    /* risk signed overflow if multiply numerator */
  599.         denom = uc / 1000L;
  600.         return ((uc >= c) ?
  601.             (int) ((uc-c + (denom>>1)) / denom) :
  602.           -((int) ((c-uc + (denom>>1)) / denom)));
  603.     } else {             /* ^^^^^^^^ rounding */
  604.         denom = uc;
  605.         return ((uc >= c) ?
  606.             (int) ((1000L*(uc-c) + (denom>>1)) / denom) :
  607.           -((int) ((1000L*(c-uc) + (denom>>1)) / denom)));
  608.     }                            /* ^^^^^^^^ rounding */
  609. }
  610.  
  611.  
  612.  
  613.  
  614.  
  615. /************************/
  616. /*  Function fnprint()  */    /* also used by ZipInfo routines */
  617. /************************/
  618.  
  619. void fnprint(__G)    /* print filename (after filtering) and newline */
  620.     __GDEF
  621. {
  622.     char *name = fnfilter(G.filename, slide);
  623.  
  624.     (*G.message)((zvoid *)&G, (uch *)name, (ulg)strlen(name), 0);
  625.     (*G.message)((zvoid *)&G, (uch *)"\n", 1L, 0);
  626.  
  627. } /* end function fnprint() */
  628.