Development of improved tic processing

This commit is contained in:
Michiel Broek 2002-11-26 20:35:50 +00:00
parent c8f93b2ac5
commit 2283b37d27
9 changed files with 422 additions and 381 deletions

View File

@ -1,15 +1,20 @@
$Id$
WARNING WARNING: DO NOT USE THIS VERSION, YOU WILL LOOSE FILES !!!!!!!!!!!
WARNING WARNING: TIC PROCESSING WILL MOST LIKELY NOT WORK !!!!!!!!!!!!!!!!
MBSEBBS History.
v0.35.06
update:
Before upgrade, close the bbs (mbstat close wait) and make
sure the inbound is empty, toss everything.
Install the new binaries.
Run "mbfile check". This will create a error in the logfile
for each file! It will update the filenames on disk to have
both short and long filenames. Just ignore the errors!
Start the bbs again (mbstat open).
general:
This may become release 0.36.00 (again).
@ -42,6 +47,8 @@ v0.35.06
command would detect and correct this.
TIC files added to the bbs will now also have a 8.3 hard link.
With TIC file attaches, the filename attached is the 8.3 name.
TIC processing completly modified to make better LFN support.
EXPERIMENTAL, I BET IT DOESN'T WORK
mbcico:
With filetransfer errors, the attempts counter was not

View File

