Upgraded files database strcuture

This commit is contained in:
Michiel Broek 2004-03-06 21:48:41 +00:00
parent 7918118edc
commit cf922872da
48 changed files with 1436 additions and 1376 deletions

View File

@ -1,7 +1,70 @@
$Id$
If you feel lucky then try this version, if not just wait
a few days so that I fix the destructive bugs that might
be present in this version.
v0.51.1 21-Feb-2004
v0.51.2 06-Mar-2004
upgrade:
Before upgrade announce all new files!
Compile all programs.
Close the system with mbstat close.
Install programs as root (as usual).
Start mbsetup, this can take a while on a system with lots of
files, during startup the files database will be converted.
After the menu appears, you may exit mbsetup.
Open the system again.
If you want you may restart mbtask.
general:
Updated to a new files database structure that allows for
expanding the records like most other databases to allow new
features.
Removed all references to costsharing for ticfiles which wasn't
fully implemented.
mbcico:
Updated file request function to new files database structure.
mbfido:
When removing files during tic import due to replace or maximum
files, thumbnails are now also removed from disk.
Updated tic file import function to the new files database
structure.
mbfile:
Updated kill, index, check, pack, list, adopt, import, move,
delete and sort to the new files database structure.
The file delete function in kill didn't delete the thumbnail.
mbaff:
When scanning for uploads, files which were hatched now have
the right tic area name instead of AREA n in the announce
record. They also contain the used magic filename if this is
known.
The scan for new uploads function is updated to the new files
database structure.
The filefind function is updated to the new files database
structure.
mbsebbs:
Updated to the new files database structure.
mbsetup:
Added auto upgrade for the files database.
Changed menus 14, 7.n.6, 10.1 and 8.4.
examples:
Updated English, German, Spanish and Dutch macro files:
html.nodes and filemgr.status.
lang:
removed obsolede prompt 240.
v0.51.1 21-Feb-2004 - 06-Mar-2004
upgrade:
In all message groups set check/set default character set.

5
TODO
View File

@ -77,6 +77,9 @@ mbtask:
space is still available.
mbfido:
N: When importing a tic file with magic name, remove the magic from
the filerecord of the previous file.
N: The elist rules files are named (8.3) areaname.rul where areaname
is the first 8 characters of the area name and we use the full name
only. Make sure both namings are accepted?
@ -132,7 +135,7 @@ mbcico:
N: Make workaround for binkp bug in Irex 2.24 upto 2.29
mbfile:
L: Add a check to see if the magic filenames are (still) valid.
N: Add a check to see if the magic filenames are (still) valid.
L: Update <filespec> <area> <-touch>

2
configure vendored
View File

@ -1275,7 +1275,7 @@ SUBDIRS="lib mbcico mbfido mbmon mbsebbs mbtask mbsetup unix lang examples html
PACKAGE="mbsebbs"
MAJOR="0"
MINOR="51"
REVISION="1"
REVISION="2"
VERSION="$MAJOR.$MINOR.$REVISION"
COPYRIGHT="Copyright (C) 1997-2004 Michiel Broek, All Rights Reserved"
SHORTRIGHT="Copyright (C) 1997-2004 M. Broek"

View File

@ -13,7 +13,7 @@ dnl
PACKAGE="mbsebbs"
MAJOR="0"
MINOR="51"
REVISION="1"
REVISION="2"
VERSION="$MAJOR.$MINOR.$REVISION"
COPYRIGHT="Copyright (C) 1997-2004 Michiel Broek, All Rights Reserved"
SHORTRIGHT="Copyright (C) 1997-2004 M. Broek"

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -238,7 +238,7 @@
237 filesub.c |Can't open file database for this area
238 filesub.c file.c |Uploaded by:
239 file.c |D E L E T E D
240 file.c |M I S S I N G
240 |
241 mail.c YN|Node not known, continue anayway [y/N]:
242 file.c |Total Files:
243 filesub.c |FATAL: Unable to open areas database

View File

@ -238,7 +238,7 @@ AVS|(A)ntwoord, (V)olgende, (S)top:
|Kan de database niet openen voor dit gebied
|Upload door:
|GEWIST
|ONTBREEKT
|
JN|Node onbekend, toch doorgaan [j/N]:
|Aantal bestanden:
|FATAAL: kan de bestanden database niet openen

View File

@ -238,7 +238,7 @@ RNQ|(R)eply, (N)ext, (Q)uit:
|Can't open file database for this area
|Uploaded by:
|D E L E T E D
|M I S S I N G
|
YN|Node not known, continue anyway [y/N]:
|Total Files:
|FATAL: Unable to open areas database

View File

@ -238,7 +238,7 @@ RNQ|(R)
|Ne paut pas ouvrir la base pour cette conférence
|Télécharrgé par:
|F A C
|M A N Q U A N T
|
ON|Node inconnu, continue quand même [o/N]:
|Total Fichiers:
|FATAL: Impossible d'ouvrir la conférence

View File

@ -238,7 +238,7 @@ CSR|(C)ontestar, (S)eguinte, (R)ematar:
|Non podo abri-la base de ficheiros desta  rea
|Enviado por:
|B O R R A D O
|P E R D I D O
|
SN|Nodo desco¤ecido. ¨Continuar? [s/N]:
|Total Fichs:
|FATAL: Imposible abrir base de  reas

View File

@ -238,7 +238,7 @@ ANE|(A)ntwort, (N)aechste, (E)nde:
|Die Datei-Datenbank fuer diesen Bereich kann nicht geoeffnet werden
|Heraufgeladen von:
|G E L O E S C H T
|F E H L T
|
JN|Adresse unbekannt, dennoch fortfahren [j/N]:
|Dateien insgesamt:
|FATAL: die Datenbank der Dateibereiche kann nicht geoeffnet werden

View File

@ -238,7 +238,7 @@ ANE|(A)ntwort, (N)aechste, (E)nde:
|Die Datei-Datenbank fuer diesen Bereich kann nicht geoeffnet werden
|Heraufgeladen von:
|G E L O E S C H T
|F E H L T
|
JN|Adresse unbekannt, dennoch fortfahren [j/N]:
|Dateien insgesamt:
|FATAL: die Datenbank der Dateibereiche kann nicht geoeffnet werden

View File

@ -238,7 +238,7 @@ RPE|(R)ispondi, (P)rossimo, (E)sci:
|Non trovo il database dei file di quest'area
|Uploadato da:
|C A N C E L L A T O
|M A N C A N T E
|
SN|Nodo sconosciuto, continua lo stesso [s/N]:
|File Totali:
|FATAL: Non trovo il database dell'area

View File

@ -238,7 +238,7 @@ RST|(R)esponder, (S)iguiente, (T)erminar:
|No puedo abrir la base de ficheros de esta  rea
|Enviado por:
|B O R R A D O
|P E R D I D O
|
SN|Nodo desconocido. ¨Continuar? [s/N]:
|Total Fichs:
|FATAL: Imposible abrir base de  reas

View File

