home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
Dloads
/
WWIVMODS
/
MODSUNKN.ZIP
/
SUBCON.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-06-13
|
2KB
|
78 lines
/* CONVERT SUBS.DAT PROGRAM */
/* Command Parameters: */
/* SUBCONVERT <old subs filename> <new subs filename> */
/**
The only thing I will add is that it was compiled and tested under
Turbo C 2.0, and it was tested in the large memory model. Use whatever you
want, I think it should work in all of them.
Lord Elric 1@18251 LINK 1@8251 NET */
#include <stdio.h>
#include <string.h>
#include <mem.h>
#include <io.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys\stat.h>
#include "vardec.h" /* rename it from subboardrec to oldsubboardrec */
void main(int argc, char *argv[])
{
int f,g;
unsigned int loop,num=0;
unsigned long len;
oldsubboardrec old;
subboardrec new;
if (argc<3) {
printf("\nRequires 2 parameters.\n");
printf("Usage: SUBCON oldfile newfile \n");
abort();
}
if ((f=open(argv[1],O_RDWR|O_BINARY,S_IREAD|S_IWRITE))<=0) {
printf("\nCould not open input subs file %s\n",argv[1]);
abort();
}
if ((g=open(argv[2],O_RDWR|O_BINARY|O_CREAT|O_TRUNC,S_IREAD|S_IWRITE))<=0) {
printf("\nCould not open output subs file %s\n",argv[2]);
abort();
}
printf("\n\nSize of old sub record %d",sizeof(oldsubboardrec));
printf("\nSize of new sub record %d\n\n",sizeof(subboardrec));
len=filelength(f);
num=(len/sizeof(oldsubboardrec))+!(len%sizeof(oldsubboardrec));
for (loop=0;loop<num;loop++) {
if (sizeof(oldsubboardrec)==read(f,&old,sizeof(oldsubboardrec))) {
printf("\015Processing sub #%u of %u, %40s",loop,num-1,old.name);
memset(&new,0,sizeof(subboardrec)); /* Nice to clear out garbage */
strcpy(new.name,old.name); /* Now copy all data over */
strcpy(new.filename,old.filename);
new.key=old.key;
new.readsl=old.readsl;
new.postsl=old.postsl;
new.anony=old.anony;
new.age=old.age;
new.maxage=0;
new.sex=0;
new.gold=0;
new.ansi=0;
new.maxmsgs=old.maxmsgs;
new.ar=old.ar;
new.storage_type=old.storage_type;
new.type=old.type;
write(g,&new,sizeof(subboardrec));
}
}
close(f);
close(g);
}