@ -62,12 +62,6 @@ int Add_BBS()
int Keep = 0, DidDelete = FALSE;
fd_list *fdl = NULL;
/*
* First create 8.3 filename
*/
sprintf(temp1, "%s", TIC.NewName);
name_mangle(temp1);
/*
* First check for an existing record with the same filename,
* if it exists, update the record and we are ready. This will
@ -77,9 +71,9 @@ int Add_BBS()
sprintf(fdbname, "%s/fdb/fdb%ld.data", getenv("MBSE_ROOT"), tic.FileArea);
if ((fdb = fopen(fdbname, "r+")) != NULL) {
while (fread(&frec, sizeof(frec), 1, fdb) == 1) {
if ((strcmp(frec.Name, temp1) == 0) && (strcmp(frec.LName, TIC.NewName) == 0)) {
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.NewName);
sprintf(temp2, "%s/%s", TIC.BBSpath, TIC.NewName);
if (strcmp(frec.Name, TIC.NewFile) == 0) {
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.NewFile);
sprintf(temp2, "%s/%s", TIC.BBSpath, TIC.NewFile);
mkdirs(temp2, 0755);
if ((rc = file_cp(temp1, temp2))) {
WriteError("Copy to %s failed: %s", temp2, strerror(rc));
@ -112,12 +106,24 @@ int Add_BBS()
fclose(fdb);
}
Syslog('f', "addbbs 1");
/*
* Create filedatabase record.
*/
memset(&frec, 0, sizeof(frec));
strcpy(frec.Name, temp1);
strcpy(frec.LName, TIC.NewName);
strncpy(frec.Name, TIC.NewFile, sizeof(frec.Name) -1);
if (strlen(TIC.NewFullName)) {
strncpy(frec.LName, TIC.NewFullName, sizeof(frec.LName) -1);
} else {
/*
* No LFN, fake it with a lowercase copy of the 8.3 filename.
*/
strncpy(frec.LName, TIC.NewFile, sizeof(frec.LName) -1);
for (i = 0; i < strlen(frec.LName); i++)
frec.LName[i] = tolower(frec.LName[i]);
}
Syslog('f', "addbbs 2");
frec.TicAreaCRC = StringCRC32(TIC.TicIn.Area);
frec.Size = TIC.FileSize;
frec.Crc32 = TIC.Crc_Int;
@ -133,8 +139,9 @@ int Add_BBS()
if (strlen(TIC.TicIn.Magic))
sprintf(frec.Desc[i], "Magic Request: %s", TIC.TicIn.Magic);
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.NewName);
sprintf(temp2, "%s/%s", TIC.BBSpath, TIC.NewName);
Syslog('f', "addbbs 3");
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.NewFile);
sprintf(temp2, "%s/%s", TIC.BBSpath, frec.Name);
mkdirs(temp2, 0755);
if ((rc = file_cp(temp1, temp2))) {
@ -143,11 +150,12 @@ int Add_BBS()
}
chmod(temp2, 0644);
lname = calloc(PATH_MAX, sizeof(char));
sprintf(lname, "%s/%s", TIC.BBSpath, frec.Name);
sprintf(lname, "%s/%s", TIC.BBSpath, frec.LName);
if (link(temp2, lname)) {
WriteError("$Create link %s to %s failed", lname, temp2);
WriteError("$Create link %s to %s failed", temp2, lname);
}
free(lname);
Syslog('f', "addbbs 4");
sprintf(fdbtemp, "%s/fdb/fdb%ld.temp", getenv("MBSE_ROOT"), tic.FileArea);
@ -173,6 +181,7 @@ int Add_BBS()
tic_imp++;
return TRUE;
}
Syslog('f', "addbbs 5");
/*
* There are already files in the area. We must now see at
@ -196,6 +205,7 @@ int Add_BBS()
}
} while ((!Found) && (!Done));
Syslog('f', "addbbs 6");
if (Found) {
if ((fdt = fopen(fdbtemp, "a+")) == NULL) {
WriteError("$Can't create %s", fdbtemp);
@ -246,6 +256,7 @@ int Add_BBS()
}
fclose(fdt);
fclose(fdb);
Syslog('f', "addbbs 7");
/*
* Now make the changes for real.
@ -273,6 +284,7 @@ int Add_BBS()
if ((i = file_rm(temp1)))
WriteError("file_rm(%s): %s", temp1, strerror(i));
Syslog('f', "addbbs 8");
/*
* Handle the replace option.
*/
@ -282,10 +294,11 @@ int Add_BBS()
if ((fdb = fopen(fdbname, "r+")) != NULL) {
while (fread(&file, sizeof(file), 1, fdb) == 1) {
if (strlen(file.LName) == strlen(TIC.NewName)) {
if (strcasecmp(file.LName, TIC.NewName) != 0) {
if (strlen(file.LName) == strlen(frec.LName)) {
// FIXME: Search must be based on a reg_exp search
if (strcasecmp(file.LName, frec.LName) != 0) {
Found = TRUE;
for (i = 0; i < strlen(TIC.NewName); i++) {
for (i = 0; i < strlen(frec.LName); i++) {
if ((TIC.TicIn.Replace[i] != '?') && (toupper(TIC.TicIn.Replace[i]) != toupper(file.LName[i])))
Found = FALSE;
}
@ -302,33 +315,37 @@ int Add_BBS()
fclose(fdb);
}
}
Syslog('f', "addbbs 9");
/*
* Handle the Keep number of files option
*/
if (TIC.KeepNum) {
Syslog('f', "AddBBS, handle KeepNum %d", TIC.KeepNum);
if ((fdb = fopen(fdbname, "r")) != NULL) {
while (fread(&file, sizeof(file), 1, fdb) == 1) {
if ((strlen(file.LName) == strlen(TIC.NewName)) && (!file.Deleted)) {
if ((strlen(file.LName) == strlen(frec.LName)) && (!file.Deleted)) {
Found = TRUE;
for (i = 0; i < strlen(file.LName); i++) {
if ((TIC.NewName[i] < '0') || (TIC.NewName[i] > '9')) {
if (TIC.NewName[i] != file.LName[i]) {
if ((frec.LName[i] < '0') || (frec.LName[i] > '9')) {
if (frec.LName[i] != file.LName[i]) {
Found = FALSE;
}
}
}
if (Found) {
Keep++;
Syslog('f', "Add \"%s\" to keeplist", file.LName);
fill_fdlist(&fdl, file.LName, file.UploadDate);
}
}
}
fclose(fdb);
}
Syslog('f', "addbbs 10");
/*
* If there are files to delete, mark them.
@ -356,6 +373,7 @@ int Add_BBS()
}
tidy_fdlist(&fdl);
}
Syslog('f', "addbbs 11");
/*
* Now realy delete the marked files and clean the file
@ -389,6 +407,7 @@ int Add_BBS()
DidDelete = FALSE;
}
}
Syslog('f', "addbbs 12");
tic_imp++;
return TRUE;

View File

@ -49,7 +49,7 @@
void ForwardFile(fidoaddr Node, fa_list *sbl)
{
char *subject = NULL, *temp, *fwdfile = NULL, *queuedir, *listfile, *ticfile = NULL, fname[PATH_MAX], *ticname, flavor;
char *subject = NULL, *fwdfile = NULL, *queuedir, *listfile, *ticfile = NULL, fname[PATH_MAX], *ticname, flavor;
FILE *fp, *fi, *fl, *net;
faddr *dest, *routeto, *Fa, *Temp, *ba;
int i, z, n;
@ -103,17 +103,14 @@ void ForwardFile(fidoaddr Node, fa_list *sbl)
* Create the full filename
*/
if (TIC.PassThru || TIC.SendOrg) {
sprintf(fwdfile, "%s/%s", TIC.Inbound, TIC.RealName);
subject = xstrcpy(TIC.RealName);
sprintf(fwdfile, "%s/%s", TIC.Inbound, TIC.TicIn.File);
subject = xstrcpy(TIC.TicIn.File);
} else {
/*
* Make sure the file attach is the 8.3 filename
*/
temp = xstrcpy(TIC.NewName);
name_mangle(temp);
sprintf(fwdfile, "%s/%s", TIC.BBSpath, temp);
subject = xstrcpy(temp);
free(temp);
sprintf(fwdfile, "%s/%s", TIC.BBSpath, TIC.NewFile);
subject = xstrcpy(TIC.NewFile);
}
flavor = 'f';
@ -152,7 +149,10 @@ void ForwardFile(fidoaddr Node, fa_list *sbl)
MacroVars("b", "s", tic.Comment);
MacroVars("c", "d", TIC.FileCost);
MacroVars("d", "s", fgroup.Comment);
if (TIC.PassThru || TIC.SendOrg)
MacroVars("f", "s", TIC.TicIn.FullName);
else
MacroVars("f", "s", TIC.NewFullName);
MacroVars("g", "d", TIC.FileSize);
MacroVars("h", "d", (TIC.FileSize / 1024));
MacroVars("i", "s", TIC.TicIn.Crc);
@ -160,10 +160,10 @@ void ForwardFile(fidoaddr Node, fa_list *sbl)
MacroVars("m", "s", rfcdate(ftime));
MacroVars("n", "s", TIC.TicIn.Desc);
MacroVars("s", "s", nodes.Sysop);
if (TIC.SendOrg)
MacroVars("e", "s", TIC.RealName);
if (TIC.PassThru || TIC.SendOrg)
MacroVars("e", "s", TIC.TicIn.File);
else
MacroVars("e", "s", TIC.NewName);
MacroVars("e", "s", TIC.NewFile);
if (strlen(TIC.TicIn.Magic))
MacroVars("k", "s", TIC.TicIn.Magic);
if (strlen(TIC.TicIn.Replace))
@ -195,26 +195,15 @@ void ForwardFile(fidoaddr Node, fa_list *sbl)
if (strlen(TIC.TicIn.Magic))
fprintf(fp, "Magic %s\r\n", TIC.TicIn.Magic);
if ((TIC.PassThru) || (TIC.SendOrg))
subject = xstrcpy(TIC.RealName);
else
subject = xstrcpy(TIC.NewName);
/*
* Create 8.3 filename if this is a long filename. In normal
* cases mbcico will transmit the long filename to the other
* node. If they can't process the TIC files which has a short
* 8.3 filename and they have a long filename in the inbound
* then in mbsetup these nodes need to be set to 8.3 filenames.
* The mailer will then transmit the file with a 8.3 name.
* Thank the inventors of the 8.3 filenames for this.
*/
temp = xstrcpy(subject);
name_mangle(temp);
fprintf(fp, "File %s\r\n", temp);
fprintf(fp, "Fullname %s\r\n", subject);
free(temp);
free(subject);
if ((TIC.PassThru) || (TIC.SendOrg)) {
fprintf(fp, "File %s\r\n", TIC.TicIn.File);
if (strlen(TIC.TicIn.FullName))
fprintf(fp, "Fullname %s\r\n", TIC.TicIn.FullName);
} else {
fprintf(fp, "File %s\r\n", TIC.NewFile);
if (strlen(TIC.NewFullName))
fprintf(fp, "Fullname %s\r\n", TIC.NewFullName);
}
fprintf(fp, "Size %ld\r\n", (long)(TIC.FileSize));
fprintf(fp, "Desc %s\r\n", TIC.TicIn.Desc);
fprintf(fp, "Crc %s\r\n", TIC.TicIn.Crc);
@ -319,7 +308,7 @@ void ForwardFile(fidoaddr Node, fa_list *sbl)
if ((fp = fopen(fname, "a+")) != NULL) {
memset(&bill, 0, sizeof(bill));
bill.Node = nodes.Aka[0];
strcpy(bill.FileName, TIC.NewName);
strcpy(bill.FileName, TIC.NewFile);
strcpy(bill.FileEcho, TIC.TicIn.Area);
bill.Size = TIC.FileSize;
bill.Cost = TIC.FileCost;

View File

@ -54,42 +54,27 @@ char *Magic_Macro(int C)
buf[0] = '\0';
switch(toupper(C)) {
case 'F':
sprintf(buf, "%s/%s", TIC.BBSpath, TIC.NewName);
case 'F': sprintf(buf, "%s/%s", TIC.BBSpath, TIC.NewFile);
break;
case 'P':
sprintf(buf, "%s", TIC.BBSpath);
case 'P': sprintf(buf, "%s", TIC.BBSpath);
break;
case 'N':
sprintf(buf, "%s", strtok(strdup(TIC.NewName), "."));
case 'N': sprintf(buf, "%s", strtok(strdup(TIC.NewFile), "."));
break;
case 'E':
sprintf(buf, "%s", strrchr(TIC.NewName, '.'));
case 'E': sprintf(buf, "%s", strrchr(TIC.NewFile, '.'));
break;
case 'L':
sprintf(buf, "%s", strrchr(TIC.NewName, '.'));
case 'L': sprintf(buf, "%s", strrchr(TIC.NewFile, '.'));
buf[0] = buf[1];
buf[1] = buf[2];
buf[2] = '\0';
break;
case 'D':
sprintf(buf, "%03d", Day_Of_Year());
case 'D': sprintf(buf, "%03d", Day_Of_Year());
break;
case 'C':
sprintf(buf, "%03d", Day_Of_Year());
case 'C': sprintf(buf, "%03d", Day_Of_Year());
buf[0] = buf[1];
buf[1] = buf[2];
buf[2] = '\0';
break;
case 'A':
sprintf(buf, "%s", TIC.TicIn.Area);
case 'A': sprintf(buf, "%s", TIC.TicIn.Area);
break;
}
@ -154,7 +139,7 @@ int GetMagicRec(int Typ, int First)
*q = '\0';
if ((re_comp(mask)) == NULL) {
if (re_exec(TIC.NewName)) {
if (re_exec(TIC.NewFile)) {
fclose(FeM);
free(temp);
return TRUE;
@ -210,7 +195,7 @@ int Magic_MoveFile(void)
{
if (GetMagicRec(MG_MOVE, TRUE)) {
strcpy(TIC.TicIn.Area, magic.ToArea);
MagicResult((char *)"Move %s to Area %s", TIC.RealName, TIC.TicIn.Area);
MagicResult((char *)"Move %s to Area %s", TIC.NewFile, TIC.TicIn.Area);
return TRUE;
} else
return FALSE;
@ -221,9 +206,7 @@ int Magic_MoveFile(void)
void Magic_ExecCommand(void)
{
int i, j, k, Err, First = TRUE;
char Line[256];
char Temp[PATH_MAX];
char *cmd, *opts;
char Line[256], Temp[PATH_MAX], *cmd, *opts;
while (GetMagicRec(MG_EXEC, First)) {
First = FALSE;
@ -276,8 +259,8 @@ void Magic_CopyFile(void)
while (GetMagicRec(MG_COPY, First)) {
First = FALSE;
sprintf(From, "%s/%s", TIC.BBSpath, TIC.NewName);
sprintf(To, "%s/%s", magic.Path, TIC.NewName);
sprintf(From, "%s/%s", TIC.BBSpath, TIC.NewFile);
sprintf(To, "%s/%s", magic.Path, TIC.NewFile);
if ((rc = file_cp(From, To) == 0)) {
MagicResult((char *)"%s copied to %s", From, To);
@ -304,7 +287,7 @@ void Magic_UnpackFile(void)
getcwd(buf, 128);
if (chdir(magic.Path) == 0) {
sprintf(Fn, "%s/%s", TIC.BBSpath, TIC.NewName);
sprintf(Fn, "%s/%s", TIC.BBSpath, TIC.NewFile);
if ((unarc = unpacker(Fn)) != NULL) {
if (getarchiver(unarc)) {
cmd = xstrcpy(archiver.funarc);
@ -380,7 +363,9 @@ void Magic_AdoptFile(void)
fprintf(Tf, "Replaces %s\r\n", TIC.TicIn.Replace);
if (strlen(TIC.TicIn.Magic))
fprintf(Tf, "Magic %s\r\n", TIC.TicIn.Magic);
fprintf(Tf, "File %s\r\n", TIC.NewName);
fprintf(Tf, "File %s\r\n", TIC.NewFile);
if (strlen(TIC.NewFullName))
fprintf(Tf, "Fullname %s\r\n", TIC.NewFullName);
fprintf(Tf, "Pth %s\r\n", TIC.BBSpath);
fprintf(Tf, "Desc %s\r\n", TIC.TicIn.Desc);
fprintf(Tf, "Crc %s\r\n", TIC.TicIn.Crc);

View File

@ -54,8 +54,9 @@ void mover(char *fn)
Syslog('!', "Moving %s to %s", From, To);
if (mkdirs(To, 0770)) {
if ((rc = file_mv(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);
}
@ -72,7 +73,7 @@ void mover(char *fn)
void MoveBad()
{
mover(TIC.TicName);
mover(TIC.RealName);
mover(TIC.NewFile);
}

View File

@ -104,7 +104,7 @@ int ProcessTic(fa_list *sbl)
fflush(stdout);
}
if (strlen(TIC.RealName) == 0) {
if (TIC.Orphaned) {
WriteError("File not in inbound: %s", TIC.TicIn.File);
/*
* Now check the age of the .tic file.
@ -123,7 +123,7 @@ int ProcessTic(fa_list *sbl)
return 2;
}
sprintf(Temp, "%s/%s", TIC.Inbound, TIC.RealName);
sprintf(Temp, "%s/%s", TIC.Inbound, TIC.TicIn.File);
crc = file_crc(Temp, CFG.slow_util && do_quiet);
TIC.FileSize = file_size(Temp);
TIC.FileDate = file_time(Temp);
@ -142,7 +142,7 @@ int ProcessTic(fa_list *sbl)
if (crc != TIC.Crc_Int) {
Syslog('!', "CRC: expected %08lX, the file is %08lX", TIC.Crc_Int, crc);
if (check_crc) {
Bad((char *)"CRC: error, %s may be damaged", TIC.RealName);
Bad((char *)"CRC: error, %s may be damaged", TIC.TicIn.File);
free(Temp);
return 1;
} else {
@ -409,8 +409,8 @@ int ProcessTic(fa_list *sbl)
* is used for this file.
*/
if (strlen(tic.Convert) || tic.VirScan || tic.FileId || tic.ConvertAll || strlen(tic.Banner)) {
if ((unarc = unpacker(TIC.RealName)) == NULL)
Syslog('+', "Unknown archive format %s", TIC.RealName);
if ((unarc = unpacker(TIC.TicIn.File)) == NULL)
Syslog('+', "Unknown archive format %s", TIC.TicIn.File);
else {
IsArchive = TRUE;
if ((strlen(tic.Convert) && (strcmp(unarc, tic.Convert) == 0)) || (tic.ConvertAll))
@ -424,8 +424,8 @@ int ProcessTic(fa_list *sbl)
* it's a passthru area.
*/
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);
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.TicIn.File);
sprintf(temp2, "%s/%s", CFG.ticout, TIC.TicIn.File);
if ((rc = file_cp(temp1, temp2) == 0)) {
TIC.SendOrg = TRUE;
} else {
@ -464,7 +464,7 @@ int ProcessTic(fa_list *sbl)
if (!unlink(temp1))
Syslog('+', "Removed stale %s", temp1);
if (!checkspace(temp2, TIC.RealName, UNPACK_FACTOR)) {
if (!checkspace(temp2, TIC.TicIn.File, UNPACK_FACTOR)) {
Bad((char *)"Not enough free diskspace left");
free(Temp);
tidy_qualify(&qal);
@ -491,7 +491,7 @@ int ProcessTic(fa_list *sbl)
if ((cmd == NULL) || (cmd == "")) {
Syslog('!', "No unarc command available");
} else {
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.RealName);
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.TicIn.File);
if (execute(cmd, temp1, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
sync();
UnPacked = TRUE;
@ -512,8 +512,8 @@ int ProcessTic(fa_list *sbl)
* whatever that is. This should catch single files
* with worms or other macro viri
*/
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.RealName);
sprintf(temp2, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), TIC.RealName);
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.TicIn.File);
sprintf(temp2, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), TIC.TicIn.File);
if ((rc = file_cp(temp1, temp2))) {
WriteError("Can't copy %s to %s: %s", temp1, temp2, strerror(rc));
@ -577,12 +577,12 @@ int ProcessTic(fa_list *sbl)
} else {
sprintf(temp1, "%s/tmp", getenv("MBSE_ROOT"));
chdir(temp1);
sprintf(temp1, "%s/%s FILE_ID.DIZ", TIC.Inbound, TIC.RealName);
sprintf(temp1, "%s/%s FILE_ID.DIZ", TIC.Inbound, TIC.TicIn.File);
if (execute(cmd, temp1, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
sync();
File_Id = TRUE;
} else {
sprintf(temp1, "%s/%s file_id.diz", TIC.Inbound, TIC.RealName);
sprintf(temp1, "%s/%s file_id.diz", TIC.Inbound, TIC.TicIn.File);
if (execute(cmd, temp1, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
sync();
File_Id = TRUE;
@ -639,16 +639,15 @@ int ProcessTic(fa_list *sbl)
}
} /* not get FILE_ID.DIZ */
/*
* Rearc file if it is an unpacked archive.
*/
if ((MustRearc) && (UnPacked) && (tic.FileArea)) {
if (Rearc(tic.Convert)) {
if (strlen(tic.Banner)) {
Syslog('f', "Must replace banner 1");
}
/*
* Get new filesize for import and announce
*/
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.NewName);
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.NewFile);
TIC.FileSize = file_size(temp1);
T_File.Size = TIC.FileSize;
T_File.SizeKb = TIC.FileSize / 1024;
@ -661,17 +660,17 @@ int ProcessTic(fa_list *sbl)
} else {
WriteError("Rearc failed");
} /* if Rearc() */
} else {
}
/*
* If the file is not unpacked, change the banner
* direct if this is needed.
* Change banner if needed.
*/
if ((strlen(tic.Banner)) && IsArchive) {
cmd = xstrcpy(archiver.barc);
if ((cmd == NULL) || (!strlen(cmd))) {
Syslog('!', "No banner command for %s", archiver.name);
} else {
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.RealName);
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.NewFile);
sprintf(Temp, "%s/etc/%s", getenv("MBSE_ROOT"), tic.Banner);
if (execute(cmd, temp1, (char *)NULL, Temp, (char *)"/dev/null", (char *)"/dev/null")) {
WriteError("$Changing the banner failed");
@ -686,7 +685,6 @@ int ProcessTic(fa_list *sbl)
}
}
}
} /* if MustRearc and Unpacked and not Passthtru */
DeleteVirusWork();
chdir(TIC.Inbound);
@ -695,7 +693,7 @@ int ProcessTic(fa_list *sbl)
* If the file is converted, we set the date of the original
* received file as the file creation date.
*/
sprintf(Temp, "%s/%s", TIC.Inbound, TIC.NewName);
sprintf(Temp, "%s/%s", TIC.Inbound, TIC.NewFile);
if ((MustRearc || DidBanner) && CFG.ct_KeepDate) {
if ((tic.Touch) && (tic.FileArea)) {
ut.actime = mktime(localtime(&TIC.FileDate));
@ -715,7 +713,7 @@ int ProcessTic(fa_list *sbl)
*/
if (tic.FileArea) {
Syslog('+', "Import: %s Area: %s", TIC.NewName, TIC.TicIn.Area);
Syslog('+', "Import: %s Area: %s", TIC.NewFile, TIC.TicIn.Area);
BBS_Imp = Add_BBS();
if (!BBS_Imp) {
@ -726,25 +724,32 @@ int ProcessTic(fa_list *sbl)
}
}
Syslog('f', "Import is done");
chdir(TIC.Inbound);
Syslog('f', "Back in inbound");
/*
* Create file announce record
*/
if (tic.FileArea) {
Syslog('f', "Start magic check");
if (strlen(TIC.TicIn.Magic))
UpDateAlias(TIC.TicIn.Magic);
else
Magic_UpDateAlias();
Syslog('f', "done");
for (i = 0; i <= TIC.File_Id_Ct; i++)
strncpy(T_File.LDesc[i], TIC.File_Id[i], 48);
T_File.TotLdesc = TIC.File_Id_Ct;
T_File.Announce = tic.Announce;
sprintf(Temp, "%s", TIC.NewName);
name_mangle(Temp);
strncpy(T_File.Name, Temp, 12);
strncpy(T_File.LName, TIC.NewName, 80);
strncpy(T_File.Name, TIC.NewFile, 12);
strncpy(T_File.LName, TIC.NewFullName, 80);
T_File.Fdate = TIC.FileDate;
T_File.Cost = TIC.TicIn.Cost;
Syslog('f', "Toberep record filled");
Add_ToBeRep();
Syslog('f', "Added");
}
if (TIC.SendOrg && !tic.FileArea) {
@ -753,11 +758,12 @@ int ProcessTic(fa_list *sbl)
* file in the inbound anymore so it can be
* deleted.
*/
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.RealName);
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.TicIn.File);
if (file_rm(temp1) == 0)
Syslog('f', "Deleted %s", temp1);
}
Syslog('f', "Prepare forward");
if (DownLinks) {
First = TRUE;
@ -775,9 +781,10 @@ int ProcessTic(fa_list *sbl)
tidy_faddr(p_from);
}
}
Syslog('f', "Seen-by's added");
/*
* Debugging, new style SB adding
* Add seen-by lines for all systems that will receive this file.
*/
for (tmpq = qal; tmpq; tmpq = tmpq->next) {
if (tmpq->send) {
@ -790,6 +797,7 @@ int ProcessTic(fa_list *sbl)
}
uniq_list(&sbl);
sort_list(&sbl);
Syslog('f', "More added");
for (tmp = sbl; tmp; tmp = tmp->next)
Syslog('f', "final SB list %s", ascfnode(tmp->addr, 0x0f));

View File

@ -165,13 +165,14 @@ int Tic()
int LoadTic(char *inb, char *tfn)
{
FILE *tfp;
char *Temp, *Temp2, *Buf, *Log = NULL;
char *Temp, *Temp2, *Buf, *Log = NULL, RealName[256];
int i, j, rc, bufsize, DescCnt = FALSE;
fa_list *sbl = NULL;
if (CFG.slow_util && do_quiet)
usleep(1);
memset(&RealName, 0, sizeof(RealName));
memset(&TIC, 0, sizeof(TIC));
memset(&T_File, 0, sizeof(T_File));
@ -399,7 +400,7 @@ int LoadTic(char *inb, char *tfn)
*/
sprintf(Temp, "%s/%s", TIC.TicIn.Pth, TIC.TicIn.FullName);
if (file_exist(Temp, R_OK) == 0) {
strcpy(TIC.RealName, TIC.TicIn.FullName);
strcpy(RealName, TIC.TicIn.FullName);
} else {
WriteError("Can't find %s", Temp);
tidy_falist(&sbl);
@ -425,17 +426,17 @@ int LoadTic(char *inb, char *tfn)
sprintf(Temp2, "%s", TIC.TicIn.File);
sprintf(Temp, "%s/%s", TIC.Inbound, Temp2);
if (file_exist(Temp, R_OK) == 0) {
strcpy(TIC.RealName, Temp2);
strcpy(RealName, Temp2);
} else {
tu(Temp2);
sprintf(Temp, "%s/%s", TIC.Inbound, Temp2);
if (file_exist(Temp, R_OK) == 0) {
strcpy(TIC.RealName, Temp2);
strcpy(RealName, Temp2);
} else {
tl(Temp2);
sprintf(Temp, "%s/%s", TIC.Inbound, Temp2);
if (file_exist(Temp, R_OK) == 0) {
strcpy(TIC.RealName, Temp2);
strcpy(RealName, Temp2);
}
}
}
@ -444,38 +445,53 @@ int LoadTic(char *inb, char *tfn)
* If the above didn't find the file and we got a LFN
* the search again.
*/
if (strlen(TIC.TicIn.FullName) && (strlen(TIC.RealName) == 0)) {
if (strlen(TIC.TicIn.FullName) && (strlen(RealName) == 0)) {
sprintf(Temp2, "%s", TIC.TicIn.FullName);
sprintf(Temp, "%s/%s", TIC.Inbound, Temp2);
if (file_exist(Temp, R_OK) == 0) {
strcpy(TIC.RealName, Temp2);
strcpy(RealName, Temp2);
} else {
tu(Temp2);
sprintf(Temp, "%s/%s", TIC.Inbound, Temp2);
if (file_exist(Temp, R_OK) == 0) {
strcpy(TIC.RealName, Temp2);
strcpy(RealName, Temp2);
} else {
tl(Temp2);
sprintf(Temp, "%s/%s", TIC.Inbound, Temp2);
if (file_exist(Temp, R_OK) == 0) {
strcpy(TIC.RealName, Temp2);
strcpy(RealName, Temp2);
}
}
}
}
}
if (strlen(TIC.RealName) == 0) {
if (strlen(RealName) == 0) {
/*
* We leave RealName empty, the ProcessTic function
* will handle this orphaned tic file.
*/
TIC.Orphaned = TRUE;
WriteError("Can't find file in inbound");
} else {
Syslog('f', "Real filename in inbound is \"%s\"", TIC.RealName);
Syslog('f', "Real filename in inbound is \"%s\"", RealName);
Syslog('f', "8.3 name \"%s\", LFN \"%s\"", TIC.TicIn.File, TIC.TicIn.FullName);
strncpy(TIC.NewName, TIC.RealName, 80);
if (strcmp(RealName, TIC.TicIn.File)) {
/*
* File in inbound has not the same name as the name on disk.
* It may be a LFN but also a case difference. The whole tic
* processing is based on 8.3 filenames.
*/
sprintf(Temp, "%s/%s", TIC.Inbound, RealName);
sprintf(Temp2, "%s/%s", TIC.Inbound, TIC.TicIn.File);
if (rename(Temp, Temp2))
WriteError("$Can't rename %s to %s", Temp, Temp2);
else
Syslog('f', "Renamed %s to %s", Temp, Temp2);
}
}
strncpy(TIC.NewFile, TIC.TicIn.File, 80);
strncpy(TIC.NewFullName, TIC.TicIn.FullName, 255);
free(Temp2);
free(Temp);

View File

@ -39,8 +39,8 @@ typedef struct _TICrec {
Tic_in TicIn; /* Original TIC record */
fidoaddr OrgAka; /* Origin address */
fidoaddr Aka; /* An address ? */
char NewName[81]; /* New name of file */
char RealName[81]; /* Real name on disk */
char NewFile[81]; /* New 8.3 filename */
char NewFullName[256]; /* New LFN name */
char File_Id[25][49]; /* Description */
int File_Id_Ct; /* Nr of lines */
unsigned long Crc_Int; /* Crc value */
@ -52,6 +52,7 @@ typedef struct _TICrec {
unsigned Charge : 1; /* Charge for this file */
unsigned PassThru : 1; /* PassThru file */
unsigned NewAlias : 1; /* New alias is set */
unsigned Orphaned : 1; /* File is Orphaned */
long FileCost; /* Cost for this file */
char BBSpath[PATH_MAX]; /* Path to import in */
char BBSdesc[55]; /* Area description */

View File

@ -81,46 +81,59 @@ int Day_Of_Year()
*/
int Rearc(char *unarc)
{
int i, j;
int i = 0, j = 0, k = 0;
char temp[PATH_MAX], *cmd = NULL;
Syslog('f', "Entering Rearc(%s)", unarc);
i = 0;
while (TIC.NewName[i] != '.')
i++;
i++;
j = 0;
for (; i < strlen(TIC.NewName); i++) {
if (TIC.NewName[i] > '9')
TIC.NewName[i] = tolower(unarc[j]);
j++;
}
Syslog('f' , "NewName = \"%s\"", TIC.NewName);
if (!getarchiver(unarc)) {
return FALSE;
}
cmd = xstrcpy(archiver.farc);
if (cmd == NULL) {
WriteError("Rearc(): No arc command available");
return FALSE;
} else {
sprintf(temp, "%s/%s .", TIC.Inbound, TIC.NewName);
}
while (TIC.NewFile[i] != '.')
i++;
i++;
while (TIC.NewFullName[k] != '.')
k++;
k++;
for (; i < strlen(TIC.NewFile); i++) {
if (TIC.NewFile[i] > '9') {
TIC.NewFile[i] = toupper(unarc[j]);
if (isupper(TIC.NewFullName[i]))
TIC.NewFullName[i] = toupper(unarc[k]);
else
TIC.NewFullName[i] = tolower(unarc[k]);
}
j++;
k++;
}
Syslog('f' , "NewFile=\"%s\", NewFullName=\"%s\"", TIC.NewFile, TIC.NewFullName);
sprintf(temp, "%s/%s .", TIC.Inbound, TIC.NewFile);
if (execute(cmd, temp, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
/* MUST SET TIC.FileDate to NEW ARCHIVE */
free(cmd);
return TRUE;
}
/*
* Restore filenames
*/
strncpy(TIC.NewFile, TIC.TicIn.File, sizeof(TIC.NewFile) -1);
strncpy(TIC.NewFullName, TIC.TicIn.FullName, sizeof(TIC.NewFullName) -1);
free(cmd);
WriteError("Rearc(%s) Failed", unarc);
return FALSE;
}
free(cmd);
}
@ -256,7 +269,7 @@ void UpDateAlias(char *Alias)
char *path;
FILE *fp;
Syslog('f', "UpDateAlias(%s) with %s", Alias, TIC.NewName);
Syslog('f', "UpDateAlias(%s) with %s", Alias, TIC.NewFile);
if (!strlen(CFG.req_magic)) {
WriteError("No magic filename path configured");
@ -269,9 +282,11 @@ void UpDateAlias(char *Alias)
if ((fp = fopen(path, "w")) == NULL) {
WriteError("$Can't create %s", path);
free(path);
return;
}
fprintf(fp, "%s\n", TIC.NewName);
fprintf(fp, "%s\n", TIC.NewFile);
fclose(fp);
free(path);
}