Category : BBS Programs+Doors
Archive   : PC.ZIP
Filename : PC.CPP

 
Output of file : PC.CPP contained in archive : PC.ZIP
//pc.cpp: reads a log file created from the Whereis command on the
//Programmer's Corner BBS. Requires a configuration file supplying the
//name of the log file, the name of the output file, and a date to scan
//for. Outputs file number, filename, and file date of all files created
//after that date.
#include
#include
#include
#include
#include

long convert (char * date);

int main(void)
{
ifstream cfg("c:\\pc.cfg");
if(!cfg)
{
cout<<"Cannot open configuration file.";
exit(1);
}

char input[60], output[60], scandate[16];
cfg>>input>>output>>scandate;
cfg.close();

const int linesz=100;
const int skip=54;

fstream in(input,ios::in|ios::nocreate);
fstream out(output,ios::out|ios::trunc);
if(!(in&&out))
{
cout<<"File open error in input or output file.";
exit(1);
}

int i; //file number
char fn[16],datestr[16]; //filename and date as char array
int goodline;//do we want to process this line?
while(!in.eof())
{
//check the first 3 positions for a number
for (int j=0;j<3;j++)
{
goodline=0;
char c;
c=in.get();
if(isdigit(c))
{
in.putback(c);
if(!(in>>i))
{
in.clear();
in.ignore(linesz,'\n');
in.get();
}
else goodline++;break;
}
}//for loop
if(goodline)
{
in.ignore(3,'\n');
in.get(fn,9);//get the file name
//the following lines are ugly, but I'm still getting the
//hang of the C++ streams functions.
char *ptr=strchr(fn,' ');
fn[ptr-fn]='\0';
//on the other hand it works. Eliminates whitespace from
//the filename.
in.ignore(skip,'\n');//skip to the date field
in>>datestr;//and fetch it.
in.get();//eat newline
//if the date of file is on or after the date to scan, print it
if(convert(datestr)>=convert(scandate))
{
strcat(fn,".ZIP");
out< }
}
}//eof reached
in.close();
out.close();
return 0;
}//end main

long convert(char * date)
{
//converts a date string in mmxddxyy format to a long.
//Gosh this is ugly...but it's safe.
char temp[9]; //12-31-90 to 901231 for ordering
//01234567

temp[0]=date[6];
temp[1]=date[7];
temp[2]=date[0];
temp[3]=date[1];
temp[4]=date[3];
temp[5]=date[4];
temp[6]='\0'; //null terminate the string
char *endptr;
long result=strtol(temp,&endptr,10);
return result;
}


  3 Responses to “Category : BBS Programs+Doors
Archive   : PC.ZIP
Filename : PC.CPP

  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/