home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 March / VPR9703A.ISO / OLS / Os2 / LHA2P205 / LHA2P205.LZH / lha2-2.05pre / source.lzh / src / disp.c < prev    next >
C/C++ Source or Header  |  1996-02-24  |  3KB  |  173 lines

  1. /*
  2.  * disp.c --- display filenames
  3.  *  Copyright (C) 1988-1992, Haruyasu YOSHIZAKI
  4.  *  Copyright (C) 1991-1996. Satoshi HIRAMATSU (OS/2 HPFS version)
  5.  *
  6.  * $Log$
  7.  */
  8.  
  9.  
  10. #include <sys/types.h>
  11. #include <stdio.h>
  12. #include <string.h>
  13. #include <time.h>
  14. #include "typedef.h"
  15. #include "port2.h"
  16. #include "lh.h"
  17. #include "header.h"
  18. #include "intrface.h"
  19.  
  20.  
  21. char *procptr;
  22. char *fileptr;
  23. ushort maxblk;
  24. ushort blkcnt;
  25. ushort curcnt;
  26. ushort nxtcnt;
  27.  
  28.  
  29. extern int fcount, tcount;
  30.  
  31.  
  32. void
  33. regdisp(char *p, char *q)
  34. {
  35.   static char __filename__[13];
  36.  
  37.   procptr = p;
  38.   /* for UNIX version LHA directory archives.  */
  39.   /* for OS/2 version LHA directory archives with "-d" option. */
  40.   if(*(hpb.pathname + strlen(hpb.pathname) - 1) == DELIM)
  41.     fileptr = hpb.pathname;
  42.   else
  43.     fileptr = hpb.filename;
  44.  
  45.   if(flg_l)
  46.     fileptr = hpb.pathname;
  47.   else
  48.     {
  49.       if(strlen(fileptr) > 12) /* long filename */
  50.     {
  51.       memcpy(__filename__, fileptr, 12);
  52.       __filename__[13] = '\0';
  53.       fileptr = __filename__;
  54.     }
  55.     }
  56.  
  57.   if(q && flg_l == 2)
  58.     fileptr = q;
  59.   maxblk = (flg_l) ? 67 : 57;
  60.   fcount++;
  61. }
  62.  
  63.  
  64. void
  65. dispname(void)
  66. {
  67.   if(flg_n == 2)
  68.     return;
  69.   eprintf((flg_l) ? "\r  %-8s " : "\r%-8s %-12s ", procptr, fileptr);
  70. }
  71.  
  72.  
  73. void
  74. dispalone(char *p)
  75. {
  76.   regdisp(p, NULL);
  77.   if(outredir)
  78.     printf("%s\n", fileptr);
  79.   if(flg_n != 2)
  80.     eprintf("%-8s %s", p, fileptr);
  81. }
  82.  
  83.  
  84. void
  85. disp(int view, int redir)
  86. {
  87.   int dicsiz, blk;
  88.  
  89.   blkcnt = -1;
  90.   if(view)
  91.     return;
  92.   if(redir)
  93.     printf("%s\n", fileptr);
  94.   if(flg_n == 2)
  95.     return;
  96.   if(flg_l)
  97.     {
  98.       eprintf("[%d", fcount);
  99.       if(cmd == 'U' || cmd == 'M')
  100.     eprintf("/%d", tcount);
  101.       eprintf("] %s\n", fileptr);
  102.     }
  103.   dispname();
  104.   if (flg_n) return;
  105.   dicsiz = 1 << interface.dicbit;
  106.   blkcnt = blk =(interface.original + dicsiz - 1) / dicsiz;
  107.   if(blk > maxblk)
  108.     blk = maxblk;
  109.   while(blk)
  110.     {
  111.       fputc('.', stderr);
  112.       fflush(stderr);
  113.       blk--;
  114.     }
  115.   dispname();
  116. }
  117.  
  118.  
  119. void
  120. enddisp(char *p)
  121. {
  122.   if(flg_n == 2)
  123.     return;
  124.   eprintf((flg_l) ? "\r  %-8s \n" : "\r%-8s \n", p);
  125. }
  126.  
  127.  
  128. void initdisp(void)
  129. {
  130.   curcnt = nxtcnt = 0;
  131.   if(blkcnt == -1)
  132.     nxtcnt = -1;
  133. }
  134.  
  135.  
  136. void
  137. dispmark(char mark)
  138. {
  139.   if(curcnt >= nxtcnt)
  140.     {
  141.       if(!flg_n)
  142.     {
  143.       fputc(mark, stderr);
  144.       fflush(stderr);
  145.     }
  146.       if(blkcnt > maxblk)
  147.     nxtcnt = (((long)curcnt * maxblk + blkcnt - 1) / blkcnt + 1) 
  148.       * blkcnt / maxblk;
  149.       else
  150.     nxtcnt++;
  151.     }
  152.   curcnt++;
  153. }
  154.  
  155.  
  156. void
  157. increment_disp(void)
  158. {
  159.   fcount++;
  160. }
  161.  
  162.  
  163. void
  164. skipdisp(char *mes)
  165. {
  166.   if(flg_n == 2)
  167.     return;
  168.   regdisp("Skipped", cmd == 'E' ? filename3 : NULL);
  169.   interface.original = 0;
  170.   disp(0, 0);
  171.   eprintf(": %s\n", mes);
  172. }
  173.