home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / dwnsrs59.zip / DOWNRPT2.C < prev    next >
C/C++ Source or Header  |  1993-11-15  |  22KB  |  517 lines

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