home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / os2 / dwnsrs57.zip / DOWNRPT2.C < prev    next >
C/C++ Source or Header  |  1993-06-18  |  22KB  |  510 lines

  1. /* ================================================================ */
  2. /*  Rob Hamerling's MAXIMUS download file scan and sort utility     */
  3. /*  -> DOWNRPT2.C                                                   */
  4. /*  -> Make all types of IPF-lists.                                 */
  5. /* ================================================================ */
  6.  
  7. #define INCL_BASE
  8. #define INCL_NOPMAPI
  9. #include <os2.h>
  10.  
  11. #include <conio.h>
  12. #include <malloc.h>
  13. #include <memory.h>
  14. #include <string.h>
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17.  
  18. #include "..\max\mstruct.h"
  19. #include "downsort.h"
  20. #include "downfpro.h"
  21.  
  22. /* IPF-tags */
  23. static char  AW[]   = ":artwork align=center name='DOWNSORT.BMP'.";
  24. static char  CD[]   = ":color fc=default.";
  25. static char  CG[]   = ":cgraphic.";
  26. static char  CR[]   = ":color fc=red.";
  27. static char  CY[]   = ":color fc=yellow.";
  28. static char  DP[]   = ":docprof toc='*3'.";
  29. static char  ED[]   = ":euserdoc.\n";
  30. static char  EG[]   = ":ecgraphic.";
  31. static char  EL[]   = ":elines.\n";
  32. static char  ET[]   = ":etable.\n";
  33. static char  H1[]   = ":h1.";
  34. static char  H2[]   = ":h2";
  35. static char  H3[]   = ":h3";
  36. static char  OV[]   = "Overview";
  37. static char  LI[]   = ":lines align=center.";
  38. static char  LL[]   = ":lines align=left.";
  39. static char  LP[]   = ":lp.";
  40. static char  TB[]   = ":table cols='12 15 38' frame=box rules=both.\n";
  41. static char  TI[]   = ":title.";
  42. static char  UD[]   = ":userdoc.";
  43.  
  44. /* prototypes of local functions */
  45.  
  46. void ipf_list_head(FILE *, struct  _filechain **,
  47.                    struct  _downpath huge *, unsigned int, unsigned int);
  48. void ipf_area_oview(FILE *,
  49.                    struct  _downpath huge *, unsigned int, unsigned int);
  50. void ipf_area_head(FILE *, struct  _filechain **,
  51.                    unsigned int, unsigned int);
  52. int  ipf_file_entry(FILE *, struct  _filechain **,
  53.                     unsigned int, unsigned int);
  54. int  ip2_file_entry(FILE *, struct  _filechain **,
  55.                     unsigned int, unsigned int);
  56.  
  57.  
  58. /* ------------------------------------------------------- */
  59. /* Produce the file-request format of IPFfiles  (IPF-list) */
  60. /* ------------------------------------------------------- */
  61. void make_ipf(struct  _filechain **dm,
  62.               struct  _downpath huge *area,
  63.               unsigned int  x)
  64. {
  65.   FILE   *pf;                           /* file handle                   */
  66.   char   outfile[MAXFN];                /* file names                    */
  67.   char   ac[40];                        /* area name                     */
  68.   unsigned int i,l,pcnt,n,pmax;         /* counters                      */
  69.  
  70.   sprintf(outfile,"%s.%s%c",
  71.           lp[P_IPF].name,
  72.           lp[P_IPF].ext,
  73.           priv_name[lp[P_IPF].priv[x]-TWIT][0]);
  74.   pf = fopen(outfile,WRITE);            /* output file                   */
  75.   if (pf != NULL) {
  76.     if (oper_mode == VERBOSE)
  77.       fprintf(stdout, MSG_SRT, file_total_count, area_total_count, outfile);
  78.     ipf_list_head(pf, dm, area, P_IPF, x); /* sort + list header         */
  79.     if (oper_mode!=QUIET)
  80.       fprintf(stdout, MSG_REP, outfile);
  81.     ipf_area_oview(pf, area, P_IPF, x); /* create area overview          */
  82.     if (oper_mode==VERBOSE)             /* keep operator awake           */
  83.       fprintf(stdout, MSG_REC, outfile);
  84.  
  85.     fprintf(pf,"%s%s\n",H1,"File List per Area");
  86.     fprintf(pf,"%s\n%s :hp8.%c:ehp8.%s, :hp8.%c:ehp8.%s\n%s\n",
  87.                LI, DF, DAYS_7, WK, DAYS_30, MO, EL);
  88.     ac[0] = '\0';                       /* null area name                */
  89.     l=n=0;                              /* init file counters            */
  90.     for (i=0; i<file_total_count; i++) {    /* all files                 */
  91.       if (strcmp(ac, dm[i]->parea->name)) { /* new area collection       */
  92.         strcpy(ac, dm[i]->parea->name);   /* set new                     */
  93.         if (dm[i]->parea->file_count > 0) { /* any files in this area    */
  94.           if (l>0)                      /* have to close open list?      */
  95.             fprintf(pf,":edl.\n");      /* close previous area-list      */
  96.           ipf_area_head(pf, dm, P_IPF, i); /* create area header         */
  97.           pcnt = l = 0;                 /* sub-counters this area        */
  98.           }
  99.         }
  100.       if (dm[i]->priv <= lp[P_IPF].priv[x]) {   /* only upto max priv_lvl*/
  101.         pmax = 1 + dm[i]->parea->file_count/lp[P_IPF].max_fil;
  102.         if ((l % lp[P_IPF].max_fil) == 0) {   /* 'page' separations      */
  103.           if (l == 0) {                 /* only for first entry          */
  104.             if (dm[i]->parea->file_count > lp[P_IPF].max_fil)  /* split  */
  105.               fprintf(pf,":p.(part %d of %d)\n", ++pcnt, pmax);
  106.             }
  107.           else {                        /* only part 2 and up            */
  108.             fprintf(pf,":edl.\n");      /* end of previous part          */
  109.             ++pcnt;                     /* increment part counter        */
  110.             fprintf(pf,":p.Jump to: :link reftype=hd refid=%.8sP%d.\n"
  111.                        "part %d of %d:elink.",
  112.                        dm[i]->parea->name, pcnt, pcnt, pmax);
  113.             fprintf(pf,"\n%s id=%.8sP%d.%s - (part %d of %d)\n",
  114.                        H3, dm[i]->parea->name, pcnt, ac, pcnt, pmax);
  115.             fprintf(pf,":p.%s (part %d of %d)\n",
  116.                        stripf(dm[i]->parea->adesc), pcnt, pmax);
  117.             }
  118.           fprintf(pf,":dl tsize=20 compact.\n");
  119.           fprintf(pf,":hp6.:dthd.%s:ddhd.%s:ehp6.\n",FN,DS);
  120.           }
  121.         ++l;                            /* listed lines (incl comments)  */
  122.         n += ipf_file_entry(pf, dm, P_IPF, i); /* print entry            */
  123.         if (dm[i]->fname[0] != '\0')    /* filename present              */
  124.           if (oper_mode==VERBOSE && (n%25)==0)
  125.             fprintf(stdout, " %5u\r",n);        /* report progress       */
  126.         }
  127.       }
  128.     fprintf(pf,":edl.\n");              /* end of file-list last area    */
  129.     if (oper_mode==VERBOSE)             /* last value                    */
  130.       fprintf(stdout," %5u\n", n);
  131.     fprintf(pf,"%s%s\n%s\n\n",H1,"Epilog",LI);
  132.     signature(pf,stripf(today));        /* leave fingerprint             */
  133.     insert_title(pf, bot_lines, 1);
  134.     fprintf(pf, "%s%s", EL, ED);
  135.     stripf(NULL);                       /* let stripf free memory        */
  136.     fclose(pf);                         /* finished with .IPF file       */
  137.     }
  138.   else {
  139.     if (oper_mode!=QUIET)
  140.       fprintf(stderr, MSG_OPO, outfile, 0);    /* open failed          */
  141.     }
  142.   }
  143.  
  144. /* ------------------------------------------------------- */
  145. /* Produce the file-request format of IP2-files (IPF-list) */
  146. /* ------------------------------------------------------- */
  147. void make_ip2(struct  _filechain **dm,
  148.               struct  _downpath huge *area,
  149.               unsigned int  x)
  150. {
  151.   FILE   *pf;                           /* file handle                  */
  152.   char   outfile[MAXFN];                /* file names                   */
  153.   char   ac[40];                        /* area name                    */
  154.   unsigned int i,l,pcnt,n,pmax;         /* counters                     */
  155.  
  156.   sprintf(outfile,"%s.%s%c",
  157.           lp[P_IP2].name,
  158.           lp[P_IP2].ext,
  159.           priv_name[lp[P_IP2].priv[x]-TWIT][0]);
  160.   pf = fopen(outfile,WRITE);            /* output file                   */
  161.   if (pf != NULL) {
  162.     if (oper_mode == VERBOSE)
  163.       fprintf(stdout, MSG_SRT, file_total_count, area_total_count, outfile);
  164.     ipf_list_head(pf, dm, area, P_IP2, x); /* sort + list header         */
  165.     if (oper_mode!=QUIET)
  166.       fprintf(stdout, MSG_REP, outfile);
  167.     ipf_area_oview(pf, area, P_IP2, x); /* create area overview          */
  168.     if (oper_mode==VERBOSE)             /* keep operator awake           */
  169.       fprintf(stdout, MSG_REC, outfile);
  170.  
  171.     fprintf(pf,"%s%s\n",H1,"File List per Area");
  172.     fprintf(pf,"%s\n%s :hp8.%c:ehp8.%s, :hp8.%c:ehp8.%s\n%s\n",
  173.                LI, DF, DAYS_7, WK, DAYS_30, MO, EL);
  174.     ac[0] = '\0';                       /* null area name                */
  175.     l = n = 0;                          /* init file counters            */
  176.     for (i=0; i<file_total_count; i++) {    /* all files                 */
  177.       if (strcmp(ac, dm[i]->parea->name)) { /* new area collection       */
  178.         strcpy(ac, dm[i]->parea->name);   /* set new                     */
  179.         if (dm[i]->parea->file_count > 0) { /* any files in this area    */
  180.           if (l>0)                      /* have to close open list?      */
  181.             fprintf(pf,ET);             /* close previous table          */
  182.           ipf_area_head(pf, dm, P_IP2, i); /* create area header         */
  183.           pcnt = l = 0;                 /* init sub-counters this area   */
  184.           }
  185.         }
  186.       if (dm[i]->priv <= lp[P_IP2].priv[x]) {   /* only upto max priv_lvl*/
  187.         pmax = 1 + dm[i]->parea->file_count/lp[P_IP2].max_fil;
  188.         if ((l % lp[P_IP2].max_fil) == 0) {   /* 'page' separations      */
  189.           if (l == 0) {                 /* only for first entry          */
  190.             if (dm[i]->parea->file_count > lp[P_IP2].max_fil)  /* split  */
  191.               fprintf(pf,":p.(part %d of %d)\n", ++pcnt, pmax);
  192.             }
  193.           else {                        /* only part 2 and up            */
  194.             fprintf(pf,ET);             /* end of previous table         */
  195.             ++pcnt;                     /* increment part counter        */
  196.             fprintf(pf,":p.Jump to: :link reftype=hd refid=%.8sP%d.\n"
  197.                        "part %d of %d:elink.",
  198.                        dm[i]->parea->name, pcnt, pcnt, pmax);
  199.             fprintf(pf,"\n%s id=%.8sP%d.%s - (part %d of %d)\n",
  200.                        H3, dm[i]->parea->name, pcnt, ac, pcnt, pmax);
  201.             fprintf(pf,":p.%s (part %d of %d)\n",
  202.                        stripf(dm[i]->parea->adesc), pcnt, pmax);
  203.             }
  204. /*        fprintf(pf,":font facename=Helv size=10x8.\n");  */
  205.           fprintf(pf,TB);
  206.           }
  207.         ++l;                            /* listed lines (incl comments) */
  208.         n += ip2_file_entry(pf, dm, P_IP2, i); /* print entry           */
  209.         if (dm[i]->fname[0] != '\0')    /* filename present             */
  210.           if (oper_mode==VERBOSE && (n%25)==0)
  211.             fprintf(stdout, " %5u\r",n); /* report progress             */
  212.         }
  213.       }
  214.     fprintf(pf,ET);                     /* end of table this area       */
  215.     if (oper_mode==VERBOSE)             /* last value                   */
  216.       fprintf(stdout, " %5u\n", n);
  217.     fprintf(pf,"%s%s\n%s\n\n",H1,"Epilog",LI);
  218.     signature(pf,stripf(today));        /* leave fingerprint            */
  219.     insert_title(pf, bot_lines, 1);
  220.     fprintf(pf,"%s%s",EL,ED);
  221.     stripf(NULL);                       /* let stripf free memory       */
  222.     fclose(pf);                         /* finished with .IPF file      */
  223.     }
  224.   else {
  225.     if (oper_mode!=QUIET)
  226.       fprintf(stdout, MSG_OPO, outfile, 0);    /* open failed         */
  227.     }
  228.   }
  229.  
  230. /* ------------------------ */
  231. /* generate IPF list header */
  232. /* ------------------------ */
  233. void ipf_list_head(FILE *pf,
  234.                    FILECHAIN **dm,
  235.                    DOWNPATH huge *area,
  236.                    unsigned int P_ppp,
  237.                    unsigned int x)
  238. {
  239.   char   s[MAXDESC];                    /* work buffer                   */
  240.  
  241.   switch(lp[P_ppp].sortflag) {
  242.     case ALPHA:     psort(dm,0,file_total_count-1,sort_all); break;
  243.     case TIMESTAMP: psort(dm,0,file_total_count-1,sort_al2); break;
  244.     case KEEPSEQ:   psort(dm,0,file_total_count-1,sort_akp); break;
  245.     default: break;
  246.     }
  247.   preproc_area(area, dm, lp[P_ppp].priv[x]);
  248.   fprintf(pf,"%s\n%s%s\n%s\n",UD,TI,stripf(list_title),DP);
  249.   fprintf(pf,"%s%s\n%s\n",H1,stripf(list_title),LI);
  250.   insert_title(pf, pre_title, 1);
  251.   fprintf(pf,"%s%s\n%s\n",EL,CG,CR);
  252.   block_title(pf, 20, list_title, P_ppp),
  253.   fprintf(pf,"%s\n%s\n",CD,EG);
  254.   file_incl(pf, P_ppp);             /* insert user-'logo'                */
  255.   fprintf(pf,"%s\n",LI);
  256.   insert_title(pf, sub_title, 1);
  257.   fprintf(pf,"%s%s%s%s%s\n",EL,H1,"About ",PROGNAME," program");
  258.   fprintf(pf,"\n%s\n",AW);
  259.   fprintf(pf,"\n%s\n%s  Version %c.%c%c\n",
  260.                    LI,PROGNAME,VERSION,SUBVERS,SUFFIX);
  261.   fprintf(pf,"\nby %s\n\n%s\n",AUTHOR, CITY);
  262.   sprintf(s,"\n%s\n%s\n",PHONE,FIDO);
  263.   fprintf(pf,"%s\n",stripf(s));
  264.   fprintf(pf,"%s",EL);
  265.   }
  266.  
  267. /* ------------------------------- */
  268. /* generate IPF list area overview */
  269. /* ------------------------------- */
  270. void ipf_area_oview(FILE *pf,
  271.                    struct  _downpath huge *area,
  272.                    unsigned int  P_ppp,
  273.                    unsigned int  x)
  274. {
  275.   char   s[MAXDESC];                    /* pointer to line buffer        */
  276.   unsigned int j;                       /* counter                       */
  277.   DOWNPATH huge *area2;         /* copy of area-array for sort   */
  278.  
  279.   if (oper_mode==VERBOSE)
  280.     fprintf(stdout, MSG_REP, OV);
  281. #ifndef __32BIT__
  282.   area2 = (DOWNPATH *)halloc(area_total_count,
  283.                                      sizeof(DOWNPATH));
  284. #else
  285.   area2 = (DOWNPATH *)malloc(area_total_count *
  286.                                      sizeof(DOWNPATH));
  287. #endif
  288.                                         /* dup area-array for sorting!   */
  289.   if (area2 == NULL) {                  /* memory not obtained?          */
  290.     if (oper_mode!=QUIET)
  291.       fprintf(stderr, "Not enough memory for summary report, skipped.\n");
  292.     }
  293.   else {
  294.     memmove(area2,area,area_total_count*sizeof(DOWNPATH));
  295.     qsort(area2,area_total_count,sizeof(DOWNPATH),sort_summ);
  296.     fprintf(pf,"%s%s\n",H1,OV);
  297.     fprintf(pf,"%s\n%s\n",CG,CR);
  298.     block_title(pf, 8, OV, P_ppp);
  299.     fprintf(pf,"%s\n%s\n",CD,EG);
  300.     fprintf(pf,"%s\nlist creation date: %s\n",
  301.                 LI,stripf(sys_date(today)));
  302.     if (lp[P_ppp].exclflag != EXCLPRIV)
  303.       fprintf(pf,"%s%s\n", MP, priv_name[lp[P_ppp].priv[x]-TWIT]);
  304.     fprintf(pf,"%s%s\n:hp2.\n%-8s %-35s %5s %8s\n",EL,CG,AC,DS,FS,BY);
  305.     sep_line(pf, '─', 44, 5, 9, 0);
  306.     for (j=0; j<area_total_count; j++) {
  307.       if (area2[j].file_count) {
  308.         fprintf(pf,":link reftype=hd refid=A$%.8s.%-8.8s:elink.",
  309.                    area2[j].name,
  310.                    area2[j].name);
  311.         sprintf(s," %-35.35s %5u %8luK",
  312.                    area2[j].adesc,
  313.                    area2[j].file_count,
  314.                    (area2[j].byte_count+512)/1024);
  315.         fprintf(pf,"%s\n",stripf(s));
  316.         }
  317.       }
  318.     sep_line(pf, '─', 44, 5, 9, 0);
  319.     fprintf(pf,"%44s %5u %8luK\n:ehp2.\n%s\n",
  320.                "Total:",
  321.                count_files(area2),
  322.                (count_bytes(area2)+512)/1024,
  323.                EG);
  324. #ifndef __32BIT__
  325.     hfree(area2);                       /* free copy of area array       */
  326. #else
  327.     free(area2);                        /* free copy of area array       */
  328. #endif
  329.     }
  330.   }
  331.  
  332.  
  333. /* ------------------------- */
  334. /* generate IPF area heading */
  335. /* ------------------------- */
  336. void ipf_area_head(FILE *pf,
  337.                    struct  _filechain **dm,
  338.                    unsigned int  P_ppp,
  339.                    unsigned int  i)
  340. {
  341.   fprintf(pf,":p.Continue with filearea"
  342.           ":link reftype=hd refid=A$%.8s. %s :elink.&colon. ",
  343.            dm[i]->parea->name,
  344.            dm[i]->parea->name);
  345.   fprintf(pf,"%-45.45s\n", stripf(dm[i]->parea->adesc));
  346.   fprintf(pf,"%s id=A$%.8s.%s - %s\n%s\n",
  347.           H2,
  348.           dm[i]->parea->name,
  349.           dm[i]->parea->name,
  350.           stripf(dm[i]->parea->adesc),CG);
  351.   if (max_aname <= 3) {                 /* short areanames */
  352.     fprintf(pf,"%s%s%s ║ :hp2.%s:ehp2.\n",
  353.             CR,
  354.             strnblk(dm[i]->parea->name,3,FONT3,LINE1),
  355.             CD,
  356.             stripf(dm[i]->parea->adesc));
  357.     fprintf(pf,"%s%s%s ║ :hp2.Available: "
  358.             "%u files (%lu.%lu MB):ehp2.\n",
  359.              CR, strnblk(dm[i]->parea->name,3,FONT3,LINE2), CD,
  360.              dm[i]->parea->file_count,
  361.              (dm[i]->parea->byte_count+52428L)/1048576L,  /* round       */
  362.              ((dm[i]->parea->byte_count+52429L)/104857L)%10); /* fract   */
  363.     fprintf(pf,"%s%s%s ║",CR,strnblk(dm[i]->parea->name,3,FONT3,LINE3),CD);
  364.     if (lp[P_ppp].exclflag != EXCLPRIV)
  365.       fprintf(pf," :hp2.Privilege: %-.9s:ehp2.\n",
  366.                   priv_name[dm[i]->parea->priv-TWIT]);  /* area priv     */
  367.     else
  368.       fprintf(pf,"\n");
  369.     fprintf(pf,"%s%s%s ║",CR,strnblk(dm[i]->parea->name,3,FONT3,LINE4),CD);
  370.     }
  371.   else {                                /* long areanames                */
  372.     fprintf(pf,"%s\n", CR);
  373.     fprintf(pf,"%s\n", strnblk(dm[i]->parea->name,8,FONT3,LINE1));
  374.     fprintf(pf,"%s\n", strnblk(dm[i]->parea->name,8,FONT3,LINE2));
  375.     fprintf(pf,"%s\n", strnblk(dm[i]->parea->name,8,FONT3,LINE3));
  376.     fprintf(pf,"%s\n", strnblk(dm[i]->parea->name,8,FONT3,LINE4));
  377.     fprintf(pf,"%s\n\n", CD);
  378.     fprintf(pf," :hp2.%s:ehp2.\n", stripf(dm[i]->parea->adesc));
  379.     fprintf(pf," :hp2.Available: %u files (%lu.%lu MB):ehp2.\n",
  380.              dm[i]->parea->file_count,
  381.              (dm[i]->parea->byte_count+52428L)/1048576L,      /* MB      */
  382.              ((dm[i]->parea->byte_count+52429L)/104857L)%10); /* fract   */
  383.     if (lp[P_ppp].exclflag != EXCLPRIV)
  384.       fprintf(pf," :hp2.Privilege: %-.9s:ehp2.\n",
  385.                   priv_name[dm[i]->parea->priv-TWIT]);  /* area priv     */
  386.     }
  387.   if (dm[i]->parea->newest != NULL) {   /* newest file                   */
  388.     fprintf(pf," :hp2.Newest:");
  389.     fprintf(pf," %s",stripf(dm[i]->parea->newest->fname));
  390.     fprintf(pf," %s",stripf(f_date(dm[i]->parea->newest->wdate)));
  391.     fprintf(pf," (avail: %s):ehp2.\n",
  392.                 stripf(f_date(dm[i]->parea->newest->cdate)));
  393.     }
  394.   fprintf(pf,"%s\n",EG);
  395.   }
  396.  
  397. /* ----------------------- */
  398. /* generate IPF file entry */
  399. /* ----------------------- */
  400. int  ipf_file_entry(FILE *pf,
  401.                    struct  _filechain **dm,
  402.                    unsigned int  P_ppp,
  403.                    unsigned int  i)
  404. {
  405.   int rc;
  406.   unsigned int k;
  407.   char ageflag, *strptr;
  408.  
  409.   rc = 0;
  410.   if (dm[i]->fname[0] != '\0') {        /* filename present              */
  411.     fprintf(pf,":dt.:link refid=F$%u reftype=fn.%-s:elink.",
  412.                i, stripf(dm[i]->fname));        /* filename              */
  413.     ageflag = file_age_ind(dm[i]->cdate,dm[i]->ctime); /* file age flag  */
  414.     if (ageflag!=' ')
  415.       fprintf(pf,":hp8.%c:ehp8.", ageflag);
  416.     fprintf(pf,"\n:dd.");
  417.     k = strsubw(dm[i]->fdesc,&strptr,240);
  418.     if (k>0)
  419.       fprintf(pf, (dm[i]->size) ? "%s\n" : ":hp1.%s:ehp1.\n",
  420.            stripf(strptr));             /* description                   */
  421.     fprintf(pf,":fn id=F$%u.%s:efn.\n",
  422.            i,                           /* file number                   */
  423.            f_size_date(dm[i]->size,
  424.            dm[i]->wdate,
  425.            dm[i]->cdate,
  426.            dm[i]->ctime));
  427.     rc = 1;                             /* file entry printed            */
  428.     }
  429.   else if(lp[P_ppp].sortflag == KEEPSEQ)  /* '/K' specified              */
  430.     fprintf(pf,"%s%s%-s%s%s",
  431.             LL, CY,
  432.             (strip_ava == 'Y') ? strava(dm[i]->fdesc) : dm[i]->fdesc,
  433.             CD, EL);
  434.   return(rc);                           /* report result                 */
  435.   }
  436.  
  437.  
  438. /* ----------------------- */
  439. /* generate IPF file entry */
  440. /* ----------------------- */
  441. int  ip2_file_entry(FILE *pf,
  442.                    struct  _filechain **dm,
  443.                    unsigned int  P_ppp,
  444.                    unsigned int  i)
  445. {
  446.   int rc;
  447.  
  448.   rc = 0;
  449.   if (dm[i]->fname[0] != '\0') {        /* filename present              */
  450.     fprintf(pf,":row.:c.%s:c.%s",
  451.            stripf(dm[i]->fname),        /* filename                      */
  452.            f_size_date(dm[i]->size, dm[i]->wdate,
  453.                        dm[i]->cdate, dm[i]->ctime));
  454.     fprintf(pf, (dm[i]->size) ? ":c.%s\n" : ":c.:hp1.%s:ehp1.\n",
  455.            stripf(dm[i]->fdesc));       /* description                   */
  456.     rc = 1;                             /* file entry printed            */
  457.     }
  458.   else if(lp[P_ppp].sortflag == KEEPSEQ)  /* '/K' specified              */
  459.     fprintf(pf,"%s%s%-s%s%s",
  460.             LL, CY,
  461.             (strip_ava == 'Y') ? strava(dm[i]->fdesc) : dm[i]->fdesc,
  462.             CD, EL);
  463.   return(rc);                           /* report result                 */
  464.   }
  465.  
  466. /* ---------------------------------------------------- */
  467. /* function to 'neutralise' IPFC conflicting characters */
  468. /* ---------------------------------------------------- */
  469. char *stripf(char *s)
  470. {
  471.   int i,j,k;
  472.  
  473.   static char colon[] = "&colon.";
  474.   static char amp[]   = "&.";
  475.   static char grave[] = "&rbl.";        /* translated to required BLANK  */
  476.   static int  maxline = MAXDESC;        /* length of work-buffer         */
  477.   static char *t = NULL;                /* pointer to work-buffer        */
  478.  
  479.   if (s == NULL && t != NULL) {         /* no input-string               */
  480.     free(t);                            /* free-up memory                */
  481.     t = NULL;                           /* for next time use             */
  482.     return(s);
  483.     }
  484.  
  485.   if (t == NULL)                        /* no memory yet                 */
  486.     t = malloc(maxline);                /* get it now                    */
  487.  
  488.   if (t != NULL) {
  489.     for (i=j=0; s[i] && j<maxline-10; ++i) { /* keep some slack          */
  490.       switch(s[i]) {
  491.         case ':': for (k=0;  colon[k]; )
  492.                     t[j++] = colon[k++];
  493.                   break;
  494.         case '`': for (k=0;  grave[k]; )
  495.                     t[j++] = grave[k++];
  496.                   break;
  497.         case '&': for (k=0;  amp[k]; )
  498.                     t[j++] = amp[k++];
  499.                   break;
  500.         default:  t[j++] = s[i];
  501.                   break;
  502.         }
  503.       }
  504.     t[j] = '\0';                        /* end of string                 */
  505.     return(t);                          /* pointer to converted line     */
  506.     }
  507.   else
  508.     return(s);                          /* no conversion done            */
  509.   }
  510.