Code cleanup

This commit is contained in:
Michiel Broek 2005-08-19 19:46:55 +00:00
parent 829514d215
commit ccc8390ad3
6 changed files with 474 additions and 466 deletions

View File

@ -8,6 +8,15 @@ v0.71.5 18-Aug-2005
mbdiff:
Code cleanup.
mball:
Code cleanup.
mbstat:
Code cleanup.
mbuser:
Code cleanup.
v0.71.4 12-Aug-2005 - 18-Aug-2005

View File

@ -438,7 +438,7 @@ void Help(void)
printf(" directory.\n");
mbse_colour(LIGHTBLUE, BLACK);
printf("\n Options are:\n\n");
mbse_colour(CYAN, BLAKC);
mbse_colour(CYAN, BLACK);
printf(" -quiet Quiet mode\n");
mbse_colour(LIGHTGRAY, BLACK);
printf("\n");

View File

@ -41,6 +41,7 @@ static char *months[]={(char *)"Jan",(char *)"Feb",(char *)"Mar",
void count_download(char *, time_t, off_t, char *);
extern int do_quiet;
void dlcount(void)
@ -84,6 +85,8 @@ void dlcount(void)
/*
* Check apache logfile
*/
if (!do_quiet)
printf("Checking WWW downloads\n");
Syslog('+', "Checking WWW downloads");
while (fgets(temp, PATH_MAX-1, fp)) {
@ -163,6 +166,8 @@ void dlcount(void)
/*
* Check apache logfile
*/
if (!do_quiet)
printf("Checking FTP downloads\n");
Syslog('+', "Checking FTP downloads");
while (fgets(temp, PATH_MAX-1, fp)) {

View File

@ -4,7 +4,7 @@
* Purpose ...............: Creates allfiles listings
*
*****************************************************************************
* Copyright (C) 1997-2004
* Copyright (C) 1997-2005
*
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
@ -52,9 +52,9 @@ void ProgName()
if (do_quiet)
return;
mbse_colour(15, 0);
mbse_colour(WHITE, BLACK);
printf("\nMBALL: MBSE BBS %s Allfiles Listing Creator\n", VERSION);
mbse_colour(14, 0);
mbse_colour(YELLOW, BLACK);
printf(" %s\n", COPYRIGHT);
}
@ -95,7 +95,7 @@ void die(int onsig)
Syslog(' ', "MBALL finished in %s", t_elapsed(t_start, t_end));
if (!do_quiet) {
mbse_colour(7, 0);
mbse_colour(LIGHTGRAY, BLACK);
printf("\n");
}
ExitClient(onsig);
@ -108,18 +108,18 @@ void Help()
do_quiet = FALSE;
ProgName();
mbse_colour(11, 0);
mbse_colour(LIGHTCYAN, BLACK);
printf("\nUsage: mball [command] <options>\n\n");
mbse_colour(9, 0);
mbse_colour(LIGHTBLUE, BLACK);
printf(" Commands are:\n\n");
mbse_colour(3, 0);
mbse_colour(CYAN, BLACK);
printf(" l list Create allfiles and newfiles lists\n");
mbse_colour(9, 0);
mbse_colour(LIGHTBLUE, BLACK);
printf("\n Options are:\n\n");
mbse_colour(3, 0);
mbse_colour(CYAN, BLACK);
printf(" -q -quiet Quiet mode\n");
printf(" -z -zip Create .zip archives\n");
mbse_colour(7, 0);
mbse_colour(LIGHTGRAY, BLACK);
printf("\n");
die(MBERR_COMMANDLINE);
}
@ -181,7 +181,7 @@ int main(int argc, char **argv)
free(cmd);
if (!do_quiet) {
mbse_colour(3, 0);
mbse_colour(CYAN, BLACK);
printf("\n");
}
@ -273,10 +273,8 @@ void Masterlist()
FILE *fp, *np, *pAreas, *pHeader;
int AreaNr = 0, z, x = 0, New;
unsigned long AllFiles = 0, AllKBytes = 0, NewFiles = 0, NewKBytes = 0;
unsigned long AllAreaFiles, AllAreaBytes, popdown, down;
unsigned long NewAreaFiles, NewAreaBytes;
char *sAreas;
char temp[81], pop[81];
unsigned long AllAreaFiles, AllAreaBytes, popdown, down, NewAreaFiles, NewAreaBytes;
char *sAreas, temp[81], pop[81];
struct _fdbarea *fdb_area = NULL;
sAreas = calloc(PATH_MAX, sizeof(char));
@ -287,7 +285,7 @@ void Masterlist()
if(( pAreas = fopen (sAreas, "r")) == NULL) {
WriteError("Can't open File Areas File: %s", sAreas);
mbse_colour(7,0);
mbse_colour(LIGHTGRAY, BLACK);
die(MBERR_GENERAL);
}
fread(&areahdr, sizeof(areahdr), 1, pAreas);
@ -338,7 +336,7 @@ void Masterlist()
Nopper();
if ((fdb_area = mbsedb_OpenFDB(AreaNr, 30)) == 0) {
WriteError("$Can't open Area %d (%s)! Skipping ...", AreaNr, area.Name);
WriteError("Can't open Area %d (%s)! Skipping ...", AreaNr, area.Name);
} else {
popdown = 0;
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
@ -507,6 +505,7 @@ void MakeArc()
if (!execute_str(cmd, (char *)"newfiles.zip newfiles.txt", (char *)NULL, (char *)"/dev/null",
(char *)"/dev/null", (char *)"/dev/null") == 0)
WriteError("Create newfiles.zip failed");
free(cmd);
cmd = NULL;
}

View File

@ -4,7 +4,7 @@
* Purpose ...............: Change BBS status
*
*****************************************************************************
* Copyright (C) 1997-2004
* Copyright (C) 1997-2005
*
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
@ -44,20 +44,20 @@ void Help(void)
do_quiet = FALSE;
ProgName();
mbse_colour(11, 0);
mbse_colour(LIGHTCYAN, BLACK);
printf("\nUsage: mbstat [command] <options>\n\n");
mbse_colour(9, 0);
mbse_colour(LIGHTBLUE, BLACK);
printf(" Commands are:\n\n");
mbse_colour(3, 0);
mbse_colour(CYAN, BLACK);
printf(" c close Close the BBS for users\n");
printf(" o open Open the BBS for users\n");
printf(" s set semafore Set named semafore\n");
printf(" w wait Wait until the BBS is free\n\n");
mbse_colour(9,0);
mbse_colour(LIGHTBLUE, BLACK);
printf(" Options are:\n\n");
mbse_colour(3, 0);
mbse_colour(CYAN, BLACK);
printf(" -q -quiet Quiet, no screen output\n");
mbse_colour(7, 0);
mbse_colour(LIGHTGRAY, BLACK);
die(MBERR_COMMANDLINE);
}
@ -68,11 +68,11 @@ void ProgName(void)
if (do_quiet)
return;
mbse_colour(15, 0);
mbse_colour(WHITE, BLACK);
printf("\nMBSTAT: MBSE BBS %s Status Changer\n", VERSION);
mbse_colour(14, 0);
mbse_colour(YELLOW, BLACK);
printf(" %s\n", COPYRIGHT);
mbse_colour(3, 0);
mbse_colour(CYAN, BLACK);
}
@ -85,7 +85,7 @@ void die(int onsig)
WriteError("Terminated on signal %d", onsig);
if (!do_quiet) {
mbse_colour(7, 0);
mbse_colour(LIGHTGRAY, BLACK);
printf("\n");
}
@ -155,7 +155,7 @@ int main(int argc, char **argv)
free(cmd);
if (!do_quiet) {
mbse_colour(3, 0);
mbse_colour(CYAN, BLACK);
printf("\n");
}

