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

  1. /* =============================================================== */
  2. /*  Rob Hamerling's MAXIMUS download file scan and sort utility     */
  3. /*  -> DOWNRPT3.C                                                   */
  4. /*  -> Make SYSOP lists: ORP-list, DUP-list, OK-file, all FILES.BBS */
  5. /* ================================================================ */
  6.  
  7. #define INCL_BASE
  8. #define INCL_NOPMAPI
  9. #include <os2.h>
  10.  
  11. #include <conio.h>
  12. #include <memory.h>
  13. #include <string.h>
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16.  
  17. #include "..\max\mstruct.h"
  18. #include "downsort.h"
  19. #include "downfpro.h"
  20.  
  21. /* prototypes of local functions */
  22.  
  23. int  filename_cmp(FILECHAIN **, unsigned int);
  24. int  dup_ext(FILECHAIN **, unsigned int, unsigned int);
  25.  
  26. /* ------------------------- */
  27. /* Produce the ORPHAN report */
  28. /* ------------------------- */
  29. void make_orp(FILECHAIN **dm,
  30.               DOWNPATH  _HUGE *area,
  31.               unsigned int  x)          /* report privilege index        */
  32. {
  33.   FILE  *pf;                            /* file handle                   */
  34.   char  outfile[MAXFN];                 /* file names                    */
  35.   unsigned int i,j,fc;                  /* counters                      */
  36.  
  37.   sprintf(outfile,"%s.%s",lp[P_ORP].name,lp[P_ORP].ext);  /* build fname */
  38.   if (oper_mode==VERBOSE)
  39.     fprintf(stdout, MSG_SRT, file_total_count, area_total_count, outfile);
  40.   switch(lp[P_ORP].sortflag) {          /* sort                          */
  41.     case ALPHA:     psort(dm,0,file_total_count-1,sort_gbl); break;
  42.     case TIMESTAMP: psort(dm,0,file_total_count-1,sort_new); break;
  43.     default: break;
  44.     }
  45.  
  46.   fc = preproc_area(area, dm, lp[P_ORP].priv[x]); /* files within priv   */
  47.   j = file_total_count - fc;            /* calc orphans                  */
  48.   if (j>0) {                            /* yes, there are orphans        */
  49.     pf = fopen(outfile,WRITE);          /* output file                   */
  50.     if (pf != NULL) {                   /* successful open               */
  51.       if (oper_mode != QUIET)
  52.         fprintf(stdout, MSG_REP, outfile);
  53.       if (oper_mode == VERBOSE)
  54.         fprintf(stdout, MSG_REC);
  55.       block_title(pf, 9, " Orphans ", P_ORP); /* generate block title    */
  56.       fprintf(pf, "\n");
  57.       sep_line(pf, '═', 79, 0);
  58.       fprintf(pf,"  %s   %s       %s    %-s\n", AC, FN, DT, FP);
  59.       sep_line(pf, '─', 8, 12, 9, 47, 0);
  60.       for (i=j=0; i<file_total_count; i++) {
  61.         if (dm[i]->priv >= HIDDEN) {    /* report "hidden" and up        */
  62.           if (oper_mode==VERBOSE && (j%25)==0) {
  63.             fprintf(stdout, " %5u\r", j);
  64.             fflush(stdout);
  65.             }
  66.           ++j;                          /* list file-count               */
  67.           dm[i]->fdesc = ORPHAN;        /* assign 'description'          */
  68.           fprintf(pf,"%8.8s %-12.12s %s%c ",
  69.                       dm[i]->parea->name,
  70.                       dm[i]->fname,
  71.                       f_date(dm[i]->wdate),
  72.                       file_age_ind(dm[i]->cdate,dm[i]->ctime)); /*age*/
  73.           desc_part(pf,
  74.                        (dm[i]->fpath==NULL) ? dm[i]->parea->pname :
  75.                                                dm[i]->fpath,
  76.                        47, 47, P_ORP);
  77.           }
  78.         }
  79.       if (oper_mode==VERBOSE) {
  80.         fprintf(stdout, " %5u\n",j);    /* total reported orphans        */
  81.         fflush(stdout);
  82.         }
  83.       signature(pf,today);              /* fingerprint                   */
  84.       fclose(pf);                       /* finished with .ORP file       */
  85.       }
  86.     else                                /* no output possible            */
  87.       fprintf(stderr, MSG_OPO, outfile, 0);
  88.     }
  89.   }
  90.  
  91. /* ------------------ */
  92. /* Produce a DUP-list */
  93. /* ------------------ */
  94. void make_dup(FILECHAIN **dm,
  95.               unsigned int x)           /* list privilege index          */
  96. {
  97.   FILE  *pf;                            /* file handle                   */
  98.   char  outfile[MAXFN];                 /* file names                    */
  99.   unsigned int i,j;                     /* counters                      */
  100.  
  101.   sprintf(outfile,"%s.%s", lp[P_DUP].name, lp[P_DUP].ext);
  102.   pf = fopen(outfile,WRITE);            /* output file                   */
  103.   if (pf != NULL) {
  104.     if (oper_mode == VERBOSE)
  105.       fprintf(stdout, MSG_SRT, file_total_count, area_total_count, outfile);
  106.     psort(dm, 0, file_total_count-1, sort_gbl);  /* filename sort        */
  107.     if (oper_mode != QUIET)
  108.       fprintf(stdout, MSG_REP, outfile);
  109.     if (oper_mode == VERBOSE)
  110.       fprintf(stdout, MSG_REC);
  111.     block_title(pf, 12, " Duplicates ", P_DUP);
  112.     if (lp[P_DUP].exclflag != EXCLPRIV)
  113.       fprintf(pf,"\n%s%s\n",
  114.                  MP, priv_name[lp[P_DUP].priv[x]-TWIT]);
  115.     fprintf(pf,"\n%s       %s    %s   %s    %s\n",FN,AC,SZ,DT,FP);
  116.     sep_line(pf, '─', 12, 8, 5, 9, 45, 0);
  117.     for (i=j=0; i<file_total_count; i++) {
  118.       if (dm[i]->priv <= lp[P_DUP].priv[x]  &&  /* within priv limit and */
  119.           !filename_cmp(dm, i)) {       /* (pseudo) equal filenames      */
  120.         if (oper_mode==VERBOSE && (j%5)==0) {
  121.           fprintf(stdout, " %5u\r", j); /* display count by 5            */
  122.           fflush(stdout);
  123.           }
  124.         if (dm[i]->fname[0] != '\0') {  /* not a comment-entry           */
  125.           j++;                          /* count duplicates              */
  126.           fprintf(pf,"%-12.12s %8.8s %15s ",
  127.                   dm[i]->fname,
  128.                   dm[i]->parea->name,
  129.                   f_size_date(dm[i]->size, dm[i]->wdate,
  130.                               dm[i]->cdate, dm[i]->ctime));
  131.           desc_part(pf,
  132.                        (dm[i]->fpath==NULL) ? dm[i]->parea->pname :
  133.                                               dm[i]->fpath,
  134.                        41, 41, P_DUP);
  135.           }
  136.         }
  137.       }
  138.     if (oper_mode==VERBOSE)
  139.       fprintf(stdout," %5u\n",j);
  140.     signature(pf,today);                /* leave fingerprint             */
  141.     fclose(pf);                         /* finished with .DUP file       */
  142.     }
  143.   else
  144.     fprintf(stderr, MSG_OPO, outfile, 0);
  145.   }
  146.  
  147. /* ---------------------------------------------- */
  148. /* Compare filename                               */
  149. /* Returns 0 if equal (or to be considered equal) */
  150. /* ---------------------------------------------- */
  151. int  filename_cmp(FILECHAIN **dm,
  152.                   unsigned int  k)      /* index in dm-array            */
  153. {
  154.   char f1[9],f2[9];                     /* filenames                    */
  155.   int  i, rc;                           /* index, (default) rc */
  156.  
  157.   rc = 1;                               /* assume not duplicate */
  158.   non_wild_init(8, f1, dm[k]->fname);   /* filename of current entry    */
  159.   f1[8] = '\0';                         /* end of string                */
  160.   if (k > 0) {                          /* not very first           */
  161.     i = k-1;                            /* previous entry    */
  162.     non_wild_init(8, f2, dm[i]->fname); /* entry before              */
  163.     f2[8] = '\0';                       /* end of string              */
  164.     if (!stricmp(f1,f2)) {              /* equal filenames */
  165.       rc = 0;                           /* an equal filename found */
  166.       while (i >= 0 && !stricmp(f1,f2)) { /* equal filenames */
  167.         if (dup_ext(dm, k, i))          /* (pseudo) unequal  */
  168.           return(1);                    /* non-duplicate -> 'unequal' */
  169.         if (--i >= 0) {                 /* within array bound */
  170.           non_wild_init(8, f2, dm[i]->fname);  /* entry before */
  171.           f2[8] = '\0';                 /* end of string */
  172.           }
  173.         }                               /* no more 'before' duplicates */
  174.       }                                 /* maybe any next equal */
  175.     }
  176.   if (k < file_total_count-1) {         /* not very last           */
  177.     i = k+1;                            /* next entry */
  178.     non_wild_init(8, f2, dm[i]->fname); /* entry before              */
  179.     f2[8] = '\0';                       /* end of string              */
  180.     if (!stricmp(f1,f2)) {              /* next filename equal */
  181.       rc = 0;                           /* an equal found */
  182.       while (i<=file_total_count-1 && !stricmp(f1,f2)) {  /* search */
  183.         if (dup_ext(dm, k, i))           /* (pseudo) unequal       */
  184.           return(1);                     /* non-duplicate -> unequal */
  185.         if (++i <= file_total_count-1) {    /* within array bounds */
  186.           non_wild_init(8, f2, dm[i]->fname);  /* next entry */
  187.           f2[8] = '\0';                   /* end of string */
  188.           }
  189.         }                                 /* no more 'after' duplicates */
  190.       }                                 /* no next equal filename */
  191.     }
  192.   return(rc);                           /* 1 = not any equal filename */
  193.   }
  194.  
  195. /* ----------------------------------------------------- */
  196. /* Test for files to be considered NOT duplicates:       */
  197. /* To be called when filenames are equal if the pair of  */
  198. /* extension is specified in the NON_DUP_EXT table.      */
  199. /* If the pair is in the table the files will not be     */
  200. /* reported as duplicate -> return(1) here.              */
  201. /* Otherwise return(0) -> consider as equal files        */
  202. /* ----------------------------------------------------- */
  203. int  dup_ext(FILECHAIN **dm,
  204.              unsigned int  k1,          /* index of 1st entry           */
  205.              unsigned int  k2)          /* index of 2nd entry           */
  206. {
  207.   char *p1, *p2;                        /* pointers to ext */
  208.   int   i;                              /* counter */
  209.  
  210.   p1 = strrchr(dm[k1]->fname, '.');     /* offset dot in fn 1 */
  211.   p2 = strrchr(dm[k2]->fname, '.');     /* offset dot in fn 2 */
  212.  
  213.   if (p1!=NULL && p2!=NULL) {           /* both have an extension */
  214.     ++p1; ++p2;                         /* 1st char after dots */
  215.     if (stricmp(p1, p2)) {              /* extensions are not equal */
  216.       for (i=0; strlen(non_dup_ext[i])>0; i++,i++) {  /* scan table */
  217.         if (!stricmp(p1,non_dup_ext[i])  &&  /* first equal to first */
  218.             !stricmp(p2,non_dup_ext[i+1]))   /* second to second */
  219.           return(1);                    /* considered unequal*/
  220.         else if (!stricmp(p1,non_dup_ext[i+1])  &&  /* first to second */
  221.                  !stricmp(p2,non_dup_ext[i]))       /* second to first */
  222.           return(1);                    /* considered unequal */
  223.         }
  224.       }
  225.     }
  226.   return(0);                            /* files (pseudo) equal */
  227.   }
  228.  
  229. /* ---------------------------------------------------------------- */
  230. /* Produce the FILES.BBS files for all area's                       */
  231. /* Sort on name within priv-group, date or as in input FILES.BBS    */
  232. /* Call them FILESBBS.xx  (where 'xx' is a 2-character area-name).  */
  233. /* Put them in the directory indicated by AREA.DAT for 'listfile'.  */
  234. /* ---------------------------------------------------------------- */
  235. void make_fil(FILECHAIN **dm,
  236.               DOWNPATH _HUGE *area,
  237.               unsigned int  x)
  238. {
  239.   FILE   *pf;                           /* file handle                   */
  240.   char   outfile[MAXPATH];              /* file spec new FILES.bbs       */
  241.   char   oldfile[MAXPATH];              /* file spec old FILES.bbs       */
  242.   char   ac[40];                        /* area name                     */
  243.   unsigned int i,j,m,fc;                /* counters                      */
  244.   int    c_priv;                        /* privilege                     */
  245.  
  246.   if (oper_mode == VERBOSE)
  247.     fprintf(stdout, MSG_SRT, file_total_count, area_total_count,
  248.              "FILES.BBS-files");
  249.  
  250.   switch(lp[P_FIL].sortflag) {
  251.     case ALPHA:     psort(dm,0,file_total_count-1,sort_fil);  break;
  252.     case TIMESTAMP: psort(dm,0,file_total_count-1,sort_al2);  break;
  253.     case KEEPSEQ:   psort(dm,0,file_total_count-1,sort_akp);  break;
  254.     default: break;
  255.     }
  256.  
  257.   if (oper_mode != QUIET)
  258.     fprintf(stdout, MSG_REP, "new FILES.BBS files");
  259.   fc = preproc_area(area, dm, lp[P_FIL].priv[x]); /* count files, bytes  */
  260.   pf = NULL;                            /* no file open yet              */
  261.   ac[0] = '\0';                         /* init with null-string         */
  262.   for (i=0; i<file_total_count; i++) {
  263.     if (strcmp(ac,dm[i]->parea->name)) {  /* new area group              */
  264.       if (pf != NULL)                   /* end of previous group         */
  265.         fclose(pf);                     /* finished                      */
  266.       strcpy(ac, dm[i]->parea->name);   /* new area                      */
  267.       c_priv = dm[i]->parea->priv;      /* new AREA-priv                 */
  268.                                         /* generate new "FILES.BBS"      */
  269.       if (strlen(filesbbs_path) > 0) {  /* FIL:path parameter specified  */
  270.         strcpy(outfile,filesbbs_path);  /* copy path                     */
  271.         if (max_aname <= 3) {           /* short areanames               */
  272.           strcat(outfile,lp[P_FIL].name); /* standard filename           */
  273.           strcat(outfile,DOT);          /* separator                     */
  274.           strncat(outfile, ac, 3);      /* extension: 3 chars areaname   */
  275.           }
  276.         else {                          /* long areanames                */
  277.           strcat(outfile,ac);           /* filename: areaname            */
  278.           strcat(outfile,DOT);          /* separator                     */
  279.           strcat(outfile, lp[P_FIL].ext);   /* standard extension        */
  280.           }
  281.         }
  282.       else if (strlen(dm[i]->parea->filesbbs) > 0) { /* "ListFile" spec  */
  283.         strcpy(outfile,dm[i]->parea->filesbbs);
  284.         strcpy(oldfile,outfile);        /* backup file                   */
  285.         for (j=strlen(oldfile), m=1;
  286.                  (j-m)>0 && m<5 && outfile[j-m]!='.'; ++m); /* search '.'*/
  287.         if (m>=5 || (j-m)<=0)           /* no extension found:           */
  288.           m=0;                          /* concat to end of name         */
  289.         strcpy(oldfile+j-m,DOT);        /* add separator                 */
  290.         strcat(oldfile,BAK);            /* backup file extension         */
  291.         unlink(oldfile);                /* erase old backup file         */
  292.         rename(outfile,oldfile);        /* rename current to backup      */
  293.         }
  294.       else {                            /* default directory             */
  295.         strcpy(outfile,dm[i]->parea->pname);  /* path to download dir    */
  296.         strcat(outfile,lp[P_FIL].name); /* add filename                  */
  297.         strcat(outfile,DOT);            /* add separator                 */
  298.         strcpy(oldfile,outfile);        /* backup file                   */
  299.         strcat(oldfile,BAK);            /* backup file extension         */
  300.         strcat(outfile,lp[P_FIL].ext);  /* add BBS-extension             */
  301.         unlink(oldfile);                /* erase old backup file         */
  302.         rename(outfile,oldfile);        /* rename current to backup      */
  303.         }
  304.  
  305.       if (oper_mode == VERBOSE)         /* progress reporting */
  306.         fprintf(stdout, MSG_REP, outfile);
  307.       else if (oper_mode != QUIET) {
  308.         fprintf(stdout, DOT);
  309.         fflush(stdout);
  310.         }
  311.       pf = fopen(outfile,WRITE);
  312.       if (pf != NULL) {
  313.         if (max_aname <= 3) {           /* short areanames               */
  314.           fprintf(pf,"%s\f\n%s%s ║ %-.*s\n",
  315.                     FILPREFX, FILPREFX, strnblk(ac,3,FONT3,LINE1),
  316.                     79-3-strlen(strnblk(ac,3,FONT3,LINE1)),
  317.                     dm[i]->parea->adesc);
  318.           fprintf(pf,"%s%s ║ Available: %u files (%lu.%lu MB)\n",
  319.                     FILPREFX,strnblk(ac,3,FONT3,LINE2),
  320.                     dm[i]->parea->file_count,         /* area filecount  */
  321.                     (dm[i]->parea->byte_count+52428L)/1048576L,   /* 100K*/
  322.                    ((dm[i]->parea->byte_count+52429L)/104857L)%10); /*.1K*/
  323.           fprintf(pf,"%s%s ║",
  324.                       FILPREFX, strnblk(ac,3,FONT3,LINE3));
  325.           if (lp[P_FIL].exclflag != EXCLPRIV)
  326.             fprintf(pf," Privilege: %-.9s",
  327.                       priv_name[dm[i]->parea->priv-TWIT]);  /* area priv */
  328.           fprintf(pf,"\n");
  329.           fprintf(pf,"%s%s ║ ",
  330.                       FILPREFX, strnblk(ac,3,FONT3,LINE4));
  331.           if (dm[i]->parea->newest != NULL) {     /* newest file         */
  332.                       dm[i]->parea->newest->fname,
  333.             fprintf(pf,"Newest: %s dd %8s",
  334.                       dm[i]->parea->newest->fname,
  335.                       f_date(dm[i]->parea->newest->wdate));
  336.             fprintf(pf," (avail: %8s)",
  337.                       f_date(dm[i]->parea->newest->cdate));
  338.             }
  339.           fprintf(pf,"\n");
  340.           }
  341.         else {                          /* long areanames */
  342.           fprintf(pf,"%s\f\n", FILPREFX);
  343.           for (j=0; j<title_lines[lp[P_FIL].tfont]; ++j)  /* block name */
  344.             fprintf(pf, "%s%s\n", FILPREFX,
  345.                          strnblk(ac, 8, lp[P_FIL].tfont,j));
  346.           fprintf(pf,"%s", FILPREFX);  /* start separator line */
  347.           sep_line(pf, '─', 78, 0);
  348.           fprintf(pf,"%s %-.77s\n", FILPREFX, dm[i]->parea->adesc);
  349.           fprintf(pf,"%s Available: %u files (%lu.%lu MB)\n",
  350.                       FILPREFX, dm[i]->parea->file_count,
  351.                      (dm[i]->parea->byte_count+52428L)/1048576L,  /* 100K*/
  352.                      ((dm[i]->parea->byte_count+52429L)/104857L)%10); /* */
  353.           if (lp[P_FIL].exclflag != EXCLPRIV)
  354.             fprintf(pf,"%s Privilege: %-.9s\n",
  355.                       FILPREFX, priv_name[dm[i]->parea->priv-TWIT]);
  356.           if (dm[i]->parea->newest != NULL) {
  357.                       dm[i]->parea->newest->fname,
  358.             fprintf(pf,"%s Newest: %s dd %8s",
  359.                       FILPREFX, dm[i]->parea->newest->fname,
  360.                       f_date(dm[i]->parea->newest->wdate));
  361.             fprintf(pf," (avail: %8s)\n",
  362.                       f_date(dm[i]->parea->newest->cdate));
  363.             }
  364.           }
  365.         fprintf(pf,"%s", FILPREFX);
  366.         sep_line(pf, '─', 78, 0);
  367.         file_incl(pf,P_FIL);            /* insert user-'logo'            */
  368.         fprintf(pf,"%s%s      %s    %s     %s\n%s",
  369.                     FILPREFX, FN, SZ, DT, DS, FILPREFX);
  370.         sep_line(pf, '─', 11, 7, 9, 48, 0);
  371.         }
  372.       else                              /* failed to open new FILES.BBS  */
  373.         fprintf(stderr, MSG_OPO, outfile, 3); /* ??? */
  374.       }                                 /* endif                         */
  375.     if (pf != NULL) {                   /* check for open file           */
  376.       if (dm[i]->priv <= lp[P_FIL].priv[x]) {  /* specified reporting lvl*/
  377.         if (dm[i]->priv > c_priv) {     /* higher priv group within area */
  378.           c_priv = dm[i]->priv;         /* set new                       */
  379.           fprintf(pf,"%c%c\n", '\20',
  380.                      (c_priv>SYSOP) ? 'S' : priv_name[c_priv-TWIT][0]);
  381.           }
  382.         if (dm[i]->fname[0] != '\0') {  /* filename present              */
  383.           if (dm[i]->fpath != NULL)     /* explicit pathspec             */
  384.             fprintf(pf,"%s%s ", dm[i]->fpath,  /* path                   */
  385.                                 dm[i]->fname); /* filename               */
  386.           else
  387.             fprintf(pf,"%-12.12s ", dm[i]->fname); /* filename           */
  388.           if (lp[P_FIL].longflag==LONGLIST)       /* 'long' format req'd */
  389.             fprintf(pf,"  %15s",                  /* file size + date    */
  390.                         f_size_date(dm[i]->size, dm[i]->wdate,
  391.                               dm[i]->cdate, dm[i]->ctime));
  392.           if (dm[i]->dl_b==1 || dm[i]->dl_t==1) {  /* download flags     */
  393.             fprintf(pf,"/");
  394.             if (dm[i]->dl_b==1)         /* free bytes flag               */
  395.               fprintf(pf,"b");
  396.             if (dm[i]->dl_t==1)         /* free time flag                */
  397.               fprintf(pf,"t");
  398.             }
  399.           fprintf(pf," %-s\n", dm[i]->fdesc);  /* description as 1 piece */
  400.           }
  401.         else if(lp[P_FIL].sortflag == KEEPSEQ)  /* comment, '/K' spec'd  */
  402.           fprintf(pf,"%-s\n", dm[i]->fdesc);
  403.         }
  404.       }
  405.     }
  406.   if (pf != NULL)                       /* end of last FILES.BBS         */
  407.     fclose(pf);                         /* finished with FILES.bbs file  */
  408.   }                                     /* end                           */
  409.  
  410. /* ------------------------------ */
  411. /* Produce the BinkleyTerm OKFile */
  412. /* (area's in downpath sequence!) */
  413. /* ------------------------------ */
  414. void make_ok(FILECHAIN **dm,
  415.              DOWNPATH _HUGE *area,
  416.              unsigned int  x)
  417. {
  418.   FILE   *pf;                           /* file handle                   */
  419.   char   outfile[MAXFN];                /* file names                    */
  420.   unsigned int i,j;                     /* counters                      */
  421.  
  422.   sprintf(outfile,"%s.%s%c",
  423.           lp[P_OK].name,
  424.           lp[P_OK].ext,
  425.           priv_name[lp[P_OK].priv[x]-TWIT][0]);
  426.   pf = fopen(outfile,WRITE);            /* output file                   */
  427.   if (pf != NULL) {
  428.     if (oper_mode != QUIET)
  429.       fprintf(stdout, MSG_REP, outfile);
  430.     file_incl(pf, P_OK);                /* insert magic filenames        */
  431.     preproc_area(area, dm, lp[P_OK].priv[x]); /* count files, bytes      */
  432.     if (lp[P_OK].longflag == LONGLIST) {   /* LONG list requested        */
  433.       for (i=0; i<file_total_count; i++) {     /* all files in chain     */
  434.         if (dm[i]->priv <= lp[P_OK].priv[x] && /* check file privilege   */
  435.             dm[i]->fname[0] != '\0')           /* filename present       */
  436.           fprintf(pf, "@%s %s%s\n",
  437.                       dm[i]->fname,
  438.                       (dm[i]->fpath==NULL) ? dm[i]->parea->pname :
  439.                                               dm[i]->fpath,
  440.                       dm[i]->fname);
  441.         }
  442.       }
  443.     else {
  444.       for (i=j=0; i<area_total_count; i++)  /* all area's in array       */
  445.         if (area[i].priv <= lp[P_OK].priv[x] &&   /* area privilege      */
  446.             area[i].file_count > 0)       /* and at least 1 file         */
  447.           if (i<1 || strcmp(area[i].pname,area[j].pname)) { /* not yet in*/
  448.             fprintf(pf, "%s*.*\n", area[i].pname);
  449.             j = i;                      /* index of last 'printed'       */
  450.             }
  451.       }
  452.     fclose(pf);                         /* finished with .ALL file       */
  453.     }
  454.   else
  455.     fprintf(stderr, MSG_OPO, outfile, 0);      /* open failed          */
  456.   }
  457.  
  458.