Updates for new fdb code

This commit is contained in:
Michiel Broek
2004-05-07 14:31:47 +00:00
parent 17ab344dee
commit b10f7ae4c0
5 changed files with 84 additions and 11 deletions

View File

@@ -268,16 +268,23 @@ void BotBox(FILE *fp, int doit)
void Masterlist()
{
FILE *fp, *np, *pAreas, *pFile, *pHeader;
FILE *fp, *np, *pAreas, *pHeader;
int AreaNr = 0, z, x = 0, New;
unsigned long AllFiles = 0, AllKBytes = 0, NewFiles = 0, NewKBytes = 0;
unsigned long AllAreaFiles, AllAreaBytes, popdown, down;
unsigned long NewAreaFiles, NewAreaBytes;
char *sAreas, *fAreas;
char *sAreas;
char temp[81], pop[81];
#ifdef USE_EXPERIMENT
struct _fdbarea *fdb_area = NULL;
#else
FILE *pFile;
char *fAreas;
fAreas = calloc(PATH_MAX, sizeof(char));
#endif
sAreas = calloc(PATH_MAX, sizeof(char));
fAreas = calloc(PATH_MAX, sizeof(char));
IsDoing("Create Allfiles list");
@@ -334,14 +341,24 @@ void Masterlist()
if (area.Available && (area.LTSec.level <= CFG.security.level)) {
Nopper();
sprintf(fAreas, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), AreaNr);
#ifdef USE_EXPERIMENT
if ((fdb_area = mbsedb_OpenFDB(AreaNr, 30)) == 0) {
#else
sprintf(fAreas, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), AreaNr);
if ((pFile = fopen (fAreas, "r")) == NULL) {
#endif
WriteError("$Can't open Area %d (%s)! Skipping ...", AreaNr, area.Name);
} else {
#ifndef USE_EXPERIMENT
fread(&fdbhdr, sizeof(fdbhdr), 1, pFile);
#endif
popdown = 0;
#ifdef USE_EXPERIMENT
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
#else
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
#endif
if (!fdb.Deleted) {
/*
* The next is to reduce system load.
@@ -395,8 +412,13 @@ void Masterlist()
BotBox(fp, TRUE);
BotBox(np, NewAreaFiles);
#ifdef USE_EXPERIMENT
fseek(fdb_area->fp, fdbhdr.hdrsize, SEEK_SET);
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
#else
fseek(pFile, fdbhdr.hdrsize, SEEK_SET);
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
#endif
if (!fdb.Deleted) {
New = (((t_start - fdb.UploadDate) / 84400) <= CFG.newdays);
sprintf(temp, "%-12s%10lu K %s [%04ld] Uploader: %s",
@@ -427,8 +449,12 @@ void Masterlist()
}
}
}
#ifdef USE_EXPERIMENT
mbsedb_CloseFDB(fdb_area);
#else
fclose(pFile);
}
#endif
}
}
} /* End of While Loop Checking for Areas Done */
@@ -474,7 +500,9 @@ void Masterlist()
Syslog('+', "Allfiles: %ld, %ld MBytes", AllFiles, AllKBytes / 1024);
Syslog('+', "Newfiles: %ld, %ld MBytes", NewFiles, NewKBytes / 1024);
free(sAreas);
#ifndef USE_EXPERIMENT
free(fAreas);
#endif
}