Updated mbsebbs for new fdb code

This commit is contained in:
Michiel Broek 2004-05-06 21:33:13 +00:00
parent 0a4722b5cc
commit 17ab344dee
5 changed files with 213 additions and 22 deletions

View File

@ -41,6 +41,8 @@ v0.51.4 11-Apr-2004
Fixed a bug that tossed echomail was attempted to post to the Fixed a bug that tossed echomail was attempted to post to the
ISP newsserver (that didn't accept it). ISP newsserver (that didn't accept it).
More debug logging info added for double filename announces. More debug logging info added for double filename announces.
Added new experimental files database code which will only be
used if configured with --enable-experiment.
mbfile: mbfile:
The toberep command now logs the toberep.data in the debug The toberep command now logs the toberep.data in the debug
@ -52,6 +54,10 @@ v0.51.4 11-Apr-2004
Added new experimental files database code which will only be Added new experimental files database code which will only be
used if configured with --enable-experiment. used if configured with --enable-experiment.
mbaff:
Added new experimental files database code which will only be
used if configured with --enable-experiment.
mbnntp: mbnntp:
New program, news server to read echomail with a news client. New program, news server to read echomail with a news client.
Reading news works, no posts yet. Reading news works, no posts yet.
@ -60,6 +66,8 @@ v0.51.4 11-Apr-2004
Added loging of virus scanner results. Added loging of virus scanner results.
Patches for offline reader programs that create messages with Patches for offline reader programs that create messages with
wrong line terminaters (Sempoint). wrong line terminaters (Sempoint).
Added new experimental files database code which will only be
used if configured with --enable-experiment.
mbsetup: mbsetup:
Added auto setup for message area creation date. Also creates Added auto setup for message area creation date. Also creates

View File

@ -119,7 +119,7 @@ depend:
# DO NOT DELETE THIS LINE - MAKE DEPEND RELIES ON IT # DO NOT DELETE THIS LINE - MAKE DEPEND RELIES ON IT
# Dependencies generated by make depend # Dependencies generated by make depend
signature.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h signature.h funcs.h input.h language.h timeout.h signature.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h signature.h funcs.h input.h language.h timeout.h
filesub.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h filesub.h funcs.h language.h input.h misc.h timeout.h exitinfo.h change.h filesub.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/mbsedb.h filesub.h funcs.h language.h input.h misc.h timeout.h exitinfo.h change.h
language.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h input.h language.h language.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h input.h language.h
mbtoberep.o: ../config.h ../lib/mbselib.h mbtoberep.o: ../config.h ../lib/mbselib.h
msgutil.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/msgtext.h ../lib/msg.h oneline.h msgutil.h msgutil.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/msgtext.h ../lib/msg.h oneline.h msgutil.h
@ -147,7 +147,7 @@ pop3.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/mbinet.
lastcallers.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h input.h language.h lastcallers.h lastcallers.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h input.h language.h lastcallers.h
timeout.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/msg.h timeout.h funcs.h bye.h filesub.h language.h timeout.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/msg.h timeout.h funcs.h bye.h filesub.h language.h
chat.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h chat.h funcs.h input.h language.h misc.h whoson.h chat.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h chat.h funcs.h input.h language.h misc.h whoson.h
file.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h filesub.h file.h funcs.h input.h language.h misc.h timeout.h exitinfo.h whoson.h change.h dispfile.h file.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/mbsedb.h filesub.h file.h funcs.h input.h language.h misc.h timeout.h exitinfo.h whoson.h change.h dispfile.h
mbstat.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbsedb.h mbstat.h mbstat.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbsedb.h mbstat.h
misc.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h funcs.h input.h language.h misc.h timeout.h exitinfo.h misc.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h funcs.h input.h language.h misc.h timeout.h exitinfo.h
offline.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/bluewave.h ../lib/msgtext.h ../lib/msg.h mail.h funcs.h input.h language.h file.h filesub.h exitinfo.h timeout.h msgutil.h pop3.h offline.h whoson.h offline.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/bluewave.h ../lib/msgtext.h ../lib/msg.h mail.h funcs.h input.h language.h file.h filesub.h exitinfo.h timeout.h msgutil.h pop3.h offline.h whoson.h

