Improved error logging

This commit is contained in:
Michiel Broek
2002-05-18 12:57:00 +00:00
parent a7545f2b10
commit 909f055c55
10 changed files with 37 additions and 35 deletions

View File

@@ -53,7 +53,7 @@ extern int tic_imp;
int Add_BBS()
{
struct FILERecord frec;
int i, Insert, Done = FALSE, Found = FALSE;
int rc, i, Insert, Done = FALSE, Found = FALSE;
char fdbname[PATH_MAX], fdbtemp[PATH_MAX];
char temp1[PATH_MAX], temp2[PATH_MAX], *fname;
FILE *fdb, *fdt;
@@ -87,8 +87,8 @@ int Add_BBS()
sprintf(temp2, "%s/%s", TIC.BBSpath, TIC.NewName);
mkdirs(temp2, 0755);
if (file_cp(temp1, temp2) != 0) {
WriteError("$Copy to %s failed", temp2);
if ((rc = file_cp(temp1, temp2))) {
WriteError("Copy to %s failed: %s", temp2, strerror(rc));
return FALSE;
}
chmod(temp2, 0644);

View File

@@ -269,7 +269,7 @@ void Magic_ExecCommand(void)
void Magic_CopyFile(void)
{
int First = TRUE;
int First = TRUE, rc;
char *From, *To;
From = calloc(PATH_MAX, sizeof(char));
@@ -280,11 +280,11 @@ void Magic_CopyFile(void)
sprintf(From, "%s/%s", TIC.BBSpath, TIC.NewName);
sprintf(To, "%s/%s", magic.Path, TIC.NewName);
if (file_cp(From, To) == 0) {
if ((rc = file_cp(From, To) == 0)) {
MagicResult((char *)"%s copied to %s", From, To);
Magic_CheckCompile();
} else
WriteError("Magic: copy: %s to %s failed");
WriteError("Magic: copy: %s to %s failed, %s", strerror(rc));
}
free(From);
@@ -295,10 +295,10 @@ void Magic_CopyFile(void)
void Magic_UnpackFile(void)
{
int rc, First = TRUE;
char *buf = NULL, *unarc = NULL, *cmd = NULL;
char Fn[PATH_MAX];
int rc, First = TRUE;
char *Fn, *buf = NULL, *unarc = NULL, *cmd = NULL;
Fn = calloc(PATH_MAX, sizeof(char));
while (GetMagicRec(MG_UNPACK, First)) {
First = FALSE;
buf = calloc(PATH_MAX, sizeof(char));
@@ -328,6 +328,7 @@ void Magic_UnpackFile(void)
free(buf);
}
free(Fn);
}

View File

@@ -334,12 +334,12 @@ int main(int argc, char **argv)
die(100);
}
} else {
if (file_cp(nd, ond)) {
if ((rc = file_cp(nd, ond))) {
show_log = TRUE;
free(ond);
free(onl);
free(wrk);
WriteError("$Copy %s failed", nd);
WriteError("Copy %s failed, %s", nd, strerror(rc));
die(100);
}
Syslog('s', "Copied %s", nd);

View File

@@ -84,7 +84,7 @@ void AdoptFile(int Area, char *File, char *Description)
sprintf(temp2, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), File);
mkdirs(temp2, 0755);
if ((rc = file_cp(temp, temp2))) {
WriteError("Can't copy file to %s", temp2);
WriteError("Can't copy file to %s, %s", temp2, strerror(rc));
if (!do_quiet)
printf("Can't copy file to %s, %s\n", temp2, strerror(rc));
die(0);

View File

@@ -105,7 +105,7 @@ void ImportFiles(int Area)
sprintf(temp2, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), fdb.LName);
mkdirs(temp2, 0755);
if ((rc = file_cp(temp, temp2))) {
WriteError("Can't copy file to %s", temp2);
WriteError("Can't copy file to %s, %s", temp2, strerror(rc));
if (!do_quiet)
printf("Can't copy file to %s, %s\n", temp2, strerror(rc));
Doit = FALSE;
@@ -305,8 +305,8 @@ void ImportFiles(int Area)
Syslog('+', "Unknown archive format %s", temp);
sprintf(temp2, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), fdb.LName);
mkdirs(temp2, 0755);
if (file_cp(temp, temp2)) {
WriteError("Can't copy file to %s", temp2);
if ((rc = file_cp(temp, temp2))) {
WriteError("Can't copy file to %s, %s", temp2, strerror(rc));
Doit = FALSE;
} else {
if (!do_quiet) {

View File

@@ -188,8 +188,8 @@ void Kill(void)
fwrite(&file, sizeof(file), 1, pFile);
iMoved++;
} else {
WriteError("Move %s to area %d failed rc = %d",
file.Name, area.MoveArea, rc);
WriteError("Move %s to area %d failed, %s",
file.Name, area.MoveArea, strerror(rc));
}
} else {
Syslog('+', "Delete %s, area %d", file.LName, i);

View File

@@ -42,6 +42,7 @@
void mover(char *fn)
{
char *From, *To;
int rc;
From = calloc(PATH_MAX, sizeof(char));
To = calloc(PATH_MAX, sizeof(char));
@@ -51,8 +52,10 @@ void mover(char *fn)
Syslog('!', "Moving %s to %s", From, To);
if (mkdirs(To, 0770)) {
if (file_mv(From, To) != 0)
WriteError("$Failed to move %s to %s", From, To);
if ((rc = file_mv(From, To)))
WriteError("$Failed to move %s to %s: %s", From, To, strerror(rc));
} else {
WriteError("$Can't create directory for %s", To);
}
free(From);

View File

@@ -75,7 +75,7 @@ int ProcessTic(fa_list *sbl)
int DownLinks = 0;
int MustRearc = FALSE;
int UnPacked = FALSE, IsArchive = FALSE;
int i, j, k, File_Id = FALSE;
int rc, i, j, k, File_Id = FALSE;
char *Temp, *unarc = NULL, *cmd = NULL;
char temp1[PATH_MAX], temp2[PATH_MAX], sbe[24], TDesc[256];
unsigned long crc, crc2, Kb;
@@ -235,7 +235,7 @@ int ProcessTic(fa_list *sbl)
Magic_Keepnum();
if (!tic.FileArea) {
Syslog('f', "Passthru area!");
Syslog('+', "Passthru TIC area!");
strcpy(TIC.BBSpath, CFG.ticout);
strcpy(TIC.BBSdesc, tic.Comment);
} else {
@@ -276,7 +276,7 @@ int ProcessTic(fa_list *sbl)
* the area is not linked to an existing BBS area.
*/
if (tic.FileArea && access(TIC.BBSpath, W_OK)) {
WriteError("$No write access to \"%s\"", TIC.BBSpath);
WriteError("No write access to \"%s\"", TIC.BBSpath);
Bad((char *)"Dest directory not available");
free(Temp);
return 1;
@@ -406,10 +406,10 @@ int ProcessTic(fa_list *sbl)
if (((tic.SendOrg) && (MustRearc || strlen(tic.Banner))) || (!tic.FileArea)) {
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.RealName);
sprintf(temp2, "%s/%s", CFG.ticout, TIC.RealName);
if (file_cp(temp1, temp2) == 0) {
if ((rc = file_cp(temp1, temp2) == 0)) {
TIC.SendOrg = TRUE;
} else {
WriteError("$Copy %s to %s failed", temp1, temp2);
WriteError("Copy %s to %s failed: %s", temp1, temp2, strerror(rc));
}
}
@@ -492,12 +492,10 @@ int ProcessTic(fa_list *sbl)
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.RealName);
sprintf(temp2, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), TIC.RealName);
if (file_cp(temp1, temp2)) {
WriteError("Can't copy %s to %s", temp1, temp2);
if ((rc = file_cp(temp1, temp2))) {
WriteError("Can't copy %s to %s: %s", temp1, temp2, strerror(rc));
free(Temp);
return 1;
} else {
Syslog('f', "file_cp(%s, %s) ok", temp1, temp2);
}
sprintf(temp2, "%s/tmp/arc", getenv("MBSE_ROOT"));
@@ -704,7 +702,9 @@ int ProcessTic(fa_list *sbl)
strncpy(T_File.LDesc[i], TIC.File_Id[i], 48);
T_File.TotLdesc = TIC.File_Id_Ct;
T_File.Announce = tic.Announce;
strncpy(T_File.Name, TIC.NewName, 12);
sprintf(Temp, "%s", TIC.NewName);
name_mangle(Temp);
strncpy(T_File.Name, Temp, 12);
strncpy(T_File.LName, TIC.NewName, 80);
T_File.Fdate = TIC.FileDate;
T_File.Cost = TIC.TicIn.Cost;
@@ -772,15 +772,11 @@ int ProcessTic(fa_list *sbl)
Magic_CopyFile();
Magic_UnpackFile();
Magic_AdoptFile();
Syslog('f', "Almost at end of ptic");
sprintf(Temp, "%s/%s", TIC.Inbound, TIC.TicName);
Syslog('f', "About to erase \"%s\"", Temp);
unlink(Temp);
Syslog('f', "Done, about to free Temp");
free(Temp);
Syslog('f', "Done with ptic");
return 0;
}

View File

@@ -400,8 +400,8 @@ int LoadTic(char *inb, char *tfn)
return 2;
}
sprintf(Temp2, "%s/%s", TIC.Inbound, TIC.TicIn.FullName);
if (file_mv(Temp, Temp2)) {
WriteError("Can't move %s to inbound", Temp);
if ((rc = file_mv(Temp, Temp2))) {
WriteError("Can't move %s to inbound: %s", Temp, strerror(rc));
tidy_falist(&sbl);
return 1;
}