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$ $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: upgrade:
In all message groups set check/set default character set. In all message groups set check/set default character set.

5
TODO
View File

@ -77,6 +77,9 @@ mbtask:
space is still available. space is still available.
mbfido: 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 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 is the first 8 characters of the area name and we use the full name
only. Make sure both namings are accepted? 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 N: Make workaround for binkp bug in Irex 2.24 upto 2.29
mbfile: 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> 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" PACKAGE="mbsebbs"
MAJOR="0" MAJOR="0"
MINOR="51" MINOR="51"
REVISION="1" REVISION="2"
VERSION="$MAJOR.$MINOR.$REVISION" VERSION="$MAJOR.$MINOR.$REVISION"
COPYRIGHT="Copyright (C) 1997-2004 Michiel Broek, All Rights Reserved" COPYRIGHT="Copyright (C) 1997-2004 Michiel Broek, All Rights Reserved"
SHORTRIGHT="Copyright (C) 1997-2004 M. Broek" SHORTRIGHT="Copyright (C) 1997-2004 M. Broek"

View File

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

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 237 filesub.c |Can't open file database for this area
238 filesub.c file.c |Uploaded by: 238 filesub.c file.c |Uploaded by:
239 file.c |D E L E T E D 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]: 241 mail.c YN|Node not known, continue anayway [y/N]:
242 file.c |Total Files: 242 file.c |Total Files:
243 filesub.c |FATAL: Unable to open areas database 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 |Kan de database niet openen voor dit gebied
|Upload door: |Upload door:
|GEWIST |GEWIST
|ONTBREEKT |
JN|Node onbekend, toch doorgaan [j/N]: JN|Node onbekend, toch doorgaan [j/N]:
|Aantal bestanden: |Aantal bestanden:
|FATAAL: kan de bestanden database niet openen |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 |Can't open file database for this area
|Uploaded by: |Uploaded by:
|D E L E T E D |D E L E T E D
|M I S S I N G |
YN|Node not known, continue anyway [y/N]: YN|Node not known, continue anyway [y/N]:
|Total Files: |Total Files:
|FATAL: Unable to open areas database |FATAL: Unable to open areas database

View File

@ -238,7 +238,7 @@ RNQ|(R)
|Ne paut pas ouvrir la base pour cette conférence |Ne paut pas ouvrir la base pour cette conférence
|Télécharrgé par: |Télécharrgé par:
|F A C |F A C
|M A N Q U A N T |
ON|Node inconnu, continue quand même [o/N]: ON|Node inconnu, continue quand même [o/N]:
|Total Fichiers: |Total Fichiers:
|FATAL: Impossible d'ouvrir la conférence |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 |Non podo abri-la base de ficheiros desta  rea
|Enviado por: |Enviado por:
|B O R R A D O |B O R R A D O
|P E R D I D O |
SN|Nodo desco¤ecido. ¨Continuar? [s/N]: SN|Nodo desco¤ecido. ¨Continuar? [s/N]:
|Total Fichs: |Total Fichs:
|FATAL: Imposible abrir base de  reas |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 |Die Datei-Datenbank fuer diesen Bereich kann nicht geoeffnet werden
|Heraufgeladen von: |Heraufgeladen von:
|G E L O E S C H T |G E L O E S C H T
|F E H L T |
JN|Adresse unbekannt, dennoch fortfahren [j/N]: JN|Adresse unbekannt, dennoch fortfahren [j/N]:
|Dateien insgesamt: |Dateien insgesamt:
|FATAL: die Datenbank der Dateibereiche kann nicht geoeffnet werden |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 |Die Datei-Datenbank fuer diesen Bereich kann nicht geoeffnet werden
|Heraufgeladen von: |Heraufgeladen von:
|G E L O E S C H T |G E L O E S C H T
|F E H L T |
JN|Adresse unbekannt, dennoch fortfahren [j/N]: JN|Adresse unbekannt, dennoch fortfahren [j/N]:
|Dateien insgesamt: |Dateien insgesamt:
|FATAL: die Datenbank der Dateibereiche kann nicht geoeffnet werden |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 |Non trovo il database dei file di quest'area
|Uploadato da: |Uploadato da:
|C A N C E L L A T O |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]: SN|Nodo sconosciuto, continua lo stesso [s/N]:
|File Totali: |File Totali:
|FATAL: Non trovo il database dell'area |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 |No puedo abrir la base de ficheros de esta  rea
|Enviado por: |Enviado por:
|B O R R A D O |B O R R A D O
|P E R D I D O |
SN|Nodo desconocido. ¨Continuar? [s/N]: SN|Nodo desconocido. ¨Continuar? [s/N]:
|Total Fichs: |Total Fichs:
|FATAL: Imposible abrir base de  reas |FATAL: Imposible abrir base de  reas

View File

@ -731,7 +731,7 @@ struct fileareas {
unsigned DLdays; /* Move not DL for days */ unsigned DLdays; /* Move not DL for days */
unsigned FDdays; /* Move if FD older than */ unsigned FDdays; /* Move if FD older than */
unsigned MoveArea; /* Move to Area */ unsigned MoveArea; /* Move to Area */
int Cost; /* File Cost */ int xCost; /* File Cost */
char FilesBbs[65]; /* Path to files.bbs if CD */ char FilesBbs[65]; /* Path to files.bbs if CD */
char NewGroup[13]; /* Newfiles scan group */ char NewGroup[13]; /* Newfiles scan group */
char Archiver[6]; /* Archiver for area */ 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 Name[13]; /* DOS style filename */
char LName[81]; /* Long filename */ char LName[81]; /* Long filename */
char xTicArea[9]; /* Tic area file came in */ char xTicArea[9]; /* Tic area file came in */
@ -1518,9 +1549,9 @@ struct _nodes {
unsigned FileFwd : 1; /* Accept File Forward */ unsigned FileFwd : 1; /* Accept File Forward */
unsigned MailFwd : 1; /* Accept Mail Forward */ unsigned MailFwd : 1; /* Accept Mail Forward */
unsigned AdvTic : 1; /* Advanced Tic files */ 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 Crash : 1; /* Netmail crash */
unsigned Hold : 1; /* Netmail hold */ unsigned Hold : 1; /* Netmail hold */
unsigned AddPlus : 1; /* Add + for uplink msgs */ unsigned AddPlus : 1; /* Add + for uplink msgs */
@ -1549,11 +1580,11 @@ struct _nodes {
char xExtra[94]; char xExtra[94];
time_t StartDate; /* Node start date */ time_t StartDate; /* Node start date */
time_t LastDate; /* Last action date */ time_t LastDate; /* Last action date */
long Credit; /* Node's credit */ long xCredit; /* Node's credit */
long Debet; /* Node's debet */ long xDebet; /* Node's debet */
long AddPerc; /* Add Percentage */ long xAddPerc; /* Add Percentage */
long WarnLevel; /* Warning level */ long xWarnLevel; /* Warning level */
long StopLevel; /* Stop level */ long xStopLevel; /* Stop level */
fidoaddr RouteVia; /* Routing address */ fidoaddr RouteVia; /* Routing address */
int Language; /* Language for netmail */ int Language; /* Language for netmail */
statcnt FilesSent; /* Files sent to node */ statcnt FilesSent; /* Files sent to node */
@ -1637,12 +1668,12 @@ struct _fgroup {
char Comment[56]; /* Group Comment */ char Comment[56]; /* Group Comment */
unsigned Active : 1; /* Group Active */ unsigned Active : 1; /* Group Active */
unsigned Deleted : 1; /* Is group deleted */ 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 UseAka; /* Aka to use */
fidoaddr UpLink; /* Uplink address */ fidoaddr UpLink; /* Uplink address */
long UnitCost; /* Cost per unit */ long xUnitCost; /* Cost per unit */
long UnitSize; /* Size per unit */ long xUnitSize; /* Size per unit */
long AddProm; /* Promillage to add */ long xAddProm; /* Promillage to add */
time_t StartDate; /* Start Date */ time_t StartDate; /* Start Date */
time_t LastDate; /* Last active date */ time_t LastDate; /* Last active date */
char AreaFile[13]; /* Areas filename */ 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) * Newfile reports (newfiles.data)
*/ */
@ -1883,7 +1900,6 @@ struct _filerecord {
char Desc[256]; /* Short description */ char Desc[256]; /* Short description */
char LDesc[25][49]; /* Long description */ char LDesc[25][49]; /* Long description */
int TotLdesc; /* Total long desc lines */ int TotLdesc; /* Total long desc lines */
long Cost; /* File cost */
unsigned Announce : 1; /* Announce this file */ unsigned Announce : 1; /* Announce this file */
}; };
@ -2478,7 +2494,9 @@ struct oneline ol;
struct fileareashdr areahdr; /* File areas */ struct fileareashdr areahdr; /* File areas */
struct fileareas area; 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 _fgrouphdr fgrouphdr; /* File groups */
struct _fgroup fgroup; struct _fgroup fgroup;
@ -2533,7 +2551,7 @@ struct _magic magic;
struct _nodeshdr nodeshdr; /* Fidonet nodes */ struct _nodeshdr nodeshdr; /* Fidonet nodes */
struct _nodes nodes; struct _nodes nodes;
struct _bill bill; /* Unsent bills */ //struct _bill bill; /* Unsent bills */
struct _newfileshdr newfileshdr; /* New file reports */ struct _newfileshdr newfileshdr; /* New file reports */
struct _newfiles newfiles; struct _newfiles newfiles;

View File

@ -151,245 +151,236 @@ file_list *respond_bark(char *buf)
file_list *respfreq(char *nm, char *pw, char *dt) file_list *respfreq(char *nm, char *pw, char *dt)
{ {
file_list *fl = NULL; file_list *fl = NULL;
struct stat st; struct stat st;
char mask[256], *p, *q; char mask[256], *p, *q, *tnm, *t;
char *tnm, *t; time_t upd = 0L;
time_t upd = 0L; int newer = 1, Send;
int newer = 1; FILE *fa, *fb, *fi;
FILE *fa, *fb, *fi; long Area;
long Area; struct FILEIndex idx;
int Send;
struct FILEIndex idx;
if (localoptions & NOFREQS) { if (localoptions & NOFREQS) {
Syslog('+', "File requests disabled"); Syslog('+', "File requests disabled");
add_report((char *)"ER: \"%s\" denied: file requests disabled", nm); add_report((char *)"ER: \"%s\" denied: file requests disabled", nm);
return NULL; return NULL;
} }
if (strchr(nm, '/') || strchr(nm, '\\') || strchr(nm, ':')) { if (strchr(nm, '/') || strchr(nm, '\\') || strchr(nm, ':')) {
Syslog('+', "Illegal characters in request"); Syslog('+', "Illegal characters in request");
add_report((char *)"ER: \"%s\" denied: illegal characters", nm); add_report((char *)"ER: \"%s\" denied: illegal characters", nm);
return NULL; return NULL;
} }
if (dt) { if (dt) {
if (*dt == '+') { if (*dt == '+') {
newer = 1; newer = 1;
dt++; dt++;
} else if (*dt == '-') { } else if (*dt == '-') {
newer = 0; newer = 0;
dt++; dt++;
} else } else
newer = 1; newer = 1;
upd=atoul(dt); upd=atoul(dt);
} }
if (strlen(CFG.req_magic)) {
/*
* Check for uppercase and lowercase magic names.
*/
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 (access(tnm, X_OK) == 0) {
return respmagic(tnm);
/* respmagic will free(tnm) */
} else if (access(tnm, R_OK) == 0) {
return resplist(tnm, pw, dt);
/* resplist will free(tnm) */
} else
free(tnm);
} else
free(tnm);
tnm = xstrcpy(CFG.req_magic);
tnm = xstrcat(tnm,(char *)"/");
t = xstrcpy(nm);
tnm = xstrcat(tnm,tu(t));
free(t);
if ((stat(tnm, &st) == 0) &&
(S_ISREG(st.st_mode))) {
if (access(tnm, X_OK) == 0) {
return respmagic(tnm);
/* respmagic will free(tnm) */
} else if (access(tnm, R_OK) == 0) {
return resplist(tnm, pw, dt);
/* resplist will free(tnm) */
} else
free(tnm);
} else free(tnm);
}
Syslog('+', "File request : %s (update (%s), password \"%s\")",MBSE_SS(nm),MBSE_SS(dt),MBSE_SS(pw));
add_report((char *)"RQ: Regular file \"%s\"",nm);
p = tl(nm);
q = mask;
*q++ = '^';
while ((*p) && (q < (mask + sizeof(mask) - 4))) {
switch (*p) {
case '\\': *q++ = '\\'; *q++ = '\\'; break;
case '?': *q++ = '.'; break;
case '.': *q++ = '\\'; *q++ = '.'; break;
case '+': *q++ = '\\'; *q++ = '+'; break;
case '*': *q++ = '.'; *q++ = '*'; break;
default: *q++ = toupper(*p); break;
}
p++;
}
*q++ = '$';
*q = '\0';
Syslog('f', "Search mask \"%s\"", mask);
re_comp(mask);
if (strlen(CFG.req_magic)) {
/* /*
* Open the areas database and request index. * Check for uppercase and lowercase magic names.
*/ */
p = xstrcpy(getenv("MBSE_ROOT")); tnm = xstrcpy(CFG.req_magic);
p = xstrcat(p, (char *)"/etc/fareas.data"); tnm = xstrcat(tnm,(char *)"/");
if ((fa = fopen(p, "r")) == NULL) { tnm = xstrcat(tnm,tl(xstrcpy(nm)));
WriteError("$Can't open %s", p); if ((stat(tnm, &st) == 0) && (S_ISREG(st.st_mode))) {
return NULL; if (access(tnm, X_OK) == 0) {
return respmagic(tnm);
/* respmagic will free(tnm) */
} else if (access(tnm, R_OK) == 0) {
return resplist(tnm, pw, dt);
/* resplist will free(tnm) */
} else
free(tnm);
} else
free(tnm);
tnm = xstrcpy(CFG.req_magic);
tnm = xstrcat(tnm,(char *)"/");
t = xstrcpy(nm);
tnm = xstrcat(tnm,tu(t));
free(t);
if ((stat(tnm, &st) == 0) && (S_ISREG(st.st_mode))) {
if (access(tnm, X_OK) == 0) {
return respmagic(tnm);
/* respmagic will free(tnm) */
} else if (access(tnm, R_OK) == 0) {
return resplist(tnm, pw, dt);
/* resplist will free(tnm) */
} else
free(tnm);
} else free(tnm);
}
Syslog('+', "File request : %s (update (%s), password \"%s\")",MBSE_SS(nm),MBSE_SS(dt),MBSE_SS(pw));
add_report((char *)"RQ: Regular file \"%s\"",nm);
p = tl(nm);
q = mask;
*q++ = '^';
while ((*p) && (q < (mask + sizeof(mask) - 4))) {
switch (*p) {
case '\\': *q++ = '\\'; *q++ = '\\'; break;
case '?': *q++ = '.'; break;
case '.': *q++ = '\\'; *q++ = '.'; break;
case '+': *q++ = '\\'; *q++ = '+'; break;
case '*': *q++ = '.'; *q++ = '*'; break;
default: *q++ = toupper(*p); break;
} }
free(p); p++;
fread(&areahdr, sizeof(areahdr), 1, fa); }
*q++ = '$';
*q = '\0';
Syslog('f', "Search mask \"%s\"", mask);
re_comp(mask);
p = xstrcpy(getenv("MBSE_ROOT")); /*
p = xstrcat(p, (char *)"/etc/request.index"); * Open the areas database and request index.
if ((fi = fopen(p, "r")) == NULL) { */
WriteError("$Can't open %s", p); p = xstrcpy(getenv("MBSE_ROOT"));
p = xstrcat(p, (char *)"/etc/fareas.data");
if ((fa = fopen(p, "r")) == NULL) {
WriteError("$Can't open %s", p);
return NULL;
}
free(p);
fread(&areahdr, sizeof(areahdr), 1, fa);
p = xstrcpy(getenv("MBSE_ROOT"));
p = xstrcat(p, (char *)"/etc/request.index");
if ((fi = fopen(p, "r")) == NULL) {
WriteError("$Can't open %s", p);
return NULL;
}
Area = 0L;
free(p);
Syslog('f', "Start search ...");
while (!no_more && (fread(&idx, sizeof(idx), 1, fi) == 1)) {
if (re_exec(idx.Name) || re_exec(idx.LName)) {
Syslog('f', "Index found %s area %d record %d", idx.LName, idx.AreaNum, idx.Record);
if (fseek(fa, ((idx.AreaNum - 1) * areahdr.recsize) + areahdr.hdrsize, SEEK_SET) == -1) {
WriteError("$Can't seek in fareas.data");
return NULL; return NULL;
} }
Area = 0L; if (fread(&area, areahdr.recsize, 1, fa) != 1) {
free(p); WriteError("$Can't read record %d in fareas.data", idx.AreaNum);
return NULL;
Syslog('f', "Start search ..."); }
while (!no_more && (fread(&idx, sizeof(idx), 1, fi) == 1)) { Syslog('f', "Area %s", area.Name);
if (re_exec(idx.Name) || re_exec(idx.LName)) { p = calloc(PATH_MAX, sizeof(char));
Syslog('f', "Index found %s area %d record %d", idx.LName, idx.AreaNum, idx.Record); sprintf(p, "%s/fdb/file%ld.data", getenv("MBSE_ROOT"), idx.AreaNum);
if (fseek(fa, ((idx.AreaNum - 1) * areahdr.recsize) + areahdr.hdrsize, SEEK_SET) == -1) { if ((fb = fopen(p, "r+")) == NULL) {
WriteError("$Can't seek in fareas.data"); WriteError("$Can't open %s", p);
return NULL; free(p);
} else {
free(p);
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(&fdb, fdbhdr.recsize, 1, fb) != 1) {
WriteError("$Can't read filerecord %d", idx.Record);
} else {
Send = FALSE;
Syslog('f', "Found \"%s\" in %s", fdb.LName, area.Name);
tnm = xstrcpy(area.Path);
tnm = xstrcat(tnm, (char *)"/");
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)))) {
Send = TRUE;
} }
if (fread(&area, areahdr.recsize, 1, fa) != 1) {
WriteError("$Can't read record %d in fareas.data", idx.AreaNum);
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);
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) {
WriteError("$Can't seek filerecord %d", idx.Record);
} else {
if (fread(&file, sizeof(file), 1, fb) != 1) {
WriteError("$Can't read filerecord %d", idx.Record);
} else {
Send = FALSE;
Syslog('f', "Found \"%s\" in %s", file.LName, area.Name);
tnm = xstrcpy(area.Path);
tnm = xstrcat(tnm, (char *)"/");
tnm = xstrcat(tnm, file.LName);
if ((stat(tnm, &st) == 0) && (S_ISREG(st.st_mode)) &&
(access(tnm, R_OK) == 0) && ((upd == 0L) ||
((newer) && (st.st_mtime <= upd)))) {
Send = TRUE;
}
/* /*
* If no password is given, we do not respond * If no password is given, we do not respond
* on requests to password protected areas * on requests to password protected areas
* or files in case it was a wildcard request. * or files in case it was a wildcard request.
* Wrong passwords are honored with an error * Wrong passwords are honored with an error
* response. * response.
*/ */
if (Send && strlen(area.Password)) { if (Send && strlen(area.Password)) {
if (pw != NULL) { if (pw != NULL) {
if (strcasecmp(area.Password, pw)) { if (strcasecmp(area.Password, pw)) {
Send = FALSE; Send = FALSE;
Syslog('+', "Bad password for area %s", area.Name); Syslog('+', "Bad password for area %s", area.Name);
add_report((char *)"ER: bad password for area %s", add_report((char *)"ER: bad password for area %s", area.Name);
area.Name);
}
} else {
Send = FALSE;
}
}
if (Send && strlen(file.Password)) {
if (pw != NULL) {
if (strcasecmp(file.Password, pw)) {
Send = FALSE;
Syslog('+', "Bad password for file %s", file.Name);
add_report((char *)"ER: bad password for file %s",
file.LName);
}
} else {
Send = FALSE;
}
}
if (Send && CFG.Req_Files) {
if (report_count >= CFG.Req_Files) {
Send = FALSE;
add_report((char *)"ER: too many files requested");
Syslog('+', "Exceeding maximum files limit");
no_more = TRUE;
}
}
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);
Syslog('+', "Exceeding request size limit");
no_more = TRUE;
}
}
if (Send) {
Syslog('f', "Will send %s", file.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);
else
add_report((char *)"OK: Sending \"%s\" (%lu bytes)",
file.LName, file.Size);
add_list(&fl, tnm, file.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);
}
free(tnm);
}
} }
fclose(fb); } else {
Send = FALSE;
}
} }
if (Send && strlen(fdb.Password)) {
if (pw != NULL) {
if (strcasecmp(fdb.Password, pw)) {
Send = FALSE;
Syslog('+', "Bad password for file %s", fdb.Name);
add_report((char *)"ER: bad password for file %s", fdb.LName);
}
} else {
Send = FALSE;
}
}
if (Send && CFG.Req_Files) {
if (report_count >= CFG.Req_Files) {
Send = FALSE;
add_report((char *)"ER: too many files requested");
Syslog('+', "Exceeding maximum files limit");
no_more = TRUE;
}
}
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", fdb.Name);
Syslog('+', "Exceeding request size limit");
no_more = TRUE;
}
}
if (Send) {
Syslog('f', "Will send %s", fdb.LName);
report_total += st.st_size;
report_count++;
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)", fdb.LName, fdb.Size);
add_list(&fl, tnm, fdb.LName, 0, 0L, NULL, 1);
/*
* Update file information
*/
fdb.TimesDL++;
fdb.LastDL = time(NULL);
fseek(fb, - fdbhdr.recsize, SEEK_CUR);
fwrite(&fdb, fdbhdr.recsize, 1, fb);
}
free(tnm);
}
} }
fclose(fb);
}
} }
}
fclose(fa); fclose(fa);
fclose(fi); fclose(fi);
if (fl == NULL) if (fl == NULL)
add_report((char *)"ER: No matching files found"); add_report((char *)"ER: No matching files found");
return fl; return fl;
} }

View File

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

View File

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

View File

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

View File

@ -305,11 +305,6 @@ void F_Status(faddr *t, char *replyid)
MacroVars("B", "d", nodes.Tic); MacroVars("B", "d", nodes.Tic);
MacroVars("C", "d", nodes.AdvTic); MacroVars("C", "d", nodes.AdvTic);
MacroVars("D", "d", nodes.Notify); 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("a", "d", nodes.FilesSent.lweek);
MacroVars("b", "d", nodes.FilesSent.month[i]); MacroVars("b", "d", nodes.FilesSent.month[i]);
MacroVars("c", "d", nodes.FilesSent.total); MacroVars("c", "d", nodes.FilesSent.total);

View File

@ -43,7 +43,7 @@
void ForwardFile(fidoaddr Node, fa_list *sbl) 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; FILE *fp, *fi, *fl, *net;
faddr *dest, *routeto, *Fa, *Temp, *ba; faddr *dest, *routeto, *Fa, *Temp, *ba;
int i, z, n; 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"); 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)); fwdfile = calloc(PATH_MAX, sizeof(char));
queuedir = calloc(PATH_MAX, sizeof(char)); queuedir = calloc(PATH_MAX, sizeof(char));
listfile = 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) { if (nodes.AdvTic) {
fprintf(fp, "Areadesc %s\r\n", tic.Comment); fprintf(fp, "Areadesc %s\r\n", tic.Comment);
fprintf(fp, "Fdn %s\r\n", fgroup.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) if (TIC.TicIn.TotLDesc)
for (i = 0; i < TIC.TicIn.TotLDesc; i++) for (i = 0; i < TIC.TicIn.TotLDesc; i++)
fprintf(fp, "LDesc %s\r\n", TIC.TicIn.LDesc[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); 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)); fsync(fileno(fl));
fclose(fl); fclose(fl);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -98,63 +98,46 @@ void ListFileAreas(int Area)
/* /*
* Open the file database, create new one if it doesn't exist. * 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) { if ((pFile = fopen(fAreas, "r+")) == NULL) {
Syslog('!', "Creating new %s", fAreas); Syslog('!', "Creating new %s", fAreas);
if ((pFile = fopen(fAreas, "a+")) == NULL) { if ((pFile = fopen(fAreas, "a+")) == NULL) {
WriteError("$Can't create %s", fAreas); WriteError("$Can't create %s", fAreas);
die(MBERR_GENERAL); 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; fcount = 0;
fsize = 0L; fsize = 0L;
colour(CYAN, BLACK); colour(CYAN, BLACK);
printf("File listing of area %d, %s\n\n", Area, area.Name); 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("Short name Kb. File date Down Flg TIC Area Long name\n");
printf("------------ ----- ---------- ---- ----- -------------------- "); printf("------------ ----- ---------- ---- --- -------------------- ");
for (i = 63; i < COLS; i++) for (i = 63; i < COLS; i++)
printf("-"); printf("-");
printf("\n"); printf("\n");
colour(LIGHTGRAY, BLACK); colour(LIGHTGRAY, BLACK);
while (fread(&file, sizeof(file), 1, pFile) == 1) { while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
sprintf(flags, "-----"); sprintf(flags, "---");
if (file.Free) if (fdb.Deleted)
flags[0] = 'F'; flags[0] = 'D';
if (file.Deleted) if (fdb.NoKill)
flags[1] = 'D'; flags[1] = 'N';
if (file.Missing) if (fdb.Announced)
flags[2] = 'M'; flags[2] = 'A';
if (file.NoKill)
flags[3] = 'N';
if (file.Announced)
flags[4] = 'A';
if (file.TicAreaCRC) { fdb.LName[COLS - 63] = '\0';
/* printf("%-12s %5ld %s %4ld %s %-20s %s\n", fdb.Name, (long)(fdb.Size / 1024), StrDateDMY(fdb.FileDate),
* Fill the default answer (long)(fdb.TimesDL), flags, fdb.TicArea, fdb.LName);
*/
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);
fcount++; fcount++;
fsize = fsize + file.Size; fsize = fsize + fdb.Size;
} }
fsize = fsize / 1024; fsize = fsize / 1024;
@ -196,20 +179,25 @@ void ListFileAreas(int Area)
/* /*
* Open the file database, create new one if it doesn't exist. * 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) { if ((pFile = fopen(fAreas, "r+")) == NULL) {
Syslog('!', "Creating new %s", fAreas); Syslog('!', "Creating new %s", fAreas);
if ((pFile = fopen(fAreas, "a+")) == NULL) { if ((pFile = fopen(fAreas, "a+")) == NULL) {
WriteError("$Can't create %s", fAreas); WriteError("$Can't create %s", fAreas);
die(MBERR_GENERAL); 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; fcount = 0;
fsize = 0L; fsize = 0L;
while (fread(&file, sizeof(file), 1, pFile) == 1) { while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
fcount++; fcount++;
fsize = fsize + file.Size; fsize = fsize + fdb.Size;
} }
fsize = fsize / 1048576; fsize = fsize / 1048576;
tcount += fcount; tcount += fcount;

View File

@ -46,10 +46,11 @@ extern int do_quiet; /* Suppress screen output */
*/ */
void Move(int From, int To, char *File) void Move(int From, int To, char *File)
{ {
char *frompath, *topath, *temp1, *temp2, *fromlink, *tolink, *fromthumb, *tothumb; char *frompath, *topath, *temp1, *temp2, *fromlink, *tolink, *fromthumb, *tothumb;
struct FILERecord fdb; struct FILE_recordhdr f_dbhdr;
FILE *fp1, *fp2; struct FILE_record f_db;
int rc = FALSE, Found = FALSE; FILE *fp1, *fp2;
int rc = FALSE, Found = FALSE;
IsDoing("Move file"); IsDoing("Move file");
colour(LIGHTRED, BLACK); colour(LIGHTRED, BLACK);
@ -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. * Find the file in the "from" area, check LFN and 8.3 names.
*/ */
temp1 = calloc(PATH_MAX, sizeof(char)); 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) if ((fp1 = fopen(temp1, "r")) == NULL)
die(MBERR_GENERAL); die(MBERR_GENERAL);
while (fread(&fdb, sizeof(fdb), 1, fp1) == 1) { fread(&f_dbhdr, sizeof(fdbhdr), 1, fp1);
if ((strcmp(fdb.LName, File) == 0) || strcmp(fdb.Name, File) == 0) {
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; Found = TRUE;
break; break;
} }
@ -107,13 +110,13 @@ void Move(int From, int To, char *File)
frompath = xstrcpy(area.Path); frompath = xstrcpy(area.Path);
frompath = xstrcat(frompath, (char *)"/"); frompath = xstrcat(frompath, (char *)"/");
frompath = xstrcat(frompath, fdb.Name); frompath = xstrcat(frompath, f_db.Name);
fromlink = xstrcpy(area.Path); fromlink = xstrcpy(area.Path);
fromlink = xstrcat(fromlink, (char *)"/"); fromlink = xstrcat(fromlink, (char *)"/");
fromlink = xstrcat(fromlink, fdb.LName); fromlink = xstrcat(fromlink, f_db.LName);
fromthumb = xstrcpy(area.Path); fromthumb = xstrcpy(area.Path);
fromthumb = xstrcat(fromthumb, (char *)"/."); fromthumb = xstrcat(fromthumb, (char *)"/.");
fromthumb = xstrcat(fromthumb, fdb.Name); fromthumb = xstrcat(fromthumb, f_db.Name);
/* /*
* Check Destination area * Check Destination area
@ -139,13 +142,13 @@ void Move(int From, int To, char *File)
topath = xstrcpy(area.Path); topath = xstrcpy(area.Path);
topath = xstrcat(topath, (char *)"/"); topath = xstrcat(topath, (char *)"/");
topath = xstrcat(topath, fdb.Name); topath = xstrcat(topath, f_db.Name);
tolink = xstrcpy(area.Path); tolink = xstrcpy(area.Path);
tolink = xstrcat(tolink, (char *)"/"); tolink = xstrcat(tolink, (char *)"/");
tolink = xstrcat(tolink, fdb.LName); tolink = xstrcat(tolink, f_db.LName);
tothumb = xstrcpy(area.Path); tothumb = xstrcpy(area.Path);
tothumb = xstrcat(tothumb, (char *)"/."); tothumb = xstrcat(tothumb, (char *)"/.");
tothumb = xstrcat(tothumb, fdb.Name); tothumb = xstrcat(tothumb, f_db.Name);
if (file_exist(topath, F_OK) == 0) { if (file_exist(topath, F_OK) == 0) {
WriteError("File %s already exists in area %d", File, To); 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)); 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) if ((fp1 = fopen(temp1, "r")) == NULL)
die(MBERR_GENERAL); die(MBERR_GENERAL);
fread(&f_dbhdr, sizeof(fdbhdr), 1, fp1);
if ((fp2 = fopen(temp2, "a+")) == NULL) if ((fp2 = fopen(temp2, "a+")) == NULL)
die(MBERR_GENERAL); die(MBERR_GENERAL);
fwrite(&f_dbhdr, f_dbhdr.hdrsize, 1, fp2);
/* /*
* Search the file if the From area, if found, the * Search the file if the From area, if found, the
* temp database holds all records except the moved * temp database holds all records except the moved
* file. * file.
*/ */
while (fread(&fdb, sizeof(fdb), 1, fp1) == 1) { while (fread(&f_db, f_dbhdr.recsize, 1, fp1) == 1) {
if (strcmp(fdb.LName, File) && strcmp(fdb.Name, File)) if (strcmp(f_db.LName, File) && strcmp(f_db.Name, File))
fwrite(&fdb, sizeof(fdb), 1, fp2); fwrite(&f_db, f_dbhdr.recsize, 1, fp2);
else { else {
rc = AddFile(fdb, To, topath, frompath, tolink); rc = AddFile(f_db, To, topath, frompath, tolink);
if (rc) { if (rc) {
unlink(fromlink); unlink(fromlink);
unlink(frompath); unlink(frompath);

View File

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

View File

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

View File

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

View File

@ -9,7 +9,7 @@ void Help(void); /* Show help screen */
void Marker(void); /* Eyecatcher */ void Marker(void); /* Eyecatcher */
void DeleteVirusWork(void); /* Delete unarc directory */ void DeleteVirusWork(void); /* Delete unarc directory */
int UnpackFile(char *File); /* Unpack archive */ 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 CheckFDB(int, char *); /* Check FDB of area */
int LoadAreaRec(int); /* Load Area record */ int LoadAreaRec(int); /* Load Area record */

View File

@ -74,7 +74,6 @@ int ProcessTic(fa_list *sbl)
unsigned long crc, crc2, Kb; unsigned long crc, crc2, Kb;
sysconnect Link; sysconnect Link;
FILE *fp; FILE *fp;
long FwdCost = 0, FwdSize = 0;
struct utimbuf ut; struct utimbuf ut;
int BBS_Imp = FALSE, DidBanner = FALSE; int BBS_Imp = FALSE, DidBanner = FALSE;
faddr *p_from; 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.Size = TIC.FileSize;
T_File.SizeKb = TIC.FileSize / 1024; 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. * Update the uplink's counters.
*/ */
Kb = TIC.FileSize / 1024; Kb = TIC.FileSize / 1024;
if (SearchNode(TIC.Aka)) { 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.FilesRcvd, 1L);
StatAdd(&nodes.F_KbRcvd, Kb); StatAdd(&nodes.F_KbRcvd, Kb);
UpdateNode(); UpdateNode();
@ -727,7 +677,6 @@ int ProcessTic(fa_list *sbl)
strncpy(T_File.Name, TIC.NewFile, 12); strncpy(T_File.Name, TIC.NewFile, 12);
strncpy(T_File.LName, TIC.NewFullName, 80); strncpy(T_File.LName, TIC.NewFullName, 80);
T_File.Fdate = TIC.FileDate; T_File.Fdate = TIC.FileDate;
T_File.Cost = TIC.TicIn.Cost;
Add_ToBeRep(); Add_ToBeRep();
} }

View File

@ -55,31 +55,31 @@ int FileRecno = 0;
int CheckFile(char *, int); int CheckFile(char *, int);
int CheckFile(char *File, int iArea) int CheckFile(char *File, int iArea)
{ {
FILE *pFileB; FILE *pFileB;
char *sFileArea; char *sFileArea;
sFileArea = calloc(PATH_MAX, sizeof(char)); 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) { if ((pFileB = fopen(sFileArea,"r+")) == NULL) {
mkdir(sFileArea, 775); mkdir(sFileArea, 775);
return FALSE;
}
free(sFileArea);
/*
* 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)) {
fclose(pFileB);
return TRUE;
}
}
fclose(pFileB);
return FALSE; return FALSE;
}
free(sFileArea);
fread(&fdbhdr, sizeof(fdbhdr), 1, pFileB);
/*
* Check long and short filenames, case insensitive
*/
while (fread(&fdb, fdbhdr.recsize, 1, pFileB) == 1) {
if (((strcasecmp(fdb.Name, File)) == 0) || ((strcasecmp(fdb.LName, File)) == 0)) {
fclose(pFileB);
return TRUE;
}
}
fclose(pFileB);
return FALSE;
} }
@ -89,75 +89,69 @@ int CheckFile(char *File, int iArea)
*/ */
void File_List() void File_List()
{ {
FILE *pFile; FILE *pFile;
int FileCount = 0; int FileCount = 0;
unsigned FileBytes = 0; unsigned FileBytes = 0;
_Tag T; _Tag T;
iLineCount = 0; iLineCount = 0;
WhosDoingWhat(FILELIST, NULL); WhosDoingWhat(FILELIST, NULL);
Syslog('+', "Listing File Area # %d", iAreaNumber); Syslog('+', "Listing File Area # %d", iAreaNumber);
if(Access(exitinfo.Security, area.LTSec) == FALSE) { if (Access(exitinfo.Security, area.LTSec) == FALSE) {
colour(14, 0); colour(14, 0);
/* You don't have enough security to list this area */ /* You don't have enough security to list this area */
printf("\n%s\n", (char *) Language(236)); printf("\n%s\n", (char *) Language(236));
Pause();
return;
}
InitTag();
if ((pFile = OpenFileBase(iAreaNumber, FALSE)) == NULL)
return;
clear();
Header();
if (iLC(2) == 1) {
fclose(pFile);
return;
}
while (fread(&file, sizeof(file), 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);
SetTag(T);
if (ShowOneFile() == 1) {
fclose(pFile);
return;
}
if (file.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);
FileCount++; /* Increase File Counter by 1 */
FileBytes += file.Size; /* Increase File Byte Count */
}
Mark();
colour(11,0);
/* Total Files: */
printf("\n%s%d / %d bytes\n\n", (char *) Language(242), FileCount, FileBytes);
iLineCount = 0;
fclose(pFile);
Pause(); Pause();
return;
}
InitTag();
if ((pFile = OpenFileBase(iAreaNumber, FALSE)) == NULL)
return;
clear();
Header();
if (iLC(2) == 1) {
fclose(pFile);
return;
}
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
memset(&T, 0, sizeof(T));
T.Area = iAreaNumber;
T.Active = FALSE;
T.Size = fdb.Size;
strncpy(T.SFile, fdb.Name, 12);
strncpy(T.LFile, fdb.LName, 80);
SetTag(T);
if (ShowOneFile() == 1) {
fclose(pFile);
return;
}
if (fdb.Deleted)
/* D E L E T E D */ /* Uploaded by: */
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 += fdb.Size; /* Increase File Byte Count */
}
Mark();
colour(11,0);
/* Total Files: */
printf("\n%s%d / %d bytes\n\n", (char *) Language(242), FileCount, FileBytes);
iLineCount = 0;
fclose(pFile);
Pause();
} }
@ -205,26 +199,25 @@ void Download(void)
SetFileArea(Tag.Area); 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) { if ((fp = OpenFileBase(Tag.Area, FALSE)) != NULL) {
while (fread(&file, sizeof(file), 1, fp) == 1) { while (fread(&fdb, fdbhdr.recsize, 1, fp) == 1) {
if (strcmp(file.LName, Tag.LFile) == 0) if (strcmp(fdb.LName, Tag.LFile) == 0)
break; break;
} }
fclose(fp); fclose(fp);
} }
if (strcmp(file.LName, Tag.LFile) == 0) { if (strcmp(fdb.LName, Tag.LFile) == 0) {
Syslog('b', "Found file %s in area %d", file.LName, Tag.Area); Syslog('b', "Found file %s in area %d", fdb.LName, Tag.Area);
if ((file.Deleted) || (file.Missing)) { if (fdb.Deleted) {
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(248)); pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(248));
/* Sorry that file is unavailable for download */ /* 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; Tag.Active = FALSE;
Syslog('+', "File %s in area %d unavailable for download, %s", Syslog('+', "File %s in area %d unavailable for download, deleted", fdb.LName, Tag.Area);
file.LName, Tag.Area, file.Deleted?"deleted":"missing");
} }
} }
@ -237,10 +230,10 @@ void Download(void)
*/ */
sprintf(symTo, "./tag/filedesc.%ld", exitinfo.Downloads % 256); sprintf(symTo, "./tag/filedesc.%ld", exitinfo.Downloads % 256);
if ((fd = fopen(symTo, "a")) != NULL) { 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++) { for (i = 0; i < 25; i++) {
if (strlen(file.Desc[i]) > 1) if (strlen(fdb.Desc[i]) > 1)
fprintf(fd, " %s\r\n", file.Desc[i]); fprintf(fd, " %s\r\n", fdb.Desc[i]);
} }
fprintf(fd, "\r\n"); fprintf(fd, "\r\n");
fclose(fd); fclose(fd);
@ -287,9 +280,9 @@ void Download(void)
* Count file and sizes. * Count file and sizes.
*/ */
Count++; Count++;
Size += file.Size; Size += fdb.Size;
if ((!file.Free) && (!area.Free)) if (!area.Free)
CostSize += file.Size; CostSize += fdb.Size;
} }
} }
} }
@ -437,15 +430,15 @@ void Download(void)
*/ */
SetFileArea(Tag.Area); SetFileArea(Tag.Area);
if ((fp = OpenFileBase(Tag.Area, TRUE)) != NULL) { if ((fp = OpenFileBase(Tag.Area, TRUE)) != NULL) {
while (fread(&file, sizeof(file), 1, fp) == 1) { while (fread(&fdb, fdbhdr.recsize, 1, fp) == 1) {
if (strcmp(file.LName, Tag.LFile) == 0) if (strcmp(fdb.LName, Tag.LFile) == 0)
break; break;
} }
Size += file.Size; Size += fdb.Size;
file.TimesDL++; fdb.TimesDL++;
file.LastDL = time(NULL); fdb.LastDL = time(NULL);
fseek(fp, - sizeof(file), SEEK_CUR); fseek(fp, - fdbhdr.recsize, SEEK_CUR);
fwrite(&file, sizeof(file), 1, fp); fwrite(&fdb, fdbhdr.recsize, 1, fp);
fclose(fp); fclose(fp);
Count++; Count++;
} }
@ -570,136 +563,129 @@ void File_RawDir(char *OpData)
*/ */
int KeywordScan() int KeywordScan()
{ {
FILE *pAreas, *pFile; FILE *pAreas, *pFile;
int i, z, y, Found, Count = 0; int i, z, y, Found, Count = 0;
char *Name; char *Name, *tmpname, *BigDesc, temp[81];
char *tmpname; _Tag T;
char *BigDesc; unsigned long OldArea;
char temp[81];
_Tag T;
unsigned long OldArea;
Name = calloc(81, sizeof(char)); Name = calloc(81, sizeof(char));
tmpname = calloc(81, sizeof(char)); tmpname = calloc(81, sizeof(char));
BigDesc = calloc(1230, sizeof(char)); BigDesc = calloc(1230, sizeof(char));
OldArea = iAreaNumber; OldArea = iAreaNumber;
iLineCount = 2; /* Reset Line Counter to Zero */ iLineCount = 2; /* Reset Line Counter to Zero */
arecno = 1; /* Reset Area Number to One */ arecno = 1; /* Reset Area Number to One */
Enter(2); Enter(2);
/* Enter keyword to use for Search: */ /* Enter keyword to use for Search: */
pout(11, 0, (char *) Language(267)); pout(11, 0, (char *) Language(267));
colour(CFG.InputColourF, CFG.InputColourB); colour(CFG.InputColourF, CFG.InputColourB);
GetstrC(Name, 80); GetstrC(Name, 80);
if ((strcmp(Name, "")) == 0) if ((strcmp(Name, "")) == 0)
return 0; return 0;
strcpy(tmpname, tl(Name)); strcpy(tmpname, tl(Name));
strcpy(Name, ""); strcpy(Name, "");
y = strlen(tmpname); y = strlen(tmpname);
for (z = 0; z < y; z++) { for (z = 0; z < y; z++) {
if (tmpname[z] != '*') { if (tmpname[z] != '*') {
sprintf(temp, "%c", tmpname[z]); sprintf(temp, "%c", tmpname[z]);
strcat(Name, temp); strcat(Name, temp);
}
} }
Syslog('+', "KeywordScan(): \"%s\"", Name); }
Syslog('+', "KeywordScan(): \"%s\"", Name);
clear(); clear();
/* File search by keyword */ /* File search by keyword */
pout(15, 0, (char *) Language(268)); pout(15, 0, (char *) Language(268));
Enter(1); Enter(1);
InitTag(); InitTag();
for(i = 0; i < 25; i++) if ((pAreas = OpenFareas(FALSE)) == NULL)
sprintf(BigDesc, "%s%s", BigDesc, *(file.Desc + i)); return 0;
if ((pAreas = OpenFareas(FALSE)) == NULL) while (fread(&area, areahdr.recsize, 1, pAreas) == 1) {
return 0;
while (fread(&area, areahdr.recsize, 1, pAreas) == 1) { if ((Access(exitinfo.Security, area.LTSec)) && (area.Available) && (strlen(area.Password) == 0)) {
if ((Access(exitinfo.Security, area.LTSec)) && (area.Available) && (strlen(area.Password) == 0)) { if ((pFile = OpenFileBase(arecno, FALSE)) != NULL) {
if ((pFile = OpenFileBase(arecno, FALSE)) != NULL) { Nopper();
Found = FALSE;
Sheader();
Nopper(); while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
Found = FALSE;
Sheader();
while (fread(&file, sizeof(file), 1, pFile) == 1) { for (i = 0; i < 25; i++)
sprintf(BigDesc, "%s%s", BigDesc, *(fdb.Desc + i));
for(i = 0; i < 25; i++) if ((strstr(fdb.Name,Name) != NULL) || (strstr(tl(BigDesc), Name) != NULL)) {
sprintf(BigDesc, "%s%s", BigDesc, *(file.Desc + i));
if ((strstr(file.Name,Name) != NULL) || (strstr(tl(BigDesc), Name) != NULL)) { if (!Found) {
Enter(2);
if (iLC(2) == 1) {
free(BigDesc);
free(Name);
free(tmpname);
SetFileArea(OldArea);
return 1;
}
Found = TRUE;
}
if (!Found) { memset(&T, 0, sizeof(T));
Enter(2); T.Area = arecno;
if (iLC(2) == 1) { T.Active = FALSE;
free(BigDesc); T.Size = fdb.Size;
free(Name); strncpy(T.SFile, fdb.Name, 12);
free(tmpname); strncpy(T.LFile, fdb.LName, 80);
SetFileArea(OldArea); SetTag(T);
return 1; Count++;
} if (ShowOneFile() == 1) {
Found = TRUE; free(BigDesc);
} free(Name);
free(tmpname);
SetFileArea(OldArea);
return 1;
}
}
strcpy(BigDesc, ""); /* Clear BigDesc */
memset(&T, 0, sizeof(T)); } /* while */
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);
SetTag(T);
Count++;
if (ShowOneFile() == 1) {
free(BigDesc);
free(Name);
free(tmpname);
SetFileArea(OldArea);
return 1;
}
}
strcpy(BigDesc, ""); /* Clear BigDesc */
} /* while */ fclose(pFile);
if (Found) {
Enter(2);
if (iLC(2) == 1) {
free(BigDesc);
free(Name);
free(tmpname);
SetFileArea(OldArea);
return 1;
}
}
fclose(pFile); } /* End check for LTSec */
if (Found) { } /* if access */
Enter(2); arecno++; /* Go to next file area */
if (iLC(2) == 1) { } /* End of Main */
free(BigDesc);
free(Name);
free(tmpname);
SetFileArea(OldArea);
return 1;
}
}
} /* End check for LTSec */ Syslog('+', "Found %d files", Count);
} /* if access */ free(BigDesc);
arecno++; /* Go to next file area */ free(Name);
} /* End of Main */ free(tmpname);
fclose(pAreas);
Syslog('+', "Found %d files", Count); printf("\n");
free(BigDesc); if (Count)
free(Name); Mark();
free(tmpname); else
fclose(pAreas); Pause();
printf("\n"); SetFileArea(OldArea);
if (Count) return 1;
Mark();
else
Pause();
SetFileArea(OldArea);
return 1;
} }
@ -779,9 +765,9 @@ int FilenameScan()
Sheader(); Sheader();
Nopper(); 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) { if (!Found) {
Enter(2); Enter(2);
if (iLC(2) == 1) { if (iLC(2) == 1) {
@ -794,10 +780,9 @@ int FilenameScan()
memset(&T, 0, sizeof(T)); memset(&T, 0, sizeof(T));
T.Area = arecno; T.Area = arecno;
T.Active = FALSE; T.Active = FALSE;
T.Cost = file.Cost; T.Size = fdb.Size;
T.Size = file.Size; strncpy(T.SFile, fdb.Name, 12);
strncpy(T.SFile, file.Name, 12); strncpy(T.LFile, fdb.LName, 81);
strncpy(T.LFile, file.LName, 81);
SetTag(T); SetTag(T);
Count++; Count++;
if (ShowOneFile() == 1) { if (ShowOneFile() == 1) {
@ -904,8 +889,8 @@ int NewfileScan(int AskStart)
Found = FALSE; Found = FALSE;
Nopper(); Nopper();
while (fread(&file, sizeof(file), 1, pFile) == 1) { while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
strcpy(temp, StrDateDMY(file.UploadDate)); /* Realloc Space for Date */ strcpy(temp, StrDateDMY(fdb.UploadDate)); /* Realloc Space for Date */
Date[0] = temp[6]; /* Swap the date around */ Date[0] = temp[6]; /* Swap the date around */
Date[1] = temp[7]; /* Instead of DD-MM-YYYY */ Date[1] = temp[7]; /* Instead of DD-MM-YYYY */
Date[2] = temp[8]; /* Let it equal YYYYMMDD */ Date[2] = temp[8]; /* Let it equal YYYYMMDD */
@ -934,10 +919,9 @@ int NewfileScan(int AskStart)
memset(&T, 0, sizeof(T)); memset(&T, 0, sizeof(T));
T.Area = arecno; T.Area = arecno;
T.Active = FALSE; T.Active = FALSE;
T.Cost = file.Cost; T.Size = fdb.Size;
T.Size = file.Size; strncpy(T.SFile, fdb.Name, 12);
strncpy(T.SFile, file.Name, 12); strncpy(T.LFile, fdb.LName, 80);
strncpy(T.LFile, file.LName, 80);
SetTag(T); SetTag(T);
Count++; Count++;
@ -1992,105 +1976,105 @@ void FileArea_List(char *Option)
*/ */
void Copy_Home() void Copy_Home()
{ {
FILE *pFile; FILE *pFile;
char *File, *temp1, *temp2; char *File, *temp1, *temp2;
int err, Found = FALSE; int err, Found = FALSE;
File = calloc(81, sizeof(char)); File = calloc(81, sizeof(char));
temp1 = calloc(PATH_MAX, sizeof(char)); temp1 = calloc(PATH_MAX, sizeof(char));
temp2 = calloc(PATH_MAX, sizeof(char)); temp2 = calloc(PATH_MAX, sizeof(char));
colour(14,0); colour(14,0);
/* Please enter filename: */ /* Please enter filename: */
printf("\n%s", (char *) Language(245)); printf("\n%s", (char *) Language(245));
colour(CFG.InputColourF, CFG.InputColourB); colour(CFG.InputColourF, CFG.InputColourB);
GetstrC(File, 80); GetstrC(File, 80);
if ((strcmp(File, "")) == 0) {
colour(CFG.HiliteF, CFG.HiliteB);
/* No filename entered, Aborting. */
printf("\n\n%s\n", (char *) Language(246));
Pause();
free(File);
free(temp1);
free(temp2);
return;
}
if (*(File) == '/' || *(File) == ' ') {
colour(CFG.HiliteF, CFG.HiliteB);
/* Illegal Filename! */
printf("\n%s\n\n", (char *) Language(247));
Pause();
free(File);
free(temp1);
free(temp2);
return;
}
if (Access(exitinfo.Security, area.DLSec) == FALSE) {
colour(14, 0);
printf("\n%s\n", (char *) Language(236));
Pause();
free(File);
free(temp1);
free(temp2);
return;
}
if ((pFile = OpenFileBase(iAreaNumber, FALSE)) == NULL) {
free(File);
free(temp1);
free(temp2);
return;
}
while (fread(&file, sizeof(file), 1, pFile) == 1) {
if ((strcasecmp(File, file.Name) == 0) || (strcasecmp(File, file.LName) == 0)) {
Found = TRUE;
if (((file.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(temp2, "%s/%s/wrk/%s", CFG.bbs_usersdir, exitinfo.Name, File);
colour(CFG.TextColourF, CFG.TextColourB);
/* Start copy: */
printf("%s%s ", (char *) Language(289), File);
fflush(stdout);
Syslog('b', "Copy from : %s", temp1);
Syslog('b', "Copy to : %s", temp2);
if ((err = file_cp(temp1, temp2))) {
colour(CFG.HiliteF, CFG.HiliteB);
/* Failed! */
printf("%s\n", (char *) Language(353));
WriteError("Copy %s to homedir failed, code %d", File, err);
} else {
/* Ok */
printf("%s\n", (char *) Language(200));
Syslog('+', "Copied %s from area %d to homedir", File, iAreaNumber);
}
}
}
}
fclose(pFile);
if (!Found) {
colour(CFG.HiliteF, CFG.HiliteB);
/* File does not exist, please try again ... */
printf("%s\n", (char *) Language(296));
}
if ((strcmp(File, "")) == 0) {
colour(CFG.HiliteF, CFG.HiliteB);
/* No filename entered, Aborting. */
printf("\n\n%s\n", (char *) Language(246));
Pause(); Pause();
free(File); free(File);
free(temp1); free(temp1);
free(temp2); free(temp2);
return;
}
if (*(File) == '/' || *(File) == ' ') {
colour(CFG.HiliteF, CFG.HiliteB);
/* Illegal Filename! */
printf("\n%s\n\n", (char *) Language(247));
Pause();
free(File);
free(temp1);
free(temp2);
return;
}
if (Access(exitinfo.Security, area.DLSec) == FALSE) {
colour(14, 0);
printf("\n%s\n", (char *) Language(236));
Pause();
free(File);
free(temp1);
free(temp2);
return;
}
if ((pFile = OpenFileBase(iAreaNumber, FALSE)) == NULL) {
free(File);
free(temp1);
free(temp2);
return;
}
while (fread(&fdb, fdbhdr.recsize, 1, pFile) == 1) {
if ((strcasecmp(File, fdb.Name) == 0) || (strcasecmp(File, fdb.LName) == 0)) {
Found = TRUE;
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, 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: */
printf("%s%s ", (char *) Language(289), File);
fflush(stdout);
Syslog('b', "Copy from : %s", temp1);
Syslog('b', "Copy to : %s", temp2);
if ((err = file_cp(temp1, temp2))) {
colour(CFG.HiliteF, CFG.HiliteB);
/* Failed! */
printf("%s\n", (char *) Language(353));
WriteError("Copy %s to homedir failed, code %d", File, err);
} else {
/* Ok */
printf("%s\n", (char *) Language(200));
Syslog('+', "Copied %s from area %d to homedir", File, iAreaNumber);
}
}
}
}
fclose(pFile);
if (!Found) {
colour(CFG.HiliteF, CFG.HiliteB);
/* File does not exist, please try again ... */
printf("%s\n", (char *) Language(296));
}
Pause();
free(File);
free(temp1);
free(temp2);
} }
@ -2289,8 +2273,8 @@ void ViewFile(char *name)
return; 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)) && (!file.Deleted) && (!file.Missing)) { if (((strcasecmp(File, fdb.Name) == 0) || (strcasecmp(File, fdb.LName) == 0)) && (!fdb.Deleted)) {
found = TRUE; found = TRUE;
break; break;
} }
@ -2306,9 +2290,9 @@ void ViewFile(char *name)
return; return;
} }
sprintf(File, "%s/%s", sAreaPath, file.LName); sprintf(File, "%s/%s", sAreaPath, fdb.LName);
arc = GetFileType(File); 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) { if (arc != NULL) {
found = FALSE; found = FALSE;

View File

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

View File

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

View File

@ -232,9 +232,8 @@ void FileScreen(void)
mvprintw(12,59, "21. DL days"); mvprintw(12,59, "21. DL days");
mvprintw(13,59, "22. FD days"); mvprintw(13,59, "22. FD days");
mvprintw(14,59, "23. Move area"); mvprintw(14,59, "23. Move area");
mvprintw(15,59, "24. Cost"); mvprintw(15,59, "24. Archiver");
mvprintw(16,59, "25. Archiver"); mvprintw(16,59, "25. Upload");
mvprintw(17,59, "26. Upload");
} }
@ -303,11 +302,10 @@ int EditFileRec(int Area)
show_int(12,73, area.DLdays); show_int(12,73, area.DLdays);
show_int(13,73, area.FDdays); show_int(13,73, area.FDdays);
show_int(14,73, area.MoveArea); show_int(14,73, area.MoveArea);
show_int(15,73, area.Cost); show_str(15,73, 5, area.Archiver);
show_str(16,73, 5, area.Archiver); show_int(16,73, area.Upload);
show_int(17,73, area.Upload);
switch(select_menu(26)) { switch(select_menu(25)) {
case 0: crc1 = 0xffffffff; case 0: crc1 = 0xffffffff;
crc1 = upd_crc32((char *)&area, crc1, areahdr.recsize); crc1 = upd_crc32((char *)&area, crc1, areahdr.recsize);
if (crc != crc1) { 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 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^"); case 7: Available = edit_bool(12, 16, area.Available, (char *)"Is this area ^available^");
temp = calloc(PATH_MAX, sizeof(char)); 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) { if (area.Available && !Available) {
/* /*
* Attempt to disable this area, but check first. * Attempt to disable this area, but check first.
*/ */
if ((fp = fopen(temp, "r"))) { if ((fp = fopen(temp, "r"))) {
fread(&fdbhdr, sizeof(fdbhdr), 1, fp);
fseek(fp, 0, SEEK_END); fseek(fp, 0, SEEK_END);
files = ftell(fp) / sizeof(file); files = ((ftell(fp) - fdbhdr.hdrsize) / fdbhdr.recsize);
if (files) { if (files) {
errmsg("There are stil %d files in this area", files); errmsg("There are stil %d files in this area", files);
Available = TRUE; 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 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 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 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 24:strcpy(area.Archiver, PickArchive((char *)"8.4"));
case 25:strcpy(area.Archiver, PickArchive((char *)"8.4"));
FileScreen(); FileScreen();
break; 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

@ -44,71 +44,61 @@ void EditFile(void);
void FHeader(void) void FHeader(void)
{ {
clr_index(); clr_index();
set_color(WHITE, BLACK); set_color(WHITE, BLACK);
mvprintw( 5, 2, "14. EDIT FILE"); mvprintw( 5, 2, "14. EDIT FILE");
set_color(CYAN, BLACK); set_color(CYAN, BLACK);
mvprintw( 7, 2, " FileName"); mvprintw( 7, 2, " FileName");
mvprintw( 8, 2, " Long fn"); mvprintw( 8, 2, " Long fn");
mvprintw( 9, 2, " FileSize"); mvprintw( 9, 2, " FileSize");
mvprintw(10, 2, " FileDate"); mvprintw(10, 2, " FileDate");
mvprintw(11, 2, " Last DL."); mvprintw(11, 2, " Last DL.");
mvprintw(12, 2, " Upl.Date"); mvprintw(12, 2, " Upl.Date");
mvprintw(13, 2, "1. Uploader"); mvprintw(13, 2, " TIC area");
mvprintw(14, 2, "2. Times DL"); mvprintw(14, 2, " Magic");
mvprintw(15, 2, "3. Times FTP"); mvprintw(15, 2, "1. Uploader");
mvprintw(16, 2, "4. Times Req"); mvprintw(16, 2, "2. Times DL");
mvprintw(17, 2, "5. Password"); mvprintw(17, 2, "3. Password");
mvprintw(18, 2, "6. Cost");
mvprintw(14,42, "7. Free"); mvprintw(15,61, "4. Deleted");
mvprintw(15,42, "8. Deleted"); mvprintw(16,61, "5. No Kill");
mvprintw(16,42, " Missing"); mvprintw(17,61, "6. Announced");
mvprintw(17,42, "9. No Kill");
mvprintw(18,42, "10. Announced");
} }
void EditFile() void EditFile()
{ {
FHeader(); FHeader();
for (;;) { for (;;) {
set_color(WHITE, BLACK); set_color(WHITE, BLACK);
show_str( 7,16,12, file.Name); show_str( 7,16,12, fdb.Name);
show_str( 8,16,64, file.LName); show_str( 8,16,64, fdb.LName);
show_int( 9,16, file.Size); show_int( 9,16, fdb.Size);
mvprintw(10,16, (char *)"%s %s", StrDateDMY(file.FileDate), StrTimeHM(file.FileDate)); mvprintw(10,16, (char *)"%s %s", StrDateDMY(fdb.FileDate), StrTimeHM(fdb.FileDate));
mvprintw(11,16, (char *)"%s %s", StrDateDMY(file.LastDL), StrTimeHM(file.LastDL)); mvprintw(11,16, (char *)"%s %s", StrDateDMY(fdb.LastDL), StrTimeHM(fdb.LastDL));
mvprintw(12,16, (char *)"%s %s", StrDateDMY(file.UploadDate), StrTimeHM(file.UploadDate)); mvprintw(12,16, (char *)"%s %s", StrDateDMY(fdb.UploadDate), StrTimeHM(fdb.UploadDate));
show_str(13,16,36, file.Uploader); show_str(13,16,20, fdb.TicArea);
show_int(14,16, file.TimesDL); show_str(14,16,20, fdb.Magic);
show_int(15,16, file.TimesFTP); show_str(15,16,36, fdb.Uploader);
show_int(16,16, file.TimesReq); show_int(16,16, fdb.TimesDL);
show_str(17,16,15, file.Password); show_str(17,16,15, fdb.Password);
show_int(18,16, file.Cost);
show_bool(14,56, file.Free); show_bool(15,75, fdb.Deleted);
show_bool(15,56, file.Deleted); show_bool(16,75, fdb.NoKill);
show_bool(16,56, file.Missing); show_bool(17,75, fdb.Announced);
show_bool(17,56, file.NoKill);
show_bool(18,56, file.Announced);
switch(select_menu(10)) { switch(select_menu(6)) {
case 0: return; case 0: return;
case 1: E_STR( 13,16,35, file.Uploader, "The ^uploader^ of this file") case 1: E_STR( 15,16,35, fdb.Uploader, "The ^uploader^ of this file")
case 2: E_INT( 14,16, file.TimesDL, "The number of times file is sent with ^download^") case 2: E_INT( 16,16, fdb.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 3: E_STR( 17,16,15, fdb.Password, "The ^password^ to protect this file with")
case 4: E_INT( 16,16, file.TimesReq, "The number of times file is sent with ^filerequest^") case 4: E_BOOL(15,75, fdb.Deleted, "Should this this file be ^deleted^")
case 5: E_STR( 17,16,15, file.Password, "The ^password^ to protect this file with") case 5: E_BOOL(16,75, fdb.NoKill, "File can't be ^killed^ automatic")
case 6: E_INT( 18,16, file.Cost, "The ^cost^ of this file") case 6: E_BOOL(17,75, fdb.Announced, "File is ^announced^ as new 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")
}
} }
}
} }
@ -126,7 +116,7 @@ void E_F(long areanr)
clr_index(); 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) { if ((fil = fopen(temp, "r+")) == NULL) {
working(2, 0, 0); working(2, 0, 0);
return; return;
@ -134,8 +124,9 @@ void E_F(long areanr)
if (! check_free()) if (! check_free())
return; return;
fread(&fdbhdr, sizeof(fdbhdr), 1, fil);
fseek(fil, 0, SEEK_END); fseek(fil, 0, SEEK_END);
records = ftell(fil) / sizeof(file); records = ((ftell(fil) - fdbhdr.hdrsize) / fdbhdr.recsize);
o = 0; o = 0;
for (;;) { for (;;) {
@ -154,41 +145,41 @@ void E_F(long areanr)
for (i = 1; i <= 10; i++) { for (i = 1; i <= 10; i++) {
if ((o + i) <= records) { if ((o + i) <= records) {
offset = ((o + i) - 1) * sizeof(file); offset = (((o + i) - 1) * fdbhdr.recsize) + fdbhdr.hdrsize;
fseek(fil, offset, SEEK_SET); fseek(fil, offset, SEEK_SET);
fread(&file, sizeof(file), 1, fil); fread(&fdb, fdbhdr.recsize, 1, fil);
set_color(WHITE, BLACK); set_color(WHITE, BLACK);
mvprintw(y, 1, (char *)"%4d.", o + i); 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); Ondisk = ((stat(temp, &statfile)) != -1);
if (file.Deleted) if (fdb.Deleted)
set_color(LIGHTBLUE, BLACK); set_color(LIGHTBLUE, BLACK);
else if (Ondisk) else if (Ondisk)
set_color(CYAN, BLACK); set_color(CYAN, BLACK);
else else
set_color(LIGHTRED, BLACK); set_color(LIGHTRED, BLACK);
mvprintw(y, 8, (char *)"%-14s", file.Name); mvprintw(y, 8, (char *)"%-14s", fdb.Name);
if (Ondisk) { if (Ondisk) {
if (file.Size == statfile.st_size) if (fdb.Size == statfile.st_size)
set_color(CYAN, BLACK); set_color(CYAN, BLACK);
else else
set_color(LIGHTRED, BLACK); 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); set_color(CYAN, BLACK);
else else
set_color(LIGHTRED, BLACK); set_color(LIGHTRED, BLACK);
Time = file.FileDate; Time = fdb.FileDate;
mvprintw(y,32, (char *)"%s %s", StrDateDMY(Time), StrTimeHM(Time)); mvprintw(y,32, (char *)"%s %s", StrDateDMY(Time), StrTimeHM(Time));
} }
set_color(CYAN, BLACK); set_color(CYAN, BLACK);
sprintf(temp, "%s", file.Desc[0]); sprintf(temp, "%s", fdb.Desc[0]);
temp[30] = '\0'; temp[30] = '\0';
mvprintw(y,49, (char *)"%s", temp); mvprintw(y,49, (char *)"%s", temp);
y++; y++;
@ -234,26 +225,23 @@ void E_F(long areanr)
if ((atoi(menu) > 0) && (atoi(menu) <= records)) { if ((atoi(menu) > 0) && (atoi(menu) <= records)) {
working(1, 0, 0); working(1, 0, 0);
offset = (atoi(menu) - 1) * sizeof(file); offset = ((atoi(menu) - 1) * fdbhdr.recsize) + fdbhdr.hdrsize;
fseek(fil, offset, SEEK_SET); fseek(fil, offset, SEEK_SET);
fread(&file, sizeof(file), 1, fil); fread(&fdb, fdbhdr.recsize, 1, fil);
crc = 0xffffffff; crc = 0xffffffff;
crc = upd_crc32((char *)&file, crc, sizeof(file)); crc = upd_crc32((char *)&fdb, crc, fdbhdr.recsize);
sprintf(temp, "%s/%s", area.Path, file.LName);
if (stat(temp, &statfile) == -1)
file.Missing = TRUE;
sprintf(temp, "%s/%s", area.Path, fdb.LName);
EditFile(); EditFile();
crc1 = 0xffffffff; crc1 = 0xffffffff;
crc1 = upd_crc32((char *)&file, crc1, sizeof(file)); crc1 = upd_crc32((char *)&fdb, crc1, fdbhdr.recsize);
if (crc != crc1) { if (crc != crc1) {
if (yes_no((char *)"Record is changed, save") == 1) { if (yes_no((char *)"Record is changed, save") == 1) {
working(1, 0, 0); working(1, 0, 0);
fseek(fil, offset, SEEK_SET); fseek(fil, offset, SEEK_SET);
fwrite(&file, sizeof(file), 1, fil); fwrite(&fdb, fdbhdr.recsize, 1, fil);
working(6, 0, 0); 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 #ifndef _M_FDB_H
#define _M_FDB_H #define _M_FDB_H
/* $Id$ */
void EditFDB(void); void EditFDB(void);
void InitFDB(void);
#endif #endif

View File

@ -219,7 +219,6 @@ int AppendFGroup(void)
if ((fil = fopen(ffile, "a")) != NULL) { if ((fil = fopen(ffile, "a")) != NULL) {
memset(&fgroup, 0, sizeof(fgroup)); memset(&fgroup, 0, sizeof(fgroup));
fgroup.StartDate = time(NULL); fgroup.StartDate = time(NULL);
fgroup.DivideCost = TRUE;
fgroup.FileGate = TRUE; fgroup.FileGate = TRUE;
fgroup.Secure = TRUE; fgroup.Secure = TRUE;
fgroup.VirScan = TRUE; fgroup.VirScan = TRUE;
@ -280,28 +279,24 @@ void FgScreen(void)
mvprintw(18, 2, "13. Deleted"); mvprintw(18, 2, "13. Deleted");
mvprintw(19, 2, "14. Start at"); mvprintw(19, 2, "14. Start at");
mvprintw(11,32, "15. Unit Cost"); mvprintw(12,32, "15. Auto chng");
mvprintw(12,32, "16. Unit Size"); mvprintw(13,32, "16. User chng");
mvprintw(13,32, "17. Add Prom."); mvprintw(14,32, "17. Replace");
mvprintw(14,32, "18. Divide"); mvprintw(15,32, "18. Dupecheck");
mvprintw(15,32, "19. Auto chng"); mvprintw(16,32, "19. Secure");
mvprintw(16,32, "20. User chng"); mvprintw(17,32, "20. Touch");
mvprintw(17,32, "21. Replace"); mvprintw(18,32, "21. Virscan");
mvprintw(18,32, "22. Dupecheck"); mvprintw(19,32, "22. Announce");
mvprintw(19,32, "23. Secure");
mvprintw( 9,56, "24. Touch"); mvprintw(11,56, "23. Upd magic");
mvprintw(10,56, "25. Virscan"); mvprintw(12,56, "24. File ID");
mvprintw(11,56, "26. Announce"); mvprintw(13,56, "25. Conv. all");
mvprintw(12,56, "27. Upd magic"); mvprintw(14,56, "26. Send orig");
mvprintw(13,56, "28. File ID"); mvprintw(15,56, "27. DL sec");
mvprintw(14,56, "29. Conv. all"); mvprintw(16,56, "28. UP sec");
mvprintw(15,56, "30. Send orig"); mvprintw(17,56, "29. LT sec");
mvprintw(16,56, "31. DL sec"); mvprintw(18,56, "30. Upl. area");
mvprintw(17,56, "32. UP sec"); mvprintw(19,56, "31. Link sec");
mvprintw(18,56, "33. LT sec");
mvprintw(19,56, "34. Upl. area");
mvprintw(20,56, "35. Link sec");
} }
@ -356,29 +351,25 @@ int EditFGrpRec(int Area)
show_bool(18,16, fgroup.Deleted); show_bool(18,16, fgroup.Deleted);
show_int( 19,16, fgroup.StartArea); show_int( 19,16, fgroup.StartArea);
show_int( 11,46, fgroup.UnitCost); show_bool(12,46, fgroup.AutoChange);
show_int( 12,46, fgroup.UnitSize); show_bool(13,46, fgroup.UserChange);
show_int( 13,46, fgroup.AddProm); show_bool(14,46, fgroup.Replace);
show_bool(14,46, fgroup.DivideCost); show_bool(15,46, fgroup.DupCheck);
show_bool(15,46, fgroup.AutoChange); show_bool(16,46, fgroup.Secure);
show_bool(16,46, fgroup.UserChange); show_bool(17,46, fgroup.Touch);
show_bool(17,46, fgroup.Replace); show_bool(18,46, fgroup.VirScan);
show_bool(18,46, fgroup.DupCheck); show_bool(19,46, fgroup.Announce);
show_bool(19,46, fgroup.Secure);
show_bool( 9,70, fgroup.Touch); show_bool(11,70, fgroup.UpdMagic);
show_bool(10,70, fgroup.VirScan); show_bool(12,70, fgroup.FileId);
show_bool(11,70, fgroup.Announce); show_bool(13,70, fgroup.ConvertAll);
show_bool(12,70, fgroup.UpdMagic); show_bool(14,70, fgroup.SendOrg);
show_bool(13,70, fgroup.FileId); show_int( 15,70, fgroup.DLSec.level);
show_bool(14,70, fgroup.ConvertAll); show_int( 16,70, fgroup.UPSec.level);
show_bool(15,70, fgroup.SendOrg); show_int( 17,70, fgroup.LTSec.level);
show_int( 16,70, fgroup.DLSec.level); show_int( 18,70, fgroup.Upload);
show_int( 17,70, fgroup.UPSec.level);
show_int( 18,70, fgroup.LTSec.level);
show_int( 19,70, fgroup.Upload);
j = select_menu(35); j = select_menu(31);
switch(j) { switch(j) {
case 0: if (!fgroup.StartArea && strlen(fgroup.AreaFile)) { case 0: if (!fgroup.StartArea && strlen(fgroup.AreaFile)) {
errmsg("Areas file defined but no BBS start area"); 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^") 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 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 15:E_BOOL(12,46, fgroup.AutoChange, "^Automatic change areas^ when a new arealist is received")
case 16:E_INT( 12,46, fgroup.UnitSize, "The ^unit size^ in KBytes, 0 means cost per file in this tic group") case 16:tmp = edit_bool(13,46, fgroup.UserChange, (char *)"Create new areas when ^users^ request new tic areas");
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");
if (tmp && !fgroup.UpLink.zone) if (tmp && !fgroup.UpLink.zone)
errmsg("It looks like you are at the toplevel, no Uplink defined"); errmsg("It looks like you are at the toplevel, no Uplink defined");
else else
fgroup.UserChange = tmp; fgroup.UserChange = tmp;
break; break;
case 21:E_BOOL(17,46, fgroup.Replace, "Set ^Replace^ in new created tic areas") case 17:E_BOOL(14,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 18:E_BOOL(15,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 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 23:E_BOOL(11,70, fgroup.UpdMagic, "Set ^Update magic^ in new created tic areas")
case 25:E_BOOL(10,70, fgroup.VirScan, "Set ^Virus scanner^ in new created tic areas") case 24:E_BOOL(12,70, fgroup.FileId, "Set ^FILE_ID.DIZ extract^ in new created tic areas")
case 26:E_BOOL(11,70, fgroup.Announce, "Set ^Announce files^ in new created tic areas") case 25:tmp = edit_bool(13,70, fgroup.ConvertAll, (char *)"Set ^Convert All^ setting 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");
if (tmp && !fgroup.ConvertAll && (strlen(fgroup.Convert) == 0)) if (tmp && !fgroup.ConvertAll && (strlen(fgroup.Convert) == 0))
errmsg("No archiver configured to convert to, edit 9 first"); errmsg("No archiver configured to convert to, edit 9 first");
else else
fgroup.ConvertAll = tmp; fgroup.ConvertAll = tmp;
break; break;
case 30:E_BOOL(15,70, fgroup.SendOrg, "Set ^Send original^ setting in new created tic areas") case 26:E_BOOL(14,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 27:E_SEC( 15,70, fgroup.DLSec, "10.1.27 FILE GROUP DOWNLOAD SECURITY", FgScreen)
case 32:E_SEC( 17,70, fgroup.UPSec, "10.1.32 FILE GROUP UPLOAD SECURITY", FgScreen) case 28:E_SEC( 16,70, fgroup.UPSec, "10.1.28 FILE GROUP UPLOAD SECURITY", FgScreen)
case 33:E_SEC( 18,70, fgroup.LTSec, "10.1.33 FILE GROUP LIST SECURITY", FgScreen) case 29:E_SEC( 17,70, fgroup.LTSec, "10.1.29 FILE GROUP LIST SECURITY", FgScreen)
case 34:E_INT( 19,70, fgroup.Upload, "Set the default ^Upload area^ in new created file areas") case 30:E_INT( 18,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 31:fgroup.LinkSec = edit_asec(fgroup.LinkSec, (char *)"10.1.31 DEFAULT NEW TIC AREAS SECURITY");
FgScreen(); FgScreen();
break; 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, " Use Aka %s\n", aka2str(fgroup.UseAka));
fprintf(fp, " Uplink %s\n", aka2str(fgroup.UpLink)); fprintf(fp, " Uplink %s\n", aka2str(fgroup.UpLink));
fprintf(fp, " Areas file %s\n", fgroup.AreaFile); 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, " Start area %ld\n", fgroup.StartArea);
fprintf(fp, " Banner file %s\n", fgroup.Banner); fprintf(fp, " Banner file %s\n", fgroup.Banner);
fprintf(fp, " Def. archiver %s\n", fgroup.Convert); 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(14, 6, "8. Advanced TIC");
mvprintw(15, 6, "9. Advanced SB"); mvprintw(15, 6, "9. Advanced SB");
mvprintw(16, 6, "10. To line in TIC"); mvprintw(16, 6, "10. To line in TIC");
mvprintw(17, 6, "11. File forward");
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");
for (;;) { for (;;) {
set_color(WHITE, BLACK); set_color(WHITE, BLACK);
@ -462,35 +454,21 @@ void E_Files(void)
show_bool(14,26, nodes.AdvTic); show_bool(14,26, nodes.AdvTic);
show_bool(15,26, nodes.TIC_AdvSB); show_bool(15,26, nodes.TIC_AdvSB);
show_bool(16,26, nodes.TIC_To); show_bool(16,26, nodes.TIC_To);
show_bool( 7,66, nodes.FileFwd); show_bool(17,26, 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);
switch(select_menu(18)) { switch(select_menu(11)) {
case 0: return; case 0: return;
case 1: E_STR( 7,26,15,nodes.Fpasswd, "The ^TIC^ files ^password^ for this node") 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") case 2: E_STR( 8,26,15,nodes.Apasswd, "The filemanager ^password^ for this node")
case 3: E_STR( 9,26,8, nodes.UplFmgrPgm, "The name of the uplink ^filemanager^ program") case 3: E_STR( 9,26,8, nodes.UplFmgrPgm, "The name of the uplink ^filemanager^ program")
case 4: E_STR( 10,26,15,nodes.UplFmgrPass,"The uplink filemanager ^password^") case 4: E_STR( 10,26,15,nodes.UplFmgrPass,"The uplink filemanager ^password^")
case 5: E_BOOL(11,26, nodes.AddPlus, "Add ^+^ in uplink manager requests for new areas") case 5: E_BOOL(11,26, nodes.AddPlus, "Add ^+^ in uplink manager requests for new areas")
case 6: E_BOOL(12,26, nodes.Message, "Send ^messages^ with files send to this node") case 6: E_BOOL(12,26, nodes.Message, "Send ^messages^ with files send to this node")
case 7: E_BOOL(13,26, nodes.Tic, "Send ^TIC^ files to this node") case 7: E_BOOL(13,26, nodes.Tic, "Send ^TIC^ files to this node")
case 8: E_BOOL(14,26, nodes.AdvTic, "Send ^advanced^ TIC files to this node") 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 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 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 11:E_BOOL(17,26, 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")
} }
} }
} }
@ -1486,8 +1464,6 @@ int node_doc(FILE *fp, FILE *toc, int page)
fprintf(fp, " Advanced TIC %s\n", getboolean(nodes.AdvTic)); fprintf(fp, " Advanced TIC %s\n", getboolean(nodes.AdvTic));
fprintf(fp, " Advanded SB %s", getboolean(nodes.TIC_AdvSB)); fprintf(fp, " Advanded SB %s", getboolean(nodes.TIC_AdvSB));
fprintf(fp, " Sent To lines %s", getboolean(nodes.TIC_To)); 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, " Uplink add + %s\n", getboolean(nodes.AddPlus));
fprintf(fp, " Security flags %s\n\n", getflag(nodes.Security.flags, nodes.Security.notflags)); 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 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); 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 "); fprintf(fp, " File groups:\n ");
groups = nodeshdr.filegrp / sizeof(group); groups = nodeshdr.filegrp / sizeof(group);
for (i = 0; i < groups; i++) { for (i = 0; i < groups; i++) {

View File

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