Made FDB experiment permanent and bumped to version 0.51.5
This commit is contained in:
parent
d87e61987f
commit
2804bac993
30
ChangeLog
30
ChangeLog
@ -1,6 +1,9 @@
|
|||||||
$Id$
|
$Id$
|
||||||
|
|
||||||
v0.51.4 11-Apr-2004
|
v0.51.5 19-May-2004
|
||||||
|
|
||||||
|
|
||||||
|
v0.51.4 11-Apr-2004 - 19-May-2004
|
||||||
|
|
||||||
upgrade:
|
upgrade:
|
||||||
Start mbsetup and leave. This wil update the message area
|
Start mbsetup and leave. This wil update the message area
|
||||||
@ -13,8 +16,8 @@ v0.51.4 11-Apr-2004
|
|||||||
With JAM_Readheader the Msg.Replyid field wasn't filled.
|
With JAM_Readheader the Msg.Replyid field wasn't filled.
|
||||||
|
|
||||||
libdbase.a:
|
libdbase.a:
|
||||||
In experimental FDB functions, removed auto unlock on FDB
|
Added new Files DataBase functions that will handle FDB io
|
||||||
close.
|
with locking.
|
||||||
|
|
||||||
mbcico:
|
mbcico:
|
||||||
All heavy debug logmessages are now in defines and are only
|
All heavy debug logmessages are now in defines and are only
|
||||||
@ -23,8 +26,7 @@ v0.51.4 11-Apr-2004
|
|||||||
must exist in the setup.
|
must exist in the setup.
|
||||||
Added protection against empty domain names received from
|
Added protection against empty domain names received from
|
||||||
remote systems.
|
remote systems.
|
||||||
Added new experimental files database code which will only be
|
Now uses new FDB functions.
|
||||||
used if configured with --enable-experiment.
|
|
||||||
|
|
||||||
mbout:
|
mbout:
|
||||||
In check for T-Mail fileboxes added condition that the zone
|
In check for T-Mail fileboxes added condition that the zone
|
||||||
@ -45,8 +47,7 @@ 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
|
Now uses new FDB functions.
|
||||||
used if configured with --enable-experiment.
|
|
||||||
Another small change for double filename announces.
|
Another small change for double filename announces.
|
||||||
Changed file open mode for double filename announces.
|
Changed file open mode for double filename announces.
|
||||||
Fixed create if toberep.data doesn't exist.
|
Fixed create if toberep.data doesn't exist.
|
||||||
@ -58,12 +59,10 @@ v0.51.4 11-Apr-2004
|
|||||||
corrupt.
|
corrupt.
|
||||||
Mbfile check will now accept an area number to just check one
|
Mbfile check will now accept an area number to just check one
|
||||||
single area.
|
single area.
|
||||||
Added new experimental files database code which will only be
|
Now uses new FDB functions.
|
||||||
used if configured with --enable-experiment.
|
|
||||||
|
|
||||||
mbaff:
|
mbaff:
|
||||||
Added new experimental files database code which will only be
|
Now uses new FDB functions.
|
||||||
used if configured with --enable-experiment.
|
|
||||||
|
|
||||||
mbnntp:
|
mbnntp:
|
||||||
New program, news server to read/write echomail with a news
|
New program, news server to read/write echomail with a news
|
||||||
@ -73,16 +72,14 @@ v0.51.4 11-Apr-2004
|
|||||||
Added logging of virus scanner results.
|
Added logging 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
|
Now uses new FDB functions.
|
||||||
used if configured with --enable-experiment.
|
|
||||||
The users tag directory wasn't properly cleaned before a new
|
The users tag directory wasn't properly cleaned before a new
|
||||||
download session.
|
download session.
|
||||||
The message group stat counters were not updated when a user
|
The message group stat counters were not updated when a user
|
||||||
posted a message at the bbs.
|
posted a message at the bbs.
|
||||||
|
|
||||||
mball:
|
mball:
|
||||||
Added new experimental files database code which will only be
|
Now uses new FDB functions.
|
||||||
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
|
||||||
@ -93,8 +90,7 @@ v0.51.4 11-Apr-2004
|
|||||||
Fixed a header include.
|
Fixed a header include.
|
||||||
Fixed an error where new created file areas were created
|
Fixed an error where new created file areas were created
|
||||||
without a file header.
|
without a file header.
|
||||||
Added new experimental files database code which will only be
|
Now uses new FDB functions.
|
||||||
used if configured with --enable-experiment.
|
|
||||||
Message group setup now sets mode 660 for ~/etc/mgroups.data.
|
Message group setup now sets mode 660 for ~/etc/mgroups.data.
|
||||||
In menu 1.2 removed Omen Id that was not used.
|
In menu 1.2 removed Omen Id that was not used.
|
||||||
In menu 18 removed settings for ISP connect and hangup.
|
In menu 18 removed settings for ISP connect and hangup.
|
||||||
|
@ -13,7 +13,7 @@ dnl
|
|||||||
PACKAGE="mbsebbs"
|
PACKAGE="mbsebbs"
|
||||||
MAJOR="0"
|
MAJOR="0"
|
||||||
MINOR="51"
|
MINOR="51"
|
||||||
REVISION="4"
|
REVISION="5"
|
||||||
VERSION="$MAJOR.$MINOR.$REVISION"
|
VERSION="$MAJOR.$MINOR.$REVISION"
|
||||||
COPYRIGHT="Copyright (C) 1997-2004 Michiel Broek, All Rights Reserved"
|
COPYRIGHT="Copyright (C) 1997-2004 Michiel Broek, All Rights Reserved"
|
||||||
SHORTRIGHT="Copyright (C) 1997-2004 M. Broek"
|
SHORTRIGHT="Copyright (C) 1997-2004 M. Broek"
|
||||||
|
@ -34,8 +34,6 @@
|
|||||||
#include "mbsedb.h"
|
#include "mbsedb.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -577,4 +575,3 @@ int mbsedb_SortFDB(struct _fdbarea *fdb_area)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@ -132,7 +132,6 @@ int SearchNetBoard(unsigned short, unsigned short); /* Search netmail */
|
|||||||
void UpdateMsgs(void); /* Update current messages record */
|
void UpdateMsgs(void); /* Update current messages record */
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Structure of current open file area
|
* Structure of current open file area
|
||||||
@ -152,8 +151,5 @@ int mbsedb_InsertFDB(struct _fdbarea *, struct FILE_record, int);
|
|||||||
int mbsedb_PackFDB(struct _fdbarea *);
|
int mbsedb_PackFDB(struct _fdbarea *);
|
||||||
int mbsedb_SortFDB(struct _fdbarea *);
|
int mbsedb_SortFDB(struct _fdbarea *);
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -161,11 +161,7 @@ file_list *respfreq(char *nm, char *pw, char *dt)
|
|||||||
FILE *fa, *fi;
|
FILE *fa, *fi;
|
||||||
long Area;
|
long Area;
|
||||||
struct FILEIndex idx;
|
struct FILEIndex idx;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
struct _fdbarea *fdb_area = NULL;
|
struct _fdbarea *fdb_area = NULL;
|
||||||
#else
|
|
||||||
FILE *fb;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (localoptions & NOFREQS) {
|
if (localoptions & NOFREQS) {
|
||||||
Syslog('+', "File requests disabled");
|
Syslog('+', "File requests disabled");
|
||||||
@ -266,31 +262,12 @@ file_list *respfreq(char *nm, char *pw, char *dt)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
Syslog('f', "Area %s", area.Name);
|
Syslog('f', "Area %s", area.Name);
|
||||||
#ifdef USE_EXPERIMENT
|
if ((fdb_area = mbsedb_OpenFDB(idx.AreaNum, 30))) {
|
||||||
if ((fdb_area = mbsedb_OpenFDB(idx.AreaNum, 30)) == 0) {
|
|
||||||
} else {
|
|
||||||
#else
|
|
||||||
p = calloc(PATH_MAX, sizeof(char));
|
|
||||||
sprintf(p, "%s/fdb/file%ld.data", getenv("MBSE_ROOT"), idx.AreaNum);
|
|
||||||
if ((fb = fopen(p, "r+")) == NULL) {
|
|
||||||
WriteError("$Can't open %s", p);
|
|
||||||
free(p);
|
|
||||||
} else {
|
|
||||||
free(p);
|
|
||||||
fread(&fdbhdr, sizeof(fdbhdr), 1, fb);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if (fseek(fdb_area->fp, fdbhdr.hdrsize + (idx.Record * fdbhdr.recsize), SEEK_SET) == -1) {
|
if (fseek(fdb_area->fp, fdbhdr.hdrsize + (idx.Record * fdbhdr.recsize), SEEK_SET) == -1) {
|
||||||
WriteError("$Can't seek filerecord %d", idx.Record);
|
WriteError("$Can't seek filerecord %d", idx.Record);
|
||||||
} else {
|
} else {
|
||||||
if (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) != 1) {
|
if (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) != 1) {
|
||||||
#else
|
|
||||||
if (fseek(fb, fdbhdr.hdrsize + (idx.Record * fdbhdr.recsize), SEEK_SET) == -1) {
|
|
||||||
WriteError("$Can't seek filerecord %d", idx.Record);
|
|
||||||
} else {
|
|
||||||
if (fread(&fdb, fdbhdr.recsize, 1, fb) != 1) {
|
|
||||||
#endif
|
|
||||||
WriteError("$Can't read filerecord %d", idx.Record);
|
WriteError("$Can't read filerecord %d", idx.Record);
|
||||||
} else {
|
} else {
|
||||||
Send = FALSE;
|
Send = FALSE;
|
||||||
@ -367,25 +344,16 @@ file_list *respfreq(char *nm, char *pw, char *dt)
|
|||||||
*/
|
*/
|
||||||
fdb.TimesDL++;
|
fdb.TimesDL++;
|
||||||
fdb.LastDL = time(NULL);
|
fdb.LastDL = time(NULL);
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if (mbsedb_LockFDB(fdb_area, 30)) {
|
if (mbsedb_LockFDB(fdb_area, 30)) {
|
||||||
fseek(fdb_area->fp, - fdbhdr.recsize, SEEK_CUR);
|
fseek(fdb_area->fp, - fdbhdr.recsize, SEEK_CUR);
|
||||||
fwrite(&fdb, fdbhdr.recsize, 1, fdb_area->fp);
|
fwrite(&fdb, fdbhdr.recsize, 1, fdb_area->fp);
|
||||||
mbsedb_UnlockFDB(fdb_area);
|
mbsedb_UnlockFDB(fdb_area);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
fseek(fb, - fdbhdr.recsize, SEEK_CUR);
|
|
||||||
fwrite(&fdb, fdbhdr.recsize, 1, fb);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
free(tnm);
|
free(tnm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
fclose(fb);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
245
mbfido/addbbs.c
245
mbfido/addbbs.c
@ -54,14 +54,7 @@ int Add_BBS()
|
|||||||
int rc, i, Found = FALSE, Keep = 0, DidDelete = FALSE;
|
int rc, i, Found = FALSE, Keep = 0, DidDelete = FALSE;
|
||||||
char temp1[PATH_MAX], temp2[PATH_MAX], *fname, *lname, *p;
|
char temp1[PATH_MAX], temp2[PATH_MAX], *fname, *lname, *p;
|
||||||
fd_list *fdl = NULL;
|
fd_list *fdl = NULL;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
struct _fdbarea *fdb_area = NULL;
|
struct _fdbarea *fdb_area = NULL;
|
||||||
#else
|
|
||||||
struct FILE_recordhdr frechdr;
|
|
||||||
int Insert, Done = FALSE;
|
|
||||||
char fdbname[PATH_MAX], fdbtemp[PATH_MAX];
|
|
||||||
FILE *fp, *fdt;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First check for an existing record with the same filename,
|
* First check for an existing record with the same filename,
|
||||||
@ -69,26 +62,15 @@ int Add_BBS()
|
|||||||
* prevent for example allfiles.zip to get a new record everytime
|
* prevent for example allfiles.zip to get a new record everytime
|
||||||
* and thus the download counters will be reset after a new update.
|
* and thus the download counters will be reset after a new update.
|
||||||
*/
|
*/
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if ((fdb_area = mbsedb_OpenFDB(tic.FileArea, 30))) {
|
if ((fdb_area = mbsedb_OpenFDB(tic.FileArea, 30))) {
|
||||||
while (fread(&frec, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
while (fread(&frec, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
||||||
#else
|
|
||||||
sprintf(fdbname, "%s/fdb/file%ld.data", getenv("MBSE_ROOT"), tic.FileArea);
|
|
||||||
if ((fp = fopen(fdbname, "r+")) != NULL) {
|
|
||||||
fread(&frechdr, sizeof(frechdr), 1, fp);
|
|
||||||
while (fread(&frec, frechdr.recsize, 1, fp) == 1) {
|
|
||||||
#endif
|
|
||||||
if (strcmp(frec.Name, TIC.NewFile) == 0) {
|
if (strcmp(frec.Name, TIC.NewFile) == 0) {
|
||||||
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.NewFile);
|
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.NewFile);
|
||||||
sprintf(temp2, "%s/%s", TIC.BBSpath, TIC.NewFile);
|
sprintf(temp2, "%s/%s", TIC.BBSpath, TIC.NewFile);
|
||||||
mkdirs(temp2, 0755);
|
mkdirs(temp2, 0755);
|
||||||
if ((rc = file_cp(temp1, temp2))) {
|
if ((rc = file_cp(temp1, temp2))) {
|
||||||
WriteError("Copy to %s failed: %s", temp2, strerror(rc));
|
WriteError("Copy to %s failed: %s", temp2, strerror(rc));
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
fclose(fp);
|
|
||||||
#endif
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
chmod(temp2, 0644);
|
chmod(temp2, 0644);
|
||||||
@ -103,7 +85,6 @@ int Add_BBS()
|
|||||||
if (i == 24)
|
if (i == 24)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if (mbsedb_LockFDB(fdb_area, 30)) {
|
if (mbsedb_LockFDB(fdb_area, 30)) {
|
||||||
fseek(fdb_area->fp, 0 - fdbhdr.recsize, SEEK_CUR);
|
fseek(fdb_area->fp, 0 - fdbhdr.recsize, SEEK_CUR);
|
||||||
fwrite(&frec, fdbhdr.recsize, 1, fdb_area->fp);
|
fwrite(&frec, fdbhdr.recsize, 1, fdb_area->fp);
|
||||||
@ -111,22 +92,13 @@ int Add_BBS()
|
|||||||
}
|
}
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
Syslog('f', "updated file entry");
|
Syslog('f', "updated file entry");
|
||||||
#else
|
|
||||||
fseek(fp, 0 - sizeof(frec), SEEK_CUR);
|
|
||||||
fwrite(&frec, sizeof(frec), 1, fp);
|
|
||||||
fclose(fp);
|
|
||||||
#endif
|
|
||||||
tic_imp++;
|
tic_imp++;
|
||||||
if ((i = file_rm(temp1)))
|
if ((i = file_rm(temp1)))
|
||||||
WriteError("file_rm(%s): %s", temp1, strerror(i));
|
WriteError("file_rm(%s): %s", temp1, strerror(i));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
fclose(fp);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -197,155 +169,10 @@ int Add_BBS()
|
|||||||
}
|
}
|
||||||
free(lname);
|
free(lname);
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if ((fdb_area = mbsedb_OpenFDB(tic.FileArea, 30)) == NULL)
|
if ((fdb_area = mbsedb_OpenFDB(tic.FileArea, 30)) == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
mbsedb_InsertFDB(fdb_area, frec, area.AddAlpha);
|
mbsedb_InsertFDB(fdb_area, frec, area.AddAlpha);
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
sprintf(fdbtemp, "%s/fdb/file%ld.temp", getenv("MBSE_ROOT"), tic.FileArea);
|
|
||||||
if ((fp = fopen(fdbname, "r+")) == NULL) {
|
|
||||||
Syslog('+', "Fdb %s doesn't exist, creating", fdbname);
|
|
||||||
if ((fp = fopen(fdbname, "a+")) == NULL) {
|
|
||||||
WriteError("$Can't create %s", fdbname);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
frechdr.hdrsize = sizeof(frechdr);
|
|
||||||
frechdr.recsize = sizeof(frec);
|
|
||||||
fwrite(&frechdr, sizeof(frechdr), 1, fp);
|
|
||||||
chmod(fdbname, 0660);
|
|
||||||
} else {
|
|
||||||
fread(&frechdr, sizeof(frechdr), 1, fp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If there are no files in this area, we append the first
|
|
||||||
* one and leave immediatly, keepnum and replace have no
|
|
||||||
* use at this point.
|
|
||||||
*/
|
|
||||||
fseek(fp, 0, SEEK_END);
|
|
||||||
if (ftell(fp) == frechdr.hdrsize) {
|
|
||||||
fwrite(&frec, sizeof(frec), 1, fp);
|
|
||||||
fclose(fp);
|
|
||||||
file_rm(temp1);
|
|
||||||
tic_imp++;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* There are already files in the area. We must now see at
|
|
||||||
* which position to insert the new file, replace or
|
|
||||||
* remove the old entry.
|
|
||||||
*/
|
|
||||||
fseek(fp, frechdr.hdrsize, SEEK_SET);
|
|
||||||
|
|
||||||
Insert = 0;
|
|
||||||
do {
|
|
||||||
if (fread(&fdb, frechdr.recsize, 1, fp) != 1)
|
|
||||||
Done = TRUE;
|
|
||||||
if (!Done) {
|
|
||||||
if (strcmp(frec.LName, fdb.LName) == 0) {
|
|
||||||
Found = TRUE;
|
|
||||||
Insert++;
|
|
||||||
} else if (strcmp(frec.LName, fdb.LName) < 0)
|
|
||||||
Found = TRUE;
|
|
||||||
else
|
|
||||||
Insert++;
|
|
||||||
}
|
|
||||||
} while ((!Found) && (!Done));
|
|
||||||
|
|
||||||
if (Found) {
|
|
||||||
if ((fdt = fopen(fdbtemp, "a+")) == NULL) {
|
|
||||||
WriteError("$Can't create %s", fdbtemp);
|
|
||||||
fclose(fp);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
fwrite(&frechdr, frechdr.hdrsize, 1, fdt);
|
|
||||||
|
|
||||||
fseek(fp, frechdr.hdrsize, SEEK_SET);
|
|
||||||
/*
|
|
||||||
* Copy entries till the insert point.
|
|
||||||
*/
|
|
||||||
for (i = 0; i < Insert; i++) {
|
|
||||||
fread(&fdb, frechdr.recsize, 1, fp);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If we see a magic that is the new magic, remove
|
|
||||||
* the old one.
|
|
||||||
*/
|
|
||||||
if (strlen(TIC.TicIn.Magic) && (strcmp(fdb.Magic, TIC.TicIn.Magic) == 0)) {
|
|
||||||
Syslog('f', "addbbs(): remove magic from %s (%s)", fdb.Name, fdb.LName);
|
|
||||||
memset(&fdb.Magic, 0, sizeof(fdb.Magic));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Check if we are importing a file with the same
|
|
||||||
* name, if so, don't copy the original database
|
|
||||||
* record. The file is also overwritten.
|
|
||||||
*/
|
|
||||||
if (strcmp(fdb.LName, frec.LName) != 0)
|
|
||||||
fwrite(&fdb, frechdr.recsize, 1, fdt);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (area.AddAlpha) {
|
|
||||||
/*
|
|
||||||
* Insert the new entry
|
|
||||||
*/
|
|
||||||
fwrite(&frec, frechdr.recsize, 1, fdt);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Append the rest of the entries.
|
|
||||||
*/
|
|
||||||
while (fread(&fdb, frechdr.recsize, 1, fp) == 1) {
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If we see a magic that is the new magic, remove
|
|
||||||
* the old one.
|
|
||||||
*/
|
|
||||||
if (strlen(TIC.TicIn.Magic) && (strcmp(fdb.Magic, TIC.TicIn.Magic) == 0)) {
|
|
||||||
Syslog('f', "addbbs(): remove magic from %s (%s)", fdb.Name, fdb.LName);
|
|
||||||
memset(&fdb.Magic, 0, sizeof(fdb.Magic));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Check if we find a file with the same name,
|
|
||||||
* then we skip the record what was origionaly
|
|
||||||
* in the database record.
|
|
||||||
*/
|
|
||||||
if (strcmp(fdb.LName, frec.LName) != 0)
|
|
||||||
fwrite(&fdb, frechdr.recsize, 1, fdt);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!area.AddAlpha) {
|
|
||||||
/*
|
|
||||||
* Append the new entry
|
|
||||||
*/
|
|
||||||
fwrite(&frec, frechdr.recsize, 1, fdt);
|
|
||||||
}
|
|
||||||
fclose(fdt);
|
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Now make the changes for real.
|
|
||||||
*/
|
|
||||||
if (unlink(fdbname) == 0) {
|
|
||||||
rename(fdbtemp, fdbname);
|
|
||||||
} else {
|
|
||||||
WriteError("$Can't unlink %s", fdbname);
|
|
||||||
unlink(fdbtemp);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* Append the new entry
|
|
||||||
*/
|
|
||||||
fseek(fp, 0, SEEK_END);
|
|
||||||
fwrite(&frec, frechdr.recsize, 1, fp);
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Delete file from the inbound
|
* Delete file from the inbound
|
||||||
@ -359,14 +186,8 @@ int Add_BBS()
|
|||||||
if ((strlen(TIC.TicIn.Replace)) && (tic.Replace)) {
|
if ((strlen(TIC.TicIn.Replace)) && (tic.Replace)) {
|
||||||
Syslog('f', "Must Replace: %s", TIC.TicIn.Replace);
|
Syslog('f', "Must Replace: %s", TIC.TicIn.Replace);
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if ((fdb_area = mbsedb_OpenFDB(tic.FileArea, 30))) {
|
if ((fdb_area = mbsedb_OpenFDB(tic.FileArea, 30))) {
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
||||||
#else
|
|
||||||
if ((fp = fopen(fdbname, "r+")) != NULL) {
|
|
||||||
fread(&fdbhdr, sizeof(fdbhdr), 1, fp);
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fp) == 1) {
|
|
||||||
#endif
|
|
||||||
if (strlen(fdb.LName) == strlen(frec.LName)) {
|
if (strlen(fdb.LName) == strlen(frec.LName)) {
|
||||||
// FIXME: Search must be based on a reg_exp search
|
// FIXME: Search must be based on a reg_exp search
|
||||||
if (strcasecmp(fdb.LName, frec.LName) != 0) {
|
if (strcasecmp(fdb.LName, frec.LName) != 0) {
|
||||||
@ -378,26 +199,17 @@ int Add_BBS()
|
|||||||
if (Found) {
|
if (Found) {
|
||||||
Syslog('+', "Replace: Deleting: %s", fdb.LName);
|
Syslog('+', "Replace: Deleting: %s", fdb.LName);
|
||||||
fdb.Deleted = TRUE;
|
fdb.Deleted = TRUE;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if (mbsedb_LockFDB(fdb_area, 30)) {
|
if (mbsedb_LockFDB(fdb_area, 30)) {
|
||||||
fseek(fdb_area->fp , - fdbhdr.recsize, SEEK_CUR);
|
fseek(fdb_area->fp , - fdbhdr.recsize, SEEK_CUR);
|
||||||
fwrite(&fdb, fdbhdr.recsize, 1, fdb_area->fp);
|
fwrite(&fdb, fdbhdr.recsize, 1, fdb_area->fp);
|
||||||
mbsedb_UnlockFDB(fdb_area);
|
mbsedb_UnlockFDB(fdb_area);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
fseek(fp , - fdbhdr.recsize, SEEK_CUR);
|
|
||||||
fwrite(&fdb, fdbhdr.recsize, 1, fp);
|
|
||||||
#endif
|
|
||||||
DidDelete = TRUE;
|
DidDelete = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
fclose(fp);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -405,14 +217,8 @@ int Add_BBS()
|
|||||||
* Handle the Keep number of files option
|
* Handle the Keep number of files option
|
||||||
*/
|
*/
|
||||||
if (TIC.KeepNum) {
|
if (TIC.KeepNum) {
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if ((fdb_area = mbsedb_OpenFDB(tic.FileArea, 30))) {
|
if ((fdb_area = mbsedb_OpenFDB(tic.FileArea, 30))) {
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
||||||
#else
|
|
||||||
if ((fp = fopen(fdbname, "r")) != NULL) {
|
|
||||||
fread(&fdbhdr, sizeof(fdbhdr), 1, fp);
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fp) == 1) {
|
|
||||||
#endif
|
|
||||||
if ((strlen(fdb.LName) == strlen(frec.LName)) && (!fdb.Deleted)) {
|
if ((strlen(fdb.LName) == strlen(frec.LName)) && (!fdb.Deleted)) {
|
||||||
Found = TRUE;
|
Found = TRUE;
|
||||||
|
|
||||||
@ -429,11 +235,7 @@ int Add_BBS()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
fclose(fp);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -442,43 +244,24 @@ int Add_BBS()
|
|||||||
if (Keep > TIC.KeepNum) {
|
if (Keep > TIC.KeepNum) {
|
||||||
sort_fdlist(&fdl);
|
sort_fdlist(&fdl);
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if ((fdb_area = mbsedb_OpenFDB(tic.FileArea, 30))) {
|
if ((fdb_area = mbsedb_OpenFDB(tic.FileArea, 30))) {
|
||||||
#else
|
|
||||||
if ((fp = fopen(fdbname, "r+")) != NULL) {
|
|
||||||
fread(&fdbhdr, sizeof(fdbhdr), 1, fp);
|
|
||||||
#endif
|
|
||||||
for (i = 0; i < (Keep - TIC.KeepNum); i++) {
|
for (i = 0; i < (Keep - TIC.KeepNum); i++) {
|
||||||
fname = pull_fdlist(&fdl);
|
fname = pull_fdlist(&fdl);
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
fseek(fdb_area->fp, fdbhdr.hdrsize, SEEK_SET);
|
fseek(fdb_area->fp, fdbhdr.hdrsize, SEEK_SET);
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
||||||
#else
|
|
||||||
fseek(fp, fdbhdr.hdrsize, SEEK_SET);
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fp) == 1) {
|
|
||||||
#endif
|
|
||||||
if (strcmp(fdb.LName, fname) == 0) {
|
if (strcmp(fdb.LName, fname) == 0) {
|
||||||
Syslog('+', "Keep %d files, deleting: %s", TIC.KeepNum, fdb.LName);
|
Syslog('+', "Keep %d files, deleting: %s", TIC.KeepNum, fdb.LName);
|
||||||
fdb.Deleted = TRUE;
|
fdb.Deleted = TRUE;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if (mbsedb_LockFDB(fdb_area, 30)) {
|
if (mbsedb_LockFDB(fdb_area, 30)) {
|
||||||
fseek(fdb_area->fp , - fdbhdr.recsize, SEEK_CUR);
|
fseek(fdb_area->fp , - fdbhdr.recsize, SEEK_CUR);
|
||||||
fwrite(&fdb, fdbhdr.recsize, 1, fdb_area->fp);
|
fwrite(&fdb, fdbhdr.recsize, 1, fdb_area->fp);
|
||||||
mbsedb_UnlockFDB(fdb_area);
|
mbsedb_UnlockFDB(fdb_area);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
fseek(fp , - fdbhdr.recsize, SEEK_CUR);
|
|
||||||
fwrite(&fdb, fdbhdr.recsize, 1, fp);
|
|
||||||
#endif
|
|
||||||
DidDelete = TRUE;
|
DidDelete = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
fclose(fp);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tidy_fdlist(&fdl);
|
tidy_fdlist(&fdl);
|
||||||
@ -489,21 +272,9 @@ int Add_BBS()
|
|||||||
* database.
|
* database.
|
||||||
*/
|
*/
|
||||||
if (DidDelete) {
|
if (DidDelete) {
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if ((fdb_area = mbsedb_OpenFDB(tic.FileArea, 30))) {
|
if ((fdb_area = mbsedb_OpenFDB(tic.FileArea, 30))) {
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1)
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1)
|
||||||
#else
|
if (fdb.Deleted) {
|
||||||
if ((fp = fopen(fdbname, "r")) != NULL) {
|
|
||||||
fread(&fdbhdr, sizeof(fdbhdr), 1, fp);
|
|
||||||
if ((fdt = fopen(fdbtemp, "a+")) != NULL) {
|
|
||||||
fwrite(&fdbhdr, fdbhdr.hdrsize, 1, fdt);
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fp) == 1)
|
|
||||||
#endif
|
|
||||||
if (!fdb.Deleted) {
|
|
||||||
#ifndef USE_EXPERIMENT
|
|
||||||
fwrite(&fdb, fdbhdr.recsize, 1, fdt);
|
|
||||||
#endif
|
|
||||||
} else {
|
|
||||||
sprintf(temp2, "%s/%s", area.Path, fdb.LName);
|
sprintf(temp2, "%s/%s", area.Path, fdb.LName);
|
||||||
if (unlink(temp2) != 0)
|
if (unlink(temp2) != 0)
|
||||||
WriteError("$Can't unlink file %s", temp2);
|
WriteError("$Can't unlink file %s", temp2);
|
||||||
@ -513,22 +284,8 @@ int Add_BBS()
|
|||||||
sprintf(temp2, "%s/.%s", area.Path, fdb.Name);
|
sprintf(temp2, "%s/.%s", area.Path, fdb.Name);
|
||||||
unlink(temp2); /* Thumbnail, no logging if there is an error */
|
unlink(temp2); /* Thumbnail, no logging if there is an error */
|
||||||
}
|
}
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
mbsedb_PackFDB(fdb_area);
|
mbsedb_PackFDB(fdb_area);
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
fclose(fp);
|
|
||||||
fclose(fdt);
|
|
||||||
if (unlink(fdbname) == 0) {
|
|
||||||
rename(fdbtemp, fdbname);
|
|
||||||
} else {
|
|
||||||
WriteError("$Can't unlink %s", fdbname);
|
|
||||||
unlink(fdbtemp);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
DidDelete = FALSE;
|
DidDelete = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,14 +59,7 @@ void Uploads()
|
|||||||
FILE *pAreas;
|
FILE *pAreas;
|
||||||
char *sAreas;
|
char *sAreas;
|
||||||
int Count = 0, i = 0, j, k;
|
int Count = 0, i = 0, j, k;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
struct _fdbarea *fdb_area = NULL;
|
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));
|
||||||
|
|
||||||
@ -82,9 +75,6 @@ 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);
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fread(&areahdr, sizeof(areahdr), 1, pAreas);
|
fread(&areahdr, sizeof(areahdr), 1, pAreas);
|
||||||
@ -103,15 +93,8 @@ void Uploads()
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if ((fdb_area = mbsedb_OpenFDB(i, 30))) {
|
if ((fdb_area = mbsedb_OpenFDB(i, 30))) {
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
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();
|
Nopper();
|
||||||
if (!fdb.Announced) {
|
if (!fdb.Announced) {
|
||||||
Syslog('m', " %d %s", i, fdb.Name);
|
Syslog('m', " %d %s", i, fdb.Name);
|
||||||
@ -147,24 +130,15 @@ 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)) {
|
if (mbsedb_LockFDB(fdb_area, 30)) {
|
||||||
fseek(fdb_area->fp, - fdbhdr.recsize, SEEK_CUR);
|
fseek(fdb_area->fp, - fdbhdr.recsize, SEEK_CUR);
|
||||||
fwrite(&fdb, fdbhdr.recsize, 1, fdb_area->fp);
|
fwrite(&fdb, fdbhdr.recsize, 1, fdb_area->fp);
|
||||||
mbsedb_CloseFDB(fdb_area);
|
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);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
fclose(pFile);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -181,9 +155,6 @@ void Uploads()
|
|||||||
|
|
||||||
fclose(pAreas);
|
fclose(pAreas);
|
||||||
free(sAreas);
|
free(sAreas);
|
||||||
#ifndef USE_EXPERIMENT
|
|
||||||
free(fAreas);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -92,9 +92,7 @@ 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;
|
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);
|
||||||
@ -330,28 +328,8 @@ int CheckTicGroup(char *Area, int SendUplink, faddr *f)
|
|||||||
/*
|
/*
|
||||||
* Create download database
|
* Create download database
|
||||||
*/
|
*/
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if ((fdb_area = mbsedb_OpenFDB(AreaNr, 30)))
|
if ((fdb_area = mbsedb_OpenFDB(AreaNr, 30)))
|
||||||
mbsedb_CloseFDB(fdb_area);
|
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);
|
|
||||||
if ((fp = fopen(temp, "a+")) == NULL) {
|
|
||||||
WriteError("$Can't create %s", temp);
|
|
||||||
} else {
|
|
||||||
fdbhdr.hdrsize = sizeof(fdbhdr);
|
|
||||||
fdbhdr.recsize = sizeof(fdb);
|
|
||||||
fwrite(&fdbhdr, sizeof(fdbhdr), 1, fp);
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
fread(&fdbhdr, sizeof(fdbhdr), 1, fp);
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
chmod(temp, 0660);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Setup new TIC area.
|
* Setup new TIC area.
|
||||||
|
@ -251,11 +251,7 @@ void ScanFiles(ff_list *tmp)
|
|||||||
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;
|
struct _fdbarea *fdb_area = NULL;
|
||||||
#else
|
|
||||||
FILE *pFile;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check for local generated requests.
|
* Check for local generated requests.
|
||||||
@ -296,15 +292,8 @@ 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))) {
|
if ((fdb_area = mbsedb_OpenFDB(areanr, 30))) {
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
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++)
|
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);
|
||||||
@ -359,11 +348,7 @@ void ScanFiles(ff_list *tmp)
|
|||||||
}
|
}
|
||||||
strcpy(BigDesc, "");
|
strcpy(BigDesc, "");
|
||||||
}
|
}
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
fclose(pFile);
|
|
||||||
#endif
|
|
||||||
} else
|
} else
|
||||||
WriteError("$Can't open %s", temp);
|
WriteError("$Can't open %s", temp);
|
||||||
}
|
}
|
||||||
@ -417,21 +402,11 @@ void ScanFiles(ff_list *tmp)
|
|||||||
areanr = rft->area;
|
areanr = rft->area;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if ((fdb_area = mbsedb_OpenFDB(rft->area, 30))) {
|
if ((fdb_area = mbsedb_OpenFDB(rft->area, 30))) {
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1)
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1)
|
||||||
if (!strcmp(rft->filename, fdb.Name))
|
if (!strcmp(rft->filename, fdb.Name))
|
||||||
break;
|
break;
|
||||||
mbsedb_CloseFDB(fdb_area);
|
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);
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1)
|
|
||||||
if (!strcmp(rft->filename, fdb.Name))
|
|
||||||
break;
|
|
||||||
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);
|
||||||
|
@ -209,14 +209,8 @@ void CheckArea(long Area)
|
|||||||
struct stat stb;
|
struct stat stb;
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
struct group *gr;
|
struct group *gr;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
struct _fdbarea *fdb_area = NULL;
|
struct _fdbarea *fdb_area = NULL;
|
||||||
#else
|
|
||||||
FILE *pFile;
|
|
||||||
char *fAreas;
|
|
||||||
|
|
||||||
fAreas = calloc(PATH_MAX, sizeof(char));
|
|
||||||
#endif
|
|
||||||
newdir = calloc(PATH_MAX, sizeof(char));
|
newdir = calloc(PATH_MAX, sizeof(char));
|
||||||
temp = calloc(PATH_MAX, sizeof(char));
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
mname = calloc(PATH_MAX, sizeof(char));
|
mname = calloc(PATH_MAX, sizeof(char));
|
||||||
@ -294,52 +288,15 @@ void CheckArea(long Area)
|
|||||||
WriteError("Can't stat %s", area.Path);
|
WriteError("Can't stat %s", area.Path);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if ((fdb_area = mbsedb_OpenFDB(Area, 30)) == NULL)
|
if ((fdb_area = mbsedb_OpenFDB(Area, 30)) == NULL)
|
||||||
return;
|
return;
|
||||||
#else
|
|
||||||
sprintf(fAreas, "%s/fdb/file%ld.data", getenv("MBSE_ROOT"), Area);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Open the file database, if it doesn't exist,
|
|
||||||
* create an empty one.
|
|
||||||
*/
|
|
||||||
if ((pFile = fopen(fAreas, "r+")) == NULL) {
|
|
||||||
Syslog('!', "Creating new %s", fAreas);
|
|
||||||
if ((pFile = fopen(fAreas, "a+")) == NULL) {
|
|
||||||
WriteError("$Can't create %s", fAreas);
|
|
||||||
die(MBERR_GENERAL);
|
|
||||||
}
|
|
||||||
fdbhdr.hdrsize = sizeof(fdbhdr);
|
|
||||||
fdbhdr.recsize = sizeof(fdb);
|
|
||||||
fwrite(&fdbhdr, sizeof(fdbhdr), 1, pFile);
|
|
||||||
} else {
|
|
||||||
fread(&fdbhdr, sizeof(fdbhdr), 1, pFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We don't do any upgrade, so the header must be correct.
|
|
||||||
*/
|
|
||||||
if (fdbhdr.hdrsize != sizeof(fdbhdr)) {
|
|
||||||
Syslog('+', "fAreas hdrsize is corrupt: %d", fdbhdr.hdrsize);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (fdbhdr.recsize != sizeof(fdb)) {
|
|
||||||
Syslog('+', "fAreas recordsize is corrupt: %d, expected %d", fdbhdr.recsize, sizeof(fdbhdr));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now start checking the files in the filedatabase
|
* Now start checking the files in the filedatabase
|
||||||
* against the contents of the directory.
|
* against the contents of the directory.
|
||||||
*/
|
*/
|
||||||
inArea = 0;
|
inArea = 0;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
||||||
#else
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
iTotal++;
|
iTotal++;
|
||||||
inArea++;
|
inArea++;
|
||||||
@ -353,16 +310,11 @@ void CheckArea(long Area)
|
|||||||
do_pack = TRUE;
|
do_pack = TRUE;
|
||||||
}
|
}
|
||||||
iErrors++;
|
iErrors++;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if (mbsedb_LockFDB(fdb_area, 30)) {
|
if (mbsedb_LockFDB(fdb_area, 30)) {
|
||||||
fseek(fdb_area->fp, - fdbhdr.recsize, SEEK_CUR);
|
fseek(fdb_area->fp, - fdbhdr.recsize, SEEK_CUR);
|
||||||
fwrite(&fdb, fdbhdr.recsize, 1, fdb_area->fp);
|
fwrite(&fdb, fdbhdr.recsize, 1, fdb_area->fp);
|
||||||
mbsedb_UnlockFDB(fdb_area);
|
mbsedb_UnlockFDB(fdb_area);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
fseek(pFile, - fdbhdr.recsize, SEEK_CUR);
|
|
||||||
fwrite(&fdb, fdbhdr.recsize, 1, pFile);
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* File exists, now check the file.
|
* File exists, now check the file.
|
||||||
@ -510,16 +462,11 @@ void CheckArea(long Area)
|
|||||||
}
|
}
|
||||||
Marker();
|
Marker();
|
||||||
if (Update) {
|
if (Update) {
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if (mbsedb_LockFDB(fdb_area, 30)) {
|
if (mbsedb_LockFDB(fdb_area, 30)) {
|
||||||
fseek(fdb_area->fp, - fdbhdr.recsize, SEEK_CUR);
|
fseek(fdb_area->fp, - fdbhdr.recsize, SEEK_CUR);
|
||||||
fwrite(&fdb, fdbhdr.recsize, 1, fdb_area->fp);
|
fwrite(&fdb, fdbhdr.recsize, 1, fdb_area->fp);
|
||||||
mbsedb_UnlockFDB(fdb_area);
|
mbsedb_UnlockFDB(fdb_area);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
fseek(pFile, - fdbhdr.recsize, SEEK_CUR);
|
|
||||||
fwrite(&fdb, fdbhdr.recsize, 1, pFile);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -528,16 +475,11 @@ void CheckArea(long Area)
|
|||||||
if (rc == -1) {
|
if (rc == -1) {
|
||||||
Syslog('+', "Area %ld magic alias %s file %s is invalid", Area, fdb.Magic, fdb.Name);
|
Syslog('+', "Area %ld magic alias %s file %s is invalid", Area, fdb.Magic, fdb.Name);
|
||||||
memset(&fdb.Magic, 0, sizeof(fdb.Magic));
|
memset(&fdb.Magic, 0, sizeof(fdb.Magic));
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if (mbsedb_LockFDB(fdb_area, 30)) {
|
if (mbsedb_LockFDB(fdb_area, 30)) {
|
||||||
fseek(fdb_area->fp, - fdbhdr.recsize, SEEK_CUR);
|
fseek(fdb_area->fp, - fdbhdr.recsize, SEEK_CUR);
|
||||||
fwrite(&fdb, fdbhdr.recsize, 1, fdb_area->fp);
|
fwrite(&fdb, fdbhdr.recsize, 1, fdb_area->fp);
|
||||||
mbsedb_UnlockFDB(fdb_area);
|
mbsedb_UnlockFDB(fdb_area);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
fseek(pFile, - fdbhdr.recsize, SEEK_CUR);
|
|
||||||
fwrite(&fdb, fdbhdr.recsize, 1, pFile);
|
|
||||||
#endif
|
|
||||||
iErrors++;
|
iErrors++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -556,13 +498,8 @@ void CheckArea(long Area)
|
|||||||
if (de->d_name[0] != '.') {
|
if (de->d_name[0] != '.') {
|
||||||
Marker();
|
Marker();
|
||||||
Found = FALSE;
|
Found = FALSE;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
fseek(fdb_area->fp, fdbhdr.hdrsize, SEEK_SET);
|
fseek(fdb_area->fp, fdbhdr.hdrsize, SEEK_SET);
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
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 ((strcmp(fdb.LName, de->d_name) == 0) || (strcmp(fdb.Name, de->d_name) == 0)) {
|
if ((strcmp(fdb.LName, de->d_name) == 0) || (strcmp(fdb.Name, de->d_name) == 0)) {
|
||||||
if (!Found) {
|
if (!Found) {
|
||||||
Found = TRUE;
|
Found = TRUE;
|
||||||
@ -575,16 +512,11 @@ void CheckArea(long Area)
|
|||||||
iErrors++;
|
iErrors++;
|
||||||
fdb.Double = TRUE;
|
fdb.Double = TRUE;
|
||||||
do_pack = TRUE;
|
do_pack = TRUE;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if (mbsedb_LockFDB(fdb_area, 30)) {
|
if (mbsedb_LockFDB(fdb_area, 30)) {
|
||||||
fseek(fdb_area->fp, - fdbhdr.recsize, SEEK_CUR);
|
fseek(fdb_area->fp, - fdbhdr.recsize, SEEK_CUR);
|
||||||
fwrite(&fdb, fdbhdr.recsize, 1, fdb_area->fp);
|
fwrite(&fdb, fdbhdr.recsize, 1, fdb_area->fp);
|
||||||
mbsedb_UnlockFDB(fdb_area);
|
mbsedb_UnlockFDB(fdb_area);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
fseek(pFile, - fdbhdr.recsize, SEEK_CUR);
|
|
||||||
fwrite(&fdb, fdbhdr.recsize, 1, pFile);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -613,13 +545,7 @@ void CheckArea(long Area)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
fclose(pFile);
|
|
||||||
chmod(fAreas, 0660);
|
|
||||||
free(fAreas);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
iAreasNew++;
|
iAreasNew++;
|
||||||
free(newdir);
|
free(newdir);
|
||||||
|
@ -48,12 +48,7 @@ void Delete(int UnDel, int Area, char *File)
|
|||||||
{
|
{
|
||||||
char mask[256];
|
char mask[256];
|
||||||
int rc = FALSE;
|
int rc = FALSE;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
struct _fdbarea *fdb_area = NULL;
|
struct _fdbarea *fdb_area = NULL;
|
||||||
#else
|
|
||||||
FILE *fp;
|
|
||||||
char *temp;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (UnDel)
|
if (UnDel)
|
||||||
IsDoing("Undelete file");
|
IsDoing("Undelete file");
|
||||||
@ -81,33 +76,16 @@ void Delete(int UnDel, int Area, char *File)
|
|||||||
die(MBERR_COMMANDLINE);
|
die(MBERR_COMMANDLINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if ((fdb_area = mbsedb_OpenFDB(Area, 30)) == NULL)
|
if ((fdb_area = mbsedb_OpenFDB(Area, 30)) == NULL)
|
||||||
die(MBERR_GENERAL);
|
die(MBERR_GENERAL);
|
||||||
|
|
||||||
#else
|
|
||||||
if (CheckFDB(Area, area.Path))
|
|
||||||
die(MBERR_GENERAL);
|
|
||||||
|
|
||||||
temp = calloc(PATH_MAX, sizeof(char));
|
|
||||||
sprintf(temp, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), Area);
|
|
||||||
|
|
||||||
if ((fp = fopen(temp, "r+")) == NULL)
|
|
||||||
die(MBERR_GENERAL);
|
|
||||||
|
|
||||||
fread(&fdbhdr, sizeof(fdbhdr), 1, fp);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
colour(CYAN, BLACK);
|
colour(CYAN, BLACK);
|
||||||
strcpy(mask, re_mask(File, FALSE));
|
strcpy(mask, re_mask(File, FALSE));
|
||||||
if (re_comp(mask))
|
if (re_comp(mask))
|
||||||
die(MBERR_GENERAL);
|
die(MBERR_GENERAL);
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
||||||
#else
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fp) == 1) {
|
|
||||||
#endif
|
|
||||||
if (re_exec(fdb.LName) || re_exec(fdb.Name)) {
|
if (re_exec(fdb.LName) || re_exec(fdb.Name)) {
|
||||||
if (UnDel && fdb.Deleted) {
|
if (UnDel && fdb.Deleted) {
|
||||||
fdb.Deleted = FALSE;
|
fdb.Deleted = FALSE;
|
||||||
@ -124,7 +102,6 @@ void Delete(int UnDel, int Area, char *File)
|
|||||||
rc = TRUE;
|
rc = TRUE;
|
||||||
}
|
}
|
||||||
if (rc) {
|
if (rc) {
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if (mbsedb_LockFDB(fdb_area, 30)) {
|
if (mbsedb_LockFDB(fdb_area, 30)) {
|
||||||
fseek(fdb_area->fp, - fdbhdr.recsize, SEEK_CUR);
|
fseek(fdb_area->fp, - fdbhdr.recsize, SEEK_CUR);
|
||||||
fwrite(&fdb, fdbhdr.recsize, 1, fdb_area->fp);
|
fwrite(&fdb, fdbhdr.recsize, 1, fdb_area->fp);
|
||||||
@ -132,19 +109,10 @@ void Delete(int UnDel, int Area, char *File)
|
|||||||
} else {
|
} else {
|
||||||
rc = FALSE;
|
rc = FALSE;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
fseek(fp, - fdbhdr.recsize, SEEK_CUR);
|
|
||||||
fwrite(&fdb, fdbhdr.recsize, 1, fp);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
fclose(fp);
|
|
||||||
free(temp);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
Syslog('+', "%selete %s in area %d failed", UnDel?"Und":"D", File, Area);
|
Syslog('+', "%selete %s in area %d failed", UnDel?"Und":"D", File, Area);
|
||||||
|
@ -324,14 +324,7 @@ void ReqIndex(void)
|
|||||||
Findex *fdx = NULL;
|
Findex *fdx = NULL;
|
||||||
Findex *tmp;
|
Findex *tmp;
|
||||||
struct FILEIndex idx;
|
struct FILEIndex idx;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
struct _fdbarea *fdb_area = NULL;
|
struct _fdbarea *fdb_area = NULL;
|
||||||
#else
|
|
||||||
FILE *pFile;
|
|
||||||
char *fAreas;
|
|
||||||
|
|
||||||
fAreas = calloc(PATH_MAX, sizeof(char));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
IsDoing("Index files");
|
IsDoing("Index files");
|
||||||
if (!do_quiet) {
|
if (!do_quiet) {
|
||||||
@ -386,29 +379,8 @@ void ReqIndex(void)
|
|||||||
newdir = NULL;
|
newdir = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if ((fdb_area = mbsedb_OpenFDB(i, 30)) == NULL)
|
if ((fdb_area = mbsedb_OpenFDB(i, 30)) == NULL)
|
||||||
die(MBERR_GENERAL);
|
die(MBERR_GENERAL);
|
||||||
#else
|
|
||||||
sprintf(fAreas, "%s/fdb/file%ld.data", getenv("MBSE_ROOT"), i);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Open the file database, if it doesn't exist,
|
|
||||||
* create an empty one.
|
|
||||||
*/
|
|
||||||
if ((pFile = fopen(fAreas, "r+")) == NULL) {
|
|
||||||
Syslog('!', "Creating new %s", fAreas);
|
|
||||||
if ((pFile = fopen(fAreas, "a+")) == NULL) {
|
|
||||||
WriteError("$Can't create %s", fAreas);
|
|
||||||
die(MBERR_GENERAL);
|
|
||||||
}
|
|
||||||
fdbhdr.hdrsize = sizeof(fdbhdr);
|
|
||||||
fdbhdr.recsize = sizeof(fdb);
|
|
||||||
fwrite(&fdbhdr, sizeof(fdbhdr), 1, pFile);
|
|
||||||
} else {
|
|
||||||
fread(&fdbhdr, sizeof(fdbhdr), 1, pFile);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create file request index if requests are allowed in this area.
|
* Create file request index if requests are allowed in this area.
|
||||||
@ -418,11 +390,7 @@ void ReqIndex(void)
|
|||||||
* Now start creating the unsorted index.
|
* Now start creating the unsorted index.
|
||||||
*/
|
*/
|
||||||
record = 0;
|
record = 0;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
||||||
#else
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
|
|
||||||
#endif
|
|
||||||
iTotal++;
|
iTotal++;
|
||||||
if ((iTotal % 10) == 0)
|
if ((iTotal % 10) == 0)
|
||||||
Marker();
|
Marker();
|
||||||
@ -448,13 +416,8 @@ void ReqIndex(void)
|
|||||||
WriteError("$Can't create %s", temp);
|
WriteError("$Can't create %s", temp);
|
||||||
} else {
|
} else {
|
||||||
fbAreas++;
|
fbAreas++;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
fseek(fdb_area->fp, fdbhdr.hdrsize, SEEK_SET);
|
fseek(fdb_area->fp, fdbhdr.hdrsize, SEEK_SET);
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
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) {
|
if (!fdb.Deleted) {
|
||||||
fbFiles++;
|
fbFiles++;
|
||||||
fprintf(fp, "%-12s [%ld] %s\r\n", fdb.Name, fdb.TimesDL, fdb.Desc[0]);
|
fprintf(fp, "%-12s [%ld] %s\r\n", fdb.Name, fdb.TimesDL, fdb.Desc[0]);
|
||||||
@ -476,13 +439,8 @@ void ReqIndex(void)
|
|||||||
if ((fp = fopen(temp, "w")) == NULL) {
|
if ((fp = fopen(temp, "w")) == NULL) {
|
||||||
WriteError("$Can't create %s", temp);
|
WriteError("$Can't create %s", temp);
|
||||||
} else {
|
} else {
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
fseek(fdb_area->fp, fdbhdr.hdrsize, SEEK_SET);
|
fseek(fdb_area->fp, fdbhdr.hdrsize, SEEK_SET);
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
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) {
|
if (!fdb.Deleted) {
|
||||||
/*
|
/*
|
||||||
* The next is to reduce system load
|
* The next is to reduce system load
|
||||||
@ -510,12 +468,7 @@ void ReqIndex(void)
|
|||||||
chmod(temp, 0644);
|
chmod(temp, 0644);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
fclose(pFile);
|
|
||||||
free(fAreas);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -552,14 +505,8 @@ void HtmlIndex(char *Lang)
|
|||||||
char linebuf[1024], outbuf[1024], desc[6400];
|
char linebuf[1024], outbuf[1024], desc[6400];
|
||||||
time_t last = 0L, later;
|
time_t last = 0L, later;
|
||||||
long fileptr = 0, fileptr1 = 0;
|
long fileptr = 0, fileptr1 = 0;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
struct _fdbarea *fdb_area = NULL;
|
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));
|
||||||
fn = calloc(PATH_MAX, sizeof(char));
|
fn = calloc(PATH_MAX, sizeof(char));
|
||||||
|
|
||||||
@ -640,48 +587,22 @@ void HtmlIndex(char *Lang)
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if ((fdb_area = mbsedb_OpenFDB(i, 30)) == NULL)
|
if ((fdb_area = mbsedb_OpenFDB(i, 30)) == NULL)
|
||||||
die(MBERR_GENERAL);
|
die(MBERR_GENERAL);
|
||||||
#else
|
|
||||||
sprintf(fAreas, "%s/fdb/file%ld.data", getenv("MBSE_ROOT"), i);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Open the file database, if it doesn't exist,
|
|
||||||
* abort, we even should have never got here.
|
|
||||||
*/
|
|
||||||
if ((pFile = fopen(fAreas, "r+")) == NULL) {
|
|
||||||
WriteError("$Can't open %s", fAreas);
|
|
||||||
die(MBERR_GENERAL);
|
|
||||||
}
|
|
||||||
fread(&fdbhdr, sizeof(fdbhdr), 1, pFile);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create index.html pages in each available download area.
|
* Create index.html pages in each available download area.
|
||||||
*/
|
*/
|
||||||
if (!area.CDrom && fm && (strncmp(CFG.ftp_base, area.Path, strlen(CFG.ftp_base)) == 0)) {
|
if (!area.CDrom && fm && (strncmp(CFG.ftp_base, area.Path, strlen(CFG.ftp_base)) == 0)) {
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
fseek(fdb_area->fp, fdbhdr.hdrsize, SEEK_SET);
|
fseek(fdb_area->fp, fdbhdr.hdrsize, SEEK_SET);
|
||||||
#else
|
|
||||||
fseek(pFile, fdbhdr.hdrsize, SEEK_SET);
|
|
||||||
#endif
|
|
||||||
AreasHtml++;
|
AreasHtml++;
|
||||||
inArea = 0;
|
inArea = 0;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
||||||
#else
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
|
|
||||||
#endif
|
|
||||||
if (!fdb.Deleted)
|
if (!fdb.Deleted)
|
||||||
inArea++;
|
inArea++;
|
||||||
}
|
}
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
fseek(fdb_area->fp, fdbhdr.hdrsize, SEEK_SET);
|
fseek(fdb_area->fp, fdbhdr.hdrsize, SEEK_SET);
|
||||||
#else
|
|
||||||
fseek(pFile, fdbhdr.hdrsize, SEEK_SET);
|
|
||||||
#endif
|
|
||||||
aSize = 0L;
|
aSize = 0L;
|
||||||
aTotal = 0;
|
aTotal = 0;
|
||||||
last = 0L;
|
last = 0L;
|
||||||
@ -692,11 +613,7 @@ void HtmlIndex(char *Lang)
|
|||||||
fileptr1 = gfilepos;
|
fileptr1 = gfilepos;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
||||||
#else
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
|
|
||||||
#endif
|
|
||||||
if (!fdb.Deleted) {
|
if (!fdb.Deleted) {
|
||||||
/*
|
/*
|
||||||
* The next is to reduce system load
|
* The next is to reduce system load
|
||||||
@ -805,12 +722,7 @@ void HtmlIndex(char *Lang)
|
|||||||
fseek(fi, fileptr, SEEK_SET);
|
fseek(fi, fileptr, SEEK_SET);
|
||||||
MacroRead(fi, fm);
|
MacroRead(fi, fm);
|
||||||
}
|
}
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
fclose(pFile);
|
|
||||||
free(fAreas);
|
|
||||||
#endif
|
|
||||||
} /* if area.Available */
|
} /* if area.Available */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,14 +56,7 @@ void Kill(void)
|
|||||||
char *sAreas, *newdir = NULL, *sTemp, from[PATH_MAX], to[PATH_MAX];
|
char *sAreas, *newdir = NULL, *sTemp, from[PATH_MAX], to[PATH_MAX];
|
||||||
time_t Now;
|
time_t Now;
|
||||||
struct fileareas darea;
|
struct fileareas darea;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
struct _fdbarea *fdb_area = NULL, *dst_area = NULL;
|
struct _fdbarea *fdb_area = NULL, *dst_area = NULL;
|
||||||
#else
|
|
||||||
FILE *pFile, *pDest, *pTemp;
|
|
||||||
char *fAreas;
|
|
||||||
|
|
||||||
fAreas = calloc(PATH_MAX, sizeof(char));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
sAreas = calloc(PATH_MAX, sizeof(char));
|
sAreas = calloc(PATH_MAX, sizeof(char));
|
||||||
sTemp = calloc(PATH_MAX, sizeof(char));
|
sTemp = calloc(PATH_MAX, sizeof(char));
|
||||||
@ -113,39 +106,14 @@ void Kill(void)
|
|||||||
newdir = NULL;
|
newdir = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if ((fdb_area = mbsedb_OpenFDB(i, 30)) == NULL)
|
if ((fdb_area = mbsedb_OpenFDB(i, 30)) == NULL)
|
||||||
die(MBERR_GENERAL);
|
die(MBERR_GENERAL);
|
||||||
#else
|
|
||||||
sprintf(fAreas, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), i);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Open the file database, if it doesn't exist,
|
|
||||||
* create an empty one.
|
|
||||||
*/
|
|
||||||
if ((pFile = fopen(fAreas, "r+")) == NULL) {
|
|
||||||
Syslog('!', "Creating new %s", fAreas);
|
|
||||||
if ((pFile = fopen(fAreas, "a+")) == NULL) {
|
|
||||||
WriteError("$Can't create %s", fAreas);
|
|
||||||
die(MBERR_GENERAL);
|
|
||||||
}
|
|
||||||
fdbhdr.hdrsize = sizeof(fdbhdr);
|
|
||||||
fdbhdr.recsize = sizeof(fdb);
|
|
||||||
fwrite(&fdbhdr, sizeof(fdbhdr), 1, pFile);
|
|
||||||
} else {
|
|
||||||
fread(&fdbhdr, sizeof(fdbhdr), 1, pFile);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now start checking the files in the filedatabase
|
* Now start checking the files in the filedatabase
|
||||||
* against the contents of the directory.
|
* against the contents of the directory.
|
||||||
*/
|
*/
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
||||||
#else
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
|
|
||||||
#endif
|
|
||||||
iTotal++;
|
iTotal++;
|
||||||
Marker();
|
Marker();
|
||||||
|
|
||||||
@ -184,27 +152,12 @@ void Kill(void)
|
|||||||
sprintf(to, "%s/%s", darea.Path, fdb.Name);
|
sprintf(to, "%s/%s", darea.Path, fdb.Name);
|
||||||
if ((rc = file_mv(from, to)) == 0) {
|
if ((rc = file_mv(from, to)) == 0) {
|
||||||
Syslog('+', "Move %s, area %d => %d", fdb.Name, i, area.MoveArea);
|
Syslog('+', "Move %s, area %d => %d", fdb.Name, i, area.MoveArea);
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if ((dst_area = mbsedb_OpenFDB(area.MoveArea, 30))) {
|
if ((dst_area = mbsedb_OpenFDB(area.MoveArea, 30))) {
|
||||||
fdb.UploadDate = time(NULL);
|
fdb.UploadDate = time(NULL);
|
||||||
fdb.LastDL = time(NULL);
|
fdb.LastDL = time(NULL);
|
||||||
mbsedb_InsertFDB(dst_area, fdb, FALSE);
|
mbsedb_InsertFDB(dst_area, fdb, FALSE);
|
||||||
mbsedb_CloseFDB(dst_area);
|
mbsedb_CloseFDB(dst_area);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
sprintf(to, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), area.MoveArea);
|
|
||||||
if ((pDest = fopen(to, "a+")) != NULL) {
|
|
||||||
fseek(pDest, 0, SEEK_END);
|
|
||||||
if (ftell(pDest) == 0) {
|
|
||||||
/* New file, write header */
|
|
||||||
fwrite(&fdbhdr, fdbhdr.hdrsize, 1, pDest);
|
|
||||||
}
|
|
||||||
fdb.UploadDate = time(NULL);
|
|
||||||
fdb.LastDL = time(NULL);
|
|
||||||
fwrite(&fdb, fdbhdr.recsize, 1, pDest);
|
|
||||||
fclose(pDest);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now again if there is a dotted version (thumbnail) of this file.
|
* Now again if there is a dotted version (thumbnail) of this file.
|
||||||
@ -228,16 +181,11 @@ void Kill(void)
|
|||||||
symlink(from, to);
|
symlink(from, to);
|
||||||
|
|
||||||
fdb.Deleted = TRUE;
|
fdb.Deleted = TRUE;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if (mbsedb_LockFDB(fdb_area, 30)) {
|
if (mbsedb_LockFDB(fdb_area, 30)) {
|
||||||
fseek(fdb_area->fp, - fdbhdr.recsize, SEEK_CUR);
|
fseek(fdb_area->fp, - fdbhdr.recsize, SEEK_CUR);
|
||||||
fwrite(&fdb, fdbhdr.recsize, 1, fdb_area->fp);
|
fwrite(&fdb, fdbhdr.recsize, 1, fdb_area->fp);
|
||||||
mbsedb_UnlockFDB(fdb_area);
|
mbsedb_UnlockFDB(fdb_area);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
fseek(pFile, - fdbhdr.recsize, SEEK_CUR);
|
|
||||||
fwrite(&fdb, fdbhdr.recsize, 1, pFile);
|
|
||||||
#endif
|
|
||||||
iMoved++;
|
iMoved++;
|
||||||
} else {
|
} else {
|
||||||
WriteError("Move %s to area %d failed, %s", fdb.Name, area.MoveArea, strerror(rc));
|
WriteError("Move %s to area %d failed, %s", fdb.Name, area.MoveArea, strerror(rc));
|
||||||
@ -245,16 +193,11 @@ void Kill(void)
|
|||||||
} else {
|
} else {
|
||||||
Syslog('+', "Delete %s, area %d", fdb.LName, i);
|
Syslog('+', "Delete %s, area %d", fdb.LName, i);
|
||||||
fdb.Deleted = TRUE;
|
fdb.Deleted = TRUE;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if (mbsedb_LockFDB(fdb_area, 30)) {
|
if (mbsedb_LockFDB(fdb_area, 30)) {
|
||||||
fseek(fdb_area->fp, - fdbhdr.recsize, SEEK_CUR);
|
fseek(fdb_area->fp, - fdbhdr.recsize, SEEK_CUR);
|
||||||
fwrite(&fdb, fdbhdr.recsize, 1, fdb_area->fp);
|
fwrite(&fdb, fdbhdr.recsize, 1, fdb_area->fp);
|
||||||
mbsedb_UnlockFDB(fdb_area);
|
mbsedb_UnlockFDB(fdb_area);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
fseek(pFile, - fdbhdr.recsize, SEEK_CUR);
|
|
||||||
fwrite(&fdb, fdbhdr.recsize, 1, pFile);
|
|
||||||
#endif
|
|
||||||
iKilled++;
|
iKilled++;
|
||||||
sprintf(from, "%s/%s", area.Path, fdb.LName);
|
sprintf(from, "%s/%s", area.Path, fdb.LName);
|
||||||
unlink(from);
|
unlink(from);
|
||||||
@ -270,31 +213,8 @@ void Kill(void)
|
|||||||
* Now we must pack this area database otherwise
|
* Now we must pack this area database otherwise
|
||||||
* we run into trouble later on.
|
* we run into trouble later on.
|
||||||
*/
|
*/
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
mbsedb_PackFDB(fdb_area);
|
mbsedb_PackFDB(fdb_area);
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
fseek(pFile, fdbhdr.hdrsize, SEEK_SET);
|
|
||||||
sprintf(sTemp, "%s/fdb/filetmp.data", getenv("MBSE_ROOT"));
|
|
||||||
|
|
||||||
if ((pTemp = fopen(sTemp, "a+")) != NULL) {
|
|
||||||
fwrite(&fdbhdr, fdbhdr.hdrsize, 1, pTemp);
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
|
|
||||||
if ((!fdb.Deleted) && strcmp(fdb.LName, "") != 0) {
|
|
||||||
fwrite(&fdb, fdbhdr.recsize, 1, pTemp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(pFile);
|
|
||||||
fclose(pTemp);
|
|
||||||
if ((rename(sTemp, fAreas)) == 0) {
|
|
||||||
unlink(sTemp);
|
|
||||||
chmod(fAreas, 006600);
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
fclose(pFile);
|
|
||||||
free(fAreas);
|
|
||||||
#endif
|
|
||||||
iAreasNew++;
|
iAreasNew++;
|
||||||
|
|
||||||
} /* if area.Available */
|
} /* if area.Available */
|
||||||
|
@ -46,11 +46,7 @@ void ListFileAreas(int Area)
|
|||||||
int i, iAreas, fcount, tcount = 0, iTotal = 0, columns = 80;
|
int i, iAreas, fcount, tcount = 0, iTotal = 0, columns = 80;
|
||||||
long fsize, tsize = 0;
|
long fsize, tsize = 0;
|
||||||
char *sAreas, *fAreas, *sTic, flags[6], *ticarea;
|
char *sAreas, *fAreas, *sTic, flags[6], *ticarea;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
struct _fdbarea *fdb_area = NULL;
|
struct _fdbarea *fdb_area = NULL;
|
||||||
#else
|
|
||||||
FILE *pFile;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If nothing to display allowed, return at once.
|
* If nothing to display allowed, return at once.
|
||||||
@ -108,30 +104,10 @@ void ListFileAreas(int Area)
|
|||||||
|
|
||||||
if (area.Available) {
|
if (area.Available) {
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
/*
|
/*
|
||||||
* Open the file database.
|
* Open the file database.
|
||||||
*/
|
*/
|
||||||
fdb_area = mbsedb_OpenFDB(Area, 30);
|
fdb_area = mbsedb_OpenFDB(Area, 30);
|
||||||
#else
|
|
||||||
/*
|
|
||||||
* Open the file database, create new one if it doesn't exist.
|
|
||||||
*/
|
|
||||||
sprintf(fAreas, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), Area);
|
|
||||||
if ((pFile = fopen(fAreas, "r+")) == NULL) {
|
|
||||||
Syslog('!', "Creating new %s", fAreas);
|
|
||||||
if ((pFile = fopen(fAreas, "a+")) == NULL) {
|
|
||||||
WriteError("$Can't create %s", fAreas);
|
|
||||||
die(MBERR_GENERAL);
|
|
||||||
}
|
|
||||||
fdbhdr.hdrsize = sizeof(fdbhdr);
|
|
||||||
fdbhdr.recsize = sizeof(fdb);
|
|
||||||
fwrite(&fdbhdr, sizeof(fdbhdr), 1, pFile);
|
|
||||||
} else {
|
|
||||||
fread(&fdbhdr, sizeof(fdbhdr), 1, pFile);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fcount = 0;
|
fcount = 0;
|
||||||
fsize = 0L;
|
fsize = 0L;
|
||||||
colour(CYAN, BLACK);
|
colour(CYAN, BLACK);
|
||||||
@ -144,11 +120,7 @@ void ListFileAreas(int Area)
|
|||||||
|
|
||||||
colour(LIGHTGRAY, BLACK);
|
colour(LIGHTGRAY, BLACK);
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
||||||
#else
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
|
|
||||||
#endif
|
|
||||||
sprintf(flags, "---");
|
sprintf(flags, "---");
|
||||||
if (fdb.Deleted)
|
if (fdb.Deleted)
|
||||||
flags[0] = 'D';
|
flags[0] = 'D';
|
||||||
@ -171,11 +143,7 @@ void ListFileAreas(int Area)
|
|||||||
printf("-");
|
printf("-");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("%d file%s, %ld Kbytes\n", fcount, (fcount == 1) ? "":"s", fsize);
|
printf("%d file%s, %ld Kbytes\n", fcount, (fcount == 1) ? "":"s", fsize);
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
fclose(pFile);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
WriteError("Area %d is not available", Area);
|
WriteError("Area %d is not available", Area);
|
||||||
@ -204,34 +172,10 @@ void ListFileAreas(int Area)
|
|||||||
|
|
||||||
if (area.Available) {
|
if (area.Available) {
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
fdb_area = mbsedb_OpenFDB(i, 30);
|
fdb_area = mbsedb_OpenFDB(i, 30);
|
||||||
#else
|
|
||||||
/*
|
|
||||||
* Open the file database, create new one if it doesn't exist.
|
|
||||||
*/
|
|
||||||
sprintf(fAreas, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), i);
|
|
||||||
if ((pFile = fopen(fAreas, "r+")) == NULL) {
|
|
||||||
Syslog('!', "Creating new %s", fAreas);
|
|
||||||
if ((pFile = fopen(fAreas, "a+")) == NULL) {
|
|
||||||
WriteError("$Can't create %s", fAreas);
|
|
||||||
die(MBERR_GENERAL);
|
|
||||||
}
|
|
||||||
fdbhdr.hdrsize = sizeof(fdbhdr);
|
|
||||||
fdbhdr.recsize = sizeof(fdb);
|
|
||||||
fwrite(&fdbhdr, sizeof(fdbhdr), 1, pFile);
|
|
||||||
} else {
|
|
||||||
fread(&fdbhdr, sizeof(fdbhdr), 1, pFile);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fcount = 0;
|
fcount = 0;
|
||||||
fsize = 0L;
|
fsize = 0L;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
||||||
#else
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
|
|
||||||
#endif
|
|
||||||
fcount++;
|
fcount++;
|
||||||
fsize = fsize + fdb.Size;
|
fsize = fsize + fdb.Size;
|
||||||
}
|
}
|
||||||
@ -241,11 +185,7 @@ void ListFileAreas(int Area)
|
|||||||
|
|
||||||
printf("%5d %5d %5ld %-12s %s\n", i, fcount, fsize, area.BbsGroup, area.Name);
|
printf("%5d %5d %5ld %-12s %s\n", i, fcount, fsize, area.BbsGroup, area.Name);
|
||||||
iTotal++;
|
iTotal++;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
fclose(pFile);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,13 +49,7 @@ void Move(int From, int To, char *File)
|
|||||||
char *frompath, *topath, *temp1, *fromlink, *tolink, *fromthumb, *tothumb;
|
char *frompath, *topath, *temp1, *fromlink, *tolink, *fromthumb, *tothumb;
|
||||||
struct FILE_record f_db;
|
struct FILE_record f_db;
|
||||||
int rc = FALSE, Found = FALSE;
|
int rc = FALSE, Found = FALSE;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
struct _fdbarea *src_area = NULL;
|
struct _fdbarea *src_area = NULL;
|
||||||
#else
|
|
||||||
struct FILE_recordhdr f_dbhdr;
|
|
||||||
FILE *fp1, *fp2;
|
|
||||||
char *temp2;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
IsDoing("Move file");
|
IsDoing("Move file");
|
||||||
colour(LIGHTRED, BLACK);
|
colour(LIGHTRED, BLACK);
|
||||||
@ -92,7 +86,6 @@ void Move(int From, int To, char *File)
|
|||||||
/*
|
/*
|
||||||
* Find the file in the "from" area, check LFN and 8.3 names.
|
* Find the file in the "from" area, check LFN and 8.3 names.
|
||||||
*/
|
*/
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if ((src_area = mbsedb_OpenFDB(From, 30)) == NULL)
|
if ((src_area = mbsedb_OpenFDB(From, 30)) == NULL)
|
||||||
die(MBERR_GENERAL);
|
die(MBERR_GENERAL);
|
||||||
|
|
||||||
@ -103,21 +96,6 @@ void Move(int From, int To, char *File)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
temp1 = calloc(PATH_MAX, sizeof(char)); // not serious
|
temp1 = calloc(PATH_MAX, sizeof(char)); // not serious
|
||||||
#else
|
|
||||||
temp1 = calloc(PATH_MAX, sizeof(char));
|
|
||||||
sprintf(temp1, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), From);
|
|
||||||
if ((fp1 = fopen(temp1, "r")) == NULL)
|
|
||||||
die(MBERR_GENERAL);
|
|
||||||
fread(&f_dbhdr, sizeof(fdbhdr), 1, fp1);
|
|
||||||
|
|
||||||
while (fread(&f_db, f_dbhdr.recsize, 1, fp1) == 1) {
|
|
||||||
if ((strcmp(f_db.LName, File) == 0) || strcmp(f_db.Name, File) == 0) {
|
|
||||||
Found = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose(fp1);
|
|
||||||
#endif
|
|
||||||
if (!Found) {
|
if (!Found) {
|
||||||
WriteError("File %s not found in area %d", File, From);
|
WriteError("File %s not found in area %d", File, From);
|
||||||
if (!do_quiet)
|
if (!do_quiet)
|
||||||
@ -175,7 +153,6 @@ void Move(int From, int To, char *File)
|
|||||||
die(MBERR_COMMANDLINE);
|
die(MBERR_COMMANDLINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
rc = AddFile(f_db, To, topath, frompath, tolink);
|
rc = AddFile(f_db, To, topath, frompath, tolink);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
unlink(fromlink);
|
unlink(fromlink);
|
||||||
@ -196,67 +173,6 @@ void Move(int From, int To, char *File)
|
|||||||
mbsedb_PackFDB(src_area);
|
mbsedb_PackFDB(src_area);
|
||||||
mbsedb_CloseFDB(src_area);
|
mbsedb_CloseFDB(src_area);
|
||||||
colour(CYAN, BLACK);
|
colour(CYAN, BLACK);
|
||||||
#else
|
|
||||||
temp2 = calloc(PATH_MAX, sizeof(char));
|
|
||||||
sprintf(temp2, "%s/fdb/file%d.temp", getenv("MBSE_ROOT"), From);
|
|
||||||
|
|
||||||
if ((fp1 = fopen(temp1, "r")) == NULL)
|
|
||||||
die(MBERR_GENERAL);
|
|
||||||
fread(&f_dbhdr, sizeof(fdbhdr), 1, fp1);
|
|
||||||
if ((fp2 = fopen(temp2, "a+")) == NULL)
|
|
||||||
die(MBERR_GENERAL);
|
|
||||||
fwrite(&f_dbhdr, f_dbhdr.hdrsize, 1, fp2);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Search the file if the From area, if found, the
|
|
||||||
* temp database holds all records except the moved
|
|
||||||
* file.
|
|
||||||
*/
|
|
||||||
while (fread(&f_db, f_dbhdr.recsize, 1, fp1) == 1) {
|
|
||||||
if (strcmp(f_db.LName, File) && strcmp(f_db.Name, File))
|
|
||||||
fwrite(&f_db, f_dbhdr.recsize, 1, fp2);
|
|
||||||
else {
|
|
||||||
rc = AddFile(f_db, To, topath, frompath, tolink);
|
|
||||||
if (rc) {
|
|
||||||
unlink(fromlink);
|
|
||||||
unlink(frompath);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Try to move thumbnail if it exists
|
|
||||||
*/
|
|
||||||
if (file_exist(fromthumb, R_OK) == 0) {
|
|
||||||
file_mv(fromthumb, tothumb);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose(fp1);
|
|
||||||
fclose(fp2);
|
|
||||||
|
|
||||||
if (rc) {
|
|
||||||
/*
|
|
||||||
* The move was successfull
|
|
||||||
*/
|
|
||||||
if (unlink(temp1) == 0) {
|
|
||||||
rename(temp2, temp1);
|
|
||||||
chmod(temp1, 0660);
|
|
||||||
} else {
|
|
||||||
WriteError("$Can't unlink %s", temp1);
|
|
||||||
unlink(temp2);
|
|
||||||
}
|
|
||||||
colour(CYAN, BLACK);
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* The move failed, it is possible that the file is
|
|
||||||
* copied already. Don't remove it here, it might
|
|
||||||
* be removed if it was not meant to be, ie if you
|
|
||||||
* gave this command twice. Let "mbfile check" take
|
|
||||||
* care of unwanted copies.
|
|
||||||
*/
|
|
||||||
unlink(temp2);
|
|
||||||
}
|
|
||||||
free(temp2);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Syslog('+', "Move %s from %d to %d %s", File, From, To, rc ? "successfull":"failed");
|
Syslog('+', "Move %s from %d to %d %s", File, From, To, rc ? "successfull":"failed");
|
||||||
if (!do_quiet)
|
if (!do_quiet)
|
||||||
|
@ -50,16 +50,8 @@ void PackFileBase(void)
|
|||||||
FILE *pAreas;
|
FILE *pAreas;
|
||||||
int i, iAreas, iAreasNew = 0, rc, iTotal = 0, iRemoved = 0;
|
int i, iAreas, iAreasNew = 0, rc, iTotal = 0, iRemoved = 0;
|
||||||
char *sAreas, fn[PATH_MAX];
|
char *sAreas, fn[PATH_MAX];
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
struct _fdbarea *fdb_area = NULL;
|
struct _fdbarea *fdb_area = NULL;
|
||||||
int purge;
|
int purge;
|
||||||
#else
|
|
||||||
FILE *pFile, *fp;
|
|
||||||
char *fAreas, *fTmp;
|
|
||||||
|
|
||||||
fAreas = calloc(PATH_MAX, sizeof(char));
|
|
||||||
fTmp = calloc(PATH_MAX, sizeof(char));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
sAreas = calloc(PATH_MAX, sizeof(char));
|
sAreas = calloc(PATH_MAX, sizeof(char));
|
||||||
|
|
||||||
@ -96,50 +88,16 @@ void PackFileBase(void)
|
|||||||
}
|
}
|
||||||
Marker();
|
Marker();
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if ((fdb_area = mbsedb_OpenFDB(i, 30)) == NULL)
|
if ((fdb_area = mbsedb_OpenFDB(i, 30)) == NULL)
|
||||||
die(MBERR_GENERAL);
|
die(MBERR_GENERAL);
|
||||||
purge = 0;
|
purge = 0;
|
||||||
#else
|
|
||||||
sprintf(fAreas, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), i);
|
|
||||||
sprintf(fTmp, "%s/fdb/file%d.temp", getenv("MBSE_ROOT"), i);
|
|
||||||
|
|
||||||
if ((pFile = fopen(fAreas, "r")) == NULL) {
|
|
||||||
Syslog('!', "Creating new %s", fAreas);
|
|
||||||
if ((pFile = fopen(fAreas, "a+")) == NULL) {
|
|
||||||
WriteError("$Can't create %s", fAreas);
|
|
||||||
die(MBERR_GENERAL);
|
|
||||||
}
|
|
||||||
fdbhdr.hdrsize = sizeof(fdbhdr);
|
|
||||||
fdbhdr.recsize = sizeof(fdb);
|
|
||||||
fwrite(&fdbhdr, sizeof(fdbhdr), 1, pFile);
|
|
||||||
} else {
|
|
||||||
fread(&fdbhdr, sizeof(fdbhdr), 1, pFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((fp = fopen(fTmp, "a+")) == NULL) {
|
|
||||||
WriteError("$Can't create %s", fTmp);
|
|
||||||
die(MBERR_GENERAL);
|
|
||||||
}
|
|
||||||
fwrite(&fdbhdr, fdbhdr.hdrsize, 1, fp);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
||||||
#else
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
|
|
||||||
#endif
|
|
||||||
iTotal++;
|
iTotal++;
|
||||||
|
|
||||||
if ((!fdb.Deleted) && (!fdb.Double) && (strcmp(fdb.Name, "") != 0)) {
|
if ((fdb.Deleted) || (fdb.Double) || (strcmp(fdb.Name, "") == 0)) {
|
||||||
#ifndef USE_EXPERIMENT
|
|
||||||
fwrite(&fdb, fdbhdr.recsize, 1, fp);
|
|
||||||
#endif
|
|
||||||
} else {
|
|
||||||
iRemoved++;
|
iRemoved++;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
purge++;
|
purge++;
|
||||||
#endif
|
|
||||||
if (fdb.Double) {
|
if (fdb.Double) {
|
||||||
Syslog('+', "Removed double record file \"%s\" from area %d", fdb.LName, i);
|
Syslog('+', "Removed double record file \"%s\" from area %d", fdb.LName, i);
|
||||||
} else {
|
} else {
|
||||||
@ -162,19 +120,9 @@ void PackFileBase(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if (purge)
|
if (purge)
|
||||||
mbsedb_PackFDB(fdb_area);
|
mbsedb_PackFDB(fdb_area);
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
fclose(fp);
|
|
||||||
fclose(pFile);
|
|
||||||
|
|
||||||
if ((rename(fTmp, fAreas)) == 0) {
|
|
||||||
unlink(fTmp);
|
|
||||||
chmod(fAreas, 00660);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
iAreasNew++;
|
iAreasNew++;
|
||||||
|
|
||||||
} /* if area.Available */
|
} /* if area.Available */
|
||||||
@ -188,12 +136,7 @@ void PackFileBase(void)
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef USE_EXPERIMENT
|
|
||||||
free(fTmp);
|
|
||||||
free(fAreas);
|
|
||||||
#endif
|
|
||||||
free(sAreas);
|
free(sAreas);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,11 +50,7 @@ void ReArc(int Area, char *File)
|
|||||||
char *p, *temp, *mname, *linkpath, mask[256];
|
char *p, *temp, *mname, *linkpath, mask[256];
|
||||||
int i, rc = -1, count = 0, errors = 0;
|
int i, rc = -1, count = 0, errors = 0;
|
||||||
struct utimbuf ut;
|
struct utimbuf ut;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
struct _fdbarea *fdb_area = NULL;
|
struct _fdbarea *fdb_area = NULL;
|
||||||
#else
|
|
||||||
FILE *fp;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
IsDoing("ReArc file(s)");
|
IsDoing("ReArc file(s)");
|
||||||
colour(LIGHTRED, BLACK);
|
colour(LIGHTRED, BLACK);
|
||||||
@ -89,28 +85,15 @@ void ReArc(int Area, char *File)
|
|||||||
|
|
||||||
temp = calloc(PATH_MAX, sizeof(char));
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if ((fdb_area = mbsedb_OpenFDB(Area, 30)) == NULL)
|
if ((fdb_area = mbsedb_OpenFDB(Area, 30)) == NULL)
|
||||||
die(MBERR_GENERAL);
|
die(MBERR_GENERAL);
|
||||||
#else
|
|
||||||
sprintf(temp, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), Area);
|
|
||||||
|
|
||||||
if ((fp = fopen(temp, "r+")) == NULL)
|
|
||||||
die(MBERR_GENERAL);
|
|
||||||
|
|
||||||
fread(&fdbhdr, sizeof(fdbhdr), 1, fp);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
colour(CYAN, BLACK);
|
colour(CYAN, BLACK);
|
||||||
strcpy(mask, re_mask(File, FALSE));
|
strcpy(mask, re_mask(File, FALSE));
|
||||||
if (re_comp(mask))
|
if (re_comp(mask))
|
||||||
die(MBERR_GENERAL);
|
die(MBERR_GENERAL);
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
||||||
#else
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fp) == 1) {
|
|
||||||
#endif
|
|
||||||
if (re_exec(fdb.LName) || re_exec(fdb.Name)) {
|
if (re_exec(fdb.LName) || re_exec(fdb.Name)) {
|
||||||
Syslog('+', "Will rearc %s", fdb.LName);
|
Syslog('+', "Will rearc %s", fdb.LName);
|
||||||
sprintf(temp, "%s/%s", area.Path, fdb.Name);
|
sprintf(temp, "%s/%s", area.Path, fdb.Name);
|
||||||
@ -200,16 +183,11 @@ void ReArc(int Area, char *File)
|
|||||||
strcpy(temp, mname);
|
strcpy(temp, mname);
|
||||||
}
|
}
|
||||||
free(mname);
|
free(mname);
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if (mbsedb_LockFDB(fdb_area, 30)) {
|
if (mbsedb_LockFDB(fdb_area, 30)) {
|
||||||
fseek(fdb_area->fp, - fdbhdr.recsize, SEEK_CUR);
|
fseek(fdb_area->fp, - fdbhdr.recsize, SEEK_CUR);
|
||||||
fwrite(&fdb, fdbhdr.recsize, 1, fdb_area->fp);
|
fwrite(&fdb, fdbhdr.recsize, 1, fdb_area->fp);
|
||||||
mbsedb_UnlockFDB(fdb_area);
|
mbsedb_UnlockFDB(fdb_area);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
fseek(fp, - fdbhdr.recsize, SEEK_CUR);
|
|
||||||
fwrite(&fdb, fdbhdr.recsize, 1, fp);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Update symbolic link to long filename
|
* Update symbolic link to long filename
|
||||||
@ -234,11 +212,7 @@ void ReArc(int Area, char *File)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
fclose(fp);
|
|
||||||
#endif
|
|
||||||
free(temp);
|
free(temp);
|
||||||
Syslog('+', "ReArc Files [%5d] Good [%5d] Errors [%5d]", count, count - errors, errors);
|
Syslog('+', "ReArc Files [%5d] Good [%5d] Errors [%5d]", count, count - errors, errors);
|
||||||
}
|
}
|
||||||
|
143
mbfido/mbfsort.c
143
mbfido/mbfsort.c
@ -40,84 +40,6 @@
|
|||||||
extern int do_quiet; /* Suppress screen output */
|
extern int do_quiet; /* Suppress screen output */
|
||||||
extern int do_index; /* Reindex filebases */
|
extern int do_index; /* Reindex filebases */
|
||||||
|
|
||||||
#ifndef USE_EXPERIMENT
|
|
||||||
|
|
||||||
typedef struct _fdbs {
|
|
||||||
struct _fdbs *next;
|
|
||||||
struct FILE_record filrec;
|
|
||||||
} fdbs;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void fill_fdbs(struct FILE_record, fdbs **);
|
|
||||||
void fill_fdbs(struct FILE_record filrec, fdbs **fap)
|
|
||||||
{
|
|
||||||
fdbs *tmp;
|
|
||||||
|
|
||||||
tmp = (fdbs *)malloc(sizeof(fdbs));
|
|
||||||
tmp->next = *fap;
|
|
||||||
tmp->filrec = filrec;
|
|
||||||
*fap = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void tidy_fdbs(fdbs **);
|
|
||||||
void tidy_fdbs(fdbs **fap)
|
|
||||||
{
|
|
||||||
fdbs *tmp, *old;
|
|
||||||
|
|
||||||
for (tmp = *fap; tmp; tmp = old) {
|
|
||||||
old = tmp->next;
|
|
||||||
free(tmp);
|
|
||||||
}
|
|
||||||
*fap = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int comp_fdbs(fdbs **, fdbs **);
|
|
||||||
|
|
||||||
|
|
||||||
void sort_fdbs(fdbs **);
|
|
||||||
void sort_fdbs(fdbs **fap)
|
|
||||||
{
|
|
||||||
fdbs *ta, **vector;
|
|
||||||
size_t n = 0, i;
|
|
||||||
|
|
||||||
if (*fap == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (ta = *fap; ta; ta = ta->next)
|
|
||||||
n++;
|
|
||||||
|
|
||||||
vector = (fdbs **)malloc(n * sizeof(fdbs *));
|
|
||||||
i = 0;
|
|
||||||
for (ta = *fap; ta; ta = ta->next)
|
|
||||||
vector[i++] = ta;
|
|
||||||
|
|
||||||
qsort(vector, n, sizeof(fdbs *), (int(*)(const void*, const void *))comp_fdbs);
|
|
||||||
(*fap) = vector[0];
|
|
||||||
i = 1;
|
|
||||||
|
|
||||||
for (ta = *fap; ta; ta = ta->next) {
|
|
||||||
if (i < n)
|
|
||||||
ta->next = vector[i++];
|
|
||||||
else
|
|
||||||
ta->next = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
free(vector);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int comp_fdbs(fdbs **fap1, fdbs **fap2)
|
|
||||||
{
|
|
||||||
return strcasecmp((*fap1)->filrec.LName, (*fap2)->filrec.LName);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -128,16 +50,8 @@ void SortFileBase(int Area)
|
|||||||
FILE *pAreas;
|
FILE *pAreas;
|
||||||
int iAreas;
|
int iAreas;
|
||||||
char *sAreas;
|
char *sAreas;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
struct _fdbarea *fdb_area = NULL;
|
struct _fdbarea *fdb_area = NULL;
|
||||||
#else
|
|
||||||
FILE *fp, *pFile;
|
|
||||||
char *fAreas, *fTmp;
|
|
||||||
fdbs *fdx = NULL, *tmp;
|
|
||||||
|
|
||||||
fAreas = calloc(PATH_MAX, sizeof(char));
|
|
||||||
fTmp = calloc(PATH_MAX, sizeof(char));
|
|
||||||
#endif
|
|
||||||
sAreas = calloc(PATH_MAX, sizeof(char));
|
sAreas = calloc(PATH_MAX, sizeof(char));
|
||||||
|
|
||||||
IsDoing("Sort filebase");
|
IsDoing("Sort filebase");
|
||||||
@ -174,61 +88,10 @@ void SortFileBase(int Area)
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if ((fdb_area = mbsedb_OpenFDB(Area, 30))) {
|
if ((fdb_area = mbsedb_OpenFDB(Area, 30))) {
|
||||||
mbsedb_SortFDB(fdb_area);
|
mbsedb_SortFDB(fdb_area);
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
sprintf(fAreas, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), Area);
|
|
||||||
sprintf(fTmp, "%s/fdb/file%d.temp", getenv("MBSE_ROOT"), Area);
|
|
||||||
|
|
||||||
if ((pFile = fopen(fAreas, "r")) == NULL) {
|
|
||||||
Syslog('!', "Creating new %s", fAreas);
|
|
||||||
if ((pFile = fopen(fAreas, "a+")) == NULL) {
|
|
||||||
WriteError("$Can't create %s", fAreas);
|
|
||||||
die(MBERR_GENERAL);
|
|
||||||
}
|
|
||||||
fdbhdr.hdrsize = sizeof(fdbhdr);
|
|
||||||
fdbhdr.recsize = sizeof(fdb);
|
|
||||||
fwrite(&fdbhdr, sizeof(fdbhdr), 1, pFile);
|
|
||||||
} else {
|
|
||||||
fread(&fdbhdr, sizeof(fdbhdr), 1, pFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((fp = fopen(fTmp, "a+")) == NULL) {
|
|
||||||
WriteError("$Can't create %s", fTmp);
|
|
||||||
die(MBERR_GENERAL);
|
|
||||||
}
|
|
||||||
fwrite(&fdbhdr, fdbhdr.hdrsize, 1, fp);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Fill the sort array
|
|
||||||
*/
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
|
|
||||||
fill_fdbs(fdb, &fdx);
|
|
||||||
Syslog('f', "Adding %s", fdb.LName);
|
|
||||||
}
|
|
||||||
|
|
||||||
sort_fdbs(&fdx);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Write sorted files to temp database
|
|
||||||
*/
|
|
||||||
for (tmp = fdx; tmp; tmp = tmp->next) {
|
|
||||||
Syslog('f', "Sorted %s", tmp->filrec.LName);
|
|
||||||
fwrite(&tmp->filrec, fdbhdr.recsize, 1, fp);
|
|
||||||
}
|
|
||||||
tidy_fdbs(&fdx);
|
|
||||||
|
|
||||||
fclose(fp);
|
|
||||||
fclose(pFile);
|
|
||||||
|
|
||||||
if ((rename(fTmp, fAreas)) == 0) {
|
|
||||||
unlink(fTmp);
|
|
||||||
chmod(fAreas, 00660);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
Syslog('+', "Sorted file area %d: %s", Area, area.Name);
|
Syslog('+', "Sorted file area %d: %s", Area, area.Name);
|
||||||
do_index = TRUE;
|
do_index = TRUE;
|
||||||
|
|
||||||
@ -244,10 +107,6 @@ void SortFileBase(int Area)
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef USE_EXPERIMENT
|
|
||||||
free(fTmp);
|
|
||||||
free(fAreas);
|
|
||||||
#endif
|
|
||||||
free(sAreas);
|
free(sAreas);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
103
mbfido/mbfutil.c
103
mbfido/mbfutil.c
@ -305,13 +305,7 @@ int UnpackFile(char *File)
|
|||||||
int AddFile(struct FILE_record f_db, int Area, char *DestPath, char *FromPath, char *LinkPath)
|
int AddFile(struct FILE_record f_db, int Area, char *DestPath, char *FromPath, char *LinkPath)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
struct _fdbarea *fdb_area = NULL;
|
struct _fdbarea *fdb_area = NULL;
|
||||||
#else
|
|
||||||
int i, Insert, Done = FALSE, Found = FALSE;
|
|
||||||
FILE *fp1, *fp2;
|
|
||||||
char *temp1, *temp2;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copy file to the final destination and make a hard link with the
|
* Copy file to the final destination and make a hard link with the
|
||||||
@ -343,7 +337,6 @@ int AddFile(struct FILE_record f_db, int Area, char *DestPath, char *FromPath, c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if ((fdb_area = mbsedb_OpenFDB(Area, 30))) {
|
if ((fdb_area = mbsedb_OpenFDB(Area, 30))) {
|
||||||
Syslog('f', "opened");
|
Syslog('f', "opened");
|
||||||
rc = mbsedb_InsertFDB(fdb_area, f_db, TRUE);
|
rc = mbsedb_InsertFDB(fdb_area, f_db, TRUE);
|
||||||
@ -353,102 +346,6 @@ int AddFile(struct FILE_record f_db, int Area, char *DestPath, char *FromPath, c
|
|||||||
Syslog('f', "not opened");
|
Syslog('f', "not opened");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
temp1 = calloc(PATH_MAX, sizeof(char));
|
|
||||||
temp2 = calloc(PATH_MAX, sizeof(char));
|
|
||||||
sprintf(temp1, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), Area);
|
|
||||||
sprintf(temp2, "%s/fdb/file%d.temp", getenv("MBSE_ROOT"), Area);
|
|
||||||
|
|
||||||
fp1 = fopen(temp1, "r+");
|
|
||||||
fread(&fdbhdr, sizeof(fdbhdr.hdrsize), 1, fp1);
|
|
||||||
fseek(fp1, 0, SEEK_END);
|
|
||||||
if (ftell(fp1) == fdbhdr.hdrsize) {
|
|
||||||
/*
|
|
||||||
* No records yet
|
|
||||||
*/
|
|
||||||
fwrite(&f_db, fdbhdr.recsize, 1, fp1);
|
|
||||||
fclose(fp1);
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* Files are already there. Find the right spot.
|
|
||||||
*/
|
|
||||||
fseek(fp1, fdbhdr.hdrsize, SEEK_SET);
|
|
||||||
|
|
||||||
Insert = 0;
|
|
||||||
do {
|
|
||||||
if (fread(&fdb, fdbhdr.recsize, 1, fp1) != 1)
|
|
||||||
Done = TRUE;
|
|
||||||
if (!Done) {
|
|
||||||
if (strcmp(f_db.LName, fdb.LName) == 0) {
|
|
||||||
Found = TRUE;
|
|
||||||
Insert++;
|
|
||||||
} else {
|
|
||||||
if (strcmp(f_db.LName, fdb.LName) < 0)
|
|
||||||
Found = TRUE;
|
|
||||||
else
|
|
||||||
Insert++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while ((!Found) && (!Done));
|
|
||||||
|
|
||||||
if (Found) {
|
|
||||||
if ((fp2 = fopen(temp2, "a+")) == NULL) {
|
|
||||||
WriteError("Can't create %s", temp2);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
fwrite(&fdbhdr, fdbhdr.hdrsize, 1, fp2);
|
|
||||||
fseek(fp1, fdbhdr.hdrsize, SEEK_SET);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copy until the insert point
|
|
||||||
*/
|
|
||||||
for (i = 0; i < Insert; i++) {
|
|
||||||
fread(&fdb, fdbhdr.recsize, 1, fp1);
|
|
||||||
/*
|
|
||||||
* If we are importing a file with the same name,
|
|
||||||
* skip the original record and put the new one in place.
|
|
||||||
*/
|
|
||||||
if (strcmp(fdb.LName, f_db.LName) != 0)
|
|
||||||
fwrite(&fdb, fdbhdr.recsize, 1, fp2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (area.AddAlpha)
|
|
||||||
fwrite(&f_db, fdbhdr.recsize, 1, fp2);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Append the rest of the records
|
|
||||||
*/
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fp1) == 1) {
|
|
||||||
if (strcmp(fdb.LName, f_db.LName) != 0)
|
|
||||||
fwrite(&fdb, fdbhdr.recsize, 1, fp2);
|
|
||||||
}
|
|
||||||
if (!area.AddAlpha)
|
|
||||||
fwrite(&f_db, fdbhdr.recsize, 1, fp2);
|
|
||||||
fclose(fp1);
|
|
||||||
fclose(fp2);
|
|
||||||
|
|
||||||
if (unlink(temp1) == 0) {
|
|
||||||
rename(temp2, temp1);
|
|
||||||
chmod(temp1, 0660);
|
|
||||||
} else {
|
|
||||||
WriteError("$Can't unlink %s", temp1);
|
|
||||||
unlink(temp2);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
} else { /* if (Found) */
|
|
||||||
/*
|
|
||||||
* Append file record
|
|
||||||
*/
|
|
||||||
fseek(fp1, 0, SEEK_END);
|
|
||||||
fwrite(&f_db, fdbhdr.recsize, 1, fp1);
|
|
||||||
fclose(fp1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
free(temp1);
|
|
||||||
free(temp2);
|
|
||||||
return TRUE;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
168
mbsebbs/file.c
168
mbsebbs/file.c
@ -56,7 +56,6 @@ 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;
|
struct _fdbarea *fdb_area = NULL;
|
||||||
|
|
||||||
if ((fdb_area = mbsedb_OpenFDB(iArea, 30)) == NULL)
|
if ((fdb_area = mbsedb_OpenFDB(iArea, 30)) == NULL)
|
||||||
@ -73,32 +72,6 @@ int CheckFile(char *File, int iArea)
|
|||||||
}
|
}
|
||||||
|
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
FILE *pFileB;
|
|
||||||
char *sFileArea;
|
|
||||||
|
|
||||||
sFileArea = calloc(PATH_MAX, sizeof(char));
|
|
||||||
sprintf(sFileArea,"%s/fdb/file%d.data", getenv("MBSE_ROOT"), iArea);
|
|
||||||
|
|
||||||
if ((pFileB = fopen(sFileArea,"r+")) == NULL) {
|
|
||||||
mkdir(sFileArea, 775);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
free(sFileArea);
|
|
||||||
fread(&fdbhdr, sizeof(fdbhdr), 1, pFileB);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Check long and short filenames, case insensitive
|
|
||||||
*/
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, pFileB) == 1) {
|
|
||||||
if (((strcasecmp(fdb.Name, File)) == 0) || ((strcasecmp(fdb.LName, File)) == 0)) {
|
|
||||||
fclose(pFileB);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(pFileB);
|
|
||||||
#endif
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,11 +85,7 @@ void File_List()
|
|||||||
int FileCount = 0;
|
int FileCount = 0;
|
||||||
unsigned FileBytes = 0;
|
unsigned FileBytes = 0;
|
||||||
_Tag T;
|
_Tag T;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
struct _fdbarea *fdb_area = NULL;
|
struct _fdbarea *fdb_area = NULL;
|
||||||
#else
|
|
||||||
FILE *pFile;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
iLineCount = 0;
|
iLineCount = 0;
|
||||||
WhosDoingWhat(FILELIST, NULL);
|
WhosDoingWhat(FILELIST, NULL);
|
||||||
@ -133,30 +102,17 @@ void File_List()
|
|||||||
|
|
||||||
InitTag();
|
InitTag();
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if ((fdb_area = mbsedb_OpenFDB(iAreaNumber, 30)) == NULL)
|
if ((fdb_area = mbsedb_OpenFDB(iAreaNumber, 30)) == NULL)
|
||||||
return;
|
return;
|
||||||
#else
|
|
||||||
if ((pFile = OpenFileBase(iAreaNumber, FALSE)) == NULL)
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
Header();
|
Header();
|
||||||
if (iLC(2) == 1) {
|
if (iLC(2) == 1) {
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
fclose(pFile);
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
||||||
#else
|
|
||||||
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;
|
||||||
@ -166,11 +122,7 @@ void File_List()
|
|||||||
SetTag(T);
|
SetTag(T);
|
||||||
|
|
||||||
if (ShowOneFile() == 1) {
|
if (ShowOneFile() == 1) {
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
fclose(pFile);
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,11 +142,7 @@ 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);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
fclose(pFile);
|
|
||||||
#endif
|
|
||||||
Pause();
|
Pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,11 +163,7 @@ 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;
|
struct _fdbarea *fdb_area = NULL;
|
||||||
#else
|
|
||||||
FILE *fp;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Enter(2);
|
Enter(2);
|
||||||
OldArea = iAreaNumber;
|
OldArea = iAreaNumber;
|
||||||
@ -256,7 +200,6 @@ 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) {
|
if ((fdb_area = mbsedb_OpenFDB(Tag.Area, 30)) != NULL) {
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
||||||
if (strcmp(fdb.LName, Tag.LFile) == 0)
|
if (strcmp(fdb.LName, Tag.LFile) == 0)
|
||||||
@ -264,15 +207,6 @@ void Download(void)
|
|||||||
}
|
}
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if ((fp = OpenFileBase(Tag.Area, FALSE)) != NULL) {
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fp) == 1) {
|
|
||||||
if (strcmp(fdb.LName, Tag.LFile) == 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
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);
|
||||||
@ -493,7 +427,6 @@ 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))) {
|
if ((fdb_area = mbsedb_OpenFDB(Tag.Area, 30))) {
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
||||||
if (strcmp(fdb.LName, Tag.LFile) == 0)
|
if (strcmp(fdb.LName, Tag.LFile) == 0)
|
||||||
@ -508,19 +441,6 @@ void Download(void)
|
|||||||
mbsedb_UnlockFDB(fdb_area);
|
mbsedb_UnlockFDB(fdb_area);
|
||||||
}
|
}
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
if ((fp = OpenFileBase(Tag.Area, TRUE)) != NULL) {
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fp) == 1) {
|
|
||||||
if (strcmp(fdb.LName, Tag.LFile) == 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Size += fdb.Size;
|
|
||||||
fdb.TimesDL++;
|
|
||||||
fdb.LastDL = time(NULL);
|
|
||||||
fseek(fp, - fdbhdr.recsize, SEEK_CUR);
|
|
||||||
fwrite(&fdb, fdbhdr.recsize, 1, fp);
|
|
||||||
fclose(fp);
|
|
||||||
#endif
|
|
||||||
Count++;
|
Count++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -649,11 +569,7 @@ int KeywordScan()
|
|||||||
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;
|
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));
|
||||||
@ -697,20 +613,12 @@ 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))) {
|
if ((fdb_area = mbsedb_OpenFDB(arecno, 30))) {
|
||||||
#else
|
|
||||||
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) {
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
||||||
#else
|
|
||||||
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));
|
||||||
|
|
||||||
@ -748,11 +656,7 @@ int KeywordScan()
|
|||||||
|
|
||||||
} /* while */
|
} /* while */
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
fclose(pFile);
|
|
||||||
#endif
|
|
||||||
if (Found) {
|
if (Found) {
|
||||||
Enter(2);
|
Enter(2);
|
||||||
if (iLC(2) == 1) {
|
if (iLC(2) == 1) {
|
||||||
@ -796,11 +700,7 @@ int FilenameScan()
|
|||||||
char *Name;
|
char *Name;
|
||||||
_Tag T;
|
_Tag T;
|
||||||
unsigned long OldArea;
|
unsigned long OldArea;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
struct _fdbarea *fdb_area = NULL;
|
struct _fdbarea *fdb_area = NULL;
|
||||||
#else
|
|
||||||
FILE *pFile;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Name = calloc(81, sizeof(char));
|
Name = calloc(81, sizeof(char));
|
||||||
OldArea = iAreaNumber;
|
OldArea = iAreaNumber;
|
||||||
@ -841,20 +741,12 @@ 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))) {
|
if ((fdb_area = mbsedb_OpenFDB(arecno, 30))) {
|
||||||
#else
|
|
||||||
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) {
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
||||||
#else
|
|
||||||
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);
|
||||||
@ -881,11 +773,7 @@ int FilenameScan()
|
|||||||
|
|
||||||
} /* End of while */
|
} /* End of while */
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
fclose(pFile);
|
|
||||||
#endif
|
|
||||||
if (Found) {
|
if (Found) {
|
||||||
Enter(2);
|
Enter(2);
|
||||||
if (iLC(2) == 1) {
|
if (iLC(2) == 1) {
|
||||||
@ -923,11 +811,7 @@ int NewfileScan(int AskStart)
|
|||||||
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;
|
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));
|
||||||
@ -980,20 +864,12 @@ 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))) {
|
if ((fdb_area = mbsedb_OpenFDB(arecno, 30))) {
|
||||||
#else
|
|
||||||
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) {
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
||||||
#else
|
|
||||||
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 */
|
||||||
@ -1013,11 +889,7 @@ 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);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
fclose(pFile);
|
|
||||||
#endif
|
|
||||||
fclose(pAreas);
|
fclose(pAreas);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -1036,11 +908,7 @@ 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);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
fclose(pFile);
|
|
||||||
#endif
|
|
||||||
fclose(pAreas);
|
fclose(pAreas);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -1048,11 +916,7 @@ int NewfileScan(int AskStart)
|
|||||||
} /* End of if */
|
} /* End of if */
|
||||||
} /* End of while */
|
} /* End of while */
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
fclose(pFile);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add 2 blank lines after found files.
|
* Add 2 blank lines after found files.
|
||||||
@ -2094,11 +1958,7 @@ void Copy_Home()
|
|||||||
{
|
{
|
||||||
char *File, *temp1, *temp2;
|
char *File, *temp1, *temp2;
|
||||||
int err, Found = FALSE;
|
int err, Found = FALSE;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
struct _fdbarea *fdb_area = NULL;
|
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));
|
||||||
@ -2142,22 +2002,14 @@ void Copy_Home()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if ((fdb_area = mbsedb_OpenFDB(iAreaNumber, 30)) == NULL) {
|
if ((fdb_area = mbsedb_OpenFDB(iAreaNumber, 30)) == NULL) {
|
||||||
#else
|
|
||||||
if ((pFile = OpenFileBase(iAreaNumber, FALSE)) == NULL) {
|
|
||||||
#endif
|
|
||||||
free(File);
|
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) {
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
||||||
#else
|
|
||||||
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;
|
||||||
@ -2190,11 +2042,7 @@ void Copy_Home()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
fclose(pFile);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!Found) {
|
if (!Found) {
|
||||||
colour(CFG.HiliteF, CFG.HiliteB);
|
colour(CFG.HiliteF, CFG.HiliteB);
|
||||||
@ -2338,11 +2186,7 @@ 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;
|
FILE *fp;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
struct _fdbarea *fdb_area = NULL;
|
struct _fdbarea *fdb_area = NULL;
|
||||||
#else
|
|
||||||
FILE *pFile;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Syslog('+', "ViewFile(%s)", printable(name, 0));
|
Syslog('+', "ViewFile(%s)", printable(name, 0));
|
||||||
|
|
||||||
@ -2404,30 +2248,18 @@ 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) {
|
if ((fdb_area = mbsedb_OpenFDB(iAreaNumber, 30)) == NULL) {
|
||||||
#else
|
|
||||||
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) {
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
||||||
#else
|
|
||||||
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);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
fclose(pFile);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
colour(YELLOW, BLACK);
|
colour(YELLOW, BLACK);
|
||||||
|
@ -151,36 +151,6 @@ void GetstrD(char *sStr, int iMaxlen)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Open FileDataBase, the filepointer is at the begin of the first record.
|
|
||||||
*/
|
|
||||||
#ifndef USE_EXPERIMENT
|
|
||||||
FILE *OpenFileBase(unsigned long Area, int Write)
|
|
||||||
{
|
|
||||||
FILE *pFile;
|
|
||||||
char *FileBase;
|
|
||||||
|
|
||||||
FileBase = calloc(PATH_MAX, sizeof(char));
|
|
||||||
sprintf(FileBase,"%s/fdb/file%ld.data", getenv("MBSE_ROOT"), Area);
|
|
||||||
|
|
||||||
if (Write)
|
|
||||||
pFile = fopen(FileBase, "r+");
|
|
||||||
else
|
|
||||||
pFile = fopen(FileBase, "r");
|
|
||||||
|
|
||||||
if (pFile == NULL) {
|
|
||||||
WriteError("$Can't open file: %s", FileBase);
|
|
||||||
/* Can't open file database for this area */
|
|
||||||
printf("%s\n\n", (char *) Language(237));
|
|
||||||
sleep(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
fread(&fdbhdr, sizeof(fdbhdr), 1, pFile);
|
|
||||||
free(FileBase);
|
|
||||||
return pFile;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Open the fareas.data file for read or R/W and read the headerrecord.
|
* Open the fareas.data file for read or R/W and read the headerrecord.
|
||||||
@ -883,11 +853,7 @@ int Addfile(char *File, int AreaNum, int fileid)
|
|||||||
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;
|
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));
|
||||||
@ -895,11 +861,7 @@ 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))) {
|
if ((fdb_area = mbsedb_OpenFDB(AreaNum, 30))) {
|
||||||
#else
|
|
||||||
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
|
||||||
@ -911,11 +873,7 @@ 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);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
fclose(pFileDB);
|
|
||||||
#endif
|
|
||||||
free(Filename);
|
free(Filename);
|
||||||
free(temp1);
|
free(temp1);
|
||||||
free(lname);
|
free(lname);
|
||||||
@ -1080,14 +1038,8 @@ 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_InsertFDB(fdb_area, fdb, area.AddAlpha);
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
fseek(pFileDB, 0, SEEK_END);
|
|
||||||
fwrite(&fdb, fdbhdr.recsize, 1, 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)
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
#ifndef _FILESUB_H
|
#ifndef _FILESUB_H
|
||||||
#define _FILESUB_H
|
#define _FILESUB_H
|
||||||
|
|
||||||
|
/* $Id$ */
|
||||||
|
|
||||||
#ifndef USE_EXPERIMENT
|
|
||||||
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);
|
||||||
|
@ -275,14 +275,7 @@ void Masterlist()
|
|||||||
unsigned long NewAreaFiles, NewAreaBytes;
|
unsigned long NewAreaFiles, NewAreaBytes;
|
||||||
char *sAreas;
|
char *sAreas;
|
||||||
char temp[81], pop[81];
|
char temp[81], pop[81];
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
struct _fdbarea *fdb_area = NULL;
|
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));
|
||||||
|
|
||||||
@ -342,23 +335,11 @@ void Masterlist()
|
|||||||
|
|
||||||
Nopper();
|
Nopper();
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if ((fdb_area = mbsedb_OpenFDB(AreaNr, 30)) == 0) {
|
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);
|
WriteError("$Can't open Area %d (%s)! Skipping ...", AreaNr, area.Name);
|
||||||
} else {
|
} else {
|
||||||
#ifndef USE_EXPERIMENT
|
|
||||||
fread(&fdbhdr, sizeof(fdbhdr), 1, pFile);
|
|
||||||
#endif
|
|
||||||
popdown = 0;
|
popdown = 0;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
||||||
#else
|
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
|
|
||||||
#endif
|
|
||||||
if (!fdb.Deleted) {
|
if (!fdb.Deleted) {
|
||||||
/*
|
/*
|
||||||
* The next is to reduce system load.
|
* The next is to reduce system load.
|
||||||
@ -412,13 +393,8 @@ void Masterlist()
|
|||||||
BotBox(fp, TRUE);
|
BotBox(fp, TRUE);
|
||||||
BotBox(np, NewAreaFiles);
|
BotBox(np, NewAreaFiles);
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
fseek(fdb_area->fp, fdbhdr.hdrsize, SEEK_SET);
|
fseek(fdb_area->fp, fdbhdr.hdrsize, SEEK_SET);
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
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) {
|
if (!fdb.Deleted) {
|
||||||
New = (((t_start - fdb.UploadDate) / 84400) <= CFG.newdays);
|
New = (((t_start - fdb.UploadDate) / 84400) <= CFG.newdays);
|
||||||
sprintf(temp, "%-12s%10lu K %s [%04ld] Uploader: %s",
|
sprintf(temp, "%-12s%10lu K %s [%04ld] Uploader: %s",
|
||||||
@ -449,11 +425,7 @@ void Masterlist()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
fclose(pFile);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} /* End of While Loop Checking for Areas Done */
|
} /* End of While Loop Checking for Areas Done */
|
||||||
@ -500,9 +472,6 @@ void Masterlist()
|
|||||||
Syslog('+', "Allfiles: %ld, %ld MBytes", AllFiles, AllKBytes / 1024);
|
Syslog('+', "Allfiles: %ld, %ld MBytes", AllFiles, AllKBytes / 1024);
|
||||||
Syslog('+', "Newfiles: %ld, %ld MBytes", NewFiles, NewKBytes / 1024);
|
Syslog('+', "Newfiles: %ld, %ld MBytes", NewFiles, NewKBytes / 1024);
|
||||||
free(sAreas);
|
free(sAreas);
|
||||||
#ifndef USE_EXPERIMENT
|
|
||||||
free(fAreas);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -254,11 +254,7 @@ int EditFileRec(int Area)
|
|||||||
DIR *dp;
|
DIR *dp;
|
||||||
struct dirent *de;
|
struct dirent *de;
|
||||||
struct stat stb;
|
struct stat stb;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
struct _fdbarea *fdb_area = NULL;
|
struct _fdbarea *fdb_area = NULL;
|
||||||
#else
|
|
||||||
FILE *fp;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
clr_index();
|
clr_index();
|
||||||
working(1, 0, 0);
|
working(1, 0, 0);
|
||||||
@ -377,7 +373,6 @@ int EditFileRec(int Area)
|
|||||||
/*
|
/*
|
||||||
* Attempt to disable this area, but check first.
|
* Attempt to disable this area, but check first.
|
||||||
*/
|
*/
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if ((fdb_area = mbsedb_OpenFDB(Area, 30))) {
|
if ((fdb_area = mbsedb_OpenFDB(Area, 30))) {
|
||||||
fseek(fdb_area->fp, 0, SEEK_END);
|
fseek(fdb_area->fp, 0, SEEK_END);
|
||||||
files = ((ftell(fdb_area->fp) - fdbhdr.hdrsize) / fdbhdr.recsize);
|
files = ((ftell(fdb_area->fp) - fdbhdr.hdrsize) / fdbhdr.recsize);
|
||||||
@ -387,19 +382,6 @@ int EditFileRec(int Area)
|
|||||||
}
|
}
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if ((fp = fopen(temp, "r"))) {
|
|
||||||
if (fread(&fdbhdr, sizeof(fdbhdr), 1, fp) == 1) {
|
|
||||||
fseek(fp, 0, SEEK_END);
|
|
||||||
files = ((ftell(fp) - fdbhdr.hdrsize) / fdbhdr.recsize);
|
|
||||||
if (files) {
|
|
||||||
errmsg("There are stil %d files in this area", files);
|
|
||||||
Available = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (!Available) {
|
if (!Available) {
|
||||||
if (yes_no((char *)"Are you sure you want to delete this area") == 0)
|
if (yes_no((char *)"Are you sure you want to delete this area") == 0)
|
||||||
Available = TRUE;
|
Available = TRUE;
|
||||||
@ -435,20 +417,8 @@ int EditFileRec(int Area)
|
|||||||
}
|
}
|
||||||
if (!area.Available && Available) {
|
if (!area.Available && Available) {
|
||||||
area.Available = TRUE;
|
area.Available = TRUE;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if ((fdb_area = mbsedb_OpenFDB(Area, 30)))
|
if ((fdb_area = mbsedb_OpenFDB(Area, 30)))
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
|
||||||
if ((fp = fopen(temp, "a+")) == NULL) {
|
|
||||||
WriteError("$Can't create file database %s", temp);
|
|
||||||
} else {
|
|
||||||
fdbhdr.hdrsize = sizeof(fdbhdr);
|
|
||||||
fdbhdr.recsize = sizeof(fdb);
|
|
||||||
fwrite(fp, sizeof(fdbhdr), 1, fp);
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
chmod(temp, 0660);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
free(temp);
|
free(temp);
|
||||||
break;
|
break;
|
||||||
|
@ -359,9 +359,7 @@ void InitFDB(void)
|
|||||||
struct dirent *de;
|
struct dirent *de;
|
||||||
struct OldFILERecord old;
|
struct OldFILERecord old;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
struct _fdbarea *fdb_area = NULL;
|
struct _fdbarea *fdb_area = NULL;
|
||||||
#endif
|
|
||||||
|
|
||||||
records = CountFilearea();
|
records = CountFilearea();
|
||||||
if (records <= 0)
|
if (records <= 0)
|
||||||
@ -458,12 +456,10 @@ void InitFDB(void)
|
|||||||
/*
|
/*
|
||||||
* Current area, check
|
* Current area, check
|
||||||
*/
|
*/
|
||||||
#ifdef USE_EXPERIMENT
|
|
||||||
if ((fdb_area = mbsedb_OpenFDB(Area, 30)) == NULL)
|
if ((fdb_area = mbsedb_OpenFDB(Area, 30)) == NULL)
|
||||||
WriteError("InitFDB(): database area %ld might be corrupt", Area);
|
WriteError("InitFDB(): database area %ld might be corrupt", Area);
|
||||||
else
|
else
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(fil);
|
fclose(fil);
|
||||||
|
Reference in New Issue
Block a user