Commit 0a9640c7 authored by rswindell's avatar rswindell
Browse files

Added -new option, to specify the maximum number of days since files were

uploaded to include the list output.
parent 1a726f2e
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* * * *
* Copyright 2000 Rob Swindell - http://www.synchro.net/copyright.html * * Copyright 2007 Rob Swindell - http://www.synchro.net/copyright.html *
* * * *
* This program is free software; you can redistribute it and/or * * This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License * * modify it under the terms of the GNU General Public License *
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#include "sbbs.h" #include "sbbs.h"
#define FILELIST_VER "3.00" #define FILELIST_VER "3.10"
#define MAX_NOTS 25 #define MAX_NOTS 25
...@@ -106,8 +106,9 @@ int main(int argc, char **argv) ...@@ -106,8 +106,9 @@ int main(int argc, char **argv)
uchar *datbuf,*ixbbuf; uchar *datbuf,*ixbbuf;
int i,j,file,dirnum,libnum,desc_off,lines,nots=0 int i,j,file,dirnum,libnum,desc_off,lines,nots=0
,omode=O_WRONLY|O_CREAT|O_TRUNC; ,omode=O_WRONLY|O_CREAT|O_TRUNC;
ulong l,m,n,cdt,misc=0,total_cdt=0,total_files=0,datbuflen; ulong l,m,n,cdt,misc=0,total_cdt=0,total_files=0,dir_files,datbuflen;
time_t uld,dld; time_t uld,dld,now;
long max_age=0;
FILE *in,*out=NULL; FILE *in,*out=NULL;
sscanf("$Revision$", "%*s %s", revision); sscanf("$Revision$", "%*s %s", revision);
...@@ -129,6 +130,7 @@ int main(int argc, char **argv) ...@@ -129,6 +130,7 @@ int main(int argc, char **argv)
printf("\n"); printf("\n");
printf("switches: -lib name All directories of specified library\n"); printf("switches: -lib name All directories of specified library\n");
printf(" -not code Exclude specific directory\n"); printf(" -not code Exclude specific directory\n");
printf(" -new days Include only new files in listing (days since upload)\n");
printf(" -cat Concatenate to existing outfile\n"); printf(" -cat Concatenate to existing outfile\n");
printf(" -pad Pad filename with spaces\n"); printf(" -pad Pad filename with spaces\n");
printf(" -hdr Include directory headers\n"); printf(" -hdr Include directory headers\n");
...@@ -156,6 +158,8 @@ int main(int argc, char **argv) ...@@ -156,6 +158,8 @@ int main(int argc, char **argv)
exit(1); exit(1);
} }
now=time(NULL);
memset(&scfg,0,sizeof(scfg)); memset(&scfg,0,sizeof(scfg));
scfg.size=sizeof(scfg); scfg.size=sizeof(scfg);
SAFECOPY(scfg.ctrl_dir,p); SAFECOPY(scfg.ctrl_dir,p);
...@@ -221,6 +225,14 @@ int main(int argc, char **argv) ...@@ -221,6 +225,14 @@ int main(int argc, char **argv)
printf("\nBoth library name and -all parameters were used.\n"); printf("\nBoth library name and -all parameters were used.\n");
exit(1); } exit(1); }
misc|=ALL; } misc|=ALL; }
else if(!stricmp(argv[i],"-new")) {
i++;
if(i>=argc) {
printf("\nDays since upload must follow -new parameter.\n");
exit(1);
}
max_age=strtol(argv[i],NULL,0);
}
else if(!stricmp(argv[i],"-pad")) else if(!stricmp(argv[i],"-pad"))
misc|=PAD; misc|=PAD;
else if(!stricmp(argv[i],"-cat")) else if(!stricmp(argv[i],"-cat"))
...@@ -271,6 +283,7 @@ int main(int argc, char **argv) ...@@ -271,6 +283,7 @@ int main(int argc, char **argv)
misc|=AUTO; } misc|=AUTO; }
for(i=0;i<scfg.total_dirs;i++) { for(i=0;i<scfg.total_dirs;i++) {
dir_files=0;
if(!(misc&ALL) && i!=dirnum && scfg.dir[i]->lib!=libnum) if(!(misc&ALL) && i!=dirnum && scfg.dir[i]->lib!=libnum)
continue; continue;
for(j=0;j<nots;j++) for(j=0;j<nots;j++)
...@@ -344,8 +357,6 @@ int main(int argc, char **argv) ...@@ -344,8 +357,6 @@ int main(int argc, char **argv)
str[j]=ixbbuf[m++]; /* Turns FILENAMEEXT into FILENAME.EXT */ str[j]=ixbbuf[m++]; /* Turns FILENAMEEXT into FILENAME.EXT */
str[j]=0; str[j]=0;
unpadfname(str,fname); unpadfname(str,fname);
fprintf(out,"%-12.12s",misc&PAD ? str : fname);
total_files++;
n=ixbbuf[m]|((long)ixbbuf[m+1]<<8)|((long)ixbbuf[m+2]<<16); n=ixbbuf[m]|((long)ixbbuf[m+1]<<8)|((long)ixbbuf[m+2]<<16);
uld=(ixbbuf[m+3]|((long)ixbbuf[m+4]<<8)|((long)ixbbuf[m+5]<<16) uld=(ixbbuf[m+3]|((long)ixbbuf[m+4]<<8)|((long)ixbbuf[m+5]<<16)
|((long)ixbbuf[m+6]<<24)); |((long)ixbbuf[m+6]<<24));
...@@ -358,7 +369,14 @@ int main(int argc, char **argv) ...@@ -358,7 +369,14 @@ int main(int argc, char **argv)
fprintf(stderr,"\n\7%s%s is corrupted!\n" fprintf(stderr,"\n\7%s%s is corrupted!\n"
,scfg.dir[i]->data_dir,scfg.dir[i]->code); ,scfg.dir[i]->data_dir,scfg.dir[i]->code);
exit(-1); } exit(-1); }
if(max_age && ((now - uld) / (24*60*60) > max_age))
continue;
fprintf(out,"%-12.12s",misc&PAD ? str : fname);
total_files++;
dir_files++;
if(misc&PLUS && datbuf[n+F_MISC]!=ETX if(misc&PLUS && datbuf[n+F_MISC]!=ETX
&& (datbuf[n+F_MISC]-' ')&FM_EXTDESC) && (datbuf[n+F_MISC]-' ')&FM_EXTDESC)
...@@ -449,7 +467,8 @@ int main(int argc, char **argv) ...@@ -449,7 +467,8 @@ int main(int argc, char **argv)
fprintf(out,"\r\n"); } fprintf(out,"\r\n"); }
free((char *)datbuf); free((char *)datbuf);
free((char *)ixbbuf); free((char *)ixbbuf);
fprintf(out,"\r\n"); /* blank line at end of dir */ if(dir_files)
fprintf(out,"\r\n"); /* blank line at end of dir */
if(misc&AUTO) fclose(out); } if(misc&AUTO) fclose(out); }
if(misc&TOT && !(misc&AUTO)) if(misc&TOT && !(misc&AUTO))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment