Updated mbaff for new fdb code

This commit is contained in:
Michiel Broek 2004-05-06 20:06:07 +00:00
parent 50fc461910
commit 0a4722b5cc
4 changed files with 66 additions and 9 deletions

View File

@ -195,7 +195,7 @@ mbfmove.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbsedb.h mbfutil.h
mbfdel.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbsedb.h mbfutil.h mbfmove.h mbfdel.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbsedb.h mbfutil.h mbfmove.h
bounce.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/msg.h ../lib/msgtext.h ../lib/mbsedb.h sendmail.h postnetmail.h ping.h bounce.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/msg.h ../lib/msgtext.h ../lib/mbsedb.h sendmail.h postnetmail.h ping.h
createm.o: ../config.h ../lib/mbselib.h ../lib/msg.h ../lib/users.h ../lib/mbsedb.h mgrutil.h createm.h createm.o: ../config.h ../lib/mbselib.h ../lib/msg.h ../lib/users.h ../lib/mbsedb.h mgrutil.h createm.h
createf.o: ../config.h ../lib/mbselib.h mgrutil.h createf.h createf.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbsedb.h mgrutil.h createf.h
msgflags.o: ../config.h ../lib/mbselib.h msgflags.h msgflags.o: ../config.h ../lib/mbselib.h msgflags.h
dirsession.o: ../config.h ../lib/mbselib.h dirsession.h dirsession.o: ../config.h ../lib/mbselib.h dirsession.h
queue.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbsedb.h fsort.h dirsession.h queue.h queue.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbsedb.h fsort.h dirsession.h queue.h

View File

@ -56,12 +56,19 @@ int MsgCount; /* Message counter */
void Uploads(void); void Uploads(void);
void Uploads() void Uploads()
{ {
FILE *pAreas, *pFile; FILE *pAreas;
char *sAreas, *fAreas; char *sAreas;
int Count = 0, i = 0, j, k; int Count = 0, i = 0, j, k;
#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)); sAreas = calloc(PATH_MAX, sizeof(char));
fAreas = calloc(PATH_MAX, sizeof(char));
Syslog('+', "Checking for uploads"); Syslog('+', "Checking for uploads");
IsDoing("Check uploads"); IsDoing("Check uploads");
@ -75,7 +82,9 @@ void Uploads()
if ((pAreas = fopen(sAreas, "r")) == NULL) { if ((pAreas = fopen(sAreas, "r")) == NULL) {
WriteError("$Can't open %s", sAreas); WriteError("$Can't open %s", sAreas);
free(sAreas); free(sAreas);
#ifndef USE_EXPERIMENT
free(fAreas); free(fAreas);
#endif
return; return;
} }
fread(&areahdr, sizeof(areahdr), 1, pAreas); fread(&areahdr, sizeof(areahdr), 1, pAreas);
@ -94,12 +103,15 @@ void Uploads()
fflush(stdout); fflush(stdout);
} }
#ifdef USE_EXPERIMENT
if ((fdb_area = mbsedb_OpenFDB(i, 30))) {
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
#else
sprintf(fAreas, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), i); sprintf(fAreas, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), i);
if ((pFile = fopen(fAreas, "r+")) != NULL) { if ((pFile = fopen(fAreas, "r+")) != NULL) {
fread(&fdbhdr, sizeof(fdbhdr), 1, pFile); fread(&fdbhdr, sizeof(fdbhdr), 1, pFile);
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) { while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
#endif
Nopper(); Nopper();
if (!fdb.Announced) { if (!fdb.Announced) {
Syslog('m', " %d %s", i, fdb.Name); Syslog('m', " %d %s", i, fdb.Name);
@ -135,12 +147,24 @@ void Uploads()
* Mark file is announced. * Mark file is announced.
*/ */
fdb.Announced = TRUE; fdb.Announced = TRUE;
#ifdef USE_EXPERIMENT
if (mbsedb_LockFDB(fdb_area, 30)) {
fseek(fdb_area->fp, - fdbhdr.recsize, SEEK_CUR);
fwrite(&fdb, fdbhdr.recsize, 1, fdb_area->fp);
mbsedb_CloseFDB(fdb_area);
}
#else
fseek(pFile, - fdbhdr.recsize, SEEK_CUR); fseek(pFile, - fdbhdr.recsize, SEEK_CUR);
fwrite(&fdb, fdbhdr.recsize, 1, pFile); fwrite(&fdb, fdbhdr.recsize, 1, pFile);
#endif
} }
} }
#ifdef USE_EXPERIMENT
mbsedb_CloseFDB(fdb_area);
#else
fclose(pFile); fclose(pFile);
#endif
} }
} }
} }
@ -157,7 +181,9 @@ void Uploads()
fclose(pAreas); fclose(pAreas);
free(sAreas); free(sAreas);
#ifndef USE_EXPERIMENT
free(fAreas); free(fAreas);
#endif
} }

View File

