Category : BBS Programs+Doors
Archive   : FILETRX.ZIP
Filename : FILETRX.C

 
Output of file : FILETRX.C contained in archive : FILETRX.ZIP
/* FileTRX
written by Jim Faucette
Released to Public Domain June 1988
327/9 - Charleston, SC
Use the FrontDoor log to create Tracking/Audit Files for programs
that are sent or recieved.
*/

#include
#include
#include
#include
#include
#include

char is_leap(int year);
long date_value(int day,int month,int year);

typedef struct { /* simulated FD log structure(b1.75) */
char marker,spc,date[6],spc2,time[8],spc3,spc4,string[100];
} LINE;

typedef struct { /* variables for output to TRX files */
char date[7],string[81];
} OUT;

static int mon[]={ 31,28,31,30,31,30,31,31,30,31,30,31 };/* days per month */

void main() {
LINE *line;
OUT *out;
FILE *logfp, *infp, *outfp;
char logfile[81], rec_date[7]={0,0,0,0,0,0,0};
char snd_date[7]={0,0,0,0,0,0,0}, *slash, node[81], lstbyte;
struct date *dateblk;
long today, adj_date, line_date, old_line, new_line;
int day, month, year, x, keep = 7, line_to_mov, stop = 0, handle;
char *mo_str[] = { "Jan","Feb","Mar","Apr","May","Jun",
"Jul","Aug","Sep","Oct","Nov","Dec" };

strcpy(logfile,"FD.LOG"); /* default FD log path & name */
if(_argc > 0) { /* get commandline parameters */
for(x=1; x < _argc; x++) {
strupr(_argv[x]); /* up case parameter */
switch(*(_argv[x])) {
case 'D' :
strcpy(logfile,&(_argv[x][1])); /* FD log path & filename */
break;
case 'K' :
keep = atoi(&(_argv[x][1])); /* num of days to keep in log */
}
}
}
keep -= 1; /* adjust for off-by-one */
cprintf("FileTRX is processing %s and keeping %d days of entries.\n",
logfile,keep+1);
line = (LINE *)calloc(1,sizeof(LINE)); /* reserve space */
out = (OUT *)calloc(1,sizeof(OUT));
dateblk = (struct date *)calloc(1,sizeof(struct date));
if((logfp = fopen(logfile,"r+t")) != NULL) { /* make sure log is found */
handle = fileno(logfp); /* get file handle */
getdate(dateblk); /* get system date */
today = date_value(dateblk->da_day,dateblk->da_mon,dateblk->da_year);
adj_date = today - keep; /* adjust to insure KEEP */
infp = fopen("RECV.TRX","a+t"); /* open TRX files */
outfp = fopen("SENT.TRX","a+t");
while((fgets((char *)line,100,logfp)) != NULL) { /* read log */
day = atoi(line->date); /* break out date */
for(x = 0; x < 12; x++) {
if(strncmp(&(line->date[3]),mo_str[x],3) == 0) {
month = x + 1;
x = 12;
}
}
if(month > dateblk->da_mon) year = dateblk->da_year - 1; /* set year */
else year = dateblk->da_year;
line_date = date_value(day,month,year); /* get comparitive date */
if(line_date >= adj_date) break;
if(line->marker == '*') { /* check for first mark */
strupr((char *)line); /* upcase line */
line->string[strlen(line->string)-1] = 0; /* null terminate line */
if(isdigit(line->string[strlen(line->string)-1]) != 0) {
if((line->string[strlen(line->string)-2] == '/') ||
(isdigit(line->string[strlen(line->string)-2]) != 0))
strcpy(node,line->string);
}
strcpy(out->string,line->string);
if(strncmp(line->string,"RECEIVED",8) == 0) {
if((line->string[strlen(line->string)-3] != 'P') &&
(line->string[strlen(line->string)-3] != 'R') &&
(isdigit(line->string[strlen(line->string)-1]) == 0)) {
if(strnicmp(line->date,rec_date,6) != 0) {
strncpy(rec_date,line->date,6);
strncpy(out->date,line->date,6);
out->date[6] = 0;
}
else strcpy(out->date," ");
fprintf(infp,"%s %s - %s\n",out->date,node,&(out->string[9]));
}
}
else if(strncmp(line->string,"SENT",4) == 0) {
if((line->string[strlen(line->string)-3] != 'P') &&
(line->string[strlen(line->string)-3] != 'R') &&
(isdigit(line->string[strlen(line->string)-1]) == 0)) {
if(strnicmp(line->date,snd_date,6) != 0) {
strncpy(snd_date,line->date,6);
strncpy(out->date,line->date,6);
out->date[6] = 0;
}
else strcpy(out->date," ");
fprintf(outfp,"%s %s - %s\n",out->date,node,&(out->string[5]));
}
}
}
}
if(keep == -1) unlink(logfile);
else {
new_line = ftell(logfp);
fseek(logfp,0L,0);
fputs((char *)line,logfp);
do {
old_line = ftell(logfp);
fseek(logfp,new_line,0);
if(fgets((char *)line,100,logfp) == NULL) break;
new_line = ftell(logfp);
fseek(logfp,old_line,0);
fputs((char *)line,logfp);
} while(stop != 100);
chsize(handle,old_line);
}
}
else {
cprintf("\nCould not file FrontDoor's log (%s).\n",logfile);
exit(0);
}
fcloseall();
}


char is_leap(int year) {
int yr;

if(year % 100 == 0) {
yr = year/100;
if(yr % 4 == 0) return(1);
else return(0);
}
else {
if(year % 4 == 0) return(1);
else return(0);
}
}


long date_value(int day,int month,int year) {
int base_yr = 1970,x;
long days=0;

for(x = 0; x < month - 1; x++) days += mon[x]; /* num of days into */
days += day; /* date's year */
if(is_leap(year) == 1) days++; /* adjust for leap years */

for(x = base_yr; x < year; x++) { /* add in num of days */
if(is_leap(x) == 1) days += 366; /* from 1970 to year */
else days += 365; /* adjusting for leaps */
}
return(days);
}




  3 Responses to “Category : BBS Programs+Doors
Archive   : FILETRX.ZIP
Filename : FILETRX.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/