View File

@ -4,7 +4,7 @@
* Purpose ...............: User Pack Util
*
*****************************************************************************
* Copyright (C) 1997-2004
* Copyright (C) 1997-2005
*
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
@ -111,7 +111,7 @@ int main(int argc, char **argv)
oldmask = umask(027);
if (!do_quiet)
mbse_colour(3, 0);
mbse_colour(CYAN, BLACK);
UserPack(Days, Level, pack);
umask(oldmask);
@ -120,7 +120,7 @@ int main(int argc, char **argv)
Syslog(' ', "MBUSER finished in %s", t_elapsed(t_start, t_end));
if (!do_quiet)
mbse_colour(7, 0);
mbse_colour(LIGHTGRAY, BLACK);
ExitClient(MBERR_OK);
return 0;
}
@ -135,11 +135,11 @@ void ProgName(void)
if (do_quiet)
return;
mbse_colour(15, 0);
mbse_colour(WHITE, BLACK);
printf("\nMBUSER: MBSE BBS %s - User maintenance utility\n", VERSION);
mbse_colour(14, 0);
mbse_colour(YELLOW, BLACK);
printf(" %s\n\n", COPYRIGHT);
mbse_colour(7, 0);
mbse_colour(LIGHTGRAY, BLACK);
}
@ -149,19 +149,19 @@ void Help(void)
do_quiet = FALSE;
ProgName();
mbse_colour(11, 0);
mbse_colour(LIGHTCYAN, BLACK);
printf("\nUsage: mbuser [commands] <options>\n\n");
mbse_colour(9, 0);
mbse_colour(LIGHTBLUE, BLACK);
printf(" Commands are:\n\n");
mbse_colour(3, 0);
mbse_colour(CYAN, BLACK);
printf(" kill [n] [l] Kill users not called in \"n\" days below level \"l\"\n");
printf(" pack Pack the userbase\n");
mbse_colour(9, 0);
mbse_colour(LIGHTBLUE, BLACK);
printf("\n Options are:\n\n");
mbse_colour(3, 0);
mbse_colour(CYAN, BLACK);
printf(" -quiet Quiet mode, (no screen output)\n\n");
mbse_colour(7, 0);
mbse_colour(LIGHTGRAY, BLACK);
printf("\n");
ExitClient(MBERR_COMMANDLINE);
}
@ -174,11 +174,10 @@ void Help(void)
void UserPack(int days, int level, int pack)
{
FILE *fin, *fout;
char *fnin, *fnout;
char *fnin, *fnout, *cmd;
long oldsize, curpos;
int updated, delete = 0, rc, highest = 0, record = 0, sysop = FALSE;
time_t Last;
char *cmd;
fnin = calloc(PATH_MAX, sizeof(char));
fnout = calloc(PATH_MAX, sizeof(char));
@ -190,13 +189,13 @@ void UserPack(int days, int level, int pack)
* on a the copy.
*/
if ((fin = fopen(fnin, "r")) == NULL) {
WriteError("Can't open %s", fnin);
WriteError("$Can't open %s", fnin);
free(fnin);
free(fnout);
return;
}
if ((fout = fopen(fnout, "w+")) == NULL) {
WriteError("Can't create %s", fnout);
WriteError("$Can't create %s", fnout);
fclose(fin);
free(fnin);
free(fnout);
@ -257,7 +256,7 @@ void UserPack(int days, int level, int pack)
/*
* Handle packing for days below level
*/
if ((days) && (level)) {
if (days && level) {
fseek(fout, sizeof(usrhdr), SEEK_SET);
curpos = sizeof(usrhdr);
@ -272,11 +271,9 @@ void UserPack(int days, int level, int pack)
Last = usr.tLastLoginDate;
/*
* Wow, killing on the second exact!. Don't kill
* the guest accounts.
* Wow, killing on the second exact!. Don't kill the guest accounts.
*/
if ((((t_start - Last) / 86400) > days) &&
(usr.Security.level < level) && (!usr.Guest) &&
if ((((t_start - Last) / 86400) > days) && (usr.Security.level < level) && (!usr.Guest) &&
(usr.sUserName[0] != '\0') && (!usr.NeverDelete)) {
Syslog('+', "Mark user %s", usr.sUserName);
if (!do_quiet) {
@ -330,15 +327,13 @@ void UserPack(int days, int level, int pack)
#ifdef _VPOPMAIL_PATH
cmd = xstrcpy((char *)_VPOPMAIL_PATH);
cmd = xstrcat(cmd, (char *)"/vdeluser ");
rc = execute_str(cmd, usr.Name, NULL,
(char *)"/dev/null",(char *)"/dev/null",(char *)"/dev/null");
rc = execute_str(cmd, usr.Name, NULL, (char *)"/dev/null",(char *)"/dev/null",(char *)"/dev/null");
free(cmd);
#endif
if (chdir(CFG.bbs_usersdir) == 0) {
cmd = xstrcpy((char *)"-Rf ");
cmd = xstrcat(cmd, usr.Name);
rc = execute_pth((char *)"rm", cmd,
(char *)"/dev/null",(char *)"/dev/null",(char *)"/dev/null");
rc = execute_pth((char *)"rm", cmd, (char *)"/dev/null",(char *)"/dev/null",(char *)"/dev/null");
free(cmd);
}
}
@ -364,7 +359,7 @@ void UserPack(int days, int level, int pack)
*/
fseek(fout, 0, SEEK_SET);
if ((fin = fopen(fnin, "w")) == NULL) {
WriteError("Can't open %s", fnin);
WriteError("$Can't open %s", fnin);
free(fnin);
free(fnout);
return;