@ -731,7 +731,7 @@ struct fileareas {
unsigned DLdays; /* Move not DL for days */
unsigned FDdays; /* Move if FD older than */
unsigned MoveArea; /* Move to Area */
int Cost; /* File Cost */
int xCost; /* File Cost */
char FilesBbs[65]; /* Path to files.bbs if CD */
char NewGroup[13]; /* Newfiles scan group */
char Archiver[6]; /* Archiver for area */
@ -753,9 +753,40 @@ struct FILEIndex {
/*
* File Record Control Structure (fdb#.data)
* Files database (file#.data)
*/
struct FILERecord {
struct FILE_recordhdr {
long hdrsize; /* Size of header */
long recsize; /* Record size */
};
struct FILE_record {
char Name[13]; /* DOS style filename */
char LName[81]; /* Long filename */
char TicArea[21]; /* Tic area file came in */
off_t Size; /* File Size */
unsigned long Crc32; /* File CRC-32 */
char Uploader[36]; /* Uploader name */
time_t UploadDate; /* Date/Time uploaded */
time_t FileDate; /* Real file date */
time_t LastDL; /* Last Download date */
unsigned long TimesDL; /* Times file was dl'ed */
char Password[16]; /* File password */
char Desc[25][49]; /* file description */
char Magic[21]; /* Magic request name */
unsigned Deleted : 1; /* Deleted */
unsigned NoKill : 1; /* Cannot be deleted */
unsigned Announced : 1; /* File is announced */
unsigned Double : 1; /* Double record */
};
/*
* Old File Record Control Structure (fdb#.data)
*/
struct OldFILERecord {
char Name[13]; /* DOS style filename */
char LName[81]; /* Long filename */
char xTicArea[9]; /* Tic area file came in */
@ -1518,9 +1549,9 @@ struct _nodes {
unsigned FileFwd : 1; /* Accept File Forward */
unsigned MailFwd : 1; /* Accept Mail Forward */
unsigned AdvTic : 1; /* Advanced Tic files */
unsigned Billing : 1; /* Cost sharing on/off */
unsigned xBilling : 1; /* Cost sharing on/off */
unsigned BillDirect : 1; /* Send bill direct */
unsigned xBillDirect : 1; /* Send bill direct */
unsigned Crash : 1; /* Netmail crash */
unsigned Hold : 1; /* Netmail hold */
unsigned AddPlus : 1; /* Add + for uplink msgs */
@ -1549,11 +1580,11 @@ struct _nodes {
char xExtra[94];
time_t StartDate; /* Node start date */
time_t LastDate; /* Last action date */
long Credit; /* Node's credit */
long Debet; /* Node's debet */
long AddPerc; /* Add Percentage */
long WarnLevel; /* Warning level */
long StopLevel; /* Stop level */
long xCredit; /* Node's credit */
long xDebet; /* Node's debet */
long xAddPerc; /* Add Percentage */
long xWarnLevel; /* Warning level */
long xStopLevel; /* Stop level */
fidoaddr RouteVia; /* Routing address */
int Language; /* Language for netmail */
statcnt FilesSent; /* Files sent to node */
@ -1637,12 +1668,12 @@ struct _fgroup {
char Comment[56]; /* Group Comment */
unsigned Active : 1; /* Group Active */
unsigned Deleted : 1; /* Is group deleted */
unsigned DivideCost : 1; /* Divide cost over links */
unsigned xDivideCost : 1; /* Divide cost over links */
fidoaddr UseAka; /* Aka to use */
fidoaddr UpLink; /* Uplink address */
long UnitCost; /* Cost per unit */
long UnitSize; /* Size per unit */
long AddProm; /* Promillage to add */
long xUnitCost; /* Cost per unit */
long xUnitSize; /* Size per unit */
long xAddProm; /* Promillage to add */
time_t StartDate; /* Start Date */
time_t LastDate; /* Last active date */
char AreaFile[13]; /* Areas filename */
@ -1799,20 +1830,6 @@ struct _magic {
/*
* Billing database
*/
struct _bill {
fidoaddr Node; /* Fido address */
char FileName[15]; /* File Name */
char FileEcho[21]; /* File Echo */
char Group[13]; /* Group */
off_t Size; /* File Size */
long Cost; /* File Cost */
};
/*
* Newfile reports (newfiles.data)
*/
@ -1883,7 +1900,6 @@ struct _filerecord {
char Desc[256]; /* Short description */
char LDesc[25][49]; /* Long description */
int TotLdesc; /* Total long desc lines */
long Cost; /* File cost */
unsigned Announce : 1; /* Announce this file */
};
@ -2478,7 +2494,9 @@ struct oneline ol;
struct fileareashdr areahdr; /* File areas */
struct fileareas area;
struct FILERecord file;
struct OldFILERecord oldfile; /* Pre 0.51.2 structure */
struct FILE_recordhdr fdbhdr; /* Files database */
struct FILE_record fdb;
struct _fgrouphdr fgrouphdr; /* File groups */
struct _fgroup fgroup;
@ -2533,7 +2551,7 @@ struct _magic magic;
struct _nodeshdr nodeshdr; /* Fidonet nodes */
struct _nodes nodes;
struct _bill bill; /* Unsent bills */
//struct _bill bill; /* Unsent bills */
struct _newfileshdr newfileshdr; /* New file reports */
struct _newfiles newfiles;

View File

@ -153,13 +153,11 @@ file_list *respfreq(char *nm, char *pw, char *dt)
{
file_list *fl = NULL;
struct stat st;
char mask[256], *p, *q;
char *tnm, *t;
char mask[256], *p, *q, *tnm, *t;
time_t upd = 0L;
int newer = 1;
int newer = 1, Send;
FILE *fa, *fb, *fi;
long Area;
int Send;
struct FILEIndex idx;
if (localoptions & NOFREQS) {
@ -193,8 +191,7 @@ file_list *respfreq(char *nm, char *pw, char *dt)
tnm = xstrcpy(CFG.req_magic);
tnm = xstrcat(tnm,(char *)"/");
tnm = xstrcat(tnm,tl(xstrcpy(nm)));
if ((stat(tnm, &st) == 0) &&
(S_ISREG(st.st_mode))) {
if ((stat(tnm, &st) == 0) && (S_ISREG(st.st_mode))) {
if (access(tnm, X_OK) == 0) {
return respmagic(tnm);
/* respmagic will free(tnm) */
@ -211,8 +208,7 @@ file_list *respfreq(char *nm, char *pw, char *dt)
t = xstrcpy(nm);
tnm = xstrcat(tnm,tu(t));
free(t);
if ((stat(tnm, &st) == 0) &&
(S_ISREG(st.st_mode))) {
if ((stat(tnm, &st) == 0) && (S_ISREG(st.st_mode))) {
if (access(tnm, X_OK) == 0) {
return respmagic(tnm);
/* respmagic will free(tnm) */
@ -279,27 +275,27 @@ file_list *respfreq(char *nm, char *pw, char *dt)
return NULL;
}
Syslog('f', "Area %s", area.Name);
p = calloc(128, sizeof(char));
sprintf(p, "%s/fdb/fdb%ld.data", getenv("MBSE_ROOT"), idx.AreaNum);
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);
if (fseek(fb, idx.Record * sizeof(file), SEEK_SET) == -1) {
fread(&fdbhdr, sizeof(fdbhdr), 1, fb);
if (fseek(fb, fdbhdr.hdrsize + (idx.Record * fdbhdr.recsize), SEEK_SET) == -1) {
WriteError("$Can't seek filerecord %d", idx.Record);
} else {
if (fread(&file, sizeof(file), 1, fb) != 1) {
if (fread(&fdb, fdbhdr.recsize, 1, fb) != 1) {
WriteError("$Can't read filerecord %d", idx.Record);
} else {
Send = FALSE;
Syslog('f', "Found \"%s\" in %s", file.LName, area.Name);
Syslog('f', "Found \"%s\" in %s", fdb.LName, area.Name);
tnm = xstrcpy(area.Path);
tnm = xstrcat(tnm, (char *)"/");
tnm = xstrcat(tnm, file.LName);
tnm = xstrcat(tnm, fdb.LName);
if ((stat(tnm, &st) == 0) && (S_ISREG(st.st_mode)) &&
(access(tnm, R_OK) == 0) && ((upd == 0L) ||
((newer) && (st.st_mtime <= upd)))) {
(access(tnm, R_OK) == 0) && ((upd == 0L) || ((newer) && (st.st_mtime <= upd)))) {
Send = TRUE;
}
@ -315,21 +311,19 @@ file_list *respfreq(char *nm, char *pw, char *dt)
if (strcasecmp(area.Password, pw)) {
Send = FALSE;
Syslog('+', "Bad password for area %s", area.Name);
add_report((char *)"ER: bad password for area %s",
area.Name);
add_report((char *)"ER: bad password for area %s", area.Name);
}
} else {
Send = FALSE;
}
}
if (Send && strlen(file.Password)) {
if (Send && strlen(fdb.Password)) {
if (pw != NULL) {
if (strcasecmp(file.Password, pw)) {
if (strcasecmp(fdb.Password, pw)) {
Send = FALSE;
Syslog('+', "Bad password for file %s", file.Name);
add_report((char *)"ER: bad password for file %s",
file.LName);
Syslog('+', "Bad password for file %s", fdb.Name);
add_report((char *)"ER: bad password for file %s", fdb.LName);
}
} else {
Send = FALSE;
@ -348,32 +342,29 @@ file_list *respfreq(char *nm, char *pw, char *dt)
if (Send && CFG.Req_MBytes) {
if ((st.st_size + report_total) > (CFG.Req_MBytes * 1048576)) {
Send = FALSE;
add_report((char *)"ER: file %s will exceed the request limit",
file.Name);
add_report((char *)"ER: file %s will exceed the request limit", fdb.Name);
Syslog('+', "Exceeding request size limit");
no_more = TRUE;
}
}
if (Send) {
Syslog('f', "Will send %s", file.LName);
Syslog('f', "Will send %s", fdb.LName);
report_total += st.st_size;
report_count++;
if (strcasecmp(file.Name, file.LName))
add_report((char *)"OK: Sending \"%s\" as \"%s\" (%lu bytes)",
file.LName, file.Name, file.Size);
if (strcasecmp(fdb.Name, fdb.LName))
add_report((char *)"OK: Sending \"%s\" as \"%s\" (%lu bytes)", fdb.LName, fdb.Name, fdb.Size);
else
add_report((char *)"OK: Sending \"%s\" (%lu bytes)",
file.LName, file.Size);
add_list(&fl, tnm, file.LName, 0, 0L, NULL, 1);
add_report((char *)"OK: Sending \"%s\" (%lu bytes)", fdb.LName, fdb.Size);
add_list(&fl, tnm, fdb.LName, 0, 0L, NULL, 1);
/*
* Update file information
*/
file.TimesReq++;
file.LastDL = time(NULL);
fseek(fb, - sizeof(file), SEEK_CUR);
fwrite(&file, sizeof(file), 1, fb);
fdb.TimesDL++;
fdb.LastDL = time(NULL);
fseek(fb, - fdbhdr.recsize, SEEK_CUR);
fwrite(&fdb, fdbhdr.recsize, 1, fb);
}
free(tnm);
}

View File

@ -48,12 +48,12 @@ extern int tic_imp;
*/
int Add_BBS()
{
struct FILERecord frec;
int rc, i, Insert, Done = FALSE, Found = FALSE;
struct FILE_recordhdr frechdr;
struct FILE_record frec;
int rc, i, Insert, Done = FALSE, Found = FALSE, Keep = 0, DidDelete = FALSE;
char fdbname[PATH_MAX], fdbtemp[PATH_MAX];
char temp1[PATH_MAX], temp2[PATH_MAX], *fname, *lname, *p;
FILE *fdb, *fdt;
int Keep = 0, DidDelete = FALSE;
FILE *fp, *fdt;
fd_list *fdl = NULL;
/*
@ -62,20 +62,21 @@ int Add_BBS()
* prevent for example allfiles.zip to get a new record everytime
* and thus the download counters will be reset after a new update.
*/
sprintf(fdbname, "%s/fdb/fdb%ld.data", getenv("MBSE_ROOT"), tic.FileArea);
if ((fdb = fopen(fdbname, "r+")) != NULL) {
while (fread(&frec, sizeof(frec), 1, fdb) == 1) {
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) {
if (strcmp(frec.Name, TIC.NewFile) == 0) {
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.NewFile);
sprintf(temp2, "%s/%s", TIC.BBSpath, TIC.NewFile);
mkdirs(temp2, 0755);
if ((rc = file_cp(temp1, temp2))) {
WriteError("Copy to %s failed: %s", temp2, strerror(rc));
fclose(fdb);
fclose(fp);
return FALSE;
}
chmod(temp2, 0644);
frec.TicAreaCRC = StringCRC32(TIC.TicIn.Area);
strncpy(frec.TicArea, TIC.TicIn.Area, sizeof(frec.TicArea) -1);
frec.Size = TIC.FileSize;
frec.Crc32 = TIC.Crc_Int;
frec.Announced = TRUE;
@ -88,16 +89,16 @@ int Add_BBS()
}
if (strlen(TIC.TicIn.Magic))
sprintf(frec.Desc[i], "Magic Request: %s", TIC.TicIn.Magic);
fseek(fdb, 0 - sizeof(frec), SEEK_CUR);
fwrite(&frec, sizeof(frec), 1, fdb);
fclose(fdb);
fseek(fp, 0 - sizeof(frec), SEEK_CUR);
fwrite(&frec, sizeof(frec), 1, fp);
fclose(fp);
tic_imp++;
if ((i = file_rm(temp1)))
WriteError("file_rm(%s): %s", temp1, strerror(i));
return TRUE;
}
}
fclose(fdb);
fclose(fp);
}
@ -116,7 +117,7 @@ int Add_BBS()
for (i = 0; i < strlen(frec.LName); i++)
frec.LName[i] = tolower(frec.LName[i]);
}
frec.TicAreaCRC = StringCRC32(TIC.TicIn.Area);
strncpy(frec.TicArea, TIC.TicIn.Area, 20);
frec.Size = TIC.FileSize;
frec.Crc32 = TIC.Crc_Int;
frec.Announced = TRUE;
@ -128,8 +129,10 @@ int Add_BBS()
if (i == 24)
break;
}
if (strlen(TIC.TicIn.Magic))
if (strlen(TIC.TicIn.Magic)) {
strncpy(frec.Magic, TIC.TicIn.Magic, sizeof(frec.Magic) -1);
sprintf(frec.Desc[i], "Magic Request: %s", TIC.TicIn.Magic);
}
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.NewFile);
sprintf(temp2, "%s/%s", TIC.BBSpath, frec.Name);
@ -167,15 +170,19 @@ int Add_BBS()
}
free(lname);
sprintf(fdbtemp, "%s/fdb/fdb%ld.temp", getenv("MBSE_ROOT"), tic.FileArea);
if ((fdb = fopen(fdbname, "r+")) == NULL) {
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 ((fdb = fopen(fdbname, "a+")) == NULL) {
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);
}
/*
@ -183,10 +190,10 @@ int Add_BBS()
* one and leave immediatly, keepnum and replace have no
* use at this point.
*/
fseek(fdb, 0, SEEK_END);
if (ftell(fdb) == 0) {
fwrite(&frec, sizeof(frec), 1, fdb);
fclose(fdb);
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;
@ -197,17 +204,17 @@ int Add_BBS()
* which position to insert the new file, replace or
* remove the old entry.
*/
fseek(fdb, 0, SEEK_SET);
fseek(fp, frechdr.hdrsize, SEEK_SET);
Insert = 0;
do {
if (fread(&file, sizeof(file), 1, fdb) != 1)
if (fread(&fdb, frechdr.recsize, 1, fp) != 1)
Done = TRUE;
if (!Done) {
if (strcmp(frec.LName, file.LName) == 0) {
if (strcmp(frec.LName, fdb.LName) == 0) {
Found = TRUE;
Insert++;
} else if (strcmp(frec.LName, file.LName) < 0)
} else if (strcmp(frec.LName, fdb.LName) < 0)
Found = TRUE;
else
Insert++;
@ -217,53 +224,54 @@ int Add_BBS()
if (Found) {
if ((fdt = fopen(fdbtemp, "a+")) == NULL) {
WriteError("$Can't create %s", fdbtemp);
fclose(fdb);
fclose(fp);
return FALSE;
}
fwrite(&frechdr, frechdr.hdrsize, 1, fdt);
fseek(fdb, 0, SEEK_SET);
fseek(fp, frechdr.hdrsize, SEEK_SET);
/*
* Copy entries till the insert point.
*/
for (i = 0; i < Insert; i++) {
fread(&file, sizeof(file), 1, fdb);
fread(&fdb, frechdr.recsize, 1, fp);
/*
* 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(file.LName, frec.LName) != 0)
fwrite(&file, sizeof(file), 1, fdt);
if (strcmp(fdb.LName, frec.LName) != 0)
fwrite(&fdb, frechdr.recsize, 1, fdt);
}
if (area.AddAlpha) {
/*
* Insert the new entry
*/
fwrite(&frec, sizeof(frec), 1, fdt);
fwrite(&frec, frechdr.recsize, 1, fdt);
}
/*
* Append the rest of the entries.
*/
while (fread(&file, sizeof(file), 1, fdb) == 1) {
while (fread(&fdb, frechdr.recsize, 1, fp) == 1) {
/*
* Check if we find a file with the same name,
* then we skip the record what was origionaly
* in the database record.
*/
if (strcmp(file.LName, frec.LName) != 0)
fwrite(&file, sizeof(file), 1, fdt);
if (strcmp(fdb.LName, frec.LName) != 0)
fwrite(&fdb, frechdr.recsize, 1, fdt);
}
if (!area.AddAlpha) {
/*
* Append the new entry
*/
fwrite(&frec, sizeof(frec), 1, fdt);
fwrite(&frec, frechdr.recsize, 1, fdt);
}
fclose(fdt);
fclose(fdb);
fclose(fp);
/*
* Now make the changes for real.
@ -280,9 +288,9 @@ int Add_BBS()
/*
* Append the new entry
*/
fseek(fdb, 0, SEEK_END);
fwrite(&frec, sizeof(frec), 1, fdb);
fclose(fdb);
fseek(fp, 0, SEEK_END);
fwrite(&frec, frechdr.recsize, 1, fp);
fclose(fp);
}
/*
@ -297,28 +305,30 @@ int Add_BBS()
if ((strlen(TIC.TicIn.Replace)) && (tic.Replace)) {
Syslog('f', "Must Replace: %s", TIC.TicIn.Replace);
if ((fdb = fopen(fdbname, "r+")) != NULL) {
if ((fp = fopen(fdbname, "r+")) != NULL) {
while (fread(&file, sizeof(file), 1, fdb) == 1) {
if (strlen(file.LName) == strlen(frec.LName)) {
fread(&fdbhdr, sizeof(fdbhdr), 1, fp);
while (fread(&fdb, fdbhdr.recsize, 1, fp) == 1) {
if (strlen(fdb.LName) == strlen(frec.LName)) {
// FIXME: Search must be based on a reg_exp search
if (strcasecmp(file.LName, frec.LName) != 0) {
if (strcasecmp(fdb.LName, frec.LName) != 0) {
Found = TRUE;
for (i = 0; i < strlen(frec.LName); i++) {
if ((TIC.TicIn.Replace[i] != '?') && (toupper(TIC.TicIn.Replace[i]) != toupper(file.LName[i])))
if ((TIC.TicIn.Replace[i] != '?') && (toupper(TIC.TicIn.Replace[i]) != toupper(fdb.LName[i])))
Found = FALSE;
}
if (Found) {
Syslog('+', "Replace: Deleting: %s", file.LName);
file.Deleted = TRUE;
fseek(fdb, - sizeof(file), SEEK_CUR);
fwrite(&file, sizeof(file), 1, fdb);
Syslog('+', "Replace: Deleting: %s", fdb.LName);
fdb.Deleted = TRUE;
fseek(fp , - fdbhdr.recsize, SEEK_CUR);
fwrite(&fdb, fdbhdr.recsize, 1, fp);
DidDelete = TRUE;
}
}
}
}
fclose(fdb);
fclose(fp);
}
}
@ -326,27 +336,29 @@ int Add_BBS()
* Handle the Keep number of files option
*/
if (TIC.KeepNum) {
if ((fdb = fopen(fdbname, "r")) != NULL) {
if ((fp = fopen(fdbname, "r")) != NULL) {
while (fread(&file, sizeof(file), 1, fdb) == 1) {
fread(&fdbhdr, sizeof(fdbhdr), 1, fp);
if ((strlen(file.LName) == strlen(frec.LName)) && (!file.Deleted)) {
while (fread(&fdb, fdbhdr.recsize, 1, fp) == 1) {
if ((strlen(fdb.LName) == strlen(frec.LName)) && (!fdb.Deleted)) {
Found = TRUE;
for (i = 0; i < strlen(file.LName); i++) {
for (i = 0; i < strlen(fdb.LName); i++) {
if ((frec.LName[i] < '0') || (frec.LName[i] > '9')) {
if (frec.LName[i] != file.LName[i]) {
if (frec.LName[i] != fdb.LName[i]) {
Found = FALSE;
}
}
}
if (Found) {
Keep++;
fill_fdlist(&fdl, file.LName, file.UploadDate);
fill_fdlist(&fdl, fdb.LName, fdb.UploadDate);
}
}
}
fclose(fdb);
fclose(fp);
}
/*
@ -355,22 +367,24 @@ int Add_BBS()
if (Keep > TIC.KeepNum) {
sort_fdlist(&fdl);
if ((fdb = fopen(fdbname, "r+")) != NULL) {
if ((fp = fopen(fdbname, "r+")) != NULL) {
fread(&fdbhdr, sizeof(fdbhdr), 1, fp);
for (i = 0; i < (Keep - TIC.KeepNum); i++) {
fname = pull_fdlist(&fdl);
fseek(fdb, 0, SEEK_SET);
fseek(fp, fdbhdr.hdrsize, SEEK_SET);
while (fread(&file, sizeof(file), 1, fdb) == 1) {
if (strcmp(file.LName, fname) == 0) {
Syslog('+', "Keep %d files, deleting: %s", TIC.KeepNum, file.LName);
file.Deleted = TRUE;
fseek(fdb, - sizeof(file), SEEK_CUR);
fwrite(&file, sizeof(file), 1, fdb);
while (fread(&fdb, fdbhdr.recsize, 1, fp) == 1) {
if (strcmp(fdb.LName, fname) == 0) {
Syslog('+', "Keep %d files, deleting: %s", TIC.KeepNum, fdb.LName);
fdb.Deleted = TRUE;
fseek(fp , - fdbhdr.recsize, SEEK_CUR);
fwrite(&fdb, fdbhdr.recsize, 1, fp);
DidDelete = TRUE;
}
}
}
fclose(fdb);
fclose(fp);
}
}
tidy_fdlist(&fdl);
@ -381,20 +395,24 @@ int Add_BBS()
* database.
*/
if (DidDelete) {
if ((fdb = fopen(fdbname, "r")) != NULL) {
if ((fp = fopen(fdbname, "r")) != NULL) {
fread(&fdbhdr, sizeof(fdbhdr), 1, fp);
if ((fdt = fopen(fdbtemp, "a+")) != NULL) {
while (fread(&file, sizeof(file), 1, fdb) == 1)
if (!file.Deleted)
fwrite(&file, sizeof(file), 1, fdt);
fwrite(&fdbhdr, fdbhdr.hdrsize, 1, fdt);
while (fread(&fdb, fdbhdr.recsize, 1, fp) == 1)
if (!fdb.Deleted)
fwrite(&fdb, fdbhdr.recsize, 1, fdt);
else {
sprintf(temp2, "%s/%s", area.Path, file.LName);
sprintf(temp2, "%s/%s", area.Path, fdb.LName);
if (unlink(temp2) != 0)
WriteError("$Can't unlink file %s", temp2);
sprintf(temp2, "%s/%s", area.Path, file.Name);
sprintf(temp2, "%s/%s", area.Path, fdb.Name);
if (unlink(temp2) != 0)
WriteError("$Can't unlink file %s", temp2);
sprintf(temp2, "%s/.%s", area.Path, fdb.Name);
unlink(temp2); /* Thumbnail, no logging if there is an error */
}
fclose(fdb);
fclose(fp);
fclose(fdt);
if (unlink(fdbname) == 0) {
rename(fdbtemp, fdbname);
@ -403,7 +421,7 @@ int Add_BBS()
unlink(fdbtemp);
}
} else {
fclose(fdb);
fclose(fp);
}
DidDelete = FALSE;
}

View File

@ -94,43 +94,49 @@ void Uploads()
fflush(stdout);
}
sprintf(fAreas, "%s/fdb/fdb%d.data", getenv("MBSE_ROOT"), i);
sprintf(fAreas, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), i);
if ((pFile = fopen(fAreas, "r+")) != NULL) {
while (fread(&file, sizeof(file), 1, pFile) == 1) {
fread(&fdbhdr, sizeof(fdbhdr), 1, pFile);
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
Nopper();
if (!file.Announced) {
Syslog('m', " %d %s", i, file.Name);
if (!fdb.Announced) {
Syslog('m', " %d %s", i, fdb.Name);
memset(&T_File, 0, sizeof(T_File));
if (strlen(fdb.TicArea))
strncpy(T_File.Echo, fdb.TicArea, sizeof(T_File.Echo) -1);
else
sprintf(T_File.Echo, "AREA %d", i);
sprintf(T_File.Group, "%s", area.NewGroup);
sprintf(T_File.Comment, "%s", area.Name);
sprintf(T_File.Name, "%s", file.Name);
sprintf(T_File.LName, "%s", file.LName);
T_File.Size = file.Size;
T_File.SizeKb = file.Size / 1024;
T_File.Fdate = file.FileDate;
sprintf(T_File.Crc, "%08lx", file.Crc32);
sprintf(T_File.Desc, "%s %s %s %s", file.Desc[0], file.Desc[1], file.Desc[2], file.Desc[3]);
strncpy(T_File.Group, area.NewGroup, sizeof(T_File.Group) -1);
strncpy(T_File.Comment, area.Name, sizeof(T_File.Comment) -1);
strncpy(T_File.Name, fdb.Name, sizeof(T_File.Name) -1);
strncpy(T_File.LName, fdb.LName, sizeof(T_File.LName) -1);
if (strlen(fdb.Magic))
strncpy(T_File.Magic, fdb.Magic, sizeof(T_File.Magic) -1);
T_File.Size = fdb.Size;
T_File.SizeKb = fdb.Size / 1024;
T_File.Fdate = fdb.FileDate;
sprintf(T_File.Crc, "%08lx", fdb.Crc32);
sprintf(T_File.Desc, "%s %s %s %s", fdb.Desc[0], fdb.Desc[1], fdb.Desc[2], fdb.Desc[3]);
k = 0;
for (j = 0; j < 25; j++) {
if (strlen(file.Desc[j])) {
sprintf(T_File.LDesc[k], "%s", file.Desc[j]);
if (strlen(fdb.Desc[j])) {
sprintf(T_File.LDesc[k], "%s", fdb.Desc[j]);
T_File.LDesc[k][49] = '\0';
k++;
}
}
T_File.TotLdesc = k;
T_File.Cost = file.Cost;
T_File.Announce = TRUE;
if (Add_ToBeRep())
Count++;
/*
* Mark file is announced.
*/
file.Announced = TRUE;
fseek(pFile, - sizeof(file), SEEK_CUR);
fwrite(&file, sizeof(file), 1, pFile);
fdb.Announced = TRUE;
fseek(pFile, - fdbhdr.recsize, SEEK_CUR);
fwrite(&fdb, fdbhdr.recsize, 1, pFile);
}
}

View File

@ -291,12 +291,13 @@ void ScanFiles(ff_list *tmp)
Back(15);
}
if (area.Available && area.FileFind) {
sprintf(temp, "%s/fdb/fdb%lu.data", getenv("MBSE_ROOT"), areanr);
sprintf(temp, "%s/fdb/file%lu.data", getenv("MBSE_ROOT"), areanr);
if ((pFile = fopen(temp, "r")) != NULL) {
while (fread(&file, sizeof(file), 1, pFile) == 1) {
fread(&fdbhdr, sizeof(fdbhdr), 1, pFile);
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
for (i = 0; i < 25; i++)
sprintf(BigDesc, "%s%s", BigDesc, *(file.Desc + i));
sprintf(BigDesc, "%s%s", BigDesc, *(fdb.Desc + i));
sprintf(temp, "%s", tmp->subject);
Found = FALSE;
@ -332,20 +333,20 @@ void ScanFiles(ff_list *tmp)
tl(kwd);
if (strlen(kwd) > 3) {
if (strstr(file.Name, kwd) != NULL) {
if (strstr(fdb.Name, kwd) != NULL) {
Found = TRUE;
Syslog('m', "Found %s in %s in filename", kwd, file.Name);
Syslog('m', "Found %s in %s in filename", kwd, fdb.Name);
}
if (keywrd && (strstr(tl(BigDesc), kwd) != NULL)) {
Found = TRUE;
Syslog('m', "Found %s in %s in description", kwd, file.Name);
Syslog('m', "Found %s in %s in description", kwd, fdb.Name);
}
}
} /* while (strlen(temp) && (!Found)) */
if (Found) {
found++;
Syslog('m', "Found %s area %d", file.Name, areanr);
fill_rflist(&rfl, file.Name, areanr);
Syslog('m', "Found %s area %d", fdb.Name, areanr);
fill_rflist(&rfl, fdb.Name, areanr);
}
strcpy(BigDesc, "");
}
@ -404,27 +405,28 @@ void ScanFiles(ff_list *tmp)
areanr = rft->area;
}
sprintf(temp, "%s/fdb/fdb%lu.data", getenv("MBSE_ROOT"), rft->area);
sprintf(temp, "%s/fdb/file%lu.data", getenv("MBSE_ROOT"), rft->area);
if ((pFile = fopen(temp, "r")) != NULL) {
while (fread(&file, sizeof(file), 1, pFile) == 1)
if (!strcmp(rft->filename, file.Name))
fread(&fdbhdr, sizeof(fdbhdr), 1, pFile);
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1)
if (!strcmp(rft->filename, fdb.Name))
break;
fclose(pFile);
MacroVars("slbkdt", "ssddss", file.Name, file.LName, file.Size, file.Size / 1024, " ",
To_Low(file.Desc[0],scanmgr.HiAscii));
MacroVars("slbkdt", "ssddss", fdb.Name, fdb.LName, fdb.Size, fdb.Size / 1024, " ",
To_Low(fdb.Desc[0],scanmgr.HiAscii));
fseek(fi, filepos1, SEEK_SET);
Msg_Macro(fi);
filepos2 = ftell(fi);
SubSize += file.Size;
SubSize += fdb.Size;
/*
* We add no more then 5 description lines
* to prevent unnecesary long messages.
*/
for (i = 1; i < MAX_DESC_LINES; i++) {
MacroVars("t", "s", To_Low(file.Desc[i],scanmgr.HiAscii));
MacroVars("t", "s", To_Low(fdb.Desc[i],scanmgr.HiAscii));
fseek(fi, filepos2, SEEK_SET);
if (strlen(file.Desc[i])) {
if (strlen(fdb.Desc[i])) {
Msg_Macro(fi);
} else {
line = calloc(255, sizeof(char));

View File

@ -305,11 +305,6 @@ void F_Status(faddr *t, char *replyid)
MacroVars("B", "d", nodes.Tic);
MacroVars("C", "d", nodes.AdvTic);
MacroVars("D", "d", nodes.Notify);
MacroVars("E", "d", nodes.Billing);
MacroVars("f", "d", nodes.BillDirect);
MacroVars("G", "d", nodes.Debet);
MacroVars("I", "d", nodes.Credit);
MacroVars("J", "d", nodes.WarnLevel);
MacroVars("a", "d", nodes.FilesSent.lweek);
MacroVars("b", "d", nodes.FilesSent.month[i]);
MacroVars("c", "d", nodes.FilesSent.total);

View File

@ -43,7 +43,7 @@
void ForwardFile(fidoaddr Node, fa_list *sbl)
{
char *subject = NULL, *fwdfile = NULL, *queuedir, *listfile, *ticfile = NULL, fname[PATH_MAX], *ticname, flavor;
char *subject = NULL, *fwdfile = NULL, *queuedir, *listfile, *ticfile = NULL, *ticname, flavor;
FILE *fp, *fi, *fl, *net;
faddr *dest, *routeto, *Fa, *Temp, *ba;
int i, z, n;
@ -56,28 +56,6 @@ void ForwardFile(fidoaddr Node, fa_list *sbl)
}
Syslog('+', "Forward file to %s %s netmail", aka2str(Node), nodes.Message?"with":"without");
/*
* If Costsharing active for this node
*/
if (nodes.Billing) {
/*
* Check if this node has enough credits for this file.
*/
T_File.Cost = TIC.FileCost + (TIC.FileCost * nodes.AddPerc / 1000);
if ((nodes.Credit < (nodes.StopLevel + T_File.Cost)) && (!TIC.Charge)) {
Syslog('!', "No forward to %s, not enough credit left", aka2str(Node));
return;
}
/*
* Check if we are passing the warning level
*/
if ((nodes.Credit > nodes.WarnLevel) && ((nodes.Credit - T_File.Cost) <= nodes.WarnLevel)) {
Syslog('+', "Low credit warning to %s", aka2str(Node));
/* CREATE NETMAIL */
}
}
fwdfile = calloc(PATH_MAX, sizeof(char));
queuedir = calloc(PATH_MAX, sizeof(char));
listfile = calloc(PATH_MAX, sizeof(char));
@ -206,12 +184,6 @@ void ForwardFile(fidoaddr Node, fa_list *sbl)
if (nodes.AdvTic) {
fprintf(fp, "Areadesc %s\r\n", tic.Comment);
fprintf(fp, "Fdn %s\r\n", fgroup.Comment);
/*
* According to Harald Harms this field must
* be multiplied with 100.
*/
if (TIC.FileCost && nodes.Billing)
fprintf(fp, "Cost %ld.00\r\n", T_File.Cost);
if (TIC.TicIn.TotLDesc)
for (i = 0; i < TIC.TicIn.TotLDesc; i++)
fprintf(fp, "LDesc %s\r\n", TIC.TicIn.LDesc[i]);
@ -289,30 +261,6 @@ void ForwardFile(fidoaddr Node, fa_list *sbl)
WriteError("$Can't create %s", ticfile);
}
}
if (TIC.Charge && nodes.Billing) {
nodes.Credit -= TIC.FileCost;
Syslog('-', "Cost: %d Left: %d", TIC.FileCost, nodes.Credit);
/*
* Add an entry to the billing file, each node has his own
* billing file.
*/
sprintf(fname, "%s/tmp/%d.%d.%d.%d.bill", getenv("MBSE_ROOT"),
nodes.Aka[0].zone, nodes.Aka[0].net, nodes.Aka[0].node, nodes.Aka[0].point);
if ((fp = fopen(fname, "a+")) != NULL) {
memset(&bill, 0, sizeof(bill));
bill.Node = nodes.Aka[0];
strcpy(bill.FileName, TIC.NewFile);
strcpy(bill.FileEcho, TIC.TicIn.Area);
bill.Size = TIC.FileSize;
bill.Cost = TIC.FileCost;
fwrite(&bill, sizeof(bill), 1, fp);
fclose(fp);
} else {
WriteError("$Can't create %s", fname);
}
}
fsync(fileno(fl));
fclose(fl);

View File

@ -322,9 +322,6 @@ void MakeStat(void)
MacroVars("d", "s", q);
MacroVars("e", "s", p);
MacroVars("f", "s", adate(nodes.LastDate));
MacroVars("g", "d", nodes.Billing);
MacroVars("h", "d", nodes.Credit);
MacroVars("i", "d", nodes.Debet);
MacroVars("j", "d", nodes.F_KbSent.total);
MacroVars("k", "d", nodes.F_KbRcvd.total);
MacroVars("l", "d", nodes.MailSent.total);

View File

@ -51,7 +51,7 @@ void AdoptFile(int Area, char *File, char *Description)
int IsArchive = FALSE, MustRearc = FALSE, UnPacked = FALSE;
int IsVirus = FALSE, File_Id = FALSE;
int i, j, k, lines = 0, File_id_cnt = 0, rc;
struct FILERecord fdb;
struct FILE_record f_db;
Syslog('f', "Adopt(%d, %s, %s)", Area, MBSE_SS(File), MBSE_SS(Description));
@ -140,11 +140,11 @@ void AdoptFile(int Area, char *File, char *Description)
fflush(stdout);
}
memset(&fdb, 0, sizeof(fdb));
strcpy(fdb.Uploader, CFG.sysop_name);
fdb.UploadDate = time(NULL);
memset(&f_db, 0, sizeof(f_db));
strcpy(f_db.Uploader, CFG.sysop_name);
f_db.UploadDate = time(NULL);
if (do_annon)
fdb.Announced = TRUE;
f_db.Announced = TRUE;
if (UnPacked) {
/*
@ -187,7 +187,7 @@ void AdoptFile(int Area, char *File, char *Description)
j = 0;
for (i = 0; i < strlen(Desc); i++) {
if ((Desc[i] >= ' ') || (Desc[i] < 0)) {
fdb.Desc[File_id_cnt][j] = Desc[i];
f_db.Desc[File_id_cnt][j] = Desc[i];
j++;
}
}
@ -200,12 +200,12 @@ void AdoptFile(int Area, char *File, char *Description)
/*
* Strip empty lines at end of FILE_ID.DIZ
*/
while ((strlen(fdb.Desc[File_id_cnt-1]) == 0) && (File_id_cnt))
while ((strlen(f_db.Desc[File_id_cnt-1]) == 0) && (File_id_cnt))
File_id_cnt--;
Syslog('f', "Got %d FILE_ID.DIZ lines", File_id_cnt);
for (i = 0; i < File_id_cnt; i++)
Syslog('f', "\"%s\"", fdb.Desc[i]);
Syslog('f', "\"%s\"", f_db.Desc[i]);
}
}
}
@ -225,7 +225,7 @@ void AdoptFile(int Area, char *File, char *Description)
/*
* Less then 48 chars, copy and ready.
*/
strcpy(fdb.Desc[0], Description);
strcpy(f_db.Desc[0], Description);
File_id_cnt++;
} else {
/*
@ -238,14 +238,14 @@ void AdoptFile(int Area, char *File, char *Description)
j = 48;
while (TDesc[j] != ' ')
j--;
strncat(fdb.Desc[File_id_cnt], TDesc, j);
strncat(f_db.Desc[File_id_cnt], TDesc, j);
File_id_cnt++;
k = strlen(TDesc);
j++; /* Correct space */
for (i = 0; i <= k; i++, j++)
TDesc[i] = TDesc[j];
}
strcpy(fdb.Desc[File_id_cnt], TDesc);
strcpy(f_db.Desc[File_id_cnt], TDesc);
File_id_cnt++;
}
}
@ -261,11 +261,11 @@ void AdoptFile(int Area, char *File, char *Description)
*/
strcpy(temp2, File);
name_mangle(temp2);
strcpy(fdb.Name, temp2);
strcpy(fdb.LName, File);
fdb.Size = file_size(File);
fdb.Crc32 = file_crc(File, TRUE);
fdb.FileDate = file_time(File);
strcpy(f_db.Name, temp2);
strcpy(f_db.LName, File);
f_db.Size = file_size(File);
f_db.Crc32 = file_crc(File, TRUE);
f_db.FileDate = file_time(File);
sprintf(temp2, "%s/%s", area.Path, File);
if (!do_quiet) {
@ -273,15 +273,15 @@ void AdoptFile(int Area, char *File, char *Description)
fflush(stdout);
}
if (strcmp(fdb.Name, fdb.LName)) {
if (strcmp(f_db.Name, f_db.LName)) {
lname = calloc(PATH_MAX, sizeof(char));
sprintf(lname, "%s/%s", area.Path, fdb.Name);
if (AddFile(fdb, Area, temp2, File, lname) == FALSE) {
sprintf(lname, "%s/%s", area.Path, f_db.Name);
if (AddFile(f_db, Area, temp2, File, lname) == FALSE) {
die(MBERR_GENERAL);
}
free(lname);
} else {
if (AddFile(fdb, Area, temp2, File, NULL) == FALSE) {
if (AddFile(f_db, Area, temp2, File, NULL) == FALSE) {
die(MBERR_GENERAL);
}
}

View File

@ -172,7 +172,7 @@ void Check(void)
WriteError("Can't stat %s", area.Path);
}
sprintf(fAreas, "%s/fdb/fdb%d.data", getenv("MBSE_ROOT"), i);
sprintf(fAreas, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), i);
/*
* Open the file database, if it doesn't exist,
@ -184,6 +184,11 @@ void Check(void)
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);
}
/*
@ -191,23 +196,22 @@ void Check(void)
* against the contents of the directory.
*/
inArea = 0;
while (fread(&file, sizeof(file), 1, pFile) == 1) {
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
iTotal++;
inArea++;
sprintf(newdir, "%s/%s", area.Path, file.LName);
sprintf(mname, "%s/%s", area.Path, file.Name);
sprintf(newdir, "%s/%s", area.Path, fdb.LName);
sprintf(mname, "%s/%s", area.Path, fdb.Name);
if (file_exist(newdir, R_OK) && file_exist(mname, R_OK)) {
Syslog('+', "File %s area %d not on disk.", newdir, i);
if (!file.NoKill) {
file.Deleted = TRUE;
if (!fdb.NoKill) {
fdb.Deleted = TRUE;
do_pack = TRUE;
}
iErrors++;
file.Missing = TRUE;
fseek(pFile, - sizeof(file), SEEK_CUR);
fwrite(&file, sizeof(file), 1, pFile);
fseek(pFile, - fdbhdr.recsize, SEEK_CUR);
fwrite(&fdb, fdbhdr.recsize, 1, pFile);
} else {
/*
* File exists, now check the file.
@ -215,16 +219,16 @@ void Check(void)
Marker();
Update = FALSE;
strcpy(temp, file.LName);
strcpy(temp, fdb.LName);
name_mangle(temp);
sprintf(mname, "%s/%s", area.Path, temp);
if (strcmp(file.Name, temp)) {
Syslog('!', "Converted %s to %s", file.Name, temp);
if (strcmp(fdb.Name, temp)) {
Syslog('!', "Converted %s to %s", fdb.Name, temp);
tname = calloc(PATH_MAX, sizeof(char));
sprintf(tname, "%s/%s", area.Path, file.Name);
sprintf(tname, "%s/%s", area.Path, fdb.Name);
rename(tname, mname);
free(tname);
strncpy(file.Name, temp, 12);
strncpy(fdb.Name, temp, 12);
iErrors++;
Update = TRUE;
}
@ -232,17 +236,17 @@ void Check(void)
/*
* If 8.3 and LFN are the same, try to rename the LFN to lowercase.
*/
if (strcmp(file.Name, file.LName) == 0) {
if (strcmp(fdb.Name, fdb.LName) == 0) {
/*
* 8.3 and LFN are the same.
*/
tname = calloc(PATH_MAX, sizeof(char));
sprintf(tname, "%s/%s", area.Path, file.LName);
for (j = 0; j < strlen(file.LName); j++)
file.LName[j] = tolower(file.LName[j]);
sprintf(newdir, "%s/%s", area.Path, file.LName);
sprintf(tname, "%s/%s", area.Path, fdb.LName);
for (j = 0; j < strlen(fdb.LName); j++)
fdb.LName[j] = tolower(fdb.LName[j]);
sprintf(newdir, "%s/%s", area.Path, fdb.LName);
if (strcmp(tname, newdir)) {
Syslog('+', "Rename LFN from %s to %s", file.Name, file.LName);
Syslog('+', "Rename LFN from %s to %s", fdb.Name, fdb.LName);
rename(tname, newdir);
Update = TRUE;
}
@ -323,7 +327,7 @@ void Check(void)
* It could be that there is a thumbnail made of the LFN.
*/
tname = calloc(PATH_MAX, sizeof(char));
sprintf(tname, "%s/.%s", area.Path, file.LName);
sprintf(tname, "%s/.%s", area.Path, fdb.LName);
if (file_exist(tname, R_OK) == 0) {
Syslog('+', "Removing thumbnail %s", tname);
iErrors++;
@ -332,28 +336,28 @@ void Check(void)
free(tname);
if (file_time(newdir) != file.FileDate) {
Syslog('!', "Date mismatch area %d file %s", i, file.LName);
file.FileDate = file_time(newdir);
if (file_time(newdir) != fdb.FileDate) {
Syslog('!', "Date mismatch area %d file %s", i, fdb.LName);
fdb.FileDate = file_time(newdir);
iErrors++;
Update = TRUE;
}
if (file_size(newdir) != file.Size) {
Syslog('!', "Size mismatch area %d file %s", i, file.LName);
file.Size = file_size(newdir);
if (file_size(newdir) != fdb.Size) {
Syslog('!', "Size mismatch area %d file %s", i, fdb.LName);
fdb.Size = file_size(newdir);
iErrors++;
Update = TRUE;
}
if (file_crc(newdir, CFG.slow_util && do_quiet) != file.Crc32) {
Syslog('!', "CRC error area %d, file %s", i, file.LName);
file.Crc32 = file_crc(newdir, CFG.slow_util && do_quiet);
if (file_crc(newdir, CFG.slow_util && do_quiet) != fdb.Crc32) {
Syslog('!', "CRC error area %d, file %s", i, fdb.LName);
fdb.Crc32 = file_crc(newdir, CFG.slow_util && do_quiet);
iErrors++;
Update = TRUE;
}
Marker();
if (Update) {
fseek(pFile, - sizeof(file), SEEK_CUR);
fwrite(&file, sizeof(file), 1, pFile);
fseek(pFile, - fdbhdr.recsize, SEEK_CUR);
fwrite(&fdb, fdbhdr.recsize, 1, pFile);
}
}
}
@ -370,9 +374,9 @@ void Check(void)
if (de->d_name[0] != '.') {
Marker();
Found = FALSE;
rewind(pFile);
while (fread(&file, sizeof(file), 1, pFile) == 1) {
if ((strcmp(file.LName, de->d_name) == 0) || (strcmp(file.Name, de->d_name) == 0)) {
fseek(pFile, fdbhdr.hdrsize, SEEK_SET);
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
if ((strcmp(fdb.LName, de->d_name) == 0) || (strcmp(fdb.Name, de->d_name) == 0)) {
if (!Found) {
Found = TRUE;
} else {
@ -380,12 +384,12 @@ void Check(void)
* Record has been found before, so this must be
* a double record.
*/
Syslog('!', "Double file record area %d file %s", i, file.LName);
Syslog('!', "Double file record area %d file %s", i, fdb.LName);
iErrors++;
file.Double = TRUE;
fdb.Double = TRUE;
do_pack = TRUE;
fseek(pFile, - sizeof(file), SEEK_CUR);
fwrite(&file, sizeof(file), 1, pFile);
fseek(pFile, - fdbhdr.recsize, SEEK_CUR);
fwrite(&fdb, fdbhdr.recsize, 1, pFile);
}
}
}
@ -421,7 +425,7 @@ void Check(void)
} else {
if (strlen(area.Name) == 0) {
sprintf(fAreas, "%s/fdb/fdb%d.data", getenv("MBSE_ROOT"), i);
sprintf(fAreas, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), i);
if (unlink(fAreas) == 0) {
Syslog('+', "Removed obsolete %s", fAreas);
}

View File

@ -42,12 +42,11 @@ extern int do_quiet; /* Suppress screen output */
/*
* Move a file
* Delete a file
*/
void Delete(int UnDel, int Area, char *File)
{
char *temp;
struct FILERecord fdb;
FILE *fp;
int rc = FALSE;

View File

@ -50,7 +50,7 @@ void ImportFiles(int Area)
DIR *dp;
int Append = FALSE, Files = 0, rc, i, line = 0, pos, x, Doit;
int Imported = 0, Errors = 0, Present = FALSE;
struct FILERecord fdb;
struct FILE_record f_db;
struct stat statfile;
struct dirent *de;
@ -105,7 +105,7 @@ void ImportFiles(int Area)
Doit = TRUE;
if ((unarc = unpacker(temp)) == NULL) {
Syslog('+', "Unknown archive format %s", temp);
sprintf(temp2, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), fdb.Name);
sprintf(temp2, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), f_db.Name);
mkdirs(temp2, 0755);
if ((rc = file_cp(temp, temp2))) {
WriteError("Can't copy file to %s, %s", temp2, strerror(rc));
@ -148,14 +148,14 @@ void ImportFiles(int Area)
printf("Adding \b\b\b\b\b\b\b\b\b\b");
fflush(stdout);
}
if (strcmp(fdb.Name, fdb.LName)) {
if (AddFile(fdb, Area, dest, temp, lname)) {
if (strcmp(f_db.Name, f_db.LName)) {
if (AddFile(f_db, Area, dest, temp, lname)) {
Imported++;
} else {
Errors++;
}
} else {
if (AddFile(fdb, Area, dest, temp, NULL)) {
if (AddFile(f_db, Area, dest, temp, NULL)) {
Imported++;
} else {
Errors++;
@ -177,7 +177,7 @@ void ImportFiles(int Area)
die(MBERR_DISK_FULL);
Files++;
memset(&fdb, 0, sizeof(fdb));
memset(&f_db, 0, sizeof(f_db));
Present = TRUE;
token = strtok(String, " \t");
@ -195,13 +195,13 @@ void ImportFiles(int Area)
/*
* Found the right file.
*/
strncpy(fdb.LName, token, 80);
strncpy(f_db.LName, token, 80);
break;
}
}
closedir(dp);
if (strlen(fdb.LName) == 0) {
if (strlen(f_db.LName) == 0) {
WriteError("Can't find file on disk, skipping: %s\n", token);
Append = FALSE;
Present = FALSE;
@ -209,28 +209,28 @@ void ImportFiles(int Area)
/*
* Create DOS 8.3 filename
*/
strcpy(temp2, fdb.LName);
strcpy(temp2, f_db.LName);
name_mangle(temp2);
strcpy(fdb.Name, temp2);
strcpy(f_db.Name, temp2);
if (strcmp(fdb.LName, fdb.Name) && (rename(fdb.LName, fdb.Name) == 0)) {
Syslog('+', "Renamed %s to %s", fdb.LName, fdb.Name);
if (strcmp(f_db.LName, f_db.Name) && (rename(f_db.LName, f_db.Name) == 0)) {
Syslog('+', "Renamed %s to %s", f_db.LName, f_db.Name);
}
sprintf(temp, "%s/%s", pwd, fdb.Name);
sprintf(temp, "%s/%s", pwd, f_db.Name);
stat(temp, &statfile);
if (do_annon)
fdb.Announced = TRUE;
Syslog('f', "File: %s (%s)", fdb.Name, fdb.LName);
f_db.Announced = TRUE;
Syslog('f', "File: %s (%s)", f_db.Name, f_db.LName);
if (!do_quiet) {
printf("\rImport file: %s ", fdb.Name);
printf("\rImport file: %s ", f_db.Name);
printf("Checking \b\b\b\b\b\b\b\b\b\b");
fflush(stdout);
}
IsDoing("Import %s", fdb.Name);
IsDoing("Import %s", f_db.Name);
token = strtok(NULL, "\0");
i = strlen(token);
@ -250,20 +250,20 @@ void ImportFiles(int Area)
if (Doit) {
if (pos > 42) {
if (token[x] == ' ') {
fdb.Desc[line][pos] = '\0';
f_db.Desc[line][pos] = '\0';
line++;
pos = 0;
} else {
if (pos == 49) {
fdb.Desc[line][pos] = '\0';
f_db.Desc[line][pos] = '\0';
pos = 0;
line++;
}
fdb.Desc[line][pos] = token[x];
f_db.Desc[line][pos] = token[x];
pos++;
}
} else {
fdb.Desc[line][pos] = token[x];
f_db.Desc[line][pos] = token[x];
pos++;
}
if (line == 25)
@ -271,14 +271,14 @@ void ImportFiles(int Area)
}
}
sprintf(dest, "%s/%s", area.Path, fdb.Name);
sprintf(lname, "%s/%s", area.Path, fdb.LName);
sprintf(dest, "%s/%s", area.Path, f_db.Name);
sprintf(lname, "%s/%s", area.Path, f_db.LName);
Append = TRUE;
fdb.Size = statfile.st_size;
fdb.FileDate = statfile.st_mtime;
fdb.Crc32 = file_crc(temp, FALSE);
strcpy(fdb.Uploader, CFG.sysop_name);
fdb.UploadDate = time(NULL);
f_db.Size = statfile.st_size;
f_db.FileDate = statfile.st_mtime;
f_db.Crc32 = file_crc(temp, FALSE);
strcpy(f_db.Uploader, CFG.sysop_name);
f_db.UploadDate = time(NULL);
}
} else if (Present) {
/*
@ -298,20 +298,20 @@ void ImportFiles(int Area)
if (Doit) {
if (pos > 42) {
if (token[x] == ' ') {
fdb.Desc[line][pos] = '\0';
f_db.Desc[line][pos] = '\0';
line++;
pos = 0;
} else {
if (pos == 49) {
fdb.Desc[line][pos] = '\0';
f_db.Desc[line][pos] = '\0';
pos = 0;
line++;
}
fdb.Desc[line][pos] = token[x];
f_db.Desc[line][pos] = token[x];
pos++;
}
} else {
fdb.Desc[line][pos] = token[x];
f_db.Desc[line][pos] = token[x];
pos++;
}
if (line == 25)
@ -336,7 +336,7 @@ void ImportFiles(int Area)
Doit = TRUE;
if ((unarc = unpacker(temp)) == NULL) {
Syslog('+', "Unknown archive format %s", temp);
sprintf(temp2, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), fdb.LName);
sprintf(temp2, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), f_db.LName);
mkdirs(temp2, 0755);
if ((rc = file_cp(temp, temp2))) {
WriteError("Can't copy file to %s, %s", temp2, strerror(rc));
@ -377,13 +377,13 @@ void ImportFiles(int Area)
printf("Adding \b\b\b\b\b\b\b\b\b\b");
fflush(stdout);
}
if (strcmp(fdb.Name, fdb.LName)) {
if (AddFile(fdb, Area, dest, temp, lname))
if (strcmp(f_db.Name, f_db.LName)) {
if (AddFile(f_db, Area, dest, temp, lname))
Imported++;
else
Errors++;
} else {
if (AddFile(fdb, Area, dest, temp, NULL))
if (AddFile(f_db, Area, dest, temp, NULL))
Imported++;
else
Errors++;

View File

@ -379,7 +379,7 @@ void ReqIndex(void)
newdir = NULL;
}
sprintf(fAreas, "%s/fdb/fdb%ld.data", getenv("MBSE_ROOT"), i);
sprintf(fAreas, "%s/fdb/file%ld.data", getenv("MBSE_ROOT"), i);
/*
* Open the file database, if it doesn't exist,
@ -391,6 +391,11 @@ void ReqIndex(void)
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);
}
/*
@ -401,13 +406,13 @@ void ReqIndex(void)
* Now start creating the unsorted index.
*/
record = 0;
while (fread(&file, sizeof(file), 1, pFile) == 1) {
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
iTotal++;
if ((iTotal % 10) == 0)
Marker();
memset(&idx, 0, sizeof(idx));
sprintf(idx.Name, "%s", tu(file.Name));
sprintf(idx.LName, "%s", tu(file.LName));
sprintf(idx.Name, "%s", tu(fdb.Name));
sprintf(idx.LName, "%s", tu(fdb.LName));
idx.AreaNum = i;
idx.Record = record;
fill_index(idx, &fdx);
@ -426,15 +431,15 @@ void ReqIndex(void)
if ((fp = fopen(temp, "w")) == NULL) {
WriteError("$Can't create %s", temp);
} else {
fseek(pFile, 0, SEEK_SET);
fseek(pFile, fdbhdr.hdrsize, SEEK_SET);
fbAreas++;
while (fread(&file, sizeof(file), 1, pFile) == 1) {
if ((!file.Deleted) && (!file.Missing)) {
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
if (!fdb.Deleted) {
fbFiles++;
fprintf(fp, "%-12s [%ld] %s\r\n", file.Name, file.TimesDL + file.TimesFTP + file.TimesReq, file.Desc[0]);
fprintf(fp, "%-12s [%ld] %s\r\n", fdb.Name, fdb.TimesDL, fdb.Desc[0]);
for (j = 1; j < 25; j++)
if (strlen(file.Desc[j]))
fprintf(fp, " +%s\r\n", file.Desc[j]);
if (strlen(fdb.Desc[j]))
fprintf(fp, " +%s\r\n", fdb.Desc[j]);
}
}
fclose(fp);
@ -450,10 +455,10 @@ void ReqIndex(void)
if ((fp = fopen(temp, "w")) == NULL) {
WriteError("$Can't create %s", temp);
} else {
fseek(pFile, 0, SEEK_SET);
fseek(pFile, fdbhdr.hdrsize, SEEK_SET);
while (fread(&file, sizeof(file), 1, pFile) == 1) {
if ((!file.Deleted) && (!file.Missing)) {
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
if (!fdb.Deleted) {
/*
* The next is to reduce system load
*/
@ -462,16 +467,16 @@ void ReqIndex(void)
msleep(1);
for (z = 0; z <= 25; z++) {
if (strlen(file.Desc[z])) {
if (strlen(fdb.Desc[z])) {
if (z == 0)
fprintf(fp, "%-12s %7luK %s ", file.Name, (long)(file.Size / 1024),
StrDateDMY(file.UploadDate));
fprintf(fp, "%-12s %7luK %s ", fdb.Name, (long)(fdb.Size / 1024),
StrDateDMY(fdb.UploadDate));
else
fprintf(fp, " ");
if ((file.Desc[z][0] == '@') && (file.Desc[z][1] == 'X'))
fprintf(fp, "%s\n", file.Desc[z]+4);
if ((fdb.Desc[z][0] == '@') && (fdb.Desc[z][1] == 'X'))
fprintf(fp, "%s\n", fdb.Desc[z]+4);
else
fprintf(fp, "%s\n", file.Desc[z]);
fprintf(fp, "%s\n", fdb.Desc[z]);
}
}
}
@ -600,7 +605,7 @@ void HtmlIndex(char *Lang)
fflush(stdout);
}
sprintf(fAreas, "%s/fdb/fdb%ld.data", getenv("MBSE_ROOT"), i);
sprintf(fAreas, "%s/fdb/file%ld.data", getenv("MBSE_ROOT"), i);
/*
* Open the file database, if it doesn't exist,
@ -610,20 +615,21 @@ void HtmlIndex(char *Lang)
WriteError("$Can't open %s", fAreas);
die(MBERR_GENERAL);
}
fread(&fdbhdr, sizeof(fdbhdr), 1, pFile);
/*
* Create index.html pages in each available download area.
*/
if (!area.CDrom && fm && (strncmp(CFG.ftp_base, area.Path, strlen(CFG.ftp_base)) == 0)) {
fseek(pFile, 0, SEEK_SET);
fseek(pFile, fdbhdr.hdrsize, SEEK_SET);
AreasHtml++;
inArea = 0;
while (fread(&file, sizeof(file), 1, pFile) == 1) {
if ((!file.Deleted) && (!file.Missing))
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
if (!fdb.Deleted)
inArea++;
}
fseek(pFile, 0, SEEK_SET);
fseek(pFile, fdbhdr.hdrsize, SEEK_SET);
aSize = 0L;
aTotal = 0;
@ -635,8 +641,8 @@ void HtmlIndex(char *Lang)
fileptr1 = gfilepos;
}
while (fread(&file, sizeof(file), 1, pFile) == 1) {
if ((!file.Deleted) && (!file.Missing)) {
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
if (!fdb.Deleted) {
/*
* The next is to reduce system load
*/
@ -654,40 +660,40 @@ void HtmlIndex(char *Lang)
* check if a thumbnail file exists. If not try to
* create a thumbnail file to add to the html listing.
*/
if (strstr(file.LName, ".gif") || strstr(file.LName, ".jpg") ||
strstr(file.LName, ".GIF") || strstr(file.LName, ".JPG")) {
sprintf(linebuf, "%s/%s", area.Path, file.Name);
sprintf(outbuf, "%s/.%s", area.Path, file.Name);
if (strstr(fdb.LName, ".gif") || strstr(fdb.LName, ".jpg") ||
strstr(fdb.LName, ".GIF") || strstr(fdb.LName, ".JPG")) {
sprintf(linebuf, "%s/%s", area.Path, fdb.Name);
sprintf(outbuf, "%s/.%s", area.Path, fdb.Name);
if (file_exist(outbuf, R_OK)) {
if ((j = execute_str(CFG.www_convert, linebuf, outbuf,
(char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null"))) {
Syslog('+', "Failed to create thumbnail for %s, rc=% d", file.Name, j);
Syslog('+', "Failed to create thumbnail for %s, rc=% d", fdb.Name, j);
} else {
chmod(outbuf, 0644);
}
}
sprintf(outbuf, "%s/%s%s/%s", CFG.www_url, CFG.www_link2ftp,
area.Path+strlen(CFG.ftp_base), file.Name);
area.Path+strlen(CFG.ftp_base), fdb.Name);
sprintf(linebuf, "%s/%s%s/.%s", CFG.www_url, CFG.www_link2ftp,
area.Path+strlen(CFG.ftp_base), file.Name);
MacroVars("fghi", "dsss", 1, outbuf, file.LName, linebuf);
area.Path+strlen(CFG.ftp_base), fdb.Name);
MacroVars("fghi", "dsss", 1, outbuf, fdb.LName, linebuf);
} else {
sprintf(outbuf, "%s/%s%s/%s", CFG.www_url, CFG.www_link2ftp,
area.Path+strlen(CFG.ftp_base), file.Name);
MacroVars("fghi", "dsss", 0, outbuf, file.LName, "");
area.Path+strlen(CFG.ftp_base), fdb.Name);
MacroVars("fghi", "dsss", 0, outbuf, fdb.LName, "");
}
sprintf(outbuf, "%lu Kb.", (long)(file.Size / 1024));
MacroVars("jkl", "ssd", StrDateDMY(file.FileDate), outbuf, file.TimesDL+file.TimesFTP+file.TimesReq);
sprintf(outbuf, "%lu Kb.", (long)(fdb.Size / 1024));
MacroVars("jkl", "ssd", StrDateDMY(fdb.FileDate), outbuf, fdb.TimesDL);
memset(&desc, 0, sizeof(desc));
k = 0;
for (j = 0; j < 25; j++)
if (strlen(file.Desc[j])) {
if (strlen(fdb.Desc[j])) {
if (j) {
sprintf(desc+k, "\n");
k += 1;
}
sprintf(linebuf, "%s", To_Html(file.Desc[j]));
sprintf(linebuf, "%s", To_Html(fdb.Desc[j]));
html_massage(linebuf, outbuf);
sprintf(desc+k, "%s", outbuf);
k += strlen(outbuf);
@ -695,10 +701,10 @@ void HtmlIndex(char *Lang)
MacroVars("m", "s", desc);
fseek(fb, fileptr1, SEEK_SET);
MacroRead(fb, fa);
aSize += file.Size;
aSize += fdb.Size;
MacroVars("efghijklm", "ddsssssds", 0, 0, "", "", "", "", "", 0, "");
if (file.FileDate > last)
last = file.FileDate;
if (fdb.FileDate > last)
last = fdb.FileDate;
if ((aTotal % CFG.www_files_page) == 0) {
closepage(fa, area.Path, inArea, aTotal, fb);
fseek(fb, 0, SEEK_SET);

View File

@ -52,7 +52,7 @@ extern int do_pack; /* Perform pack */
void Kill(void)
{
FILE *pAreas, *pFile, *pDest, *pTemp;
int i, iAreas, iAreasNew = 0, iTotal = 0, iKilled = 0, iMoved = 0, rc, Killit, FilesLeft;
int i, iAreas, iAreasNew = 0, iTotal = 0, iKilled = 0, iMoved = 0, rc, Killit;
char *sAreas, *fAreas, *newdir = NULL, *sTemp, from[PATH_MAX], to[PATH_MAX];
time_t Now;
struct fileareas darea;
@ -106,7 +106,7 @@ void Kill(void)
newdir = NULL;
}
sprintf(fAreas, "%s/fdb/fdb%d.data", getenv("MBSE_ROOT"), i);
sprintf(fAreas, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), i);
/*
* Open the file database, if it doesn't exist,
@ -118,29 +118,34 @@ void Kill(void)
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);
}
/*
* Now start checking the files in the filedatabase
* against the contents of the directory.
*/
while (fread(&file, sizeof(file), 1, pFile) == 1) {
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
iTotal++;
Marker();
Killit = FALSE;
if (!file.UploadDate)
Syslog('!', "Warning: file %s in area %d has no upload date", file.Name, i);
if (!fdb.UploadDate)
Syslog('!', "Warning: file %s in area %d has no upload date", fdb.Name, i);
if (area.DLdays) {
/*
* Test last download date or never downloaded and the
* file is more then n days available for download.
*/
if ((file.LastDL) && (((Now - file.LastDL) / 84400) > area.DLdays)) {
if ((fdb.LastDL) && (((Now - fdb.LastDL) / 84400) > area.DLdays)) {
Killit = TRUE;
}
if ((!file.LastDL) && file.UploadDate && (((Now - file.UploadDate) / 84400) > area.DLdays)) {
if ((!fdb.LastDL) && fdb.UploadDate && (((Now - fdb.UploadDate) / 84400) > area.DLdays)) {
Killit = TRUE;
}
}
@ -149,7 +154,7 @@ void Kill(void)
/*
* Check filedate
*/
if (file.UploadDate && (((Now - file.UploadDate) / 84400) > area.FDdays)) {
if (fdb.UploadDate && (((Now - fdb.UploadDate) / 84400) > area.FDdays)) {
Killit = TRUE;
}
}
@ -159,55 +164,62 @@ void Kill(void)
if (area.MoveArea) {
fseek(pAreas, ((area.MoveArea -1) * areahdr.recsize) + areahdr.hdrsize, SEEK_SET);
fread(&darea, areahdr.recsize, 1, pAreas);
sprintf(from, "%s/%s", area.Path, file.Name);
sprintf(to, "%s/%s", darea.Path, file.Name);
sprintf(from, "%s/%s", area.Path, fdb.Name);
sprintf(to, "%s/%s", darea.Path, fdb.Name);
if ((rc = file_mv(from, to)) == 0) {
Syslog('+', "Move %s, area %d => %d", file.Name, i, area.MoveArea);
sprintf(to, "%s/fdb/fdb%d.data", getenv("MBSE_ROOT"), area.MoveArea);
Syslog('+', "Move %s, area %d => %d", fdb.Name, i, area.MoveArea);
sprintf(to, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), area.MoveArea);
if ((pDest = fopen(to, "a+")) != NULL) {
file.UploadDate = time(NULL);
file.LastDL = time(NULL);
fwrite(&file, sizeof(file), 1, pDest);
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);
}
/*
* Now again if there is a dotted version (thumbnail) of this file.
*/
sprintf(from, "%s/.%s", area.Path, file.Name);
sprintf(to, "%s/.%s", darea.Path, file.Name);
sprintf(from, "%s/.%s", area.Path, fdb.Name);
sprintf(to, "%s/.%s", darea.Path, fdb.Name);
if (file_exist(from, R_OK) == 0)
file_mv(from, to);
/*
* Unlink the old symbolic link
*/
sprintf(from, "%s/%s", area.Path, file.LName);
sprintf(from, "%s/%s", area.Path, fdb.LName);
unlink(from);
/*
* Create the new symbolic link
*/
sprintf(from, "%s/%s", darea.Path, file.Name);
sprintf(to, "%s/%s", darea.Path, file.LName);
sprintf(from, "%s/%s", darea.Path, fdb.Name);
sprintf(to, "%s/%s", darea.Path, fdb.LName);
symlink(from, to);
file.Deleted = TRUE;
fseek(pFile, - sizeof(file), SEEK_CUR);
fwrite(&file, sizeof(file), 1, pFile);
fdb.Deleted = TRUE;
fseek(pFile, - fdbhdr.recsize, SEEK_CUR);
fwrite(&fdb, fdbhdr.recsize, 1, pFile);
iMoved++;
} else {
WriteError("Move %s to area %d failed, %s", file.Name, area.MoveArea, strerror(rc));
WriteError("Move %s to area %d failed, %s", fdb.Name, area.MoveArea, strerror(rc));
}
} else {
Syslog('+', "Delete %s, area %d", file.LName, i);
file.Deleted = TRUE;
fseek(pFile, - sizeof(file), SEEK_CUR);
fwrite(&file, sizeof(file), 1, pFile);
Syslog('+', "Delete %s, area %d", fdb.LName, i);
fdb.Deleted = TRUE;
fseek(pFile, - fdbhdr.recsize, SEEK_CUR);
fwrite(&fdb, fdbhdr.recsize, 1, pFile);
iKilled++;
sprintf(from, "%s/%s", area.Path, file.LName);
sprintf(from, "%s/%s", area.Path, fdb.LName);
unlink(from);
sprintf(from, "%s/%s", area.Path, file.Name);
sprintf(from, "%s/%s", area.Path, fdb.Name);
unlink(from);
sprintf(from, "%s/.%s", area.Path, fdb.Name);
unlink(from);
}
}
@ -221,11 +233,10 @@ void Kill(void)
sprintf(sTemp, "%s/fdb/fdbtmp.data", getenv("MBSE_ROOT"));
if ((pTemp = fopen(sTemp, "a+")) != NULL) {
FilesLeft = FALSE;
while (fread(&file, sizeof(file), 1, pFile) == 1) {
if ((!file.Deleted) && strcmp(file.LName, "") != 0) {
fwrite(&file, sizeof(file), 1, pTemp);
FilesLeft = TRUE;
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);
}
}

View File

@ -98,63 +98,46 @@ void ListFileAreas(int Area)
/*
* Open the file database, create new one if it doesn't exist.
*/
sprintf(fAreas, "%s/fdb/fdb%d.data", getenv("MBSE_ROOT"), Area);
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);
}
fcount = 0;
fsize = 0L;
colour(CYAN, BLACK);
printf("File listing of area %d, %s\n\n", Area, area.Name);
printf("Short name Kb. File date Down Flags TIC Area Long name\n");
printf("------------ ----- ---------- ---- ----- -------------------- ");
printf("Short name Kb. File date Down Flg TIC Area Long name\n");
printf("------------ ----- ---------- ---- --- -------------------- ");
for (i = 63; i < COLS; i++)
printf("-");
printf("\n");
colour(LIGHTGRAY, BLACK);
while (fread(&file, sizeof(file), 1, pFile) == 1) {
sprintf(flags, "-----");
if (file.Free)
flags[0] = 'F';
if (file.Deleted)
flags[1] = 'D';
if (file.Missing)
flags[2] = 'M';
if (file.NoKill)
flags[3] = 'N';
if (file.Announced)
flags[4] = 'A';
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
sprintf(flags, "---");
if (fdb.Deleted)
flags[0] = 'D';
if (fdb.NoKill)
flags[1] = 'N';
if (fdb.Announced)
flags[2] = 'A';
if (file.TicAreaCRC) {
/*
* Fill the default answer
*/
sprintf(ticarea, "Not found");
fseek(pTic, tichdr.hdrsize, SEEK_SET);
while (fread(&tic, tichdr.recsize, 1, pTic)) {
if (StringCRC32(tic.Name) == file.TicAreaCRC) {
sprintf(ticarea, "%s", tic.Name);
break;
}
fseek(pTic, tichdr.syssize, SEEK_CUR);
}
} else {
sprintf(ticarea, "N/A");
}
file.LName[COLS - 63] = '\0';
printf("%-12s %5ld %s %4ld %s %-20s %s\n",
file.Name, (long)(file.Size / 1024), StrDateDMY(file.FileDate),
(long)(file.TimesDL + file.TimesFTP + file.TimesReq), flags, ticarea, file.LName);
fdb.LName[COLS - 63] = '\0';
printf("%-12s %5ld %s %4ld %s %-20s %s\n", fdb.Name, (long)(fdb.Size / 1024), StrDateDMY(fdb.FileDate),
(long)(fdb.TimesDL), flags, fdb.TicArea, fdb.LName);
fcount++;
fsize = fsize + file.Size;
fsize = fsize + fdb.Size;
}
fsize = fsize / 1024;
@ -196,20 +179,25 @@ void ListFileAreas(int Area)
/*
* Open the file database, create new one if it doesn't exist.
*/
sprintf(fAreas, "%s/fdb/fdb%d.data", getenv("MBSE_ROOT"), i);
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);
}
fcount = 0;
fsize = 0L;
while (fread(&file, sizeof(file), 1, pFile) == 1) {
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
fcount++;
fsize = fsize + file.Size;
fsize = fsize + fdb.Size;
}
fsize = fsize / 1048576;
tcount += fcount;

View File

@ -47,7 +47,8 @@ extern int do_quiet; /* Suppress screen output */
void Move(int From, int To, char *File)
{
char *frompath, *topath, *temp1, *temp2, *fromlink, *tolink, *fromthumb, *tothumb;
struct FILERecord fdb;
struct FILE_recordhdr f_dbhdr;
struct FILE_record f_db;
FILE *fp1, *fp2;
int rc = FALSE, Found = FALSE;
@ -87,11 +88,13 @@ void Move(int From, int To, char *File)
* Find the file in the "from" area, check LFN and 8.3 names.
*/
temp1 = calloc(PATH_MAX, sizeof(char));
sprintf(temp1, "%s/fdb/fdb%d.data", getenv("MBSE_ROOT"), From);
sprintf(temp1, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), From);
if ((fp1 = fopen(temp1, "r")) == NULL)
die(MBERR_GENERAL);
while (fread(&fdb, sizeof(fdb), 1, fp1) == 1) {
if ((strcmp(fdb.LName, File) == 0) || strcmp(fdb.Name, File) == 0) {
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;
}
@ -107,13 +110,13 @@ void Move(int From, int To, char *File)
frompath = xstrcpy(area.Path);
frompath = xstrcat(frompath, (char *)"/");
frompath = xstrcat(frompath, fdb.Name);
frompath = xstrcat(frompath, f_db.Name);
fromlink = xstrcpy(area.Path);
fromlink = xstrcat(fromlink, (char *)"/");
fromlink = xstrcat(fromlink, fdb.LName);
fromlink = xstrcat(fromlink, f_db.LName);
fromthumb = xstrcpy(area.Path);
fromthumb = xstrcat(fromthumb, (char *)"/.");
fromthumb = xstrcat(fromthumb, fdb.Name);
fromthumb = xstrcat(fromthumb, f_db.Name);
/*
* Check Destination area
@ -139,13 +142,13 @@ void Move(int From, int To, char *File)
topath = xstrcpy(area.Path);
topath = xstrcat(topath, (char *)"/");
topath = xstrcat(topath, fdb.Name);
topath = xstrcat(topath, f_db.Name);
tolink = xstrcpy(area.Path);
tolink = xstrcat(tolink, (char *)"/");
tolink = xstrcat(tolink, fdb.LName);
tolink = xstrcat(tolink, f_db.LName);
tothumb = xstrcpy(area.Path);
tothumb = xstrcat(tothumb, (char *)"/.");
tothumb = xstrcat(tothumb, fdb.Name);
tothumb = xstrcat(tothumb, f_db.Name);
if (file_exist(topath, F_OK) == 0) {
WriteError("File %s already exists in area %d", File, To);
@ -155,23 +158,25 @@ void Move(int From, int To, char *File)
}
temp2 = calloc(PATH_MAX, sizeof(char));
sprintf(temp2, "%s/fdb/fdb%d.temp", getenv("MBSE_ROOT"), From);
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(&fdb, sizeof(fdb), 1, fp1) == 1) {
if (strcmp(fdb.LName, File) && strcmp(fdb.Name, File))
fwrite(&fdb, sizeof(fdb), 1, fp2);
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(fdb, To, topath, frompath, tolink);
rc = AddFile(f_db, To, topath, frompath, tolink);
if (rc) {
unlink(fromlink);
unlink(frompath);

View File

@ -88,8 +88,8 @@ void PackFileBase(void)
}
Marker();
sprintf(fAreas, "%s/fdb/fdb%d.data", getenv("MBSE_ROOT"), i);
sprintf(fTmp, "%s/fdb/fdb%d.temp", getenv("MBSE_ROOT"), i);
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);
@ -97,37 +97,43 @@ void PackFileBase(void)
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);
while (fread(&file, sizeof(file), 1, pFile) == 1) {
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
iTotal++;
if ((!file.Deleted) && (!file.Double) && (strcmp(file.Name, "") != 0)) {
fwrite(&file, sizeof(file), 1, fp);
if ((!fdb.Deleted) && (!fdb.Double) && (strcmp(fdb.Name, "") != 0)) {
fwrite(&fdb, fdbhdr.recsize, 1, fp);
} else {
iRemoved++;
if (file.Double) {
Syslog('+', "Removed double record file \"%s\" from area %d", file.LName, i);
if (fdb.Double) {
Syslog('+', "Removed double record file \"%s\" from area %d", fdb.LName, i);
} else {
Syslog('+', "Removed file \"%s\" from area %d", file.LName, i);
sprintf(fn, "%s/%s", area.Path, file.LName);
Syslog('+', "Removed file \"%s\" from area %d", fdb.LName, i);
sprintf(fn, "%s/%s", area.Path, fdb.LName);
rc = unlink(fn);
if (rc && (errno != ENOENT))
Syslog('+', "Unlink %s failed, result %d", fn, rc);
sprintf(fn, "%s/%s", area.Path, file.Name);
sprintf(fn, "%s/%s", area.Path, fdb.Name);
rc = unlink(fn);
if (rc && (errno != ENOENT))
Syslog('+', "Unlink %s failed, result %d", fn, rc);
/*
* If a dotted version (thumbnail) exists, remove it silently
*/
sprintf(fn, "%s/.%s", area.Path, file.LName);
sprintf(fn, "%s/.%s", area.Path, fdb.Name);
unlink(fn);
}
do_index = TRUE;

View File

@ -43,13 +43,13 @@ extern int do_index; /* Reindex filebases */
typedef struct _fdbs {
struct _fdbs *next;
struct FILERecord filrec;
struct FILE_record filrec;
} fdbs;
void fill_fdbs(struct FILERecord, fdbs **);
void fill_fdbs(struct FILERecord filrec, fdbs **fap)
void fill_fdbs(struct FILE_record, fdbs **);
void fill_fdbs(struct FILE_record filrec, fdbs **fap)
{
fdbs *tmp;
@ -166,8 +166,8 @@ void SortFileBase(int Area)
fflush(stdout);
}
sprintf(fAreas, "%s/fdb/fdb%d.data", getenv("MBSE_ROOT"), Area);
sprintf(fTmp, "%s/fdb/fdb%d.temp", getenv("MBSE_ROOT"), Area);
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);
@ -175,20 +175,26 @@ void SortFileBase(int Area)
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(&file, sizeof(file), 1, pFile) == 1) {
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
iTotal++;
fill_fdbs(file, &fdx);
Syslog('f', "Adding %s", file.LName);
fill_fdbs(fdb, &fdx);
Syslog('f', "Adding %s", fdb.LName);
}
sort_fdbs(&fdx);
@ -198,7 +204,7 @@ void SortFileBase(int Area)
*/
for (tmp = fdx; tmp; tmp = tmp->next) {
Syslog('f', "Sorted %s", tmp->filrec.LName);
fwrite(&tmp->filrec, sizeof(file), 1, fp);
fwrite(&tmp->filrec, fdbhdr.recsize, 1, fp);
}
tidy_fdbs(&fdx);

View File

@ -299,11 +299,10 @@ int UnpackFile(char *File)
/*
* Add file to the BBS. The file is in the current
* directory. The fdb record already has all needed
* information.
* Add file to the BBS. The file is in the current directory.
* The f_db record already has all needed information.
*/
int AddFile(struct FILERecord fdb, int Area, char *DestPath, char *FromPath, char *LinkPath)
int AddFile(struct FILE_record f_db, int Area, char *DestPath, char *FromPath, char *LinkPath)
{
char *temp1, *temp2;
FILE *fp1, *fp2;
@ -316,9 +315,9 @@ int AddFile(struct FILERecord fdb, int Area, char *DestPath, char *FromPath, cha
mkdirs(DestPath, 0775);
if (file_exist(DestPath, F_OK) == 0) {
WriteError("File %s already exists in area %d", fdb.Name, Area);
WriteError("File %s already exists in area %d", f_db.Name, Area);
if (!do_quiet)
printf("\nFile %s already exists in area %d\n", fdb.Name, Area);
printf("\nFile %s already exists in area %d\n", f_db.Name, Area);
return FALSE;
}
@ -341,33 +340,34 @@ int AddFile(struct FILERecord fdb, int Area, char *DestPath, char *FromPath, cha
temp1 = calloc(PATH_MAX, sizeof(char));
temp2 = calloc(PATH_MAX, sizeof(char));
sprintf(temp1, "%s/fdb/fdb%d.data", getenv("MBSE_ROOT"), Area);
sprintf(temp2, "%s/fdb/fdb%d.temp", getenv("MBSE_ROOT"), Area);
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) == 0) {
if (ftell(fp1) == fdbhdr.hdrsize) {
/*
* No records yet
*/
fwrite(&fdb, sizeof(fdb), 1, fp1);
fwrite(&f_db, fdbhdr.recsize, 1, fp1);
fclose(fp1);
} else {
/*
* Files are already there. Find the right spot.
*/
fseek(fp1, 0, SEEK_SET);
fseek(fp1, fdbhdr.hdrsize, SEEK_SET);
Insert = 0;
do {
if (fread(&file, sizeof(file), 1, fp1) != 1)
if (fread(&fdb, fdbhdr.recsize, 1, fp1) != 1)
Done = TRUE;
if (!Done) {
if (strcmp(fdb.LName, file.LName) == 0) {
if (strcmp(f_db.LName, fdb.LName) == 0) {
Found = TRUE;
Insert++;
} else {
if (strcmp(fdb.LName, file.LName) < 0)
if (strcmp(f_db.LName, fdb.LName) < 0)
Found = TRUE;
else
Insert++;
@ -380,33 +380,34 @@ int AddFile(struct FILERecord fdb, int Area, char *DestPath, char *FromPath, cha
WriteError("Can't create %s", temp2);
return FALSE;
}
fwrite(&fdbhdr, fdbhdr.hdrsize, 1, fp2);
fseek(fp1, fdbhdr.hdrsize, SEEK_SET);
fseek(fp1, 0, SEEK_SET);
/*
* Copy until the insert point
*/
for (i = 0; i < Insert; i++) {
fread(&file, sizeof(file), 1, fp1);
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(file.LName, fdb.LName) != 0)
fwrite(&file, sizeof(file), 1, fp2);
if (strcmp(fdb.LName, f_db.LName) != 0)
fwrite(&fdb, fdbhdr.recsize, 1, fp2);
}
if (area.AddAlpha)
fwrite(&fdb, sizeof(fdb), 1, fp2);
fwrite(&f_db, fdbhdr.recsize, 1, fp2);
/*
* Append the rest of the records
*/
while (fread(&file, sizeof(file), 1, fp1) == 1) {
if (strcmp(file.LName, fdb.LName) != 0)
fwrite(&file, sizeof(file), 1, fp2);
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(&fdb, sizeof(fdb), 1, fp2);
fwrite(&f_db, fdbhdr.recsize, 1, fp2);
fclose(fp1);
fclose(fp2);
@ -423,7 +424,7 @@ int AddFile(struct FILERecord fdb, int Area, char *DestPath, char *FromPath, cha
* Append file record
*/
fseek(fp1, 0, SEEK_END);
fwrite(&fdb, sizeof(fdb), 1, fp1);
fwrite(&f_db, fdbhdr.recsize, 1, fp1);
fclose(fp1);
}
}

View File

@ -9,7 +9,7 @@ void Help(void); /* Show help screen */
void Marker(void); /* Eyecatcher */
void DeleteVirusWork(void); /* Delete unarc directory */
int UnpackFile(char *File); /* Unpack archive */
int AddFile(struct FILERecord, int, char *, char *, char *);
int AddFile(struct FILE_record, int, char *, char *, char *);
int CheckFDB(int, char *); /* Check FDB of area */
int LoadAreaRec(int); /* Load Area record */

View File

@ -74,7 +74,6 @@ int ProcessTic(fa_list *sbl)
unsigned long crc, crc2, Kb;
sysconnect Link;
FILE *fp;
long FwdCost = 0, FwdSize = 0;
struct utimbuf ut;
int BBS_Imp = FALSE, DidBanner = FALSE;
faddr *p_from;
@ -314,63 +313,14 @@ int ProcessTic(fa_list *sbl)
}
}
/*
* Calculate the cost of this file
*/
T_File.Size = TIC.FileSize;
T_File.SizeKb = TIC.FileSize / 1024;
if ((fgroup.UnitCost) || (TIC.TicIn.Cost))
TIC.Charge = TRUE;
else
TIC.Charge = FALSE;
if (TIC.Charge) {
/*
* Calculate our filetransfer cost.
*/
FwdCost = fgroup.UnitCost;
FwdSize = fgroup.UnitSize;
/*
* If FwdSize <> 0 then calculate per size, else charge for each file.
*/
if (FwdSize)
TIC.FileCost = ((TIC.FileSize / 1024) / FwdSize) * FwdCost;
else
TIC.FileCost = FwdCost;
if (TIC.TicIn.Cost)
TIC.FileCost += TIC.TicIn.Cost;
if (fgroup.AddProm)
TIC.FileCost += (TIC.FileCost * fgroup.AddProm / 1000);
if (fgroup.DivideCost) {
/*
* If not a passthru area, we are a link too.
*/
if (DownLinks)
TIC.FileCost = TIC.FileCost / (DownLinks + 1);
}
/*
* At least charge one unit.
*/
if (!TIC.FileCost)
TIC.FileCost = 1;
Syslog('+', "The file cost will be %ld", TIC.FileCost);
}
/*
* Update the uplink's counters.
*/
Kb = TIC.FileSize / 1024;
if (SearchNode(TIC.Aka)) {
if (TIC.TicIn.Cost && nodes.Billing) {
nodes.Debet -= TIC.TicIn.Cost;
Syslog('f', "Uplink cost %ld, debet %ld", TIC.TicIn.Cost, nodes.Debet);
}
StatAdd(&nodes.FilesRcvd, 1L);
StatAdd(&nodes.F_KbRcvd, Kb);
UpdateNode();
@ -727,7 +677,6 @@ int ProcessTic(fa_list *sbl)
strncpy(T_File.Name, TIC.NewFile, 12);
strncpy(T_File.LName, TIC.NewFullName, 80);
T_File.Fdate = TIC.FileDate;
T_File.Cost = TIC.TicIn.Cost;
Add_ToBeRep();
}

View File

@ -59,23 +59,23 @@ int CheckFile(char *File, int iArea)
char *sFileArea;
sFileArea = calloc(PATH_MAX, sizeof(char));
sprintf(sFileArea,"%s/fdb/fdb%d.dta", getenv("MBSE_ROOT"), iArea);
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(&file, sizeof(file), 1, pFileB) == 1) {
if (((strcasecmp(file.Name, File)) == 0) || ((strcasecmp(file.LName, File)) == 0)) {
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);
@ -119,15 +119,14 @@ void File_List()
return;
}
while (fread(&file, sizeof(file), 1, pFile) == 1) {
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
memset(&T, 0, sizeof(T));
T.Area = iAreaNumber;
T.Active = FALSE;
T.Cost = file.Cost;
T.Size = file.Size;
strncpy(T.SFile, file.Name, 12);
strncpy(T.LFile, file.LName, 80);
T.Size = fdb.Size;
strncpy(T.SFile, fdb.Name, 12);
strncpy(T.LFile, fdb.LName, 80);
SetTag(T);
if (ShowOneFile() == 1) {
@ -135,18 +134,13 @@ void File_List()
return;
}
if (file.Deleted)
if (fdb.Deleted)
/* D E L E T E D */ /* Uploaded by: */
printf(" -- %-12s %s [%4ld] %s%s\n", file.Name, (char *) Language(239),
file.TimesDL, (char *) Language(238), file.Uploader);
if (file.Missing)
/* M I S S I N G */ /* Uploaded by: */
printf(" -- %-12s %s [%4ld] %s%s\n", file.Name, (char *) Language(240),
file.TimesDL, (char *) Language(238), file.Uploader);
printf(" -- %-12s %s [%4ld] %s%s\n", fdb.Name, (char *) Language(239),
fdb.TimesDL, (char *) Language(238), fdb.Uploader);
FileCount++; /* Increase File Counter by 1 */
FileBytes += file.Size; /* Increase File Byte Count */
FileBytes += fdb.Size; /* Increase File Byte Count */
}
Mark();
@ -205,26 +199,25 @@ void Download(void)
SetFileArea(Tag.Area);
/*
* Check password for selected file
* Check password for selected file FIXME: Where???
*/
memset(&file, 0, sizeof(file));
memset(&fdb, 0, sizeof(fdb));
if ((fp = OpenFileBase(Tag.Area, FALSE)) != NULL) {
while (fread(&file, sizeof(file), 1, fp) == 1) {
if (strcmp(file.LName, Tag.LFile) == 0)
while (fread(&fdb, fdbhdr.recsize, 1, fp) == 1) {
if (strcmp(fdb.LName, Tag.LFile) == 0)
break;
}
fclose(fp);
}
if (strcmp(file.LName, Tag.LFile) == 0) {
Syslog('b', "Found file %s in area %d", file.LName, Tag.Area);
if ((file.Deleted) || (file.Missing)) {
if (strcmp(fdb.LName, Tag.LFile) == 0) {
Syslog('b', "Found file %s in area %d", fdb.LName, Tag.Area);
if (fdb.Deleted) {
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(248));
/* Sorry that file is unavailable for download */
printf("%s (%s)\n", (char *) Language(248), file.LName);
printf("%s (%s)\n", (char *) Language(248), fdb.LName);
Tag.Active = FALSE;
Syslog('+', "File %s in area %d unavailable for download, %s",
file.LName, Tag.Area, file.Deleted?"deleted":"missing");
Syslog('+', "File %s in area %d unavailable for download, deleted", fdb.LName, Tag.Area);
}
}
@ -237,10 +230,10 @@ void Download(void)
*/
sprintf(symTo, "./tag/filedesc.%ld", exitinfo.Downloads % 256);
if ((fd = fopen(symTo, "a")) != NULL) {
fprintf(fd, "%s (%s)\r\n", file.LName, file.Name);
fprintf(fd, "%s (%s)\r\n", fdb.LName, fdb.Name);
for (i = 0; i < 25; i++) {
if (strlen(file.Desc[i]) > 1)
fprintf(fd, " %s\r\n", file.Desc[i]);
if (strlen(fdb.Desc[i]) > 1)
fprintf(fd, " %s\r\n", fdb.Desc[i]);
}
fprintf(fd, "\r\n");
fclose(fd);
@ -287,9 +280,9 @@ void Download(void)
* Count file and sizes.
*/
Count++;
Size += file.Size;
if ((!file.Free) && (!area.Free))
CostSize += file.Size;
Size += fdb.Size;
if (!area.Free)
CostSize += fdb.Size;
}
}
}
@ -437,15 +430,15 @@ void Download(void)
*/
SetFileArea(Tag.Area);
if ((fp = OpenFileBase(Tag.Area, TRUE)) != NULL) {
while (fread(&file, sizeof(file), 1, fp) == 1) {
if (strcmp(file.LName, Tag.LFile) == 0)
while (fread(&fdb, fdbhdr.recsize, 1, fp) == 1) {
if (strcmp(fdb.LName, Tag.LFile) == 0)
break;
}
Size += file.Size;
file.TimesDL++;
file.LastDL = time(NULL);
fseek(fp, - sizeof(file), SEEK_CUR);
fwrite(&file, sizeof(file), 1, fp);
Size += fdb.Size;
fdb.TimesDL++;
fdb.LastDL = time(NULL);
fseek(fp, - fdbhdr.recsize, SEEK_CUR);
fwrite(&fdb, fdbhdr.recsize, 1, fp);
fclose(fp);
Count++;
}
@ -572,10 +565,7 @@ int KeywordScan()
{
FILE *pAreas, *pFile;
int i, z, y, Found, Count = 0;
char *Name;
char *tmpname;
char *BigDesc;
char temp[81];
char *Name, *tmpname, *BigDesc, temp[81];
_Tag T;
unsigned long OldArea;
@ -615,9 +605,6 @@ int KeywordScan()
Enter(1);
InitTag();
for(i = 0; i < 25; i++)
sprintf(BigDesc, "%s%s", BigDesc, *(file.Desc + i));
if ((pAreas = OpenFareas(FALSE)) == NULL)
return 0;
@ -631,12 +618,12 @@ int KeywordScan()
Found = FALSE;
Sheader();
while (fread(&file, sizeof(file), 1, pFile) == 1) {
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
for (i = 0; i < 25; i++)
sprintf(BigDesc, "%s%s", BigDesc, *(file.Desc + i));
sprintf(BigDesc, "%s%s", BigDesc, *(fdb.Desc + i));
if ((strstr(file.Name,Name) != NULL) || (strstr(tl(BigDesc), Name) != NULL)) {
if ((strstr(fdb.Name,Name) != NULL) || (strstr(tl(BigDesc), Name) != NULL)) {
if (!Found) {
Enter(2);
@ -653,10 +640,9 @@ int KeywordScan()
memset(&T, 0, sizeof(T));
T.Area = arecno;
T.Active = FALSE;
T.Cost = file.Cost;
T.Size = file.Size;
strncpy(T.SFile, file.Name, 12);
strncpy(T.LFile, file.LName, 80);
T.Size = fdb.Size;
strncpy(T.SFile, fdb.Name, 12);
strncpy(T.LFile, fdb.LName, 80);
SetTag(T);
Count++;
if (ShowOneFile() == 1) {
@ -779,9 +765,9 @@ int FilenameScan()
Sheader();
Nopper();
while (fread(&file, sizeof(file), 1, pFile) == 1) {
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
if (re_exec(file.Name) || re_exec(file.LName)) {
if (re_exec(fdb.Name) || re_exec(fdb.LName)) {
if (!Found) {
Enter(2);
if (iLC(2) == 1) {
@ -794,10 +780,9 @@ int FilenameScan()
memset(&T, 0, sizeof(T));
T.Area = arecno;
T.Active = FALSE;
T.Cost = file.Cost;
T.Size = file.Size;
strncpy(T.SFile, file.Name, 12);
strncpy(T.LFile, file.LName, 81);
T.Size = fdb.Size;
strncpy(T.SFile, fdb.Name, 12);
strncpy(T.LFile, fdb.LName, 81);
SetTag(T);
Count++;
if (ShowOneFile() == 1) {
@ -904,8 +889,8 @@ int NewfileScan(int AskStart)
Found = FALSE;
Nopper();
while (fread(&file, sizeof(file), 1, pFile) == 1) {
strcpy(temp, StrDateDMY(file.UploadDate)); /* Realloc Space for Date */
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
strcpy(temp, StrDateDMY(fdb.UploadDate)); /* Realloc Space for Date */
Date[0] = temp[6]; /* Swap the date around */
Date[1] = temp[7]; /* Instead of DD-MM-YYYY */
Date[2] = temp[8]; /* Let it equal YYYYMMDD */
@ -934,10 +919,9 @@ int NewfileScan(int AskStart)
memset(&T, 0, sizeof(T));
T.Area = arecno;
T.Active = FALSE;
T.Cost = file.Cost;
T.Size = file.Size;
strncpy(T.SFile, file.Name, 12);
strncpy(T.LFile, file.LName, 80);
T.Size = fdb.Size;
strncpy(T.SFile, fdb.Name, 12);
strncpy(T.LFile, fdb.LName, 80);
SetTag(T);
Count++;
@ -2045,18 +2029,18 @@ void Copy_Home()
return;
}
while (fread(&file, sizeof(file), 1, pFile) == 1) {
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
if ((strcasecmp(File, file.Name) == 0) || (strcasecmp(File, file.LName) == 0)) {
if ((strcasecmp(File, fdb.Name) == 0) || (strcasecmp(File, fdb.LName) == 0)) {
Found = TRUE;
if (((file.Size + Quota()) > (CFG.iQuota * 1048576))) {
if (((fdb.Size + Quota()) > (CFG.iQuota * 1048576))) {
colour(CFG.HiliteF, CFG.HiliteB);
/* You have not enough diskspace free to copy this file */
printf("%s\n", (char *) Language(279));
Syslog('+', "Copy homedir, not enough quota");
} else {
sprintf(temp1, "%s/%s", area.Path, file.LName); /* Use real longname here */
sprintf(temp1, "%s/%s", area.Path, fdb.LName); /* Use real longname here */
sprintf(temp2, "%s/%s/wrk/%s", CFG.bbs_usersdir, exitinfo.Name, File);
colour(CFG.TextColourF, CFG.TextColourB);
/* Start copy: */
@ -2289,8 +2273,8 @@ void ViewFile(char *name)
return;
}
while (fread(&file, sizeof(file), 1, pFile) == 1) {
if (((strcasecmp(File, file.Name) == 0) || (strcasecmp(File, file.LName) == 0)) && (!file.Deleted) && (!file.Missing)) {
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
if (((strcasecmp(File, fdb.Name) == 0) || (strcasecmp(File, fdb.LName) == 0)) && (!fdb.Deleted)) {
found = TRUE;
break;
}
@ -2306,9 +2290,9 @@ void ViewFile(char *name)
return;
}
sprintf(File, "%s/%s", sAreaPath, file.LName);
sprintf(File, "%s/%s", sAreaPath, fdb.LName);
arc = GetFileType(File);
Syslog('+', "File to view: %s, type %s", file.LName, printable(arc, 0));
Syslog('+', "File to view: %s, type %s", fdb.LName, printable(arc, 0));
if (arc != NULL) {
found = FALSE;

View File

@ -151,7 +151,7 @@ void GetstrD(char *sStr, int iMaxlen)
/*
* Open FileDataBase.
* Open FileDataBase, the filepointer is at the begin of the first record.
*/
FILE *OpenFileBase(unsigned long Area, int Write)
{
@ -159,7 +159,7 @@ FILE *OpenFileBase(unsigned long Area, int Write)
char *FileBase;
FileBase = calloc(PATH_MAX, sizeof(char));
sprintf(FileBase,"%s/fdb/fdb%ld.data", getenv("MBSE_ROOT"), Area);
sprintf(FileBase,"%s/fdb/file%ld.data", getenv("MBSE_ROOT"), Area);
if (Write)
pFile = fopen(FileBase, "r+");
@ -172,6 +172,8 @@ FILE *OpenFileBase(unsigned long Area, int Write)
printf("%s\n\n", (char *) Language(237));
sleep(2);
}
fread(&fdbhdr, sizeof(fdbhdr), 1, pFile);
free(FileBase);
return pFile;
}
@ -408,48 +410,48 @@ int ShowOneFile()
{
int y, z, fg, bg;
if ((!file.Deleted) && (!file.Missing)) {
if (!fdb.Deleted) {
colour(7, 0);
printf(" %02d ", Tagnr);
colour(CFG.FilenameF, CFG.FilenameB);
printf("%-12s", file.Name);
printf("%-12s", fdb.Name);
colour(CFG.FilesizeF, CFG.FilesizeB);
printf("%10lu ", (long)(file.Size));
printf("%10lu ", (long)(fdb.Size));
colour(CFG.FiledateF, CFG.FiledateB);
printf("%-10s ", StrDateDMY(file.UploadDate));
printf("%-10s ", StrDateDMY(fdb.UploadDate));
colour(12, 0);
printf("[%4ld] ", file.TimesDL);
printf("[%4ld] ", fdb.TimesDL);
if ((strcmp(file.Uploader, "")) == 0)
strcpy(file.Uploader, "SysOp");
if ((strcmp(fdb.Uploader, "")) == 0)
strcpy(fdb.Uploader, "SysOp");
colour(CFG.HiliteF, CFG.HiliteB);
printf("%s%s\n", (char *) Language(238), file.Uploader);
printf("%s%s\n", (char *) Language(238), fdb.Uploader);
if (iLC(1) == 1)
return 1;
for (z = 0; z <= 25; z++) {
if ((y = strlen(file.Desc[z])) > 1) {
if ((file.Desc[z][0] == '@') && (file.Desc[z][1] == 'X')) {
for (z = 0; z < 25; z++) {
if ((y = strlen(fdb.Desc[z])) > 1) {
if ((fdb.Desc[z][0] == '@') && (fdb.Desc[z][1] == 'X')) {
/*
* Color formatted description lines.
*/
if (file.Desc[z][3] > '9')
fg = (int)file.Desc[z][3] - 55;
if (fdb.Desc[z][3] > '9')
fg = (int)fdb.Desc[z][3] - 55;
else
fg = (int)file.Desc[z][3] - 48;
bg = (int)file.Desc[z][2] - 48;
fg = (int)fdb.Desc[z][3] - 48;
bg = (int)fdb.Desc[z][2] - 48;
colour(fg, bg);
printf(" %s\n",file.Desc[z]+4);
printf(" %s\n",fdb.Desc[z]+4);
} else {
colour(CFG.FiledescF, CFG.FiledescB);
printf(" %s\n",file.Desc[z]);
printf(" %s\n",fdb.Desc[z]);
}
if (iLC(1) == 1)
@ -850,18 +852,18 @@ int Addfile(char *File, int AreaNum, int fileid)
return FALSE;
}
memset(&file, 0, sizeof(file));
strcpy(file.LName, File);
memset(&fdb, 0, fdbhdr.recsize);
strcpy(fdb.LName, File);
strcpy(temp1, File);
name_mangle(temp1);
strcpy(file.Name, temp1);
file.Size = (long)(statfile.st_size);
file.FileDate = statfile.st_mtime;
file.Crc32 = file_crc(Filename, TRUE);
strcpy(file.Uploader, exitinfo.sUserName);
file.UploadDate = time(NULL);
if (strcmp(file.Name, file.LName)) {
sprintf(lname, "%s/%s", area.Path, file.Name);
strcpy(fdb.Name, temp1);
fdb.Size = (long)(statfile.st_size);
fdb.FileDate = statfile.st_mtime;
fdb.Crc32 = file_crc(Filename, TRUE);
strcpy(fdb.Uploader, exitinfo.sUserName);
fdb.UploadDate = time(NULL);
if (strcmp(fdb.Name, fdb.LName)) {
sprintf(lname, "%s/%s", area.Path, fdb.Name);
if (symlink(Filename, lname)) {
WriteError("$Can't create link %s to %s", lname, Filename);
}
@ -882,7 +884,7 @@ int Addfile(char *File, int AreaNum, int fileid)
printf("%s", (char *) Language(8));
fflush(stdout);
fflush(stdin);
GetstrC(file.Password, 20);
GetstrC(fdb.Password, 20);
}
}
@ -924,7 +926,7 @@ int Addfile(char *File, int AreaNum, int fileid)
*/
GotId = FALSE;
for (i = 0; i < 25; i++)
file.Desc[i][0] = '\0';
fdb.Desc[i][0] = '\0';
lines = 0;
Syslog('!', "Trashing illegal formatted FILE_ID.DIZ");
break;
@ -933,7 +935,7 @@ int Addfile(char *File, int AreaNum, int fileid)
j = 0;
for (i = 0; i < strlen(temp1); i++) {
if (isprint(temp1[i])) {
file.Desc[lines][j] = temp1[i];
fdb.Desc[lines][j] = temp1[i];
j++;
if (j > 47)
break;
@ -943,9 +945,9 @@ int Addfile(char *File, int AreaNum, int fileid)
/*
* Remove trailing spaces
*/
while (j && isspace(file.Desc[lines][j-1]))
while (j && isspace(fdb.Desc[lines][j-1]))
j--;
file.Desc[lines][j] = '\0';
fdb.Desc[lines][j] = '\0';
lines++;
}
}
@ -957,8 +959,8 @@ int Addfile(char *File, int AreaNum, int fileid)
/*
* Strip empty FILE_ID.DIZ lines at the end
*/
while ((strlen(file.Desc[lines-1]) == 0) && (lines)) {
file.Desc[lines-1][0] = '\0';
while ((strlen(fdb.Desc[lines-1]) == 0) && (lines)) {
fdb.Desc[lines-1][0] = '\0';
lines--;
}
if (lines) {
@ -1002,14 +1004,14 @@ int Addfile(char *File, int AreaNum, int fileid)
}
for (i = 1; i < iDesc; i++)
strcpy(file.Desc[i - 1], Desc[i]);
strcpy(fdb.Desc[i - 1], Desc[i]);
for (i = 0; i < 26; i++)
free(Desc[i]);
}
fseek(pFileDB, 0, SEEK_END);
fwrite(&file, sizeof(file), 1, pFileDB);
fwrite(&fdb, fdbhdr.recsize, 1, pFileDB);
fclose(pFileDB);
sprintf(temp, "%s/log/uploads.log", getenv("MBSE_ROOT"));
@ -1018,13 +1020,13 @@ int Addfile(char *File, int AreaNum, int fileid)
else {
iPrivate = TRUE;
fprintf(pPrivate, "****************************************************");
fprintf(pPrivate, "\nUser : %s", file.Uploader);
fprintf(pPrivate, "\nFile : %s (%s)", file.LName, file.Name);
fprintf(pPrivate, "\nSize : %lu", (long)(file.Size));
fprintf(pPrivate, "\nUpload Date : %s\n\n", StrDateDMY(file.UploadDate));
fprintf(pPrivate, "\nUser : %s", fdb.Uploader);
fprintf(pPrivate, "\nFile : %s (%s)", fdb.LName, fdb.Name);
fprintf(pPrivate, "\nSize : %lu", (long)(fdb.Size));
fprintf(pPrivate, "\nUpload Date : %s\n\n", StrDateDMY(fdb.UploadDate));
for (i = 0; i < iDesc - 1; i++)
fprintf(pPrivate, "%2d: %s\n", i, file.Desc[i]);
fprintf(pPrivate, "%2d: %s\n", i, fdb.Desc[i]);
fclose(pPrivate);
}

View File

@ -332,14 +332,15 @@ void Masterlist()
if (area.Available && (area.LTSec.level <= CFG.security.level)) {
Nopper();
sprintf(fAreas, "%s/fdb/fdb%d.data", getenv("MBSE_ROOT"), AreaNr);
sprintf(fAreas, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), AreaNr);
if ((pFile = fopen (fAreas, "r")) == NULL) {
WriteError("$Can't open Area %d (%s)! Skipping ...", AreaNr, area.Name);
} else {
fread(&fdbhdr, sizeof(fdbhdr), 1, pFile);
popdown = 0;
while (fread(&file, sizeof(file), 1, pFile) == 1) {
if ((!file.Deleted) && (!file.Missing)) {
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
if (!fdb.Deleted) {
/*
* The next is to reduce system load.
*/
@ -348,16 +349,16 @@ void Masterlist()
msleep(1);
AllFiles++;
AllAreaFiles++;
AllAreaBytes += file.Size;
down = file.TimesDL + file.TimesFTP + file.TimesReq;
AllAreaBytes += fdb.Size;
down = fdb.TimesDL;
if (down > popdown) {
popdown = down;
sprintf(pop, "%s", file.Name);
sprintf(pop, "%s", fdb.Name);
}
if (((t_start - file.UploadDate) / 84400) <= CFG.newdays) {
if (((t_start - fdb.UploadDate) / 84400) <= CFG.newdays) {
NewFiles++;
NewAreaFiles++;
NewAreaBytes += file.Size;
NewAreaBytes += fdb.Size;
}
}
}
@ -392,28 +393,27 @@ void Masterlist()
BotBox(fp, TRUE);
BotBox(np, NewAreaFiles);
fseek(pFile, 0, SEEK_SET);
while (fread(&file, sizeof(file), 1, pFile) == 1) {
if((!file.Deleted) && (!file.Missing)) {
New = (((t_start - file.UploadDate) / 84400) <= CFG.newdays);
fseek(pFile, fdbhdr.hdrsize, SEEK_SET);
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
if (!fdb.Deleted) {
New = (((t_start - fdb.UploadDate) / 84400) <= CFG.newdays);
sprintf(temp, "%-12s%10lu K %s [%04ld] Uploader: %s",
file.Name, (long)(file.Size / 1024), StrDateDMY(file.UploadDate),
file.TimesDL + file.TimesFTP + file.TimesReq,
strlen(file.Uploader)?file.Uploader:"");
fdb.Name, (long)(fdb.Size / 1024), StrDateDMY(fdb.UploadDate), fdb.TimesDL,
strlen(fdb.Uploader)?fdb.Uploader:"");
fprintf(fp, "%s\r\n", temp);
if (New)
fprintf(np, "%s\r\n", temp);
for (z = 0; z <= 25; z++) {
if (strlen(file.Desc[z])) {
if ((file.Desc[z][0] == '@') && (file.Desc[z][1] == 'X')) {
fprintf(fp, " %s\r\n",file.Desc[z]+4);
if (strlen(fdb.Desc[z])) {
if ((fdb.Desc[z][0] == '@') && (fdb.Desc[z][1] == 'X')) {
fprintf(fp, " %s\r\n",fdb.Desc[z]+4);
if (New)
fprintf(np, " %s\r\n",file.Desc[z]+4);
fprintf(np, " %s\r\n",fdb.Desc[z]+4);
} else {
fprintf(fp, " %s\r\n",file.Desc[z]);
fprintf(fp, " %s\r\n",fdb.Desc[z]);
if (New)
fprintf(np, " %s\r\n",file.Desc[z]);
fprintf(np, " %s\r\n",fdb.Desc[z]);
}
}
}

View File

@ -68,7 +68,6 @@ int main(int argc, char **argv)
printf("From system %s\n", rep.From);
printf("Replace %s\n", rep.Replace);
printf("Magic %s\n", rep.Magic);
printf("Cost %ld\n", rep.Cost);
printf("Announce ");
if (rep.Announce)
printf("yes\n");

View File

@ -232,9 +232,8 @@ void FileScreen(void)
mvprintw(12,59, "21. DL days");
mvprintw(13,59, "22. FD days");
mvprintw(14,59, "23. Move area");
mvprintw(15,59, "24. Cost");
mvprintw(16,59, "25. Archiver");
mvprintw(17,59, "26. Upload");
mvprintw(15,59, "24. Archiver");
mvprintw(16,59, "25. Upload");
}
@ -303,11 +302,10 @@ int EditFileRec(int Area)
show_int(12,73, area.DLdays);
show_int(13,73, area.FDdays);
show_int(14,73, area.MoveArea);
show_int(15,73, area.Cost);
show_str(16,73, 5, area.Archiver);
show_int(17,73, area.Upload);
show_str(15,73, 5, area.Archiver);
show_int(16,73, area.Upload);
switch(select_menu(26)) {
switch(select_menu(25)) {
case 0: crc1 = 0xffffffff;
crc1 = upd_crc32((char *)&area, crc1, areahdr.recsize);
if (crc != crc1) {
@ -366,14 +364,15 @@ int EditFileRec(int Area)
case 6: E_STR( 11,16,64, area.FilesBbs, "The path and name of \"files.bbs\" if area is on CDROM")
case 7: Available = edit_bool(12, 16, area.Available, (char *)"Is this area ^available^");
temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/fdb/fdb%d.data", getenv("MBSE_ROOT"), Area);
sprintf(temp, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), Area);
if (area.Available && !Available) {
/*
* Attempt to disable this area, but check first.
*/
if ((fp = fopen(temp, "r"))) {
fread(&fdbhdr, sizeof(fdbhdr), 1, fp);
fseek(fp, 0, SEEK_END);
files = ftell(fp) / sizeof(file);
files = ((ftell(fp) - fdbhdr.hdrsize) / fdbhdr.recsize);
if (files) {
errmsg("There are stil %d files in this area", files);
Available = TRUE;
@ -444,11 +443,10 @@ int EditFileRec(int Area)
case 21:E_INT( 12,73, area.DLdays, "The not ^downloaded days^ to move/kill files")
case 22:E_INT( 13,73, area.FDdays, "The ^file age^ in days to move/kill files")
case 23:E_INT( 14,73, area.MoveArea, "The ^area to move^ files to, 0 is kill")
case 24:E_INT( 15,73, area.Cost, "The ^cost^ to download a file")
case 25:strcpy(area.Archiver, PickArchive((char *)"8.4"));
case 24:strcpy(area.Archiver, PickArchive((char *)"8.4"));
FileScreen();
break;
case 26:E_INT( 17,73, area.Upload, "The ^upload^ area, 0 if upload in this area")
case 25:E_INT( 16,73, area.Upload, "The ^upload^ area, 0 if upload in this area")
}
}
}

View File

@ -54,18 +54,15 @@ void FHeader(void)
mvprintw(10, 2, " FileDate");
mvprintw(11, 2, " Last DL.");
mvprintw(12, 2, " Upl.Date");
mvprintw(13, 2, "1. Uploader");
mvprintw(14, 2, "2. Times DL");
mvprintw(15, 2, "3. Times FTP");
mvprintw(16, 2, "4. Times Req");
mvprintw(17, 2, "5. Password");
mvprintw(18, 2, "6. Cost");
mvprintw(13, 2, " TIC area");
mvprintw(14, 2, " Magic");
mvprintw(15, 2, "1. Uploader");
mvprintw(16, 2, "2. Times DL");
mvprintw(17, 2, "3. Password");
mvprintw(14,42, "7. Free");
mvprintw(15,42, "8. Deleted");
mvprintw(16,42, " Missing");
mvprintw(17,42, "9. No Kill");
mvprintw(18,42, "10. Announced");
mvprintw(15,61, "4. Deleted");
mvprintw(16,61, "5. No Kill");
mvprintw(17,61, "6. Announced");
}
@ -76,37 +73,30 @@ void EditFile()
for (;;) {
set_color(WHITE, BLACK);
show_str( 7,16,12, file.Name);
show_str( 8,16,64, file.LName);
show_int( 9,16, file.Size);
mvprintw(10,16, (char *)"%s %s", StrDateDMY(file.FileDate), StrTimeHM(file.FileDate));
mvprintw(11,16, (char *)"%s %s", StrDateDMY(file.LastDL), StrTimeHM(file.LastDL));
mvprintw(12,16, (char *)"%s %s", StrDateDMY(file.UploadDate), StrTimeHM(file.UploadDate));
show_str(13,16,36, file.Uploader);
show_int(14,16, file.TimesDL);
show_int(15,16, file.TimesFTP);
show_int(16,16, file.TimesReq);
show_str(17,16,15, file.Password);
show_int(18,16, file.Cost);
show_str( 7,16,12, fdb.Name);
show_str( 8,16,64, fdb.LName);
show_int( 9,16, fdb.Size);
mvprintw(10,16, (char *)"%s %s", StrDateDMY(fdb.FileDate), StrTimeHM(fdb.FileDate));
mvprintw(11,16, (char *)"%s %s", StrDateDMY(fdb.LastDL), StrTimeHM(fdb.LastDL));
mvprintw(12,16, (char *)"%s %s", StrDateDMY(fdb.UploadDate), StrTimeHM(fdb.UploadDate));
show_str(13,16,20, fdb.TicArea);
show_str(14,16,20, fdb.Magic);
show_str(15,16,36, fdb.Uploader);
show_int(16,16, fdb.TimesDL);
show_str(17,16,15, fdb.Password);
show_bool(14,56, file.Free);
show_bool(15,56, file.Deleted);
show_bool(16,56, file.Missing);
show_bool(17,56, file.NoKill);
show_bool(18,56, file.Announced);
show_bool(15,75, fdb.Deleted);
show_bool(16,75, fdb.NoKill);
show_bool(17,75, fdb.Announced);
switch(select_menu(10)) {
switch(select_menu(6)) {
case 0: return;
case 1: E_STR( 13,16,35, file.Uploader, "The ^uploader^ of this file")
case 2: E_INT( 14,16, file.TimesDL, "The number of times file is sent with ^download^")
case 3: E_INT( 15,16, file.TimesFTP, "The number of times file is sent with ^FTP or WWW^")
case 4: E_INT( 16,16, file.TimesReq, "The number of times file is sent with ^filerequest^")
case 5: E_STR( 17,16,15, file.Password, "The ^password^ to protect this file with")
case 6: E_INT( 18,16, file.Cost, "The ^cost^ of this file")
case 7: E_BOOL(14,56, file.Free, "If this file is a ^free^ download")
case 8: E_BOOL(15,56, file.Deleted, "Should this this file be ^deleted^")
case 9: E_BOOL(17,56, file.NoKill, "File can't be ^killed^ automatic")
case 10:E_BOOL(18,56, file.Announced, "File is ^announced^ as new file")
case 1: E_STR( 15,16,35, fdb.Uploader, "The ^uploader^ of this file")
case 2: E_INT( 16,16, fdb.TimesDL, "The number of times file is sent with ^download^")
case 3: E_STR( 17,16,15, fdb.Password, "The ^password^ to protect this file with")
case 4: E_BOOL(15,75, fdb.Deleted, "Should this this file be ^deleted^")
case 5: E_BOOL(16,75, fdb.NoKill, "File can't be ^killed^ automatic")
case 6: E_BOOL(17,75, fdb.Announced, "File is ^announced^ as new file")
}
}
}
@ -126,7 +116,7 @@ void E_F(long areanr)
clr_index();
sprintf(temp, "%s/fdb/fdb%ld.data", getenv("MBSE_ROOT"), areanr);
sprintf(temp, "%s/fdb/file%ld.data", getenv("MBSE_ROOT"), areanr);
if ((fil = fopen(temp, "r+")) == NULL) {
working(2, 0, 0);
return;
@ -134,8 +124,9 @@ void E_F(long areanr)
if (! check_free())
return;
fread(&fdbhdr, sizeof(fdbhdr), 1, fil);
fseek(fil, 0, SEEK_END);
records = ftell(fil) / sizeof(file);
records = ((ftell(fil) - fdbhdr.hdrsize) / fdbhdr.recsize);
o = 0;
for (;;) {
@ -154,41 +145,41 @@ void E_F(long areanr)
for (i = 1; i <= 10; i++) {
if ((o + i) <= records) {
offset = ((o + i) - 1) * sizeof(file);
offset = (((o + i) - 1) * fdbhdr.recsize) + fdbhdr.hdrsize;
fseek(fil, offset, SEEK_SET);
fread(&file, sizeof(file), 1, fil);
fread(&fdb, fdbhdr.recsize, 1, fil);
set_color(WHITE, BLACK);
mvprintw(y, 1, (char *)"%4d.", o + i);
sprintf(temp, "%s/%s", area.Path, file.LName);
sprintf(temp, "%s/%s", area.Path, fdb.LName);
Ondisk = ((stat(temp, &statfile)) != -1);
if (file.Deleted)
if (fdb.Deleted)
set_color(LIGHTBLUE, BLACK);
else if (Ondisk)
set_color(CYAN, BLACK);
else
set_color(LIGHTRED, BLACK);
mvprintw(y, 8, (char *)"%-14s", file.Name);
mvprintw(y, 8, (char *)"%-14s", fdb.Name);
if (Ondisk) {
if (file.Size == statfile.st_size)
if (fdb.Size == statfile.st_size)
set_color(CYAN, BLACK);
else
set_color(LIGHTRED, BLACK);
mvprintw(y,23, (char *)"%8ld", file.Size);
mvprintw(y,23, (char *)"%8ld", fdb.Size);
if (file.FileDate == statfile.st_mtime)
if (fdb.FileDate == statfile.st_mtime)
set_color(CYAN, BLACK);
else
set_color(LIGHTRED, BLACK);
Time = file.FileDate;
Time = fdb.FileDate;
mvprintw(y,32, (char *)"%s %s", StrDateDMY(Time), StrTimeHM(Time));
}
set_color(CYAN, BLACK);
sprintf(temp, "%s", file.Desc[0]);
sprintf(temp, "%s", fdb.Desc[0]);
temp[30] = '\0';
mvprintw(y,49, (char *)"%s", temp);
y++;
@ -234,26 +225,23 @@ void E_F(long areanr)
if ((atoi(menu) > 0) && (atoi(menu) <= records)) {
working(1, 0, 0);
offset = (atoi(menu) - 1) * sizeof(file);
offset = ((atoi(menu) - 1) * fdbhdr.recsize) + fdbhdr.hdrsize;
fseek(fil, offset, SEEK_SET);
fread(&file, sizeof(file), 1, fil);
fread(&fdb, fdbhdr.recsize, 1, fil);
crc = 0xffffffff;
crc = upd_crc32((char *)&file, crc, sizeof(file));
sprintf(temp, "%s/%s", area.Path, file.LName);
if (stat(temp, &statfile) == -1)
file.Missing = TRUE;
crc = upd_crc32((char *)&fdb, crc, fdbhdr.recsize);
sprintf(temp, "%s/%s", area.Path, fdb.LName);
EditFile();
crc1 = 0xffffffff;
crc1 = upd_crc32((char *)&file, crc1, sizeof(file));
crc1 = upd_crc32((char *)&fdb, crc1, fdbhdr.recsize);
if (crc != crc1) {
if (yes_no((char *)"Record is changed, save") == 1) {
working(1, 0, 0);
fseek(fil, offset, SEEK_SET);
fwrite(&file, sizeof(file), 1, fil);
fwrite(&fdb, fdbhdr.recsize, 1, fil);
working(6, 0, 0);
}
}
@ -354,3 +342,118 @@ void EditFDB()
}
/*
* Init files database. Since version 0.51.2 the format is changed.
* Check this and automagic upgrade the database.
*/
void InitFDB(void)
{
int records, i;
long Area = 0;
char *temp, Magic[21];
FILE *fp1, *fp2, *fil, *ft, *fp;
DIR *dp;
struct dirent *de;
struct OldFILERecord old;
struct stat sb;
records = CountFilearea();
if (records <= 0)
return;
temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/etc/fareas.data", getenv("MBSE_ROOT"));
if ((fil = fopen(temp, "r")) != NULL) {
fread(&areahdr, sizeof(areahdr), 1, fil);
while (fread(&area, areahdr.recsize, 1, fil)) {
Area++;
if (area.Available) {
sprintf(temp, "%s/fdb/fdb%ld.data", getenv("MBSE_ROOT"), Area);
if ((fp1 = fopen(temp, "r")) != NULL) {
/*
* Old area available, upgrade.
*/
sprintf(temp, "%s/fdb/file%ld.data", getenv("MBSE_ROOT"), Area);
if ((fp2 = fopen(temp, "w+")) == NULL) {
WriteError("$Can't create %s", temp);
} else {
fdbhdr.hdrsize = sizeof(fdbhdr);
fdbhdr.recsize = sizeof(fdb);
fwrite(&fdbhdr, sizeof(fdbhdr), 1, fp2);
while (fread(&old, sizeof(old), 1, fp1)) {
Nopper();
memset(&fdb, 0, fdbhdr.recsize);
strncpy(fdb.Name, old.Name, sizeof(fdb.Name) -1);
strncpy(fdb.LName, old.LName, sizeof(fdb.LName) -1);
sprintf(temp, "%s/etc/tic.data", getenv("MBSE_ROOT"));
if ((ft = fopen(temp, "r")) != NULL) {
fread(&tichdr, sizeof(tichdr), 1, ft);
while (fread(&tic, tichdr.recsize, 1, ft)) {
if (StringCRC32(tic.Name) == old.TicAreaCRC) {
strncpy(fdb.TicArea, tic.Name, sizeof(fdb.TicArea) -1);
break;
}
fseek(ft, tichdr.syssize, SEEK_CUR);
}
fclose(ft);
}
fdb.Size = old.Size;
fdb.Crc32 = old.Crc32;
strncpy(fdb.Uploader, old.Uploader, sizeof(fdb.Uploader) -1);
fdb.UploadDate = old.UploadDate;
fdb.FileDate = old.FileDate;
fdb.LastDL = old.LastDL;
fdb.TimesDL = old.TimesDL + old.TimesFTP + old.TimesReq;
strncpy(fdb.Password, old.Password, sizeof(fdb.Password) -1);
for (i = 0; i < 25; i++)
strncpy(fdb.Desc[i], old.Desc[i], 48);
/*
* Search the magic directory to see if this file is a magic file.
*/
sprintf(temp, "%s/magic", getenv("MBSE_ROOT"));
if ((dp = opendir(temp)) != NULL) {
while ((de = readdir(dp))) {
if (de->d_name[0] != '.') {
sprintf(temp, "%s/magic/%s", getenv("MBSE_ROOT"), de->d_name);
/*
* Only regular files without execute permission are magic requests.
*/
if ((lstat(temp, &sb) != -1) && (S_ISREG(sb.st_mode)) && (! (sb.st_mode & S_IXUSR))) {
if ((fp = fopen(temp, "r"))) {
fgets(Magic, sizeof(Magic) -1, fp);
Striplf(Magic);
if ((strcasecmp(Magic, fdb.Name) == 0) || (strcasecmp(Magic, fdb.LName) == 0)) {
strncpy(fdb.Magic, de->d_name, sizeof(fdb.Magic) -1);
}
fclose(fp);
}
}
}
}
closedir(dp);
}
fdb.Deleted = old.Deleted;
fdb.NoKill = old.NoKill;
fdb.Announced = old.Announced;
fdb.Double = old.Double;
fwrite(&fdb, fdbhdr.recsize, 1, fp2);
}
fclose(fp2);
Syslog('+', "Upgraded file area database %d", Area);
}
fclose(fp1);
sprintf(temp, "%s/fdb/fdb%ld.data", getenv("MBSE_ROOT"), Area);
unlink(temp);
}
}
}
fclose(fil);
}
free(temp);
}

View File

@ -1,7 +1,10 @@
#ifndef _M_FDB_H
#define _M_FDB_H
/* $Id$ */
void EditFDB(void);
void InitFDB(void);
#endif

View File

@ -219,7 +219,6 @@ int AppendFGroup(void)
if ((fil = fopen(ffile, "a")) != NULL) {
memset(&fgroup, 0, sizeof(fgroup));
fgroup.StartDate = time(NULL);
fgroup.DivideCost = TRUE;
fgroup.FileGate = TRUE;
fgroup.Secure = TRUE;
fgroup.VirScan = TRUE;
@ -280,28 +279,24 @@ void FgScreen(void)
mvprintw(18, 2, "13. Deleted");
mvprintw(19, 2, "14. Start at");
mvprintw(11,32, "15. Unit Cost");
mvprintw(12,32, "16. Unit Size");
mvprintw(13,32, "17. Add Prom.");
mvprintw(14,32, "18. Divide");
mvprintw(15,32, "19. Auto chng");
mvprintw(16,32, "20. User chng");
mvprintw(17,32, "21. Replace");
mvprintw(18,32, "22. Dupecheck");
mvprintw(19,32, "23. Secure");
mvprintw(12,32, "15. Auto chng");
mvprintw(13,32, "16. User chng");
mvprintw(14,32, "17. Replace");
mvprintw(15,32, "18. Dupecheck");
mvprintw(16,32, "19. Secure");
mvprintw(17,32, "20. Touch");
mvprintw(18,32, "21. Virscan");
mvprintw(19,32, "22. Announce");
mvprintw( 9,56, "24. Touch");
mvprintw(10,56, "25. Virscan");
mvprintw(11,56, "26. Announce");
mvprintw(12,56, "27. Upd magic");
mvprintw(13,56, "28. File ID");
mvprintw(14,56, "29. Conv. all");
mvprintw(15,56, "30. Send orig");
mvprintw(16,56, "31. DL sec");
mvprintw(17,56, "32. UP sec");
mvprintw(18,56, "33. LT sec");
mvprintw(19,56, "34. Upl. area");
mvprintw(20,56, "35. Link sec");
mvprintw(11,56, "23. Upd magic");
mvprintw(12,56, "24. File ID");
mvprintw(13,56, "25. Conv. all");
mvprintw(14,56, "26. Send orig");
mvprintw(15,56, "27. DL sec");
mvprintw(16,56, "28. UP sec");
mvprintw(17,56, "29. LT sec");
mvprintw(18,56, "30. Upl. area");
mvprintw(19,56, "31. Link sec");
}
@ -356,29 +351,25 @@ int EditFGrpRec(int Area)
show_bool(18,16, fgroup.Deleted);
show_int( 19,16, fgroup.StartArea);
show_int( 11,46, fgroup.UnitCost);
show_int( 12,46, fgroup.UnitSize);
show_int( 13,46, fgroup.AddProm);
show_bool(14,46, fgroup.DivideCost);
show_bool(15,46, fgroup.AutoChange);
show_bool(16,46, fgroup.UserChange);
show_bool(17,46, fgroup.Replace);
show_bool(18,46, fgroup.DupCheck);
show_bool(19,46, fgroup.Secure);
show_bool(12,46, fgroup.AutoChange);
show_bool(13,46, fgroup.UserChange);
show_bool(14,46, fgroup.Replace);
show_bool(15,46, fgroup.DupCheck);
show_bool(16,46, fgroup.Secure);
show_bool(17,46, fgroup.Touch);
show_bool(18,46, fgroup.VirScan);
show_bool(19,46, fgroup.Announce);
show_bool( 9,70, fgroup.Touch);
show_bool(10,70, fgroup.VirScan);
show_bool(11,70, fgroup.Announce);
show_bool(12,70, fgroup.UpdMagic);
show_bool(13,70, fgroup.FileId);
show_bool(14,70, fgroup.ConvertAll);
show_bool(15,70, fgroup.SendOrg);
show_int( 16,70, fgroup.DLSec.level);
show_int( 17,70, fgroup.UPSec.level);
show_int( 18,70, fgroup.LTSec.level);
show_int( 19,70, fgroup.Upload);
show_bool(11,70, fgroup.UpdMagic);
show_bool(12,70, fgroup.FileId);
show_bool(13,70, fgroup.ConvertAll);
show_bool(14,70, fgroup.SendOrg);
show_int( 15,70, fgroup.DLSec.level);
show_int( 16,70, fgroup.UPSec.level);
show_int( 17,70, fgroup.LTSec.level);
show_int( 18,70, fgroup.Upload);
j = select_menu(35);
j = select_menu(31);
switch(j) {
case 0: if (!fgroup.StartArea && strlen(fgroup.AreaFile)) {
errmsg("Areas file defined but no BBS start area");
@ -450,38 +441,34 @@ int EditFGrpRec(int Area)
E_BOOL(18,16, fgroup.Deleted, "Is this file group ^Deleted^")
case 14:E_INT( 19,16, fgroup.StartArea, "The ^start area^ to create new BBS areas")
case 15:E_INT( 11,46, fgroup.UnitCost, "The ^cost per size unit^ files received in this tic group")
case 16:E_INT( 12,46, fgroup.UnitSize, "The ^unit size^ in KBytes, 0 means cost per file in this tic group")
case 17:E_INT( 13,46, fgroup.AddProm, "The ^Promillage^ to add or substract of the filecost")
case 18:E_BOOL(14,46, fgroup.DivideCost, "^Divide^ the cost over all downlinks or charge each link full cost")
case 19:E_BOOL(15,46, fgroup.AutoChange, "^Automatic change areas^ when a new arealist is received")
case 20:tmp = edit_bool(16,46, fgroup.UserChange, (char *)"Create new areas when ^users^ request new tic areas");
case 15:E_BOOL(12,46, fgroup.AutoChange, "^Automatic change areas^ when a new arealist is received")
case 16:tmp = edit_bool(13,46, fgroup.UserChange, (char *)"Create new areas when ^users^ request new tic areas");
if (tmp && !fgroup.UpLink.zone)
errmsg("It looks like you are at the toplevel, no Uplink defined");
else
fgroup.UserChange = tmp;
break;
case 21:E_BOOL(17,46, fgroup.Replace, "Set ^Replace^ in new created tic areas")
case 22:E_BOOL(18,46, fgroup.DupCheck, "Set ^Dupe check^ in new created tic areas")
case 23:E_BOOL(19,46, fgroup.Secure, "Set ^Secure^ tic processing in new created tic areas")
case 17:E_BOOL(14,46, fgroup.Replace, "Set ^Replace^ in new created tic areas")
case 18:E_BOOL(15,46, fgroup.DupCheck, "Set ^Dupe check^ in new created tic areas")
case 19:E_BOOL(16,46, fgroup.Secure, "Set ^Secure^ tic processing in new created tic areas")
case 20:E_BOOL(17,46, fgroup.Touch, "Set ^Touch filedate^ in new created tic areas")
case 21:E_BOOL(18,46, fgroup.VirScan, "Set ^Virus scanner^ in new created tic areas")
case 22:E_BOOL(19,46, fgroup.Announce, "Set ^Announce files^ in new created tic areas")
case 24:E_BOOL( 9,70, fgroup.Touch, "Set ^Touch filedate^ in new created tic areas")
case 25:E_BOOL(10,70, fgroup.VirScan, "Set ^Virus scanner^ in new created tic areas")
case 26:E_BOOL(11,70, fgroup.Announce, "Set ^Announce files^ in new created tic areas")
case 27:E_BOOL(12,70, fgroup.UpdMagic, "Set ^Update magic^ in new created tic areas")
case 28:E_BOOL(13,70, fgroup.FileId, "Set ^FILE_ID.DIZ extract^ in new created tic areas")
case 29:tmp = edit_bool(14,70, fgroup.ConvertAll, (char *)"Set ^Convert All^ setting in new created tic areas");
case 23:E_BOOL(11,70, fgroup.UpdMagic, "Set ^Update magic^ in new created tic areas")
case 24:E_BOOL(12,70, fgroup.FileId, "Set ^FILE_ID.DIZ extract^ in new created tic areas")
case 25:tmp = edit_bool(13,70, fgroup.ConvertAll, (char *)"Set ^Convert All^ setting in new created tic areas");
if (tmp && !fgroup.ConvertAll && (strlen(fgroup.Convert) == 0))
errmsg("No archiver configured to convert to, edit 9 first");
else
fgroup.ConvertAll = tmp;
break;
case 30:E_BOOL(15,70, fgroup.SendOrg, "Set ^Send original^ setting in new created tic areas")
case 31:E_SEC( 16,70, fgroup.DLSec, "10.1.31 FILE GROUP DOWNLOAD SECURITY", FgScreen)
case 32:E_SEC( 17,70, fgroup.UPSec, "10.1.32 FILE GROUP UPLOAD SECURITY", FgScreen)
case 33:E_SEC( 18,70, fgroup.LTSec, "10.1.33 FILE GROUP LIST SECURITY", FgScreen)
case 34:E_INT( 19,70, fgroup.Upload, "Set the default ^Upload area^ in new created file areas")
case 35:fgroup.LinkSec = edit_asec(fgroup.LinkSec, (char *)"10.1.35 DEFAULT NEW TIC AREAS SECURITY");
case 26:E_BOOL(14,70, fgroup.SendOrg, "Set ^Send original^ setting in new created tic areas")
case 27:E_SEC( 15,70, fgroup.DLSec, "10.1.27 FILE GROUP DOWNLOAD SECURITY", FgScreen)
case 28:E_SEC( 16,70, fgroup.UPSec, "10.1.28 FILE GROUP UPLOAD SECURITY", FgScreen)
case 29:E_SEC( 17,70, fgroup.LTSec, "10.1.29 FILE GROUP LIST SECURITY", FgScreen)
case 30:E_INT( 18,70, fgroup.Upload, "Set the default ^Upload area^ in new created file areas")
case 31:fgroup.LinkSec = edit_asec(fgroup.LinkSec, (char *)"10.1.31 DEFAULT NEW TIC AREAS SECURITY");
FgScreen();
break;
}
@ -726,10 +713,6 @@ int tic_group_doc(FILE *fp, FILE *toc, int page)
fprintf(fp, " Use Aka %s\n", aka2str(fgroup.UseAka));
fprintf(fp, " Uplink %s\n", aka2str(fgroup.UpLink));
fprintf(fp, " Areas file %s\n", fgroup.AreaFile);
fprintf(fp, " Divice cost %s\n", getboolean(fgroup.DivideCost));
fprintf(fp, " Unit cost %ld\n", fgroup.UnitCost);
fprintf(fp, " Unit size %ld\n", fgroup.UnitSize);
fprintf(fp, " Add promille %ld\n", fgroup.AddProm);
fprintf(fp, " Start area %ld\n", fgroup.StartArea);
fprintf(fp, " Banner file %s\n", fgroup.Banner);
fprintf(fp, " Def. archiver %s\n", fgroup.Convert);

View File

@ -440,15 +440,7 @@ void E_Files(void)
mvprintw(14, 6, "8. Advanced TIC");
mvprintw(15, 6, "9. Advanced SB");
mvprintw(16, 6, "10. To line in TIC");
mvprintw( 7,46, "11. File forward");
mvprintw( 8,46, "12. Billing (CSO)");
mvprintw( 9,46, "13. Bill direct");
mvprintw(10,46, "14. Credit");
mvprintw(11,46, "15. Debit");
mvprintw(12,46, "16. Add %");
mvprintw(13,46, "17. Warn level");
mvprintw(14,46, "18. Stop level");
mvprintw(17, 6, "11. File forward");
for (;;) {
set_color(WHITE, BLACK);
@ -462,16 +454,9 @@ void E_Files(void)
show_bool(14,26, nodes.AdvTic);
show_bool(15,26, nodes.TIC_AdvSB);
show_bool(16,26, nodes.TIC_To);
show_bool( 7,66, nodes.FileFwd);
show_bool( 8,66, nodes.Billing);
show_bool( 9,66, nodes.BillDirect);
show_int( 10,66, nodes.Credit);
show_int( 11,66, nodes.Debet);
show_int( 12,66, nodes.AddPerc);
show_int( 13,66, nodes.WarnLevel);
show_int( 14,66, nodes.StopLevel);
show_bool(17,26, nodes.FileFwd);
switch(select_menu(18)) {
switch(select_menu(11)) {
case 0: return;
case 1: E_STR( 7,26,15,nodes.Fpasswd, "The ^TIC^ files ^password^ for this node")
case 2: E_STR( 8,26,15,nodes.Apasswd, "The filemanager ^password^ for this node")
@ -483,14 +468,7 @@ void E_Files(void)
case 8: E_BOOL(14,26, nodes.AdvTic, "Send ^advanced^ TIC files to this node")
case 9: E_BOOL(15,26, nodes.TIC_AdvSB, "Send ^advanced Seen-By^ lines in ticfiles to this node")
case 10:E_BOOL(16,26, nodes.TIC_To, "Send ^To^ line in ticfiles to this node")
case 11:E_BOOL( 7,66, nodes.FileFwd, "^Forward TIC^ files for this node")
case 12:E_BOOL( 8,66, nodes.Billing, "Send ^bills^ to this node, Costsharing is active")
case 13:E_BOOL( 9,66, nodes.BillDirect, "Send bills ^direct^ after file processing")
case 14:E_INT( 10,66, nodes.Credit, "The ^credit^ this node has for costsharing")
case 15:E_INT( 11,66, nodes.Debet, "The ^debit^ in cents we have credit from this node")
case 16:E_INT( 12,66, nodes.AddPerc, "The + or - ^promille^ factor for this node")
case 17:E_INT( 13,66, nodes.WarnLevel, "Credit level in cents to ^Warn^ node for low credit")
case 18:E_INT( 14,66, nodes.StopLevel, "Credit level in cents to ^Stop^ sending files")
case 11:E_BOOL(17,26, nodes.FileFwd, "^Forward TIC^ files for this node")
}
}
}
@ -1486,8 +1464,6 @@ int node_doc(FILE *fp, FILE *toc, int page)
fprintf(fp, " Advanced TIC %s\n", getboolean(nodes.AdvTic));
fprintf(fp, " Advanded SB %s", getboolean(nodes.TIC_AdvSB));
fprintf(fp, " Sent To lines %s", getboolean(nodes.TIC_To));
fprintf(fp, " Billing %s\n", getboolean(nodes.Billing));
fprintf(fp, " Bill direct %s", getboolean(nodes.BillDirect));
fprintf(fp, " Uplink add + %s\n", getboolean(nodes.AddPlus));
fprintf(fp, " Security flags %s\n\n", getflag(nodes.Security.flags, nodes.Security.notflags));
@ -1525,11 +1501,6 @@ int node_doc(FILE *fp, FILE *toc, int page)
fprintf(fp, " Total files %-8lu %-8lu %-8lu %-8lu\n", nodes.FilesSent.total, nodes.F_KbSent.total, nodes.FilesRcvd.total, nodes.F_KbSent.total);
fprintf(fp, " Total mail %-8lu %-8lu\n\n", nodes.MailSent.total, nodes.MailRcvd.total);
if (nodes.Billing) {
fprintf(fp, " Credit units %-8ld Warnlevel %ld\n", nodes.Credit, nodes.WarnLevel);
fprintf(fp, " Debit units %-8ld Stoplevel %ld\n", nodes.Debet, nodes.StopLevel);
fprintf(fp, " Add promille %ld\n\n", nodes.AddPerc);
}
fprintf(fp, " File groups:\n ");
groups = nodeshdr.filegrp / sizeof(group);
for (i = 0; i < groups; i++) {

View File

@ -384,6 +384,7 @@ void initdatabases(void)
InitUsers();
InitVirus();
InitRoute();
InitFDB();
if (!init) {
clr_index();