diff --git a/mbfido/Makefile b/mbfido/Makefile index fe1994fc..fd1d3e9c 100644 --- a/mbfido/Makefile +++ b/mbfido/Makefile @@ -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 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 -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 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 diff --git a/mbfido/announce.c b/mbfido/announce.c index abc8d58c..fe963480 100644 --- a/mbfido/announce.c +++ b/mbfido/announce.c @@ -56,12 +56,19 @@ int MsgCount; /* Message counter */ void Uploads(void); void Uploads() { - FILE *pAreas, *pFile; - char *sAreas, *fAreas; + FILE *pAreas; + char *sAreas; 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)); - fAreas = calloc(PATH_MAX, sizeof(char)); Syslog('+', "Checking for uploads"); IsDoing("Check uploads"); @@ -75,7 +82,9 @@ void Uploads() if ((pAreas = fopen(sAreas, "r")) == NULL) { WriteError("$Can't open %s", sAreas); free(sAreas); +#ifndef USE_EXPERIMENT free(fAreas); +#endif return; } fread(&areahdr, sizeof(areahdr), 1, pAreas); @@ -94,12 +103,15 @@ void Uploads() 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); if ((pFile = fopen(fAreas, "r+")) != NULL) { - fread(&fdbhdr, sizeof(fdbhdr), 1, pFile); - while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) { +#endif Nopper(); if (!fdb.Announced) { Syslog('m', " %d %s", i, fdb.Name); @@ -135,12 +147,24 @@ void Uploads() * Mark file is announced. */ 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); fwrite(&fdb, fdbhdr.recsize, 1, pFile); +#endif } } +#ifdef USE_EXPERIMENT + mbsedb_CloseFDB(fdb_area); +#else fclose(pFile); +#endif } } } @@ -157,7 +181,9 @@ void Uploads() fclose(pAreas); free(sAreas); +#ifndef USE_EXPERIMENT free(fAreas); +#endif } diff --git a/mbfido/createf.c b/mbfido/createf.c index d4206912..9a4e9d92 100644 --- a/mbfido/createf.c +++ b/mbfido/createf.c @@ -30,6 +30,8 @@ #include "../config.h" #include "../lib/mbselib.h" +#include "../lib/users.h" +#include "../lib/mbsedb.h" #include "mgrutil.h" #include "createf.h" @@ -90,6 +92,9 @@ int CheckTicGroup(char *Area, int SendUplink, faddr *f) int i, rc = 0, Found = FALSE; sysconnect System; faddr *From, *To; +#ifdef USE_EXPERIMENT + struct _fdbarea *fdb_area = NULL; +#endif temp = calloc(PATH_MAX, sizeof(char)); 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 */ +#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); if ((fp = fopen(temp, "r+")) == NULL) { Syslog('f', "Creating new %s", temp); @@ -341,6 +351,7 @@ int CheckTicGroup(char *Area, int SendUplink, faddr *f) fclose(fp); } chmod(temp, 0660); +#endif /* * Setup new TIC area. diff --git a/mbfido/filefind.c b/mbfido/filefind.c index 98351840..4db575a9 100644 --- a/mbfido/filefind.c +++ b/mbfido/filefind.c @@ -245,12 +245,17 @@ void ScanFiles(ff_list *); void ScanFiles(ff_list *tmp) { char *temp, *kwd, *BigDesc, *line; - FILE *pAreas, *pFile, *fi; + FILE *pAreas, *fi; unsigned long areanr = 0, found = 0, SubSize = 0; int i, j, k, keywrd, Found; rf_list *rfl = NULL, *rft; int Rep = 0, Sub = 0, Stop = FALSE; 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. @@ -291,11 +296,15 @@ void ScanFiles(ff_list *tmp) Back(15); } 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); if ((pFile = fopen(temp, "r")) != NULL) { - fread(&fdbhdr, sizeof(fdbhdr), 1, pFile); while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) { +#endif for (i = 0; i < 25; i++) sprintf(BigDesc, "%s%s", BigDesc, *(fdb.Desc + i)); sprintf(temp, "%s", tmp->subject); @@ -350,8 +359,11 @@ void ScanFiles(ff_list *tmp) } strcpy(BigDesc, ""); } - +#ifdef USE_EXPERIMENT + mbsedb_CloseFDB(fdb_area); +#else fclose(pFile); +#endif } else WriteError("$Can't open %s", temp); } @@ -405,6 +417,13 @@ void ScanFiles(ff_list *tmp) 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); if ((pFile = fopen(temp, "r")) != NULL) { fread(&fdbhdr, sizeof(fdbhdr), 1, pFile); @@ -412,6 +431,7 @@ void ScanFiles(ff_list *tmp) if (!strcmp(rft->filename, fdb.Name)) break; fclose(pFile); +#endif MacroVars("slbkdt", "ssddss", fdb.Name, fdb.LName, fdb.Size, fdb.Size / 1024, " ", To_Low(fdb.Desc[0],scanmgr.HiAscii)); fseek(fi, filepos1, SEEK_SET);