View File

@ -32,6 +32,7 @@
#include "../lib/mbselib.h" #include "../lib/mbselib.h"
#include "../lib/mbse.h" #include "../lib/mbse.h"
#include "../lib/users.h" #include "../lib/users.h"
#include "../lib/mbsedb.h"
#include "filesub.h" #include "filesub.h"
#include "file.h" #include "file.h"
#include "funcs.h" #include "funcs.h"
@ -55,6 +56,24 @@ int FileRecno = 0;
int CheckFile(char *, int); int CheckFile(char *, int);
int CheckFile(char *File, int iArea) int CheckFile(char *File, int iArea)
{ {
#ifdef USE_EXPERIMENT
struct _fdbarea *fdb_area = NULL;
if ((fdb_area = mbsedb_OpenFDB(iArea, 30)) == NULL)
return FALSE;
/*
* Check long and short filenames, case insensitive
*/
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
if (((strcasecmp(fdb.Name, File)) == 0) || ((strcasecmp(fdb.LName, File)) == 0)) {
mbsedb_CloseFDB(fdb_area);
return TRUE;
}
}
mbsedb_CloseFDB(fdb_area);
#else
FILE *pFileB; FILE *pFileB;
char *sFileArea; char *sFileArea;
@ -79,6 +98,7 @@ int CheckFile(char *File, int iArea)
} }
fclose(pFileB); fclose(pFileB);
#endif
return FALSE; return FALSE;
} }
@ -89,10 +109,14 @@ int CheckFile(char *File, int iArea)
*/ */
void File_List() void File_List()
{ {
FILE *pFile;
int FileCount = 0; int FileCount = 0;
unsigned FileBytes = 0; unsigned FileBytes = 0;
_Tag T; _Tag T;
#ifdef USE_EXPERIMENT
struct _fdbarea *fdb_area = NULL;
#else
FILE *pFile;
#endif
iLineCount = 0; iLineCount = 0;
WhosDoingWhat(FILELIST, NULL); WhosDoingWhat(FILELIST, NULL);
@ -109,18 +133,30 @@ void File_List()
InitTag(); InitTag();
#ifdef USE_EXPERIMENT
if ((fdb_area = mbsedb_OpenFDB(iAreaNumber, 30)) == NULL)
return;
#else
if ((pFile = OpenFileBase(iAreaNumber, FALSE)) == NULL) if ((pFile = OpenFileBase(iAreaNumber, FALSE)) == NULL)
return; return;
#endif
clear(); clear();
Header(); Header();
if (iLC(2) == 1) { if (iLC(2) == 1) {
#ifdef USE_EXPERIMENT
mbsedb_CloseFDB(fdb_area);
#else
fclose(pFile); fclose(pFile);
#endif
return; return;
} }
#ifdef USE_EXPERIMENT
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
#else
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) { while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
#endif
memset(&T, 0, sizeof(T)); memset(&T, 0, sizeof(T));
T.Area = iAreaNumber; T.Area = iAreaNumber;
T.Active = FALSE; T.Active = FALSE;
@ -130,7 +166,11 @@ void File_List()
SetTag(T); SetTag(T);
if (ShowOneFile() == 1) { if (ShowOneFile() == 1) {
#ifdef USE_EXPERIMENT
mbsedb_CloseFDB(fdb_area);
#else
fclose(pFile); fclose(pFile);
#endif
return; return;
} }
@ -150,7 +190,11 @@ void File_List()
printf("\n%s%d / %d bytes\n\n", (char *) Language(242), FileCount, FileBytes); printf("\n%s%d / %d bytes\n\n", (char *) Language(242), FileCount, FileBytes);
iLineCount = 0; iLineCount = 0;
#ifdef USE_EXPERIMENT
mbsedb_CloseFDB(fdb_area);
#else
fclose(pFile); fclose(pFile);
#endif
Pause(); Pause();
} }
@ -163,7 +207,7 @@ void Download(void)
{ {
DIR *dirp; DIR *dirp;
struct dirent *dp; struct dirent *dp;
FILE *tf, *fp, *fd; FILE *tf, *fd;
int i, err, Count = 0; int i, err, Count = 0;
int OldArea; int OldArea;
char *symTo, *symFrom; char *symTo, *symFrom;
@ -171,6 +215,11 @@ void Download(void)
long Size = 0, CostSize = 0; long Size = 0, CostSize = 0;
time_t ElapstimeStart, ElapstimeFin, iTime; time_t ElapstimeStart, ElapstimeFin, iTime;
long iTransfer = 0; long iTransfer = 0;
#ifdef USE_EXPERIMENT
struct _fdbarea *fdb_area = NULL;
#else
FILE *fp;
#endif
Enter(2); Enter(2);
OldArea = iAreaNumber; OldArea = iAreaNumber;
@ -202,6 +251,15 @@ void Download(void)
* Check password for selected file FIXME: Where??? * Check password for selected file FIXME: Where???
*/ */
memset(&fdb, 0, sizeof(fdb)); memset(&fdb, 0, sizeof(fdb));
#ifdef USE_EXPERIMENT
if ((fdb_area = mbsedb_OpenFDB(Tag.Area, 30)) != NULL) {
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
if (strcmp(fdb.LName, Tag.LFile) == 0)
break;
}
mbsedb_CloseFDB(fdb_area);
}
#else
if ((fp = OpenFileBase(Tag.Area, FALSE)) != NULL) { if ((fp = OpenFileBase(Tag.Area, FALSE)) != NULL) {
while (fread(&fdb, fdbhdr.recsize, 1, fp) == 1) { while (fread(&fdb, fdbhdr.recsize, 1, fp) == 1) {
if (strcmp(fdb.LName, Tag.LFile) == 0) if (strcmp(fdb.LName, Tag.LFile) == 0)
@ -209,6 +267,7 @@ void Download(void)
} }
fclose(fp); fclose(fp);
} }
#endif
if (strcmp(fdb.LName, Tag.LFile) == 0) { if (strcmp(fdb.LName, Tag.LFile) == 0) {
Syslog('b', "Found file %s in area %d", fdb.LName, Tag.Area); Syslog('b', "Found file %s in area %d", fdb.LName, Tag.Area);
@ -429,6 +488,22 @@ void Download(void)
* Update the download counter and the last download date. * Update the download counter and the last download date.
*/ */
SetFileArea(Tag.Area); SetFileArea(Tag.Area);
#ifdef USE_EXPERIMENT
if ((fdb_area = mbsedb_OpenFDB(Tag.Area, 30))) {
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
if (strcmp(fdb.LName, Tag.LFile) == 0)
break;
}
Size += fdb.Size;
fdb.TimesDL++;
fdb.LastDL = time(NULL);
if (mbsedb_LockFDB(fdb_area, 30)) {
fseek(fdb_area->fp, - fdbhdr.recsize, SEEK_CUR);
fwrite(&fdb, fdbhdr.recsize, 1, fdb_area->fp);
mbsedb_UnlockFDB(fdb_area);
}
mbsedb_CloseFDB(fdb_area);
#else
if ((fp = OpenFileBase(Tag.Area, TRUE)) != NULL) { if ((fp = OpenFileBase(Tag.Area, TRUE)) != NULL) {
while (fread(&fdb, fdbhdr.recsize, 1, fp) == 1) { while (fread(&fdb, fdbhdr.recsize, 1, fp) == 1) {
if (strcmp(fdb.LName, Tag.LFile) == 0) if (strcmp(fdb.LName, Tag.LFile) == 0)
@ -440,6 +515,7 @@ void Download(void)
fseek(fp, - fdbhdr.recsize, SEEK_CUR); fseek(fp, - fdbhdr.recsize, SEEK_CUR);
fwrite(&fdb, fdbhdr.recsize, 1, fp); fwrite(&fdb, fdbhdr.recsize, 1, fp);
fclose(fp); fclose(fp);
#endif
Count++; Count++;
} }
} else { } else {
@ -563,12 +639,16 @@ void File_RawDir(char *OpData)
*/ */
int KeywordScan() int KeywordScan()
{ {
FILE *pAreas, *pFile; FILE *pAreas;
int i, z, y, Found, Count = 0; int i, z, y, Found, Count = 0;
char *Name, *tmpname, *BigDesc, temp[81]; char *Name, *tmpname, *BigDesc, temp[81];
_Tag T; _Tag T;
unsigned long OldArea; unsigned long OldArea;
#ifdef USE_EXPERIMENT
struct _fdbarea *fdb_area = NULL;
#else
FILE *pFile;
#endif
Name = calloc(81, sizeof(char)); Name = calloc(81, sizeof(char));
tmpname = calloc(81, sizeof(char)); tmpname = calloc(81, sizeof(char));
@ -612,14 +692,20 @@ int KeywordScan()
if ((Access(exitinfo.Security, area.LTSec)) && (area.Available) && (strlen(area.Password) == 0)) { if ((Access(exitinfo.Security, area.LTSec)) && (area.Available) && (strlen(area.Password) == 0)) {
#ifdef USE_EXPERIMENT
if ((fdb_area = mbsedb_OpenFDB(arecno, 30))) {
#else
if ((pFile = OpenFileBase(arecno, FALSE)) != NULL) { if ((pFile = OpenFileBase(arecno, FALSE)) != NULL) {
#endif
Nopper(); Nopper();
Found = FALSE; Found = FALSE;
Sheader(); Sheader();
#ifdef USE_EXPERIMENT
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
#else
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));
@ -657,7 +743,11 @@ int KeywordScan()
} /* while */ } /* while */
#ifdef USE_EXPERIMENT
mbsedb_CloseFDB(fdb_area);
#else
fclose(pFile); fclose(pFile);
#endif
if (Found) { if (Found) {
Enter(2); Enter(2);
if (iLC(2) == 1) { if (iLC(2) == 1) {
@ -695,12 +785,17 @@ int KeywordScan()
*/ */
int FilenameScan() int FilenameScan()
{ {
FILE *pAreas, *pFile; FILE *pAreas;
int Found, Count = 0; int Found, Count = 0;
char mask[256]; char mask[256];
char *Name; char *Name;
_Tag T; _Tag T;
unsigned long OldArea; unsigned long OldArea;
#ifdef USE_EXPERIMENT
struct _fdbarea *fdb_area = NULL;
#else
FILE *pFile;
#endif
Name = calloc(81, sizeof(char)); Name = calloc(81, sizeof(char));
OldArea = iAreaNumber; OldArea = iAreaNumber;
@ -741,14 +836,20 @@ int FilenameScan()
while (fread(&area, areahdr.recsize, 1, pAreas) == 1) { while (fread(&area, areahdr.recsize, 1, pAreas) == 1) {
if ((Access(exitinfo.Security, area.LTSec)) && (area.Available) && (strlen(area.Password) == 0)) { if ((Access(exitinfo.Security, area.LTSec)) && (area.Available) && (strlen(area.Password) == 0)) {
#ifdef USE_EXPERIMENT
if ((fdb_area = mbsedb_OpenFDB(arecno, 30))) {
#else
if ((pFile = OpenFileBase(arecno, FALSE)) != NULL) { if ((pFile = OpenFileBase(arecno, FALSE)) != NULL) {
#endif
Found = FALSE; Found = FALSE;
Sheader(); Sheader();
Nopper(); Nopper();
#ifdef USE_EXPERIMENT
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
#else
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) { while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
#endif
if (re_exec(fdb.Name) || re_exec(fdb.LName)) { if (re_exec(fdb.Name) || re_exec(fdb.LName)) {
if (!Found) { if (!Found) {
Enter(2); Enter(2);
@ -775,7 +876,11 @@ int FilenameScan()
} /* End of while */ } /* End of while */
#ifdef USE_EXPERIMENT
mbsedb_CloseFDB(fdb_area);
#else
fclose(pFile); fclose(pFile);
#endif
if (Found) { if (Found) {
Enter(2); Enter(2);
if (iLC(2) == 1) { if (iLC(2) == 1) {
@ -808,11 +913,16 @@ int FilenameScan()
*/ */
int NewfileScan(int AskStart) int NewfileScan(int AskStart)
{ {
FILE *pAreas, *pFile; FILE *pAreas;
long ifDate, itDate; long ifDate, itDate;
char *temp, *Date; char *temp, *Date;
int Found, Count = 0; int Found, Count = 0;
_Tag T; _Tag T;
#ifdef USE_EXPERIMENT
struct _fdbarea *fdb_area = NULL;
#else
FILE *pFile;
#endif
Date = calloc(81, sizeof(char)); Date = calloc(81, sizeof(char));
temp = calloc(81, sizeof(char)); temp = calloc(81, sizeof(char));
@ -865,13 +975,20 @@ int NewfileScan(int AskStart)
if ((Access(exitinfo.Security, area.LTSec)) && (area.Available) && (strlen(area.Password) == 0) && (area.New)) { if ((Access(exitinfo.Security, area.LTSec)) && (area.Available) && (strlen(area.Password) == 0) && (area.New)) {
#ifdef USE_EXPERIMENT
if ((fdb_area = mbsedb_OpenFDB(arecno, 30))) {
#else
if ((pFile = OpenFileBase(arecno, FALSE)) != NULL ) { if ((pFile = OpenFileBase(arecno, FALSE)) != NULL ) {
#endif
Sheader(); Sheader();
Found = FALSE; Found = FALSE;
Nopper(); Nopper();
#ifdef USE_EXPERIMENT
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
#else
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) { while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
#endif
strcpy(temp, StrDateDMY(fdb.UploadDate)); /* Realloc Space for Date */ strcpy(temp, StrDateDMY(fdb.UploadDate)); /* Realloc Space for Date */
Date[0] = temp[6]; /* Swap the date around */ Date[0] = temp[6]; /* Swap the date around */
Date[1] = temp[7]; /* Instead of DD-MM-YYYY */ Date[1] = temp[7]; /* Instead of DD-MM-YYYY */
@ -891,7 +1008,11 @@ int NewfileScan(int AskStart)
if (iLC(2) == 1) { if (iLC(2) == 1) {
free(Date); free(Date);
free(temp); free(temp);
#ifdef USE_EXPERIMENT
mbsedb_CloseFDB(fdb_area);
#else
fclose(pFile); fclose(pFile);
#endif
fclose(pAreas); fclose(pAreas);
return 1; return 1;
} }
@ -910,7 +1031,11 @@ int NewfileScan(int AskStart)
if (ShowOneFile() == 1) { if (ShowOneFile() == 1) {
free(Date); free(Date);
free(temp); free(temp);
#ifdef USE_EXPERIMENT
mbsedb_CloseFDB(fdb_area);
#else
fclose(pFile); fclose(pFile);
#endif
fclose(pAreas); fclose(pAreas);
return 1; return 1;
} }
@ -918,8 +1043,12 @@ int NewfileScan(int AskStart)
} /* End of if */ } /* End of if */
} /* End of while */ } /* End of while */
#ifdef USE_EXPERIMENT
mbsedb_CloseFDB(fdb_area);
#else
fclose(pFile); fclose(pFile);
#endif
/* /*
* Add 2 blank lines after found files. * Add 2 blank lines after found files.
*/ */
@ -1958,10 +2087,14 @@ void FileArea_List(char *Option)
*/ */
void Copy_Home() void Copy_Home()
{ {
FILE *pFile;
char *File, *temp1, *temp2; char *File, *temp1, *temp2;
int err, Found = FALSE; int err, Found = FALSE;
#ifdef USE_EXPERIMENT
struct _fdbarea *fdb_area = NULL;
#else
FILE *pFile;
#endif
File = calloc(81, sizeof(char)); File = calloc(81, sizeof(char));
temp1 = calloc(PATH_MAX, sizeof(char)); temp1 = calloc(PATH_MAX, sizeof(char));
temp2 = calloc(PATH_MAX, sizeof(char)); temp2 = calloc(PATH_MAX, sizeof(char));
@ -2004,15 +2137,22 @@ void Copy_Home()
return; return;
} }
#ifdef USE_EXPERIMENT
if ((fdb_area = mbsedb_OpenFDB(iAreaNumber, 30)) == NULL) {
#else
if ((pFile = OpenFileBase(iAreaNumber, FALSE)) == NULL) { if ((pFile = OpenFileBase(iAreaNumber, FALSE)) == NULL) {
free(File); #endif
free(File);
free(temp1); free(temp1);
free(temp2); free(temp2);
return; return;
} }
#ifdef USE_EXPERIMENT
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
#else
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) { while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
#endif
if ((strcasecmp(File, fdb.Name) == 0) || (strcasecmp(File, fdb.LName) == 0)) { if ((strcasecmp(File, fdb.Name) == 0) || (strcasecmp(File, fdb.LName) == 0)) {
Found = TRUE; Found = TRUE;
@ -2045,7 +2185,11 @@ void Copy_Home()
} }
} }
} }
#ifdef USE_EXPERIMENT
mbsedb_CloseFDB(fdb_area);
#else
fclose(pFile); fclose(pFile);
#endif
if (!Found) { if (!Found) {
colour(CFG.HiliteF, CFG.HiliteB); colour(CFG.HiliteF, CFG.HiliteB);
@ -2188,7 +2332,12 @@ void ViewFile(char *name)
{ {
char *File, *temp, *arc; char *File, *temp, *arc;
int count, total, rc, found = FALSE; int count, total, rc, found = FALSE;
FILE *fp, *pFile; FILE *fp;
#ifdef USE_EXPERIMENT
struct _fdbarea *fdb_area = NULL;
#else
FILE *pFile;
#endif
Syslog('+', "ViewFile(%s)", printable(name, 0)); Syslog('+', "ViewFile(%s)", printable(name, 0));
@ -2250,18 +2399,30 @@ void ViewFile(char *name)
/* /*
* Now check if this file is present * Now check if this file is present
*/ */
#ifdef USE_EXPERIMENT
if ((fdb_area = mbsedb_OpenFDB(iAreaNumber, 30)) == NULL) {
#else
if ((pFile = OpenFileBase(iAreaNumber, FALSE)) == NULL) { if ((pFile = OpenFileBase(iAreaNumber, FALSE)) == NULL) {
#endif
free(File); free(File);
return; return;
} }
#ifdef USE_EXPERIMENT
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
#else
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) { while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
#endif
if (((strcasecmp(File, fdb.Name) == 0) || (strcasecmp(File, fdb.LName) == 0)) && (!fdb.Deleted)) { if (((strcasecmp(File, fdb.Name) == 0) || (strcasecmp(File, fdb.LName) == 0)) && (!fdb.Deleted)) {
found = TRUE; found = TRUE;
break; break;
} }
} }
#ifdef USE_EXPERIMENT
mbsedb_CloseFDB(fdb_area);
#else
fclose(pFile); fclose(pFile);
#endif
if (!found) { if (!found) {
colour(YELLOW, BLACK); colour(YELLOW, BLACK);

View File

@ -32,6 +32,7 @@
#include "../lib/mbselib.h" #include "../lib/mbselib.h"
#include "../lib/mbse.h" #include "../lib/mbse.h"
#include "../lib/users.h" #include "../lib/users.h"
#include "../lib/mbsedb.h"
#include "filesub.h" #include "filesub.h"
#include "funcs.h" #include "funcs.h"
#include "language.h" #include "language.h"
@ -153,6 +154,7 @@ void GetstrD(char *sStr, int iMaxlen)
/* /*
* Open FileDataBase, the filepointer is at the begin of the first record. * Open FileDataBase, the filepointer is at the begin of the first record.
*/ */
#ifndef USE_EXPERIMENT
FILE *OpenFileBase(unsigned long Area, int Write) FILE *OpenFileBase(unsigned long Area, int Write)
{ {
FILE *pFile; FILE *pFile;
@ -177,7 +179,7 @@ FILE *OpenFileBase(unsigned long Area, int Write)
free(FileBase); free(FileBase);
return pFile; return pFile;
} }
#endif
/* /*
@ -877,10 +879,15 @@ int ImportFile(char *fn, int Area, int fileid, time_t iTime, off_t Size)
*/ */
int Addfile(char *File, int AreaNum, int fileid) int Addfile(char *File, int AreaNum, int fileid)
{ {
FILE *id, *pFileDB, *pPrivate; FILE *id, *pPrivate;
int err = 1, iDesc = 1, iPrivate = FALSE, GotId = FALSE, lines, i, j; int err = 1, iDesc = 1, iPrivate = FALSE, GotId = FALSE, lines, i, j;
char *Filename, *temp1, *idname = NULL, *Desc[26], *lname, temp[81]; char *Filename, *temp1, *idname = NULL, *Desc[26], *lname, temp[81];
struct stat statfile; struct stat statfile;
#ifdef USE_EXPERIMENT
struct _fdbarea *fdb_area = NULL;
#else
FILE *pFileDB;
#endif
Filename = calloc(PATH_MAX, sizeof(char)); Filename = calloc(PATH_MAX, sizeof(char));
temp1 = calloc(PATH_MAX, sizeof(char)); temp1 = calloc(PATH_MAX, sizeof(char));
@ -888,7 +895,11 @@ int Addfile(char *File, int AreaNum, int fileid)
sprintf(Filename, "%s/%s", area.Path, File); sprintf(Filename, "%s/%s", area.Path, File);
#ifdef USE_EXPERIMENT
if ((fdb_area = mbsedb_OpenFDB(AreaNum, 30))) {
#else
if ((pFileDB = OpenFileBase(AreaNum, TRUE)) != NULL) { if ((pFileDB = OpenFileBase(AreaNum, TRUE)) != NULL) {
#endif
/* /*
* Do a physical check of file to see if it exists * Do a physical check of file to see if it exists
* if it fails it will return a zero which will not * if it fails it will return a zero which will not
@ -900,7 +911,11 @@ int Addfile(char *File, int AreaNum, int fileid)
/* Upload was unsuccessful for: */ /* Upload was unsuccessful for: */
printf("\n%s%s\n\n", (char *) Language(284), File); printf("\n%s%s\n\n", (char *) Language(284), File);
#ifdef USE_EXPERIMENT
mbsedb_CloseFDB(fdb_area);
#else
fclose(pFileDB); fclose(pFileDB);
#endif
free(Filename); free(Filename);
free(temp1); free(temp1);
free(lname); free(lname);
@ -1065,9 +1080,14 @@ int Addfile(char *File, int AreaNum, int fileid)
free(Desc[i]); free(Desc[i]);
} }
#ifdef USE_EXPERIMENT
mbsedb_InsertFDB(fdb_area, fdb, area.AddAlpha);
mbsedb_CloseFDB(fdb_area);
#else
fseek(pFileDB, 0, SEEK_END); fseek(pFileDB, 0, SEEK_END);
fwrite(&fdb, fdbhdr.recsize, 1, pFileDB); fwrite(&fdb, fdbhdr.recsize, 1, pFileDB);
fclose(pFileDB); fclose(pFileDB);
#endif
sprintf(temp, "%s/log/uploads.log", getenv("MBSE_ROOT")); sprintf(temp, "%s/log/uploads.log", getenv("MBSE_ROOT"));
if ((pPrivate = fopen(temp, "a+")) == NULL) if ((pPrivate = fopen(temp, "a+")) == NULL)

View File

@ -2,7 +2,9 @@
#define _FILESUB_H #define _FILESUB_H
#ifndef USE_EXPERIMENT
FILE *OpenFileBase(unsigned long Area, int); FILE *OpenFileBase(unsigned long Area, int);
#endif
FILE *OpenFareas(int); FILE *OpenFareas(int);
int ForceProtocol(void); int ForceProtocol(void);
int CheckBytesAvailable(long); int CheckBytesAvailable(long);