home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
W
/
DEVBBS.ZIP
/
USERLST.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-08-04
|
2KB
|
68 lines
#include <stdio.h>
#include <io.h>
#include <fcntl.h>
#include <sys\stat.h>
#include "vardec.h"
int exist(char *string)
{
int f;
f=open(string,O_RDONLY | O_BINARY);
close(f);
if (f>0)
return(1);
else
return(0);
}
main(int argc, char *argv[])
{
int binfile;
FILE *txtfile;
userrec u;
unsigned int loop,num=0;
unsigned long len;
char s[81],s1[81];
if (argc<3) {
puts("\nRequires TWO parameters.\n");
puts("USERLST [path to USER.LST] [dest filename & path]\n");
abort();
}
if ((binfile=open(argv[1],O_RDWR|O_BINARY,S_IREAD|S_IWRITE))<=0) {
puts("\nCould not open USER.LST\n");
close(binfile);
abort();
}
if (exist(argv[2])) {
printf("\nCould not open output file %s. Same file exists.\n",argv[1]);
abort();
}
if (binfile<0) {
puts("\nNo users to process!\n");
close(binfile);
abort();
}
txtfile=fopen(argv[2],"a+");
len=filelength(binfile);
num=(len/sizeof(userrec))+!(len%sizeof(userrec));
for (loop=1; loop<num; ++loop) {
printf("\015Processing user #%u of %u",loop,num);
read(binfile,&u,sizeof(userrec));
if (u.inact == 0) {
sprintf(s,"%s c/o %s %s\n",u.name,u.realname,u.lastname);
fputs(s,txtfile);
sprintf(s,"%s\n",u.stretadd);
fputs(s,txtfile);
sprintf(s,"%s\n",u.citstate);
fputs(s,txtfile);
sprintf(s," %s\n",u.zipcode);
fputs(s,txtfile);
fputs("\r\n",txtfile);
}
}
close(binfile);
fclose(txtfile);
return(0);
}