home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / com / bbs / downsrt / source / downrpt1.c < prev    next >
Text File  |  1991-06-06  |  24KB  |  512 lines

  1. /* ================================================================ */
  2. /*  Rob Hamerling's MAXIMUS download file scan and sort utility     */
  3. /*  -> Functions for creating file reports (the mainlines of them). */
  4. /* ================================================================ */
  5.  
  6. // #define DEBUG_MODE
  7.  
  8. #define INCL_BASE
  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 "downsort.h"
  18.  
  19. /* ------------------------- */
  20. /* Produce the ORPHAN report */
  21. /* ------------------------- */
  22. void make_orp(dm)
  23. struct  _filechain **dm;                // pointer to file-sort array
  24. {
  25.   static char orp_title[] = " Orphans ";
  26.   FILE  *pf;                            // file handle
  27.   char  outfile[MAXFN];                 // file names
  28.   USHORT i,j,k;                         // counters
  29.   char   *strptr;                       // pointer to a string
  30.   struct _filechain *ca;                // pointer to file-info
  31.  
  32.   sprintf(outfile,"%s.%s",lp[P_ORP].name,lp[P_ORP].ext);  // build filename
  33.   if (oper_mode==VERBOSE)
  34.     printf(MSG_SRT,file_count,area_count,outfile);
  35.   if (lp[P_ORP].sortflag == ALPHA)      // sort on name
  36.     psort(dm,0,file_count-1,sort_gbl);
  37.   else if (lp[P_ORP].sortflag == TIMESTAMP)   // sort on date
  38.     psort(dm,0,file_count-1,sort_new);
  39.  
  40.   j = file_count - count_files(dm, SYSOP);  // calc orphans in array
  41.   if (j>0) {                            // yes, there are orphans
  42.     if (oper_mode == VERBOSE)
  43.       printf("\n%d Orphans detected",j);  // console message
  44.     pf = fopen(outfile,"w");            // output file
  45.     if (pf != NULL) {                   // successful open
  46.       if (oper_mode == VERBOSE)
  47.         printf("\nCreating Orphan-report: %s",outfile);
  48.       for (i=0; i<title_lines[lp[P_ORP].tfont]; ++i)   // whole title
  49.         fprintf(pf,"%s\n",strnblk(orp_title,13,lp[P_ORP].tfont,i));
  50.       fprintf(pf,"%-.39s%-.40s",HD,HD);
  51.       fprintf(pf,"\n%s %s       %s    %-s",AC,FN,DT,FP);
  52.       fprintf(pf,"\n%4.4s %-12.12s %-8.8s  %-.26s%-.26s",HS,HS,HS,HS,HS);
  53.       for (i=0; i<file_count; i++) {
  54.         ca = dm[i];                       // pointer to file information
  55.         if (ca->priv >= HIDDEN) {         // report "hidden" and up
  56.           ca->fdesc = ORPHAN;             // assign 'description'
  57.           k = strsubw(ca->parea->pname,&strptr,52);
  58.           fprintf(pf,"\n %2.2s  %-12.12s %s  %-.*s",
  59.                       ca->parea->name,
  60.                       ca->fname,
  61.                       f_date(ca->wdate),
  62.                       k,(k>0)?strptr:"");  // (part of) path-name
  63.           while (k>0) {
  64.             k = strsubw(strptr+k,&strptr,52);
  65.             if (k>0)
  66.               fprintf(pf,"\n%-27.27s%-.*s",
  67.                          "",k,strptr);  // remainder of path-name
  68.             }
  69.           }
  70.         }
  71.       signature(pf,today);              // fingerprint
  72.       fclose(pf);                       // finished with .ORP file
  73.       }
  74.     else                                // no output possible
  75.       printf(OPEN_FAIL,outfile);
  76.     }
  77.   }
  78.  
  79. /* --------------------------------------- */
  80. /* Produce the bulletin format of BBS-list */
  81. /* --------------------------------------- */
  82. void make_bbs(dm,m,r_priv)
  83. struct  _filechain **dm;                // pointer to file-sort array
  84. USHORT  m;                              // maximum file lines
  85. int     r_priv;                         // maximum report privilege
  86. {
  87.   FILE  *pf;                            // report file handle
  88.   char  outfile[MAXFN];                 // file names
  89.   USHORT i,j,k,n;                       // counters
  90.   char   *strptr;                       // pointer to a string
  91.   struct _filechain *ca,*cn;            // current and newest file ptr
  92.  
  93.   sprintf(outfile,"%s.%s",lp[P_BBS].name,lp[P_BBS].ext);  // build filename
  94.   pf = fopen(outfile,"w");              // output file
  95.   if (pf != NULL) {                     // successful open
  96.     if (oper_mode!=QUIET)
  97.       printf(MSG_SRT, file_count, area_count, outfile);
  98.     psort(dm,0,file_count-1,sort_new);
  99.     n = m;                              // take maximum files to be listed
  100.     cn = NULL;                          // not assigned
  101.     for (i=j=0; j<n && i<file_count; i++)  // stop when req'd # reached
  102.       if (dm[i]->priv <= r_priv) {      // check file-privilege
  103.         j++;                            // presentable file count
  104.         cn = new_acq(dm[i],cn);         // keep pointer to most recent
  105.         }                               //       within privilege
  106.     if (n > j)                          // more req'd than within priv
  107.       n = j;                            // new request-limit
  108.     if (lp[P_BBS].sortflag == ALPHA) {  // resort first entries on name
  109.       if (oper_mode == VERBOSE)
  110.         printf(MSG_RST,i);              // re-sort msg
  111.       psort(dm,0,i-1,sort_gbl);         // sort first 'i' entries
  112.       }
  113.  
  114.     if (oper_mode==VERBOSE)
  115.       printf(MSG_REC,outfile);
  116.     strcpy(outfile,PROGNAME);           // build headerfilename
  117.     strcat(outfile,".HDR");
  118.     file_incl(pf, outfile);             // include bbs headerfile
  119.     fprintf(pf,"\n%c(%s) %c%u%c most recent of a total of"
  120.                " %c%u%c files (%c%lu%c MB)",
  121.                 O_CYAN,sys_date(today),
  122.                 O_YELLOW,n,O_CYAN,
  123.                 O_YELLOW,count_files(dm, r_priv),O_CYAN,
  124.                 O_BRIGHT+O_MAGENTA,
  125.                   (count_bytes(dm, r_priv)/1024+512)/1024,O_CYAN);
  126.     if (lp[P_BBS].sortflag == ALPHA &&      // for filename-sorted list only
  127.                         cn != NULL)  {      // new file available
  128.       fprintf(pf,"\n%19sNewest: %c%s %c%8s",
  129.                  "",O_YELLOW,cn->fname,
  130.                     O_GREEN,f_date(cn->wdate));
  131.       fprintf(pf," %c(avail: %c%8s%c)",
  132.                     O_CYAN,O_GREEN,f_date(cn->cdate),O_CYAN);
  133.       }
  134.     fprintf(pf,"\n%19sDate flag: new on this system since:"
  135.                " %c = week, %c = month.","",DAYS_7,DAYS_30);
  136.     if (lp[P_BBS].exclflag != EXCLPRIV)
  137.       fprintf(pf,"\n\n%c(Your privilege-level may limit the number "
  138.                 "of files actually shown to you!)%c",O_RED,O_CYAN);
  139.     fprintf(pf,"\n\n%c%s    %c%s %c%s   %c%s    %c%s\n",
  140.                 O_YELLOW,FN,
  141.                 O_BRIGHT+O_RED,AC,
  142.                 O_MAGENTA,SZ,
  143.                 O_GREEN,DT,
  144.                 O_CYAN,DS);
  145.  
  146.     for (i=j=0; j<n && i<file_count; i++) {
  147.       ca = dm[i];                       // pointer to file information
  148.       if (ca->priv <= r_priv) {         // limit to report privilege
  149.         if (oper_mode==VERBOSE && (j%25)==0)
  150.           cprintf("\r %5u",j);
  151.         j++;                            // list file-count
  152.         k = strsubw(ca->fdesc,&strptr,47);
  153.         if (k>0 && lp[P_BBS].wrapflag != WRAP)   // default: trunc
  154.           k = 47;
  155.         fprintf(pf,"\n%cL%c%c%-12.12s %c%2.2s "
  156.                    "%c%4ldK %c%s%c %c%-.*s",
  157.               '\20',priv_name[ca->priv-TWIT][0],
  158.                     O_YELLOW,ca->fname,
  159.                     O_RED+O_BRIGHT,ca->parea->name,
  160.                     O_MAGENTA,(ca->size+1023)/1024,  // roundup for list only
  161.                     O_GREEN,f_date(ca->wdate),
  162.                     file_age_ind(ca->cdate,ca->ctime), // file age indicator
  163.                     O_CYAN,k,(k>0)?strptr:"");  // (part of) description
  164.         if (lp[P_BBS].wrapflag == WRAP)
  165.           while (k>0) {
  166.             k = strsubw(strptr+k,&strptr,47);
  167.             if (k>0)
  168.               fprintf(pf,"\n%-32.32s%-.*s",
  169.                          "",k,strptr);  // remainder
  170.             }
  171.         }
  172.       }
  173.     if (oper_mode==VERBOSE)
  174.       printf("\r %5u",j);
  175.     signature(pf,today);                // fingerprint
  176.     strcpy(outfile,PROGNAME);           // build trailerfilename
  177.     strcat(outfile,".TRL");
  178.     file_incl(pf, outfile);             // include bbs trailerfile
  179.     fclose(pf);                         // finished with .BBS file
  180.     }
  181.   else                                  // no output possible
  182.     printf(OPEN_FAIL,outfile);
  183.   }
  184.  
  185. /* ------------------------------------------- */
  186. /* Produce the file-request format of NEW-list */
  187. /* ------------------------------------------- */
  188. void make_new(dm,m,r_priv)
  189. struct  _filechain **dm;                // pointer to file-sort array
  190. USHORT  m;                              // max files to be listed
  191. int     r_priv;                         // maximum report privilege
  192. {
  193.   FILE  *pf;                            // file handle
  194.   char  outfile[MAXFN];                 // file names
  195.   USHORT i,j,k,n;                       // counters
  196.   char   *strptr;                       // pointer to a string
  197.   struct _filechain *ca,*cn;            // pointer to file-info
  198.  
  199.   sprintf(outfile,"%s.%s%c",
  200.           lp[P_NEW].name,lp[P_NEW].ext,priv_name[r_priv-TWIT][0]);
  201.   pf = fopen(outfile,"w");              // output file
  202.   if (pf != NULL) {                     // opened!
  203.     if (oper_mode!=QUIET)
  204.       printf(MSG_SRT,file_count,area_count,outfile);
  205.     psort(dm,0,file_count-1,sort_new);
  206.     n = m;                              // take maximum files to be listed
  207.     cn = NULL;                          // no assigned
  208.     for (i=j=0; j<n && i<file_count; i++) {  // stop when req'd # reached
  209.       if (dm[i]->priv <= r_priv) {      // check file-privilege
  210.         j++;                            // presentable file count
  211.         cn = new_acq(dm[i],cn);         // keep pointer to most recent
  212.         }
  213.       }
  214.     if (n > j)                          // more req'd than within priv
  215.       n = j;                            // new request-limit
  216.     if (lp[P_NEW].sortflag == ALPHA) {           // resort first entries on name
  217.       if (oper_mode==VERBOSE)
  218.         printf(MSG_RST,i);              // re-sort msg
  219.       psort(dm,0,i-1,sort_gbl);         // sort first 'i' entries
  220.       }
  221.  
  222.     if (oper_mode==VERBOSE)
  223.       printf(MSG_REC,outfile);
  224.     for (i=0; i<MAXTIT && pre_title[i]!=NULL; ++i)
  225.       fprintf(pf,"%s\n",pre_title[i]);
  226.     for (i=0; i<title_lines[lp[P_NEW].tfont]; ++i)
  227.       fprintf(pf,"%s\n",strnblk(list_title,20,lp[P_NEW].tfont,i));
  228.     if (lp[P_NEW].incl_fspec != NULL)
  229.       file_incl(pf,lp[P_NEW].incl_fspec); // insert user-'logo'
  230.     for (i=0; i<MAXTIT && sub_title[i]!=NULL; ++i)
  231.       fprintf(pf,"%s\n",sub_title[i]);
  232.     fprintf(pf,"\n(%s) %u most recent of a total of %u files (%lu MB)",
  233.                  sys_date(today),
  234.                  n,
  235.                  count_files(dm, r_priv),
  236.                  (count_bytes(dm, r_priv)/1024+512)/1024);
  237.     if (lp[P_NEW].exclflag != EXCLPRIV)
  238.       fprintf(pf,"\n%19sMaximum privilege shown: %s",
  239.                "",priv_name[r_priv-TWIT]);
  240.     if (lp[P_NEW].sortflag == ALPHA  &&  // for filename-sorted list only
  241.                         cn != NULL) {    // newest file
  242.       fprintf(pf,"\n%19sNewest: %s dd %8s",
  243.                  "",cn->fname,f_date(cn->wdate));
  244.       fprintf(pf," (avail: %8s)",f_date(cn->cdate));
  245.       }
  246.     fprintf(pf,"\n%19sDate flag: new on this system since:"
  247.                " %c = week, %c = month.","",DAYS_7,DAYS_30);
  248.     fprintf(pf,"\n\n%s    %s %s   %s    %s",FN,AC,SZ,DT,DS);
  249.     fprintf(pf,"\n%-.12s ── %-.5s %-.8s  %-.23s%-.24s",HS,HS,HS,HS,HS);
  250.     for (i=j=0; j<n && i<file_count; i++) {
  251.       ca = dm[i];                       // pointer to file information
  252.       if (ca->priv <= r_priv) {         // only upto max priv_level
  253.         if (oper_mode==VERBOSE && (j%25)==0)
  254.           cprintf("\r %5u",j);
  255.         j++;                            // file list-count
  256.         k = strsubw(ca->fdesc,&strptr,47);
  257.         if (k>0 && lp[P_NEW].wrapflag != WRAP)   // default: TRUNC
  258.           k = 47;
  259.         fprintf(pf,"\n%-12.12s %2.2s %4ldK %s%c %-.*s",
  260.               ca->fname,
  261.               ca->parea->name,
  262.               (ca->size+1023)/1024,     // roundup for list only
  263.               f_date(ca->wdate),
  264.               file_age_ind(ca->cdate,ca->ctime), // file age indicator
  265.               k,(k>0)?strptr:"");      // (part of) description
  266.         if (lp[P_NEW].wrapflag == WRAP)
  267.           while (k>0) {
  268.             k = strsubw(strptr+k,&strptr,47);
  269.             if (k>0)
  270.               fprintf(pf,"\n%-32.32s%-.*s",
  271.                          "",k,strptr);  // remainder
  272.             }
  273.         }
  274.       }
  275.     if (oper_mode==VERBOSE)
  276.       printf("\r %5u",j);
  277.     signature(pf,today);                // leave fingerprint
  278.     for (i=0; i<MAXTIT && bot_lines[i]!=NULL; ++i)
  279.       fprintf(pf,"%s\n",bot_lines[i]);
  280.     fclose(pf);                         // finished with .NEW file
  281.     }
  282.   else
  283.     printf(OPEN_FAIL,outfile);
  284.   }
  285.  
  286. /* ------------------------------------------- */
  287. /* Produce the file-request format of GBL-list */
  288. /* ------------------------------------------- */
  289. void make_gbl(dm,r_priv)
  290. struct  _filechain **dm;                // pointer to file-sort array
  291. int     r_priv;                         // maximum report privilege
  292. {
  293.   FILE  *pf;                            // file handle
  294.   char  outfile[MAXFN];                 // file names
  295.   USHORT i,j,k;                         // counters
  296.   char   *strptr;                       // pointer to a string
  297.   struct _filechain *ca,*cn;            // pointer to file-info
  298.  
  299.   sprintf(outfile,"%s.%s%c",
  300.           lp[P_GBL].name,lp[P_GBL].ext,priv_name[r_priv-TWIT][0]);
  301.   pf = fopen(outfile,"w");              // output file
  302.   if (pf != NULL) {
  303.     if (oper_mode!=QUIET)
  304.       printf(MSG_SRT,file_count,area_count,outfile);
  305.     if (lp[P_GBL].sortflag == ALPHA)
  306.       psort(dm,0,file_count-1,sort_gbl); // filename sort
  307.     else if (lp[P_GBL].sortflag == TIMESTAMP)
  308.       psort(dm,0,file_count-1,sort_new); // filedate sort
  309.     cn = NULL;                          // no assigned
  310.     for (i=k=0; i<file_count; ++i) {    // stop at end of files
  311.       if (dm[i]->priv <= r_priv) {      // check file-privilege
  312.         k++;                            // presentable file count
  313.         cn = new_acq(dm[i],cn);         // keep pointer to most recent
  314.         }                               // endif
  315.       }                                 // endfor
  316.     if (oper_mode==VERBOSE)
  317.       printf(MSG_REC,outfile);
  318.     for (i=0; i<MAXTIT && pre_title[i]!=NULL; ++i)
  319.       fprintf(pf,"%s\n",pre_title[i]);
  320.     for (i=0; i<title_lines[lp[P_GBL].tfont]; ++i)  // whole title
  321.       fprintf(pf,"%s\n",strnblk(list_title,20,lp[P_GBL].tfont,i));
  322.     if (lp[P_GBL].incl_fspec != NULL)
  323.       file_incl(pf,lp[P_GBL].incl_fspec); // insert user-'logo'
  324.     for (i=0; i<MAXTIT && sub_title[i]!=NULL; ++i)
  325.       fprintf(pf,"%s\n",sub_title[i]);
  326.     fprintf(pf,"\n(%s) Available: %u files (%lu MB)",
  327.                 sys_date(today),
  328.                 count_files(dm, r_priv),
  329.                (count_bytes(dm, r_priv)/1024+512)/1024);
  330.     if (lp[P_GBL].exclflag != EXCLPRIV)
  331.       fprintf(pf,"\n%19sMaximum privilege shown: %s",
  332.                "",priv_name[r_priv-TWIT]);
  333.     if (cn != NULL) {
  334.       fprintf(pf,"\n%19sNewest: %s %8s",
  335.                "",cn->fname,f_date(cn->wdate));
  336.       fprintf(pf," (avail: %8s)",f_date(cn->cdate));
  337.       }
  338.     fprintf(pf,"\n%19sDate flag: new on this system since:"
  339.                " %c = week, %c = month.","",DAYS_7,DAYS_30);
  340.     fprintf(pf,"\n\n%s    %s %s   %s    %s\n",FN,AC,SZ,DT,DS);
  341.     fprintf(pf,"%-.12s ── %-.5s %-.8s  %-.23s%-.24s",HS,HS,HS,HS,HS);
  342.     for (i=j=0; i<file_count; i++) {
  343.       ca = dm[i];                       // pointer to file information
  344.       if (ca->priv <= r_priv) {         // within priv limit
  345.         if (oper_mode==VERBOSE && (j%25)==0)
  346.           cprintf("\r %5u",j);
  347.         j++;
  348.         k = strsubw(ca->fdesc,&strptr,47);
  349.         if (k>0 && lp[P_GBL].wrapflag == TRUNC)  // default: wrap!
  350.           k = 47;
  351.         fprintf(pf,"\n%-12.12s %2.2s %4ldK %s%c %-.*s",
  352.                 ca->fname,
  353.                 ca->parea->name,
  354.                 (ca->size+1023)/1024,   // roundup for list only
  355.                 f_date(ca->wdate),
  356.                 file_age_ind(ca->cdate,ca->ctime),  // file age indicator
  357.                 k,(k>0)?strptr:"");     // (part of) description
  358.         if (lp[P_GBL].wrapflag != TRUNC) {
  359.           while (k>0) {
  360.             k = strsubw(strptr+k,&strptr,47);
  361.             if (k>0)
  362.               fprintf(pf,"\n%-32.32s%-.*s",
  363.                          "",k,strptr);  // remainder
  364.             }
  365.           }
  366.         }
  367.       }
  368.     if (oper_mode==VERBOSE)
  369.       printf("\r %5u",j);
  370.     signature(pf,today);                // leave fingerprint
  371.     for (i=0; i<MAXTIT && bot_lines[i]!=NULL; ++i)
  372.       fprintf(pf,"%s\n",bot_lines[i]);
  373.     fclose(pf);                         // finished with .GBL file
  374.     }
  375.   else
  376.     printf(OPEN_FAIL,outfile);
  377.   }
  378.  
  379. /* ---------------------------------------------------------------- */
  380. /* Produce the FILES.BBS files for all area's                       */
  381. /* Sort on name within priv-group, date or as in input FILES.BBS    */
  382. /* Call them FILESBBS.xx  (where 'xx' is a 2-character area-name).  */
  383. /* Put them in the directory indicated by AREA.DAT for 'listfile'.  */
  384. /* ---------------------------------------------------------------- */
  385. void make_fil(dm,r_priv)
  386. struct  _filechain **dm;                // pointer to file-sort array
  387. int     r_priv;                         // maximum report privilege
  388. {
  389.   FILE   *pf;                           // file handle
  390.   char   outfile[MAXPATH];              // file spec new FILES.bbs
  391.   char   oldfile[MAXPATH];              // file spec old FILES.bbs
  392.   char   ac[40];                        // area name
  393.   USHORT i,j,k,m;                       // counters
  394.   ULONG  ab_count;                      // byte count per area
  395.   struct _filechain *ca,*cb,*cn;        // pointer to file-info
  396.   int    c_priv;                        // privilege
  397.  
  398.   if (oper_mode!=QUIET)
  399.     printf(MSG_SRT,file_count,area_count,"FILES.BBS-files");
  400.   if (lp[P_FIL].sortflag == ALPHA)
  401.     psort(dm,0,file_count-1,sort_fil);  // filename within priv-group
  402.   else if (lp[P_FIL].sortflag == TIMESTAMP)
  403.     psort(dm,0,file_count-1,sort_al2);  // filedate within area
  404.   else if (lp[P_FIL].sortflag == KEEPSEQ)
  405.     psort(dm,0,file_count-1,sort_akp);  // seq. of FILES.BBS per area
  406.  
  407.   if (oper_mode==VERBOSE)
  408.     printf("\nWriting all FILES.BBS files");
  409.   pf = NULL;                            // no file open yet
  410.   strcpy(ac,"");                        // initial area name
  411.  
  412.   for (i=0; i<file_count; i++) {
  413.     ca = dm[i];                         // pointer to fileinfo
  414.     if (strcmp(ac,ca->parea->name)) {   // new area group
  415.       if (pf != NULL) {                 // end of previous group
  416.         fprintf(pf,"\n");               // extra blank line at end
  417.         fclose(pf);                     // finished
  418.         }
  419.       strcpy(ac,ca->parea->name);       // new area-name
  420.       c_priv = ca->parea->priv;         // new AREA-priv
  421.       ab_count = 0L;                    // init area byte count
  422.       cb = ca;                          // copy pointer (first file)
  423.       cn = NULL;                        // not assigned
  424.       for (j=k=0; i+j<file_count &&          // stop at end of files
  425.            !strcmp(ac,cb->parea->name); ) {  // or at end of area
  426.         if (cb->priv <= r_priv) {       // within area privilege
  427.           ++k;                          // update included file count
  428.           ab_count += cb->size;         // effective area byte count
  429.           cn = new_acq(cb,cn);          // keep pointer to most recent
  430.           }                             // endif
  431.         ++j;                            // next file-entry
  432.         if (i+j<file_count)             // stop at end of files
  433.           cb = dm[i+j];                 // ptr to next file
  434.         }                               // endfor
  435.  
  436.                                         // generate new FILES.bbs
  437.       if (strlen(filesbbs_path) > 0) {  // FIL:path specified
  438.         strcpy(outfile,filesbbs_path);  // copy path
  439.         strcat(outfile,lp[P_FIL].name); // add filename
  440.         strcat(outfile,".");            // add separator
  441.         strncat(outfile,((ac[0]==' ') ? &ac[1] : ac),2); // add ext
  442.         }
  443.       else if (strlen(ca->parea->filesbbs) > 0) { // "ListFile" spec
  444.         strcpy(outfile,ca->parea->filesbbs);
  445.         strcpy(oldfile,outfile);        // backup file
  446.         for (j=strlen(oldfile), m=1;
  447.                  (j-m)>0 && m<5 && outfile[j-m]!='.'; ++m); // search '.'
  448.         if (m>=5 || (j-m)<=0)           // no extension found:
  449.           m=0;                          // concat to end of name
  450.         strcpy(oldfile+j-m,".");        // add separator
  451.         strcat(oldfile,BAK);            // backup file extension
  452.         unlink(oldfile);                // erase old backup file
  453.         rename(outfile,oldfile);        // rename current to backup
  454.         }
  455.       else {                            // default directory
  456.         strcpy(outfile,ca->parea->pname);  // path to download directory
  457.         strcat(outfile,lp[P_FIL].name); // add filename
  458.         strcat(outfile,".");            // add separator
  459.         strcpy(oldfile,outfile);        // backup file
  460.         strcat(oldfile,BAK);            // backup file extension
  461.         strcat(outfile,lp[P_FIL].ext);  // add BBS-extension
  462.         unlink(oldfile);                // erase old backup file
  463.         rename(outfile,oldfile);        // rename current to backup
  464.         }
  465.  
  466.       pf = fopen(outfile,"w");
  467.       if (pf != NULL) {
  468.         fprintf(pf,"\f\n-%s ║ %-.60s\n",
  469.                     strnblk(ac,2,FONT3,LINE1),ca->parea->adesc);
  470.         fprintf(pf,"-%s ║ Available: %u files (%lu.%lu MB)\n",
  471.                     strnblk(ac,2,FONT3,LINE2),k,
  472.                     (ab_count+52428L)/1048576L,        // rounded to 100K
  473.                     ((ab_count+52429L)/104857L)%10);   // 100K fraction
  474.         fprintf(pf,"-%s ║",
  475.                     strnblk(ac,2,FONT3,LINE3));
  476.         if (lp[P_FIL].exclflag != EXCLPRIV)
  477.           fprintf(pf," Privilege: %-.9s",
  478.                     priv_name[ca->parea->priv-TWIT]);  // area privilege
  479.         fprintf(pf,"\n-%s ║ ",strnblk(ac,2,FONT3,LINE4));
  480.         if (cn  != NULL) {              // newest file
  481.           fprintf(pf,"Newest: %s %8s",
  482.                     cn->fname,f_date(cn->wdate));
  483.           fprintf(pf," (avail: %8s)",f_date(cn->cdate));
  484.           }
  485.         fprintf(pf,"\n-%-.39s%-.39s\n",HS,HS);
  486.         if (lp[P_FIL].incl_fspec != NULL)
  487.           file_incl(pf,lp[P_FIL].incl_fspec); // insert user-'logo'
  488.         fprintf(pf," %s      %s    %s     %s\n",FN,SZ,DT,DS);
  489.         fprintf(pf,"-%-.11s %-.7s %-.8s  %-.25s%-.23s\n",HS,HS,HS,HS,HS);
  490.         }
  491.       else
  492.         printf(OPEN_FAIL,outfile);
  493.       }                                 // endif
  494.     if (pf != NULL) {                   // check for open file
  495.       if (ca->priv <= r_priv) {         // specified reporting level
  496.         if (ca->priv > c_priv) {        // higher priv group within area
  497.           c_priv = ca->priv;            // set new
  498.           fprintf(pf,"%c%c\n",'\20',priv_name[ca->priv-TWIT][0]);
  499.           fprintf(pf,"- Following files are classified %s:\n",
  500.                       priv_name[ca->priv-TWIT]);
  501.           }
  502.         fprintf(pf,"%-12.12s %-s\n",
  503.                  ca->fname,             // name
  504.                  ca->fdesc);            // description
  505.         }                               // endif
  506.       }                                 // endif
  507.     }                                   // endfor
  508.   if (pf != NULL)                       // end of last FILES.BBS
  509.     fclose(pf);                         // finished with FILES.bbs file
  510.   }                                     // end
  511.  
  512.