@ -30,6 +30,8 @@
#include "../config.h" #include "../config.h"
#include "../lib/mbselib.h" #include "../lib/mbselib.h"
#include "../lib/users.h"
#include "../lib/mbsedb.h"
#include "mgrutil.h" #include "mgrutil.h"
#include "createf.h" #include "createf.h"
@ -90,6 +92,9 @@ int CheckTicGroup(char *Area, int SendUplink, faddr *f)
int i, rc = 0, Found = FALSE; int i, rc = 0, Found = FALSE;
sysconnect System; sysconnect System;
faddr *From, *To; faddr *From, *To;
#ifdef USE_EXPERIMENT
struct _fdbarea *fdb_area = NULL;
#endif
temp = calloc(PATH_MAX, sizeof(char)); temp = calloc(PATH_MAX, sizeof(char));
Syslog('f', "Checking file group \"%s\" \"%s\"", fgroup.Name, fgroup.Comment); Syslog('f', "Checking file group \"%s\" \"%s\"", fgroup.Name, fgroup.Comment);
@ -325,6 +330,11 @@ int CheckTicGroup(char *Area, int SendUplink, faddr *f)
/* /*
* Create download database * Create download database
*/ */
#ifdef USE_EXPERIMENT
if ((fdb_area = mbsedb_OpenFDB(AreaNr, 30)))
mbsedb_CloseFDB(fdb_area);
#else
sprintf(temp, "%s/fdb/file%ld.data", getenv("MBSE_ROOT"), AreaNr); sprintf(temp, "%s/fdb/file%ld.data", getenv("MBSE_ROOT"), AreaNr);
if ((fp = fopen(temp, "r+")) == NULL) { if ((fp = fopen(temp, "r+")) == NULL) {
Syslog('f', "Creating new %s", temp); Syslog('f', "Creating new %s", temp);
@ -341,6 +351,7 @@ int CheckTicGroup(char *Area, int SendUplink, faddr *f)
fclose(fp); fclose(fp);
} }
chmod(temp, 0660); chmod(temp, 0660);
#endif
/* /*
* Setup new TIC area. * Setup new TIC area.

View File

@ -245,12 +245,17 @@ void ScanFiles(ff_list *);
void ScanFiles(ff_list *tmp) void ScanFiles(ff_list *tmp)
{ {
char *temp, *kwd, *BigDesc, *line; char *temp, *kwd, *BigDesc, *line;
FILE *pAreas, *pFile, *fi; FILE *pAreas, *fi;
unsigned long areanr = 0, found = 0, SubSize = 0; unsigned long areanr = 0, found = 0, SubSize = 0;
int i, j, k, keywrd, Found; int i, j, k, keywrd, Found;
rf_list *rfl = NULL, *rft; rf_list *rfl = NULL, *rft;
int Rep = 0, Sub = 0, Stop = FALSE; int Rep = 0, Sub = 0, Stop = FALSE;
long filepos, filepos1 = 0, filepos2 = 0, filepos3 = 0, filepos4 = 0; long filepos, filepos1 = 0, filepos2 = 0, filepos3 = 0, filepos4 = 0;
#ifdef USE_EXPERIMENT
struct _fdbarea *fdb_area = NULL;
#else
FILE *pFile;
#endif
/* /*
* Check for local generated requests. * Check for local generated requests.
@ -291,11 +296,15 @@ void ScanFiles(ff_list *tmp)
Back(15); Back(15);
} }
if (area.Available && area.FileFind) { if (area.Available && area.FileFind) {
#ifdef USE_EXPERIMENT
if ((fdb_area = mbsedb_OpenFDB(areanr, 30))) {
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
#else
sprintf(temp, "%s/fdb/file%lu.data", getenv("MBSE_ROOT"), areanr); sprintf(temp, "%s/fdb/file%lu.data", getenv("MBSE_ROOT"), areanr);
if ((pFile = fopen(temp, "r")) != NULL) { if ((pFile = fopen(temp, "r")) != NULL) {
fread(&fdbhdr, sizeof(fdbhdr), 1, pFile); fread(&fdbhdr, sizeof(fdbhdr), 1, pFile);
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) { while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
#endif
for (i = 0; i < 25; i++) for (i = 0; i < 25; i++)
sprintf(BigDesc, "%s%s", BigDesc, *(fdb.Desc + i)); sprintf(BigDesc, "%s%s", BigDesc, *(fdb.Desc + i));
sprintf(temp, "%s", tmp->subject); sprintf(temp, "%s", tmp->subject);
@ -350,8 +359,11 @@ void ScanFiles(ff_list *tmp)
} }
strcpy(BigDesc, ""); strcpy(BigDesc, "");
} }
#ifdef USE_EXPERIMENT
mbsedb_CloseFDB(fdb_area);
#else
fclose(pFile); fclose(pFile);
#endif
} else } else
WriteError("$Can't open %s", temp); WriteError("$Can't open %s", temp);
} }
@ -405,6 +417,13 @@ void ScanFiles(ff_list *tmp)
areanr = rft->area; areanr = rft->area;
} }
#ifdef USE_EXPERIMENT
if ((fdb_area = mbsedb_OpenFDB(rft->area, 30))) {
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1)
if (!strcmp(rft->filename, fdb.Name))
break;
mbsedb_CloseFDB(fdb_area);
#else
sprintf(temp, "%s/fdb/file%lu.data", getenv("MBSE_ROOT"), rft->area); sprintf(temp, "%s/fdb/file%lu.data", getenv("MBSE_ROOT"), rft->area);
if ((pFile = fopen(temp, "r")) != NULL) { if ((pFile = fopen(temp, "r")) != NULL) {
fread(&fdbhdr, sizeof(fdbhdr), 1, pFile); fread(&fdbhdr, sizeof(fdbhdr), 1, pFile);
@ -412,6 +431,7 @@ void ScanFiles(ff_list *tmp)
if (!strcmp(rft->filename, fdb.Name)) if (!strcmp(rft->filename, fdb.Name))
break; break;
fclose(pFile); fclose(pFile);
#endif
MacroVars("slbkdt", "ssddss", fdb.Name, fdb.LName, fdb.Size, fdb.Size / 1024, " ", MacroVars("slbkdt", "ssddss", fdb.Name, fdb.LName, fdb.Size, fdb.Size / 1024, " ",
To_Low(fdb.Desc[0],scanmgr.HiAscii)); To_Low(fdb.Desc[0],scanmgr.HiAscii));
fseek(fi, filepos1, SEEK_SET); fseek(fi, filepos1, SEEK_SET);