Skip to content
Snippets Groups Projects
Commit fbd1f2b6 authored by rswindell's avatar rswindell
Browse files

Ported to Win32 (MSVC++ 6.0).

Better detection of corrupted SBL database entries.
parent a54295c5
No related branches found
No related tags found
No related merge requests found
......@@ -7,49 +7,63 @@
/***************************************/
#include <stdio.h>
#include <stdlib.h> /* exit() */
#include <share.h>
#include <time.h>
#include <io.h>
#include <fcntl.h>
#include <sys/stat.h>
#include "gen_defs.h"
#include "xsdkwrap.h" /* PLATFORM_DESC */
#include "xsdkdefs.h"
#include "sbldefs.h"
int main(void)
{
int file;
FILE *in,*out;
bbs_t bbs;
printf("\nSBLPACK v1.00 Developed 1995-1997 Rob Swindell\n\n");
if((file=open("SBL.DAB",O_RDWR|O_BINARY|O_DENYNONE|O_CREAT
,S_IWRITE|S_IREAD))==-1) {
printf("\n\7Error opening/creating SBL.DAB\n");
exit(1); }
if((in=fdopen(file,"w+b"))==NULL) {
printf("\n\7Error converting SBL.DAB file handle to stream\n");
exit(1); }
setvbuf(in,0L,_IOFBF,2048);
if((out=fopen("SBL.TMP","wb"))==NULL) {
printf("\n\7Error opening SBL.TMP file\n");
exit(1); }
while(!feof(in)) {
if(!fread(&bbs,sizeof(bbs_t),1,in))
break;
putchar('.');
if(!bbs.name[0])
continue;
fwrite(&bbs,sizeof(bbs_t),1,out); }
fcloseall();
putchar('\n');
if(remove("SBL.DAB")) {
printf("\n\7Data file in use, can't remove.\n");
remove("SBL.TMP");
exit(1); }
rename("SBL.TMP","SBL.DAB");
printf("\nDone.\n");
return(0);
int file;
FILE * in;
FILE * out;
bbs_t bbs;
ulong records=0;
ulong deleted=0;
printf("\nSBLPACK v1.10/%s Developed 1995-2001 Rob Swindell\n\n"
,PLATFORM_DESC);
if((file=sopen("sbl.dab",O_RDWR|O_BINARY,SH_DENYNO))==-1) {
printf("\n\7Error opening/creating sbl.dab\n");
exit(1); }
if((in=fdopen(file,"w+b"))==NULL) {
printf("\n\7Error converting sbl.dab file handle to stream\n");
exit(1); }
setvbuf(in,0L,_IOFBF,2048);
if((out=fopen("sbl.tmp","wb"))==NULL) {
printf("\n\7Error opening sbl.tmp file\n");
exit(1); }
while(!feof(in)) {
if(!fread(&bbs,sizeof(bbs_t),1,in))
break;
records++;
putchar('.');
if(bbs.name[0]==0
|| bbs.user[0]==0
|| bbs.total_numbers<1) {
deleted++;
continue;
}
fwrite(&bbs,sizeof(bbs_t),1,out);
}
fcloseall();
putchar('\n');
if(remove("sbl.dab")) {
printf("\n\7Data file in use, can't remove.\n");
remove("sbl.tmp");
exit(1);
}
rename("sbl.tmp","sbl.dab");
printf("\nDone.\n");
printf("\n%lu records in original file, %lu deleted (packed), new total = %lu.\n"
,records,deleted,records-deleted);
return(0);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment