Fixed mball to prevent negative values

This commit is contained in:
Michiel Broek 2002-02-02 10:23:13 +00:00
parent 3ca520d2e0
commit 03016abff7
2 changed files with 17 additions and 15 deletions

View File

@ -4525,6 +4525,7 @@ v0.33.19 26-Oct-2001
The index function is now obsolete, this is added to mbfile. The index function is now obsolete, this is added to mbfile.
You may need to adjust your scripts that call "mball index". You may need to adjust your scripts that call "mball index".
Fixes for Sparc systems. Fixes for Sparc systems.
Fixed to prevent negative values with large filebases.
mbaff: mbaff:
Fixes for Sparc systems. Fixes for Sparc systems.

View File

@ -268,9 +268,9 @@ void Masterlist()
{ {
FILE *fp, *np, *pAreas, *pFile, *pHeader; FILE *fp, *np, *pAreas, *pFile, *pHeader;
int AreaNr = 0, z, x = 0, New; int AreaNr = 0, z, x = 0, New;
long AllFiles = 0, AllBytes = 0, NewFiles = 0, NewBytes = 0; unsigned long AllFiles = 0, AllKBytes = 0, NewFiles = 0, NewKBytes = 0;
int AllAreaFiles, AllAreaBytes, popdown, down; unsigned long AllAreaFiles, AllAreaBytes, popdown, down;
int NewAreaFiles, NewAreaBytes; unsigned long NewAreaFiles, NewAreaBytes;
char *sAreas, *fAreas; char *sAreas, *fAreas;
char temp[81], pop[81]; char temp[81], pop[81];
@ -346,7 +346,6 @@ void Masterlist()
if (CFG.slow_util && do_quiet && ((x % 3) == 0)) if (CFG.slow_util && do_quiet && ((x % 3) == 0))
usleep(1); usleep(1);
AllFiles++; AllFiles++;
AllBytes += file.Size;
AllAreaFiles++; AllAreaFiles++;
AllAreaBytes += file.Size; AllAreaBytes += file.Size;
down = file.TimesDL + file.TimesFTP + file.TimesReq; down = file.TimesDL + file.TimesFTP + file.TimesReq;
@ -356,13 +355,15 @@ void Masterlist()
} }
if (((t_start - file.UploadDate) / 84400) <= CFG.newdays) { if (((t_start - file.UploadDate) / 84400) <= CFG.newdays) {
NewFiles++; NewFiles++;
NewBytes += file.Size;
NewAreaFiles++; NewAreaFiles++;
NewAreaBytes += file.Size; NewAreaBytes += file.Size;
} }
} }
} }
AllKBytes += AllAreaBytes / 1024;
NewKBytes += NewAreaBytes / 1024;
/* /*
* If there are files to report do it. * If there are files to report do it.
*/ */
@ -378,9 +379,9 @@ void Masterlist()
MidLine(temp, fp, area.FileReq); MidLine(temp, fp, area.FileReq);
MidLine(temp, np, area.FileReq && NewAreaFiles); MidLine(temp, np, area.FileReq && NewAreaFiles);
sprintf(temp, "%d KBytes in %d files", AllAreaBytes / 1024, AllAreaFiles); sprintf(temp, "%ld KBytes in %ld files", AllAreaBytes / 1024, AllAreaFiles);
MidLine(temp, fp, TRUE); MidLine(temp, fp, TRUE);
sprintf(temp, "%d KBytes in %d files", NewAreaBytes / 1024, NewAreaFiles); sprintf(temp, "%ld KBytes in %ld files", NewAreaBytes / 1024, NewAreaFiles);
MidLine(temp, np, NewAreaFiles); MidLine(temp, np, NewAreaFiles);
if (popdown) { if (popdown) {
sprintf(temp, "Most popular file is %s", pop); sprintf(temp, "Most popular file is %s", pop);
@ -427,9 +428,9 @@ void Masterlist()
TopBox(fp, TRUE); TopBox(fp, TRUE);
TopBox(np, TRUE); TopBox(np, TRUE);
sprintf(temp, "Total %ld files, %ld KBytes", AllFiles, AllBytes / 1024); sprintf(temp, "Total %ld files, %ld KBytes", AllFiles, AllKBytes);
MidLine(temp, fp, TRUE); MidLine(temp, fp, TRUE);
sprintf(temp, "Total %ld files, %ld KBytes", NewFiles, NewBytes / 1024); sprintf(temp, "Total %ld files, %ld KBytes", NewFiles, NewKBytes);
MidLine(temp, np, TRUE); MidLine(temp, np, TRUE);
MidLine((char *)"", fp, TRUE); MidLine((char *)"", fp, TRUE);
@ -461,8 +462,8 @@ void Masterlist()
if ((rename("newfiles.tmp", "newfiles.txt")) == 0) if ((rename("newfiles.tmp", "newfiles.txt")) == 0)
unlink("newfiles.tmp"); unlink("newfiles.tmp");
Syslog('+', "Allfiles: %ld, %ld MBytes", AllFiles, AllBytes / 1048576); Syslog('+', "Allfiles: %ld, %ld MBytes", AllFiles, AllKBytes / 1024);
Syslog('+', "Newfiles: %ld, %ld MBytes", NewFiles, NewBytes / 1048576); Syslog('+', "Newfiles: %ld, %ld MBytes", NewFiles, NewKBytes / 1024);
free(sAreas); free(sAreas);
free(fAreas); free(fAreas);
} }