Code cleanup

This commit is contained in:
Michiel Broek 2005-08-19 19:07:24 +00:00
parent 5705cb1538
commit d224ff61eb
4 changed files with 52 additions and 57 deletions

View File

@ -2,6 +2,12 @@ $Id$
v0.71.5 18-Aug-2005
mbfido:
Removed debug logging for solved crash.
mbdiff:
Code cleanup.
v0.71.4 12-Aug-2005 - 18-Aug-2005

View File

@ -5,7 +5,7 @@
* Original ideas ........: Eugene G. Crosser.
*
*****************************************************************************
* Copyright (C) 1997-2004
* Copyright (C) 1997-2005
*
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
@ -55,55 +55,55 @@ time_t t_end; /* End time */
void ProgName(void)
{
if (do_quiet)
return;
if (do_quiet)
return;
mbse_colour(15, 0);
printf("\nMBDIFF: MBSE BBS %s Nodelist diff processor\n", VERSION);
mbse_colour(14, 0);
printf(" %s\n", COPYRIGHT);
mbse_colour(15, 0);
printf("\nMBDIFF: MBSE BBS %s Nodelist diff processor\n", VERSION);
mbse_colour(14, 0);
printf(" %s\n", COPYRIGHT);
}
void die(int onsig)
{
/*
* First check if a child is running, if so, kill it.
*/
if (e_pid) {
if ((kill(e_pid, SIGTERM)) == 0)
Syslog('+', "SIGTERM to pid %d succeeded", e_pid);
else {
if ((kill(e_pid, SIGKILL)) == 0)
Syslog('+', "SIGKILL to pid %d succeded", e_pid);
else
WriteError("$Failed to kill pid %d", e_pid);
}
/*
* First check if a child is running, if so, kill it.
* In case the child had the tty in raw mode...
*/
if (e_pid) {
if ((kill(e_pid, SIGTERM)) == 0)
Syslog('+', "SIGTERM to pid %d succeeded", e_pid);
else {
if ((kill(e_pid, SIGKILL)) == 0)
Syslog('+', "SIGKILL to pid %d succeded", e_pid);
else
WriteError("$Failed to kill pid %d", e_pid);
}
execute_pth((char *)"stty", (char *)"sane", (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
}
/*
* In case the child had the tty in raw mode...
*/
execute_pth((char *)"stty", (char *)"sane", (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
}
signal(onsig, SIG_IGN);
signal(onsig, SIG_IGN);
if (onsig) {
if (onsig <= NSIG)
WriteError("Terminated on signal %d (%s)", onsig, SigName[onsig]);
else
WriteError("Terminated with error %d", onsig);
}
if (onsig) {
if (onsig <= NSIG)
WriteError("Terminated on signal %d (%s)", onsig, SigName[onsig]);
else
WriteError("Terminated with error %d", onsig);
}
t_end = time(NULL);
Syslog(' ', "MBDIFF finished in %s", t_elapsed(t_start, t_end));
t_end = time(NULL);
Syslog(' ', "MBDIFF finished in %s", t_elapsed(t_start, t_end));
if (!do_quiet) {
mbse_colour(7, 0);
printf("\n");
}
ExitClient(onsig);
if (!do_quiet) {
mbse_colour(7, 0);
printf("\n");
}
ExitClient(onsig);
}
@ -252,9 +252,9 @@ int main(int argc, char **argv)
*/
if ((arc = unpacker(nd)) == NULL) {
show_log = TRUE;
WriteError("Can't get filetype for %s", nd);
free(onl);
free(wrk);
WriteError("Can't get filetype for %s", nd);
die(MBERR_CONFIG_ERROR);
}
@ -290,18 +290,13 @@ int main(int argc, char **argv)
}
if (execute_str(cmd, nd, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null")) {
WriteError("Warning: unpack error, trying again after a sync");
sync();
sleep(1);
if (execute_str(cmd, nd, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null")) {
show_log = TRUE;
free(cmd);
free(onl);
free(wrk);
free(ond);
WriteError("Fatal: unpack error");
die(MBERR_EXEC_FAILED);
}
show_log = TRUE;
free(cmd);
free(onl);
free(wrk);
free(ond);
WriteError("Fatal: unpack error");
die(MBERR_EXEC_FAILED);
}
free(cmd);
@ -339,7 +334,6 @@ int main(int argc, char **argv)
WriteError("Copy %s failed, %s", nd, strerror(rc));
die(MBERR_DIFF_ERROR);
}
Syslog('s', "Copied %s", nd);
}
if (((p = strrchr(onl, '.'))) && ((q = strrchr(ond, '.'))) && (strlen(p) == strlen(q))) {

View File

@ -610,7 +610,7 @@ int ProcessTic(fa_list **sbl)
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.NewFile);
sprintf(Temp, "%s/etc/%s", getenv("MBSE_ROOT"), tic.Banner);
if (execute_str(cmd, temp1, (char *)NULL, Temp, (char *)"/dev/null", (char *)"/dev/null")) {
WriteError("$Changing the banner failed");
WriteError("Changing the banner failed");
} else {
Syslog('+', "New banner %s", tic.Banner);
TIC.FileSize = file_size(temp1);
@ -717,8 +717,6 @@ int ProcessTic(fa_list **sbl)
if (tmpq->send) {
sprintf(sbe, "%u:%u/%u", tmpq->aka.zone, tmpq->aka.net, tmpq->aka.node);
fill_list(sbl, sbe, NULL);
} else {
Syslog('f', "Skip SB %u:%u/%u", tmpq->aka.zone, tmpq->aka.net, tmpq->aka.node);
}
}
uniq_list(sbl);
@ -746,7 +744,6 @@ int ProcessTic(fa_list **sbl)
free(Temp);
tidy_qualify(&qal);
Syslog('f', "ProcessTic: post processing end");
return 0;
}

View File

@ -484,9 +484,7 @@ int LoadTic(char *inb, char *tfn)
tic_in++;
rc = ProcessTic(&sbl);
Syslog('f', "back from ProcessTic");
tidy_falist(&sbl);
Syslog('f', "tidy_falist(&sbl) done");
return rc;
}