Development of improved tic processing
This commit is contained in:
parent
c8f93b2ac5
commit
2283b37d27
@ -1,15 +1,20 @@
|
|||||||
$Id$
|
$Id$
|
||||||
|
|
||||||
WARNING WARNING: DO NOT USE THIS VERSION, YOU WILL LOOSE FILES !!!!!!!!!!!
|
WARNING WARNING: DO NOT USE THIS VERSION, YOU WILL LOOSE FILES !!!!!!!!!!!
|
||||||
|
WARNING WARNING: TIC PROCESSING WILL MOST LIKELY NOT WORK !!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
MBSEBBS History.
|
MBSEBBS History.
|
||||||
|
|
||||||
v0.35.06
|
v0.35.06
|
||||||
|
|
||||||
update:
|
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
|
Run "mbfile check". This will create a error in the logfile
|
||||||
for each file! It will update the filenames on disk to have
|
for each file! It will update the filenames on disk to have
|
||||||
both short and long filenames. Just ignore the errors!
|
both short and long filenames. Just ignore the errors!
|
||||||
|
Start the bbs again (mbstat open).
|
||||||
|
|
||||||
general:
|
general:
|
||||||
This may become release 0.36.00 (again).
|
This may become release 0.36.00 (again).
|
||||||
@ -42,7 +47,9 @@ v0.35.06
|
|||||||
command would detect and correct this.
|
command would detect and correct this.
|
||||||
TIC files added to the bbs will now also have a 8.3 hard link.
|
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.
|
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:
|
mbcico:
|
||||||
With filetransfer errors, the attempts counter was not
|
With filetransfer errors, the attempts counter was not
|
||||||
increased.
|
increased.
|
||||||
|
@ -62,12 +62,6 @@ int Add_BBS()
|
|||||||
int Keep = 0, DidDelete = FALSE;
|
int Keep = 0, DidDelete = FALSE;
|
||||||
fd_list *fdl = NULL;
|
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,
|
* First check for an existing record with the same filename,
|
||||||
* if it exists, update the record and we are ready. This will
|
* 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);
|
sprintf(fdbname, "%s/fdb/fdb%ld.data", getenv("MBSE_ROOT"), tic.FileArea);
|
||||||
if ((fdb = fopen(fdbname, "r+")) != NULL) {
|
if ((fdb = fopen(fdbname, "r+")) != NULL) {
|
||||||
while (fread(&frec, sizeof(frec), 1, fdb) == 1) {
|
while (fread(&frec, sizeof(frec), 1, fdb) == 1) {
|
||||||
if ((strcmp(frec.Name, temp1) == 0) && (strcmp(frec.LName, TIC.NewName) == 0)) {
|
if (strcmp(frec.Name, TIC.NewFile) == 0) {
|
||||||
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.NewName);
|
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.NewFile);
|
||||||
sprintf(temp2, "%s/%s", TIC.BBSpath, TIC.NewName);
|
sprintf(temp2, "%s/%s", TIC.BBSpath, TIC.NewFile);
|
||||||
mkdirs(temp2, 0755);
|
mkdirs(temp2, 0755);
|
||||||
if ((rc = file_cp(temp1, temp2))) {
|
if ((rc = file_cp(temp1, temp2))) {
|
||||||
WriteError("Copy to %s failed: %s", temp2, strerror(rc));
|
WriteError("Copy to %s failed: %s", temp2, strerror(rc));
|
||||||
@ -112,12 +106,24 @@ int Add_BBS()
|
|||||||
fclose(fdb);
|
fclose(fdb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Syslog('f', "addbbs 1");
|
||||||
/*
|
/*
|
||||||
* Create filedatabase record.
|
* Create filedatabase record.
|
||||||
*/
|
*/
|
||||||
memset(&frec, 0, sizeof(frec));
|
memset(&frec, 0, sizeof(frec));
|
||||||
strcpy(frec.Name, temp1);
|
strncpy(frec.Name, TIC.NewFile, sizeof(frec.Name) -1);
|
||||||
strcpy(frec.LName, TIC.NewName);
|
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.TicAreaCRC = StringCRC32(TIC.TicIn.Area);
|
||||||
frec.Size = TIC.FileSize;
|
frec.Size = TIC.FileSize;
|
||||||
frec.Crc32 = TIC.Crc_Int;
|
frec.Crc32 = TIC.Crc_Int;
|
||||||
@ -133,8 +139,9 @@ int Add_BBS()
|
|||||||
if (strlen(TIC.TicIn.Magic))
|
if (strlen(TIC.TicIn.Magic))
|
||||||
sprintf(frec.Desc[i], "Magic Request: %s", TIC.TicIn.Magic);
|
sprintf(frec.Desc[i], "Magic Request: %s", TIC.TicIn.Magic);
|
||||||
|
|
||||||
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.NewName);
|
Syslog('f', "addbbs 3");
|
||||||
sprintf(temp2, "%s/%s", TIC.BBSpath, TIC.NewName);
|
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.NewFile);
|
||||||
|
sprintf(temp2, "%s/%s", TIC.BBSpath, frec.Name);
|
||||||
mkdirs(temp2, 0755);
|
mkdirs(temp2, 0755);
|
||||||
|
|
||||||
if ((rc = file_cp(temp1, temp2))) {
|
if ((rc = file_cp(temp1, temp2))) {
|
||||||
@ -143,11 +150,12 @@ int Add_BBS()
|
|||||||
}
|
}
|
||||||
chmod(temp2, 0644);
|
chmod(temp2, 0644);
|
||||||
lname = calloc(PATH_MAX, sizeof(char));
|
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)) {
|
if (link(temp2, lname)) {
|
||||||
WriteError("$Create link %s to %s failed", lname, temp2);
|
WriteError("$Create link %s to %s failed", temp2, lname);
|
||||||
}
|
}
|
||||||
free(lname);
|
free(lname);
|
||||||
|
Syslog('f', "addbbs 4");
|
||||||
|
|
||||||
sprintf(fdbtemp, "%s/fdb/fdb%ld.temp", getenv("MBSE_ROOT"), tic.FileArea);
|
sprintf(fdbtemp, "%s/fdb/fdb%ld.temp", getenv("MBSE_ROOT"), tic.FileArea);
|
||||||
|
|
||||||
@ -173,6 +181,7 @@ int Add_BBS()
|
|||||||
tic_imp++;
|
tic_imp++;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
Syslog('f', "addbbs 5");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* There are already files in the area. We must now see at
|
* There are already files in the area. We must now see at
|
||||||
@ -196,6 +205,7 @@ int Add_BBS()
|
|||||||
}
|
}
|
||||||
} while ((!Found) && (!Done));
|
} while ((!Found) && (!Done));
|
||||||
|
|
||||||
|
Syslog('f', "addbbs 6");
|
||||||
if (Found) {
|
if (Found) {
|
||||||
if ((fdt = fopen(fdbtemp, "a+")) == NULL) {
|
if ((fdt = fopen(fdbtemp, "a+")) == NULL) {
|
||||||
WriteError("$Can't create %s", fdbtemp);
|
WriteError("$Can't create %s", fdbtemp);
|
||||||
@ -246,6 +256,7 @@ int Add_BBS()
|
|||||||
}
|
}
|
||||||
fclose(fdt);
|
fclose(fdt);
|
||||||
fclose(fdb);
|
fclose(fdb);
|
||||||
|
Syslog('f', "addbbs 7");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now make the changes for real.
|
* Now make the changes for real.
|
||||||
@ -273,6 +284,7 @@ int Add_BBS()
|
|||||||
if ((i = file_rm(temp1)))
|
if ((i = file_rm(temp1)))
|
||||||
WriteError("file_rm(%s): %s", temp1, strerror(i));
|
WriteError("file_rm(%s): %s", temp1, strerror(i));
|
||||||
|
|
||||||
|
Syslog('f', "addbbs 8");
|
||||||
/*
|
/*
|
||||||
* Handle the replace option.
|
* Handle the replace option.
|
||||||
*/
|
*/
|
||||||
@ -282,10 +294,11 @@ int Add_BBS()
|
|||||||
if ((fdb = fopen(fdbname, "r+")) != NULL) {
|
if ((fdb = fopen(fdbname, "r+")) != NULL) {
|
||||||
|
|
||||||
while (fread(&file, sizeof(file), 1, fdb) == 1) {
|
while (fread(&file, sizeof(file), 1, fdb) == 1) {
|
||||||
if (strlen(file.LName) == strlen(TIC.NewName)) {
|
if (strlen(file.LName) == strlen(frec.LName)) {
|
||||||
if (strcasecmp(file.LName, TIC.NewName) != 0) {
|
// FIXME: Search must be based on a reg_exp search
|
||||||
|
if (strcasecmp(file.LName, frec.LName) != 0) {
|
||||||
Found = TRUE;
|
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])))
|
if ((TIC.TicIn.Replace[i] != '?') && (toupper(TIC.TicIn.Replace[i]) != toupper(file.LName[i])))
|
||||||
Found = FALSE;
|
Found = FALSE;
|
||||||
}
|
}
|
||||||
@ -302,33 +315,37 @@ int Add_BBS()
|
|||||||
fclose(fdb);
|
fclose(fdb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Syslog('f', "addbbs 9");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Handle the Keep number of files option
|
* Handle the Keep number of files option
|
||||||
*/
|
*/
|
||||||
if (TIC.KeepNum) {
|
if (TIC.KeepNum) {
|
||||||
|
Syslog('f', "AddBBS, handle KeepNum %d", TIC.KeepNum);
|
||||||
if ((fdb = fopen(fdbname, "r")) != NULL) {
|
if ((fdb = fopen(fdbname, "r")) != NULL) {
|
||||||
|
|
||||||
while (fread(&file, sizeof(file), 1, fdb) == 1) {
|
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;
|
Found = TRUE;
|
||||||
|
|
||||||
for (i = 0; i < strlen(file.LName); i++) {
|
for (i = 0; i < strlen(file.LName); i++) {
|
||||||
if ((TIC.NewName[i] < '0') || (TIC.NewName[i] > '9')) {
|
if ((frec.LName[i] < '0') || (frec.LName[i] > '9')) {
|
||||||
if (TIC.NewName[i] != file.LName[i]) {
|
if (frec.LName[i] != file.LName[i]) {
|
||||||
Found = FALSE;
|
Found = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Found) {
|
if (Found) {
|
||||||
Keep++;
|
Keep++;
|
||||||
|
Syslog('f', "Add \"%s\" to keeplist", file.LName);
|
||||||
fill_fdlist(&fdl, file.LName, file.UploadDate);
|
fill_fdlist(&fdl, file.LName, file.UploadDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(fdb);
|
fclose(fdb);
|
||||||
}
|
}
|
||||||
|
Syslog('f', "addbbs 10");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If there are files to delete, mark them.
|
* If there are files to delete, mark them.
|
||||||
@ -356,6 +373,7 @@ int Add_BBS()
|
|||||||
}
|
}
|
||||||
tidy_fdlist(&fdl);
|
tidy_fdlist(&fdl);
|
||||||
}
|
}
|
||||||
|
Syslog('f', "addbbs 11");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now realy delete the marked files and clean the file
|
* Now realy delete the marked files and clean the file
|
||||||
@ -389,6 +407,7 @@ int Add_BBS()
|
|||||||
DidDelete = FALSE;
|
DidDelete = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Syslog('f', "addbbs 12");
|
||||||
|
|
||||||
tic_imp++;
|
tic_imp++;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
|
|
||||||
void ForwardFile(fidoaddr Node, fa_list *sbl)
|
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;
|
FILE *fp, *fi, *fl, *net;
|
||||||
faddr *dest, *routeto, *Fa, *Temp, *ba;
|
faddr *dest, *routeto, *Fa, *Temp, *ba;
|
||||||
int i, z, n;
|
int i, z, n;
|
||||||
@ -103,17 +103,14 @@ void ForwardFile(fidoaddr Node, fa_list *sbl)
|
|||||||
* Create the full filename
|
* Create the full filename
|
||||||
*/
|
*/
|
||||||
if (TIC.PassThru || TIC.SendOrg) {
|
if (TIC.PassThru || TIC.SendOrg) {
|
||||||
sprintf(fwdfile, "%s/%s", TIC.Inbound, TIC.RealName);
|
sprintf(fwdfile, "%s/%s", TIC.Inbound, TIC.TicIn.File);
|
||||||
subject = xstrcpy(TIC.RealName);
|
subject = xstrcpy(TIC.TicIn.File);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* Make sure the file attach is the 8.3 filename
|
* Make sure the file attach is the 8.3 filename
|
||||||
*/
|
*/
|
||||||
temp = xstrcpy(TIC.NewName);
|
sprintf(fwdfile, "%s/%s", TIC.BBSpath, TIC.NewFile);
|
||||||
name_mangle(temp);
|
subject = xstrcpy(TIC.NewFile);
|
||||||
sprintf(fwdfile, "%s/%s", TIC.BBSpath, temp);
|
|
||||||
subject = xstrcpy(temp);
|
|
||||||
free(temp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
flavor = 'f';
|
flavor = 'f';
|
||||||
@ -152,7 +149,10 @@ void ForwardFile(fidoaddr Node, fa_list *sbl)
|
|||||||
MacroVars("b", "s", tic.Comment);
|
MacroVars("b", "s", tic.Comment);
|
||||||
MacroVars("c", "d", TIC.FileCost);
|
MacroVars("c", "d", TIC.FileCost);
|
||||||
MacroVars("d", "s", fgroup.Comment);
|
MacroVars("d", "s", fgroup.Comment);
|
||||||
MacroVars("f", "s", TIC.TicIn.FullName);
|
if (TIC.PassThru || TIC.SendOrg)
|
||||||
|
MacroVars("f", "s", TIC.TicIn.FullName);
|
||||||
|
else
|
||||||
|
MacroVars("f", "s", TIC.NewFullName);
|
||||||
MacroVars("g", "d", TIC.FileSize);
|
MacroVars("g", "d", TIC.FileSize);
|
||||||
MacroVars("h", "d", (TIC.FileSize / 1024));
|
MacroVars("h", "d", (TIC.FileSize / 1024));
|
||||||
MacroVars("i", "s", TIC.TicIn.Crc);
|
MacroVars("i", "s", TIC.TicIn.Crc);
|
||||||
@ -160,10 +160,10 @@ void ForwardFile(fidoaddr Node, fa_list *sbl)
|
|||||||
MacroVars("m", "s", rfcdate(ftime));
|
MacroVars("m", "s", rfcdate(ftime));
|
||||||
MacroVars("n", "s", TIC.TicIn.Desc);
|
MacroVars("n", "s", TIC.TicIn.Desc);
|
||||||
MacroVars("s", "s", nodes.Sysop);
|
MacroVars("s", "s", nodes.Sysop);
|
||||||
if (TIC.SendOrg)
|
if (TIC.PassThru || TIC.SendOrg)
|
||||||
MacroVars("e", "s", TIC.RealName);
|
MacroVars("e", "s", TIC.TicIn.File);
|
||||||
else
|
else
|
||||||
MacroVars("e", "s", TIC.NewName);
|
MacroVars("e", "s", TIC.NewFile);
|
||||||
if (strlen(TIC.TicIn.Magic))
|
if (strlen(TIC.TicIn.Magic))
|
||||||
MacroVars("k", "s", TIC.TicIn.Magic);
|
MacroVars("k", "s", TIC.TicIn.Magic);
|
||||||
if (strlen(TIC.TicIn.Replace))
|
if (strlen(TIC.TicIn.Replace))
|
||||||
@ -195,26 +195,15 @@ void ForwardFile(fidoaddr Node, fa_list *sbl)
|
|||||||
if (strlen(TIC.TicIn.Magic))
|
if (strlen(TIC.TicIn.Magic))
|
||||||
fprintf(fp, "Magic %s\r\n", TIC.TicIn.Magic);
|
fprintf(fp, "Magic %s\r\n", TIC.TicIn.Magic);
|
||||||
|
|
||||||
if ((TIC.PassThru) || (TIC.SendOrg))
|
if ((TIC.PassThru) || (TIC.SendOrg)) {
|
||||||
subject = xstrcpy(TIC.RealName);
|
fprintf(fp, "File %s\r\n", TIC.TicIn.File);
|
||||||
else
|
if (strlen(TIC.TicIn.FullName))
|
||||||
subject = xstrcpy(TIC.NewName);
|
fprintf(fp, "Fullname %s\r\n", TIC.TicIn.FullName);
|
||||||
/*
|
} else {
|
||||||
* Create 8.3 filename if this is a long filename. In normal
|
fprintf(fp, "File %s\r\n", TIC.NewFile);
|
||||||
* cases mbcico will transmit the long filename to the other
|
if (strlen(TIC.NewFullName))
|
||||||
* node. If they can't process the TIC files which has a short
|
fprintf(fp, "Fullname %s\r\n", TIC.NewFullName);
|
||||||
* 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);
|
|
||||||
|
|
||||||
fprintf(fp, "Size %ld\r\n", (long)(TIC.FileSize));
|
fprintf(fp, "Size %ld\r\n", (long)(TIC.FileSize));
|
||||||
fprintf(fp, "Desc %s\r\n", TIC.TicIn.Desc);
|
fprintf(fp, "Desc %s\r\n", TIC.TicIn.Desc);
|
||||||
fprintf(fp, "Crc %s\r\n", TIC.TicIn.Crc);
|
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) {
|
if ((fp = fopen(fname, "a+")) != NULL) {
|
||||||
memset(&bill, 0, sizeof(bill));
|
memset(&bill, 0, sizeof(bill));
|
||||||
bill.Node = nodes.Aka[0];
|
bill.Node = nodes.Aka[0];
|
||||||
strcpy(bill.FileName, TIC.NewName);
|
strcpy(bill.FileName, TIC.NewFile);
|
||||||
strcpy(bill.FileEcho, TIC.TicIn.Area);
|
strcpy(bill.FileEcho, TIC.TicIn.Area);
|
||||||
bill.Size = TIC.FileSize;
|
bill.Size = TIC.FileSize;
|
||||||
bill.Cost = TIC.FileCost;
|
bill.Cost = TIC.FileCost;
|
||||||
|
315
mbfido/magic.c
315
mbfido/magic.c
@ -50,51 +50,36 @@ int Magics = 0; /* Processed magics */
|
|||||||
char *Magic_Macro(int);
|
char *Magic_Macro(int);
|
||||||
char *Magic_Macro(int C)
|
char *Magic_Macro(int C)
|
||||||
{
|
{
|
||||||
static char buf[PATH_MAX];
|
static char buf[PATH_MAX];
|
||||||
|
|
||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
switch(toupper(C)) {
|
switch(toupper(C)) {
|
||||||
case 'F':
|
case 'F': sprintf(buf, "%s/%s", TIC.BBSpath, TIC.NewFile);
|
||||||
sprintf(buf, "%s/%s", TIC.BBSpath, TIC.NewName);
|
break;
|
||||||
break;
|
case 'P': sprintf(buf, "%s", TIC.BBSpath);
|
||||||
|
break;
|
||||||
|
case 'N': sprintf(buf, "%s", strtok(strdup(TIC.NewFile), "."));
|
||||||
|
break;
|
||||||
|
case 'E': sprintf(buf, "%s", strrchr(TIC.NewFile, '.'));
|
||||||
|
break;
|
||||||
|
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());
|
||||||
|
break;
|
||||||
|
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);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 'P':
|
Syslog('f', "Mgc Macro(%c): \"%s\"", C, buf);
|
||||||
sprintf(buf, "%s", TIC.BBSpath);
|
return buf;
|
||||||
break;
|
|
||||||
|
|
||||||
case 'N':
|
|
||||||
sprintf(buf, "%s", strtok(strdup(TIC.NewName), "."));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'E':
|
|
||||||
sprintf(buf, "%s", strrchr(TIC.NewName, '.'));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'L':
|
|
||||||
sprintf(buf, "%s", strrchr(TIC.NewName, '.'));
|
|
||||||
buf[0] = buf[1];
|
|
||||||
buf[1] = buf[2];
|
|
||||||
buf[2] = '\0';
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'D':
|
|
||||||
sprintf(buf, "%03d", Day_Of_Year());
|
|
||||||
break;
|
|
||||||
|
|
||||||
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);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Syslog('f', "Mgc Macro(%c): \"%s\"", C, buf);
|
|
||||||
return buf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -154,7 +139,7 @@ int GetMagicRec(int Typ, int First)
|
|||||||
*q = '\0';
|
*q = '\0';
|
||||||
|
|
||||||
if ((re_comp(mask)) == NULL) {
|
if ((re_comp(mask)) == NULL) {
|
||||||
if (re_exec(TIC.NewName)) {
|
if (re_exec(TIC.NewFile)) {
|
||||||
fclose(FeM);
|
fclose(FeM);
|
||||||
free(temp);
|
free(temp);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -179,18 +164,18 @@ int GetMagicRec(int Typ, int First)
|
|||||||
|
|
||||||
void MagicResult(char *format, ...)
|
void MagicResult(char *format, ...)
|
||||||
{
|
{
|
||||||
char *outputstr;
|
char *outputstr;
|
||||||
va_list va_ptr;
|
va_list va_ptr;
|
||||||
|
|
||||||
outputstr = calloc(1024, sizeof(char));
|
outputstr = calloc(1024, sizeof(char));
|
||||||
|
|
||||||
va_start(va_ptr, format);
|
va_start(va_ptr, format);
|
||||||
vsprintf(outputstr, format, va_ptr);
|
vsprintf(outputstr, format, va_ptr);
|
||||||
va_end(va_ptr);
|
va_end(va_ptr);
|
||||||
|
|
||||||
Syslog('+', "Magic: %s", outputstr);
|
Syslog('+', "Magic: %s", outputstr);
|
||||||
free(outputstr);
|
free(outputstr);
|
||||||
Magics++;
|
Magics++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -198,96 +183,94 @@ void MagicResult(char *format, ...)
|
|||||||
void Magic_CheckCompile(void);
|
void Magic_CheckCompile(void);
|
||||||
void Magic_CheckCompile(void)
|
void Magic_CheckCompile(void)
|
||||||
{
|
{
|
||||||
if (magic.Compile) {
|
if (magic.Compile) {
|
||||||
CompileNL = TRUE;
|
CompileNL = TRUE;
|
||||||
Syslog('+', "Magic: Trigger Compile Nodelists");
|
Syslog('+', "Magic: Trigger Compile Nodelists");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int Magic_MoveFile(void)
|
int Magic_MoveFile(void)
|
||||||
{
|
{
|
||||||
if (GetMagicRec(MG_MOVE, TRUE)) {
|
if (GetMagicRec(MG_MOVE, TRUE)) {
|
||||||
strcpy(TIC.TicIn.Area, magic.ToArea);
|
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;
|
return TRUE;
|
||||||
} else
|
} else
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Magic_ExecCommand(void)
|
void Magic_ExecCommand(void)
|
||||||
{
|
{
|
||||||
int i, j, k, Err, First = TRUE;
|
int i, j, k, Err, First = TRUE;
|
||||||
char Line[256];
|
char Line[256], Temp[PATH_MAX], *cmd, *opts;
|
||||||
char Temp[PATH_MAX];
|
|
||||||
char *cmd, *opts;
|
|
||||||
|
|
||||||
while (GetMagicRec(MG_EXEC, First)) {
|
while (GetMagicRec(MG_EXEC, First)) {
|
||||||
First = FALSE;
|
First = FALSE;
|
||||||
j = 0;
|
j = 0;
|
||||||
memset(&Line, 0, sizeof(Line));
|
memset(&Line, 0, sizeof(Line));
|
||||||
for (i = 0; i < strlen(magic.Cmd); i++) {
|
for (i = 0; i < strlen(magic.Cmd); i++) {
|
||||||
if (magic.Cmd[i] != '%') {
|
if (magic.Cmd[i] != '%') {
|
||||||
Line[j] = magic.Cmd[i];
|
Line[j] = magic.Cmd[i];
|
||||||
j++;
|
j++;
|
||||||
} else {
|
} else {
|
||||||
i++;
|
i++;
|
||||||
if (magic.Cmd[i] == '%') {
|
if (magic.Cmd[i] == '%') {
|
||||||
Line[j] = '%';
|
Line[j] = '%';
|
||||||
j++;
|
j++;
|
||||||
} else {
|
} else {
|
||||||
Temp[0] = '\0';
|
Temp[0] = '\0';
|
||||||
sprintf(Temp, "%s", Magic_Macro(magic.Cmd[i]));
|
sprintf(Temp, "%s", Magic_Macro(magic.Cmd[i]));
|
||||||
for (k = 0; k < strlen(Temp); k++) {
|
for (k = 0; k < strlen(Temp); k++) {
|
||||||
Line[j] = Temp[k];
|
Line[j] = Temp[k];
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
cmd = xstrcpy(getenv("MBSE_ROOT"));
|
|
||||||
cmd = xstrcat(cmd, (char *)"/bin/");
|
|
||||||
cmd = xstrcat(cmd, strtok(Line, " "));
|
|
||||||
opts = strtok(NULL, "\0");
|
|
||||||
MagicResult((char *)"Exec: \"%s %s\"", cmd, opts);
|
|
||||||
|
|
||||||
if ((Err = execute(cmd, opts, NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null")) == 0) {
|
|
||||||
Magics++;
|
|
||||||
} else
|
|
||||||
Syslog('!', "Mgc Exec: (%s %s) returns %d", cmd, opts, Err);
|
|
||||||
|
|
||||||
Magic_CheckCompile();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmd = xstrcpy(getenv("MBSE_ROOT"));
|
||||||
|
cmd = xstrcat(cmd, (char *)"/bin/");
|
||||||
|
cmd = xstrcat(cmd, strtok(Line, " "));
|
||||||
|
opts = strtok(NULL, "\0");
|
||||||
|
MagicResult((char *)"Exec: \"%s %s\"", cmd, opts);
|
||||||
|
|
||||||
|
if ((Err = execute(cmd, opts, NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null")) == 0) {
|
||||||
|
Magics++;
|
||||||
|
} else
|
||||||
|
Syslog('!', "Mgc Exec: (%s %s) returns %d", cmd, opts, Err);
|
||||||
|
|
||||||
|
Magic_CheckCompile();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Magic_CopyFile(void)
|
void Magic_CopyFile(void)
|
||||||
{
|
{
|
||||||
int First = TRUE, rc;
|
int First = TRUE, rc;
|
||||||
char *From, *To;
|
char *From, *To;
|
||||||
|
|
||||||
From = calloc(PATH_MAX, sizeof(char));
|
From = calloc(PATH_MAX, sizeof(char));
|
||||||
To = calloc(PATH_MAX, sizeof(char));
|
To = calloc(PATH_MAX, sizeof(char));
|
||||||
|
|
||||||
while (GetMagicRec(MG_COPY, First)) {
|
while (GetMagicRec(MG_COPY, First)) {
|
||||||
First = FALSE;
|
First = FALSE;
|
||||||
sprintf(From, "%s/%s", TIC.BBSpath, TIC.NewName);
|
sprintf(From, "%s/%s", TIC.BBSpath, TIC.NewFile);
|
||||||
sprintf(To, "%s/%s", magic.Path, TIC.NewName);
|
sprintf(To, "%s/%s", magic.Path, TIC.NewFile);
|
||||||
|
|
||||||
if ((rc = file_cp(From, To) == 0)) {
|
if ((rc = file_cp(From, To) == 0)) {
|
||||||
MagicResult((char *)"%s copied to %s", From, To);
|
MagicResult((char *)"%s copied to %s", From, To);
|
||||||
Magic_CheckCompile();
|
Magic_CheckCompile();
|
||||||
} else
|
} else
|
||||||
WriteError("Magic: copy: %s to %s failed, %s", strerror(rc));
|
WriteError("Magic: copy: %s to %s failed, %s", strerror(rc));
|
||||||
}
|
}
|
||||||
|
|
||||||
free(From);
|
free(From);
|
||||||
free(To);
|
free(To);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -304,7 +287,7 @@ void Magic_UnpackFile(void)
|
|||||||
getcwd(buf, 128);
|
getcwd(buf, 128);
|
||||||
|
|
||||||
if (chdir(magic.Path) == 0) {
|
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 ((unarc = unpacker(Fn)) != NULL) {
|
||||||
if (getarchiver(unarc)) {
|
if (getarchiver(unarc)) {
|
||||||
cmd = xstrcpy(archiver.funarc);
|
cmd = xstrcpy(archiver.funarc);
|
||||||
@ -334,78 +317,80 @@ void Magic_UnpackFile(void)
|
|||||||
|
|
||||||
void Magic_Keepnum(void)
|
void Magic_Keepnum(void)
|
||||||
{
|
{
|
||||||
if (GetMagicRec(MG_KEEPNUM, TRUE)) {
|
if (GetMagicRec(MG_KEEPNUM, TRUE)) {
|
||||||
TIC.KeepNum = magic.KeepNum;
|
TIC.KeepNum = magic.KeepNum;
|
||||||
MagicResult((char *)"Keep %d files", TIC.KeepNum);
|
MagicResult((char *)"Keep %d files", TIC.KeepNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Magic_UpDateAlias(void)
|
void Magic_UpDateAlias(void)
|
||||||
{
|
{
|
||||||
if (GetMagicRec(MG_UPDALIAS, TRUE)) {
|
if (GetMagicRec(MG_UPDALIAS, TRUE)) {
|
||||||
UpDateAlias(TIC.TicIn.Area);
|
UpDateAlias(TIC.TicIn.Area);
|
||||||
MagicResult((char *)"Update Alias");
|
MagicResult((char *)"Update Alias");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Magic_AdoptFile(void)
|
void Magic_AdoptFile(void)
|
||||||
{
|
{
|
||||||
int First = TRUE;
|
int First = TRUE;
|
||||||
char *temp;
|
char *temp;
|
||||||
FILE *Tf;
|
FILE *Tf;
|
||||||
|
|
||||||
temp = calloc(PATH_MAX, sizeof(char));
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
|
|
||||||
while (GetMagicRec(MG_ADOPT, First)) {
|
while (GetMagicRec(MG_ADOPT, First)) {
|
||||||
First = FALSE;
|
First = FALSE;
|
||||||
|
|
||||||
if (SearchTic(magic.ToArea)) {
|
if (SearchTic(magic.ToArea)) {
|
||||||
MagicResult((char *)"Adoptfile in %s", magic.ToArea);
|
MagicResult((char *)"Adoptfile in %s", magic.ToArea);
|
||||||
|
|
||||||
sprintf(temp, "%s/%s", TIC.Inbound, MakeTicName());
|
sprintf(temp, "%s/%s", TIC.Inbound, MakeTicName());
|
||||||
if ((Tf = fopen(temp, "a+")) == NULL)
|
if ((Tf = fopen(temp, "a+")) == NULL)
|
||||||
WriteError("$Can't create %s", temp);
|
WriteError("$Can't create %s", temp);
|
||||||
else {
|
else {
|
||||||
fprintf(Tf, "Hatch\r\n");
|
fprintf(Tf, "Hatch\r\n");
|
||||||
fprintf(Tf, "NoMove\r\n");
|
fprintf(Tf, "NoMove\r\n");
|
||||||
fprintf(Tf, "Created MBSE BBS v%s, %s\r\n", VERSION, SHORTRIGHT);
|
fprintf(Tf, "Created MBSE BBS v%s, %s\r\n", VERSION, SHORTRIGHT);
|
||||||
fprintf(Tf, "Area %s\r\n", magic.ToArea);
|
fprintf(Tf, "Area %s\r\n", magic.ToArea);
|
||||||
fprintf(Tf, "Origin %s\r\n", aka2str(tic.Aka));
|
fprintf(Tf, "Origin %s\r\n", aka2str(tic.Aka));
|
||||||
fprintf(Tf, "From %s\r\n", aka2str(tic.Aka));
|
fprintf(Tf, "From %s\r\n", aka2str(tic.Aka));
|
||||||
if (strlen(TIC.TicIn.Replace))
|
if (strlen(TIC.TicIn.Replace))
|
||||||
fprintf(Tf, "Replaces %s\r\n", TIC.TicIn.Replace);
|
fprintf(Tf, "Replaces %s\r\n", TIC.TicIn.Replace);
|
||||||
if (strlen(TIC.TicIn.Magic))
|
if (strlen(TIC.TicIn.Magic))
|
||||||
fprintf(Tf, "Magic %s\r\n", 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);
|
||||||
fprintf(Tf, "Pth %s\r\n", TIC.BBSpath);
|
if (strlen(TIC.NewFullName))
|
||||||
fprintf(Tf, "Desc %s\r\n", TIC.TicIn.Desc);
|
fprintf(Tf, "Fullname %s\r\n", TIC.NewFullName);
|
||||||
fprintf(Tf, "Crc %s\r\n", TIC.TicIn.Crc);
|
fprintf(Tf, "Pth %s\r\n", TIC.BBSpath);
|
||||||
fprintf(Tf, "Pw %s\r\n", CFG.hatchpasswd);
|
fprintf(Tf, "Desc %s\r\n", TIC.TicIn.Desc);
|
||||||
fclose(Tf);
|
fprintf(Tf, "Crc %s\r\n", TIC.TicIn.Crc);
|
||||||
}
|
fprintf(Tf, "Pw %s\r\n", CFG.hatchpasswd);
|
||||||
|
fclose(Tf);
|
||||||
|
}
|
||||||
|
|
||||||
SearchTic(TIC.TicIn.Area);
|
SearchTic(TIC.TicIn.Area);
|
||||||
} else
|
} else
|
||||||
WriteError("Mgc Adopt: Area \"%s\" not found");
|
WriteError("Mgc Adopt: Area \"%s\" not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
free(temp);
|
free(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int Magic_DeleteFile(void)
|
int Magic_DeleteFile(void)
|
||||||
{
|
{
|
||||||
int Result;
|
int Result;
|
||||||
|
|
||||||
if ((Result = GetMagicRec(MG_DELETE, TRUE)))
|
if ((Result = GetMagicRec(MG_DELETE, TRUE)))
|
||||||
MagicResult((char *)"Delete file");
|
MagicResult((char *)"Delete file");
|
||||||
|
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,25 +43,26 @@
|
|||||||
|
|
||||||
void mover(char *fn)
|
void mover(char *fn)
|
||||||
{
|
{
|
||||||
char *From, *To;
|
char *From, *To;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
From = calloc(PATH_MAX, sizeof(char));
|
From = calloc(PATH_MAX, sizeof(char));
|
||||||
To = calloc(PATH_MAX, sizeof(char));
|
To = calloc(PATH_MAX, sizeof(char));
|
||||||
|
|
||||||
sprintf(From, "%s/%s", TIC.Inbound, fn);
|
sprintf(From, "%s/%s", TIC.Inbound, fn);
|
||||||
sprintf(To, "%s/%s", CFG.badtic, fn);
|
sprintf(To, "%s/%s", CFG.badtic, fn);
|
||||||
Syslog('!', "Moving %s to %s", From, To);
|
Syslog('!', "Moving %s to %s", From, To);
|
||||||
|
|
||||||
if (mkdirs(To, 0770)) {
|
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));
|
WriteError("$Failed to move %s to %s: %s", From, To, strerror(rc));
|
||||||
} else {
|
|
||||||
WriteError("$Can't create directory for %s", To);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
WriteError("$Can't create directory for %s", To);
|
||||||
|
}
|
||||||
|
|
||||||
free(From);
|
free(From);
|
||||||
free(To);
|
free(To);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -71,8 +72,8 @@ void mover(char *fn)
|
|||||||
*/
|
*/
|
||||||
void MoveBad()
|
void MoveBad()
|
||||||
{
|
{
|
||||||
mover(TIC.TicName);
|
mover(TIC.TicName);
|
||||||
mover(TIC.RealName);
|
mover(TIC.NewFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
106
mbfido/ptic.c
106
mbfido/ptic.c
@ -104,7 +104,7 @@ int ProcessTic(fa_list *sbl)
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen(TIC.RealName) == 0) {
|
if (TIC.Orphaned) {
|
||||||
WriteError("File not in inbound: %s", TIC.TicIn.File);
|
WriteError("File not in inbound: %s", TIC.TicIn.File);
|
||||||
/*
|
/*
|
||||||
* Now check the age of the .tic file.
|
* Now check the age of the .tic file.
|
||||||
@ -123,7 +123,7 @@ int ProcessTic(fa_list *sbl)
|
|||||||
return 2;
|
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);
|
crc = file_crc(Temp, CFG.slow_util && do_quiet);
|
||||||
TIC.FileSize = file_size(Temp);
|
TIC.FileSize = file_size(Temp);
|
||||||
TIC.FileDate = file_time(Temp);
|
TIC.FileDate = file_time(Temp);
|
||||||
@ -142,7 +142,7 @@ int ProcessTic(fa_list *sbl)
|
|||||||
if (crc != TIC.Crc_Int) {
|
if (crc != TIC.Crc_Int) {
|
||||||
Syslog('!', "CRC: expected %08lX, the file is %08lX", TIC.Crc_Int, crc);
|
Syslog('!', "CRC: expected %08lX, the file is %08lX", TIC.Crc_Int, crc);
|
||||||
if (check_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);
|
free(Temp);
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
@ -409,8 +409,8 @@ int ProcessTic(fa_list *sbl)
|
|||||||
* is used for this file.
|
* is used for this file.
|
||||||
*/
|
*/
|
||||||
if (strlen(tic.Convert) || tic.VirScan || tic.FileId || tic.ConvertAll || strlen(tic.Banner)) {
|
if (strlen(tic.Convert) || tic.VirScan || tic.FileId || tic.ConvertAll || strlen(tic.Banner)) {
|
||||||
if ((unarc = unpacker(TIC.RealName)) == NULL)
|
if ((unarc = unpacker(TIC.TicIn.File)) == NULL)
|
||||||
Syslog('+', "Unknown archive format %s", TIC.RealName);
|
Syslog('+', "Unknown archive format %s", TIC.TicIn.File);
|
||||||
else {
|
else {
|
||||||
IsArchive = TRUE;
|
IsArchive = TRUE;
|
||||||
if ((strlen(tic.Convert) && (strcmp(unarc, tic.Convert) == 0)) || (tic.ConvertAll))
|
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.
|
* it's a passthru area.
|
||||||
*/
|
*/
|
||||||
if (((tic.SendOrg) && (MustRearc || strlen(tic.Banner))) || (!tic.FileArea)) {
|
if (((tic.SendOrg) && (MustRearc || strlen(tic.Banner))) || (!tic.FileArea)) {
|
||||||
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.RealName);
|
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.TicIn.File);
|
||||||
sprintf(temp2, "%s/%s", CFG.ticout, TIC.RealName);
|
sprintf(temp2, "%s/%s", CFG.ticout, TIC.TicIn.File);
|
||||||
if ((rc = file_cp(temp1, temp2) == 0)) {
|
if ((rc = file_cp(temp1, temp2) == 0)) {
|
||||||
TIC.SendOrg = TRUE;
|
TIC.SendOrg = TRUE;
|
||||||
} else {
|
} else {
|
||||||
@ -464,7 +464,7 @@ int ProcessTic(fa_list *sbl)
|
|||||||
if (!unlink(temp1))
|
if (!unlink(temp1))
|
||||||
Syslog('+', "Removed stale %s", 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");
|
Bad((char *)"Not enough free diskspace left");
|
||||||
free(Temp);
|
free(Temp);
|
||||||
tidy_qualify(&qal);
|
tidy_qualify(&qal);
|
||||||
@ -491,7 +491,7 @@ int ProcessTic(fa_list *sbl)
|
|||||||
if ((cmd == NULL) || (cmd == "")) {
|
if ((cmd == NULL) || (cmd == "")) {
|
||||||
Syslog('!', "No unarc command available");
|
Syslog('!', "No unarc command available");
|
||||||
} else {
|
} 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) {
|
if (execute(cmd, temp1, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
|
||||||
sync();
|
sync();
|
||||||
UnPacked = TRUE;
|
UnPacked = TRUE;
|
||||||
@ -512,8 +512,8 @@ int ProcessTic(fa_list *sbl)
|
|||||||
* whatever that is. This should catch single files
|
* whatever that is. This should catch single files
|
||||||
* with worms or other macro viri
|
* with worms or other macro viri
|
||||||
*/
|
*/
|
||||||
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.RealName);
|
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.TicIn.File);
|
||||||
sprintf(temp2, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), TIC.RealName);
|
sprintf(temp2, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), TIC.TicIn.File);
|
||||||
|
|
||||||
if ((rc = file_cp(temp1, temp2))) {
|
if ((rc = file_cp(temp1, temp2))) {
|
||||||
WriteError("Can't copy %s to %s: %s", temp1, temp2, strerror(rc));
|
WriteError("Can't copy %s to %s: %s", temp1, temp2, strerror(rc));
|
||||||
@ -577,12 +577,12 @@ int ProcessTic(fa_list *sbl)
|
|||||||
} else {
|
} else {
|
||||||
sprintf(temp1, "%s/tmp", getenv("MBSE_ROOT"));
|
sprintf(temp1, "%s/tmp", getenv("MBSE_ROOT"));
|
||||||
chdir(temp1);
|
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) {
|
if (execute(cmd, temp1, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
|
||||||
sync();
|
sync();
|
||||||
File_Id = TRUE;
|
File_Id = TRUE;
|
||||||
} else {
|
} 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) {
|
if (execute(cmd, temp1, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
|
||||||
sync();
|
sync();
|
||||||
File_Id = TRUE;
|
File_Id = TRUE;
|
||||||
@ -639,16 +639,15 @@ int ProcessTic(fa_list *sbl)
|
|||||||
}
|
}
|
||||||
} /* not get FILE_ID.DIZ */
|
} /* not get FILE_ID.DIZ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Rearc file if it is an unpacked archive.
|
||||||
|
*/
|
||||||
if ((MustRearc) && (UnPacked) && (tic.FileArea)) {
|
if ((MustRearc) && (UnPacked) && (tic.FileArea)) {
|
||||||
if (Rearc(tic.Convert)) {
|
if (Rearc(tic.Convert)) {
|
||||||
if (strlen(tic.Banner)) {
|
|
||||||
Syslog('f', "Must replace banner 1");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get new filesize for import and announce
|
* 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);
|
TIC.FileSize = file_size(temp1);
|
||||||
T_File.Size = TIC.FileSize;
|
T_File.Size = TIC.FileSize;
|
||||||
T_File.SizeKb = TIC.FileSize / 1024;
|
T_File.SizeKb = TIC.FileSize / 1024;
|
||||||
@ -661,32 +660,31 @@ int ProcessTic(fa_list *sbl)
|
|||||||
} else {
|
} else {
|
||||||
WriteError("Rearc failed");
|
WriteError("Rearc failed");
|
||||||
} /* if Rearc() */
|
} /* 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) {
|
if ((strlen(tic.Banner)) && IsArchive) {
|
||||||
cmd = xstrcpy(archiver.barc);
|
cmd = xstrcpy(archiver.barc);
|
||||||
if ((cmd == NULL) || (!strlen(cmd))) {
|
if ((cmd == NULL) || (!strlen(cmd))) {
|
||||||
Syslog('!', "No banner command for %s", archiver.name);
|
Syslog('!', "No banner command for %s", archiver.name);
|
||||||
|
} else {
|
||||||
|
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");
|
||||||
} else {
|
} else {
|
||||||
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.RealName);
|
sync();
|
||||||
sprintf(Temp, "%s/etc/%s", getenv("MBSE_ROOT"), tic.Banner);
|
Syslog('+', "New banner %s", tic.Banner);
|
||||||
if (execute(cmd, temp1, (char *)NULL, Temp, (char *)"/dev/null", (char *)"/dev/null")) {
|
TIC.FileSize = file_size(temp1);
|
||||||
WriteError("$Changing the banner failed");
|
T_File.Size = TIC.FileSize;
|
||||||
} else {
|
T_File.SizeKb = TIC.FileSize / 1024;
|
||||||
sync();
|
ReCalcCrc(temp1);
|
||||||
Syslog('+', "New banner %s", tic.Banner);
|
DidBanner = TRUE;
|
||||||
TIC.FileSize = file_size(temp1);
|
|
||||||
T_File.Size = TIC.FileSize;
|
|
||||||
T_File.SizeKb = TIC.FileSize / 1024;
|
|
||||||
ReCalcCrc(temp1);
|
|
||||||
DidBanner = TRUE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} /* if MustRearc and Unpacked and not Passthtru */
|
}
|
||||||
|
|
||||||
DeleteVirusWork();
|
DeleteVirusWork();
|
||||||
chdir(TIC.Inbound);
|
chdir(TIC.Inbound);
|
||||||
@ -695,7 +693,7 @@ int ProcessTic(fa_list *sbl)
|
|||||||
* If the file is converted, we set the date of the original
|
* If the file is converted, we set the date of the original
|
||||||
* received file as the file creation date.
|
* 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 ((MustRearc || DidBanner) && CFG.ct_KeepDate) {
|
||||||
if ((tic.Touch) && (tic.FileArea)) {
|
if ((tic.Touch) && (tic.FileArea)) {
|
||||||
ut.actime = mktime(localtime(&TIC.FileDate));
|
ut.actime = mktime(localtime(&TIC.FileDate));
|
||||||
@ -715,7 +713,7 @@ int ProcessTic(fa_list *sbl)
|
|||||||
*/
|
*/
|
||||||
if (tic.FileArea) {
|
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();
|
BBS_Imp = Add_BBS();
|
||||||
|
|
||||||
if (!BBS_Imp) {
|
if (!BBS_Imp) {
|
||||||
@ -726,25 +724,32 @@ int ProcessTic(fa_list *sbl)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Syslog('f', "Import is done");
|
||||||
chdir(TIC.Inbound);
|
chdir(TIC.Inbound);
|
||||||
|
Syslog('f', "Back in inbound");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create file announce record
|
||||||
|
*/
|
||||||
if (tic.FileArea) {
|
if (tic.FileArea) {
|
||||||
|
Syslog('f', "Start magic check");
|
||||||
if (strlen(TIC.TicIn.Magic))
|
if (strlen(TIC.TicIn.Magic))
|
||||||
UpDateAlias(TIC.TicIn.Magic);
|
UpDateAlias(TIC.TicIn.Magic);
|
||||||
else
|
else
|
||||||
Magic_UpDateAlias();
|
Magic_UpDateAlias();
|
||||||
|
|
||||||
|
Syslog('f', "done");
|
||||||
for (i = 0; i <= TIC.File_Id_Ct; i++)
|
for (i = 0; i <= TIC.File_Id_Ct; i++)
|
||||||
strncpy(T_File.LDesc[i], TIC.File_Id[i], 48);
|
strncpy(T_File.LDesc[i], TIC.File_Id[i], 48);
|
||||||
T_File.TotLdesc = TIC.File_Id_Ct;
|
T_File.TotLdesc = TIC.File_Id_Ct;
|
||||||
T_File.Announce = tic.Announce;
|
T_File.Announce = tic.Announce;
|
||||||
sprintf(Temp, "%s", TIC.NewName);
|
strncpy(T_File.Name, TIC.NewFile, 12);
|
||||||
name_mangle(Temp);
|
strncpy(T_File.LName, TIC.NewFullName, 80);
|
||||||
strncpy(T_File.Name, Temp, 12);
|
|
||||||
strncpy(T_File.LName, TIC.NewName, 80);
|
|
||||||
T_File.Fdate = TIC.FileDate;
|
T_File.Fdate = TIC.FileDate;
|
||||||
T_File.Cost = TIC.TicIn.Cost;
|
T_File.Cost = TIC.TicIn.Cost;
|
||||||
|
Syslog('f', "Toberep record filled");
|
||||||
Add_ToBeRep();
|
Add_ToBeRep();
|
||||||
|
Syslog('f', "Added");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TIC.SendOrg && !tic.FileArea) {
|
if (TIC.SendOrg && !tic.FileArea) {
|
||||||
@ -753,11 +758,12 @@ int ProcessTic(fa_list *sbl)
|
|||||||
* file in the inbound anymore so it can be
|
* file in the inbound anymore so it can be
|
||||||
* deleted.
|
* deleted.
|
||||||
*/
|
*/
|
||||||
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.RealName);
|
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.TicIn.File);
|
||||||
if (file_rm(temp1) == 0)
|
if (file_rm(temp1) == 0)
|
||||||
Syslog('f', "Deleted %s", temp1);
|
Syslog('f', "Deleted %s", temp1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Syslog('f', "Prepare forward");
|
||||||
if (DownLinks) {
|
if (DownLinks) {
|
||||||
First = TRUE;
|
First = TRUE;
|
||||||
|
|
||||||
@ -775,9 +781,10 @@ int ProcessTic(fa_list *sbl)
|
|||||||
tidy_faddr(p_from);
|
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) {
|
for (tmpq = qal; tmpq; tmpq = tmpq->next) {
|
||||||
if (tmpq->send) {
|
if (tmpq->send) {
|
||||||
@ -790,6 +797,7 @@ int ProcessTic(fa_list *sbl)
|
|||||||
}
|
}
|
||||||
uniq_list(&sbl);
|
uniq_list(&sbl);
|
||||||
sort_list(&sbl);
|
sort_list(&sbl);
|
||||||
|
Syslog('f', "More added");
|
||||||
|
|
||||||
for (tmp = sbl; tmp; tmp = tmp->next)
|
for (tmp = sbl; tmp; tmp = tmp->next)
|
||||||
Syslog('f', "final SB list %s", ascfnode(tmp->addr, 0x0f));
|
Syslog('f', "final SB list %s", ascfnode(tmp->addr, 0x0f));
|
||||||
|
40
mbfido/tic.c
40
mbfido/tic.c
@ -165,13 +165,14 @@ int Tic()
|
|||||||
int LoadTic(char *inb, char *tfn)
|
int LoadTic(char *inb, char *tfn)
|
||||||
{
|
{
|
||||||
FILE *tfp;
|
FILE *tfp;
|
||||||
char *Temp, *Temp2, *Buf, *Log = NULL;
|
char *Temp, *Temp2, *Buf, *Log = NULL, RealName[256];
|
||||||
int i, j, rc, bufsize, DescCnt = FALSE;
|
int i, j, rc, bufsize, DescCnt = FALSE;
|
||||||
fa_list *sbl = NULL;
|
fa_list *sbl = NULL;
|
||||||
|
|
||||||
if (CFG.slow_util && do_quiet)
|
if (CFG.slow_util && do_quiet)
|
||||||
usleep(1);
|
usleep(1);
|
||||||
|
|
||||||
|
memset(&RealName, 0, sizeof(RealName));
|
||||||
memset(&TIC, 0, sizeof(TIC));
|
memset(&TIC, 0, sizeof(TIC));
|
||||||
memset(&T_File, 0, sizeof(T_File));
|
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);
|
sprintf(Temp, "%s/%s", TIC.TicIn.Pth, TIC.TicIn.FullName);
|
||||||
if (file_exist(Temp, R_OK) == 0) {
|
if (file_exist(Temp, R_OK) == 0) {
|
||||||
strcpy(TIC.RealName, TIC.TicIn.FullName);
|
strcpy(RealName, TIC.TicIn.FullName);
|
||||||
} else {
|
} else {
|
||||||
WriteError("Can't find %s", Temp);
|
WriteError("Can't find %s", Temp);
|
||||||
tidy_falist(&sbl);
|
tidy_falist(&sbl);
|
||||||
@ -425,17 +426,17 @@ int LoadTic(char *inb, char *tfn)
|
|||||||
sprintf(Temp2, "%s", TIC.TicIn.File);
|
sprintf(Temp2, "%s", TIC.TicIn.File);
|
||||||
sprintf(Temp, "%s/%s", TIC.Inbound, Temp2);
|
sprintf(Temp, "%s/%s", TIC.Inbound, Temp2);
|
||||||
if (file_exist(Temp, R_OK) == 0) {
|
if (file_exist(Temp, R_OK) == 0) {
|
||||||
strcpy(TIC.RealName, Temp2);
|
strcpy(RealName, Temp2);
|
||||||
} else {
|
} else {
|
||||||
tu(Temp2);
|
tu(Temp2);
|
||||||
sprintf(Temp, "%s/%s", TIC.Inbound, Temp2);
|
sprintf(Temp, "%s/%s", TIC.Inbound, Temp2);
|
||||||
if (file_exist(Temp, R_OK) == 0) {
|
if (file_exist(Temp, R_OK) == 0) {
|
||||||
strcpy(TIC.RealName, Temp2);
|
strcpy(RealName, Temp2);
|
||||||
} else {
|
} else {
|
||||||
tl(Temp2);
|
tl(Temp2);
|
||||||
sprintf(Temp, "%s/%s", TIC.Inbound, Temp2);
|
sprintf(Temp, "%s/%s", TIC.Inbound, Temp2);
|
||||||
if (file_exist(Temp, R_OK) == 0) {
|
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
|
* If the above didn't find the file and we got a LFN
|
||||||
* the search again.
|
* 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(Temp2, "%s", TIC.TicIn.FullName);
|
||||||
sprintf(Temp, "%s/%s", TIC.Inbound, Temp2);
|
sprintf(Temp, "%s/%s", TIC.Inbound, Temp2);
|
||||||
if (file_exist(Temp, R_OK) == 0) {
|
if (file_exist(Temp, R_OK) == 0) {
|
||||||
strcpy(TIC.RealName, Temp2);
|
strcpy(RealName, Temp2);
|
||||||
} else {
|
} else {
|
||||||
tu(Temp2);
|
tu(Temp2);
|
||||||
sprintf(Temp, "%s/%s", TIC.Inbound, Temp2);
|
sprintf(Temp, "%s/%s", TIC.Inbound, Temp2);
|
||||||
if (file_exist(Temp, R_OK) == 0) {
|
if (file_exist(Temp, R_OK) == 0) {
|
||||||
strcpy(TIC.RealName, Temp2);
|
strcpy(RealName, Temp2);
|
||||||
} else {
|
} else {
|
||||||
tl(Temp2);
|
tl(Temp2);
|
||||||
sprintf(Temp, "%s/%s", TIC.Inbound, Temp2);
|
sprintf(Temp, "%s/%s", TIC.Inbound, Temp2);
|
||||||
if (file_exist(Temp, R_OK) == 0) {
|
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
|
* We leave RealName empty, the ProcessTic function
|
||||||
* will handle this orphaned tic file.
|
* will handle this orphaned tic file.
|
||||||
*/
|
*/
|
||||||
|
TIC.Orphaned = TRUE;
|
||||||
WriteError("Can't find file in inbound");
|
WriteError("Can't find file in inbound");
|
||||||
} else {
|
} 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);
|
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(Temp2);
|
||||||
free(Temp);
|
free(Temp);
|
||||||
|
@ -39,8 +39,8 @@ typedef struct _TICrec {
|
|||||||
Tic_in TicIn; /* Original TIC record */
|
Tic_in TicIn; /* Original TIC record */
|
||||||
fidoaddr OrgAka; /* Origin address */
|
fidoaddr OrgAka; /* Origin address */
|
||||||
fidoaddr Aka; /* An address ? */
|
fidoaddr Aka; /* An address ? */
|
||||||
char NewName[81]; /* New name of file */
|
char NewFile[81]; /* New 8.3 filename */
|
||||||
char RealName[81]; /* Real name on disk */
|
char NewFullName[256]; /* New LFN name */
|
||||||
char File_Id[25][49]; /* Description */
|
char File_Id[25][49]; /* Description */
|
||||||
int File_Id_Ct; /* Nr of lines */
|
int File_Id_Ct; /* Nr of lines */
|
||||||
unsigned long Crc_Int; /* Crc value */
|
unsigned long Crc_Int; /* Crc value */
|
||||||
@ -52,6 +52,7 @@ typedef struct _TICrec {
|
|||||||
unsigned Charge : 1; /* Charge for this file */
|
unsigned Charge : 1; /* Charge for this file */
|
||||||
unsigned PassThru : 1; /* PassThru file */
|
unsigned PassThru : 1; /* PassThru file */
|
||||||
unsigned NewAlias : 1; /* New alias is set */
|
unsigned NewAlias : 1; /* New alias is set */
|
||||||
|
unsigned Orphaned : 1; /* File is Orphaned */
|
||||||
long FileCost; /* Cost for this file */
|
long FileCost; /* Cost for this file */
|
||||||
char BBSpath[PATH_MAX]; /* Path to import in */
|
char BBSpath[PATH_MAX]; /* Path to import in */
|
||||||
char BBSdesc[55]; /* Area description */
|
char BBSdesc[55]; /* Area description */
|
||||||
|
179
mbfido/utic.c
179
mbfido/utic.c
@ -48,14 +48,14 @@ extern int do_quiet;
|
|||||||
|
|
||||||
char *MakeTicName()
|
char *MakeTicName()
|
||||||
{
|
{
|
||||||
static char buf[13];
|
static char buf[13];
|
||||||
|
|
||||||
buf[12] = '\0';
|
buf[12] = '\0';
|
||||||
sprintf(buf, "%08lx.tic", sequencer());
|
sprintf(buf, "%08lx.tic", sequencer());
|
||||||
buf[0] = 'm';
|
buf[0] = 'm';
|
||||||
buf[1] = 'b';
|
buf[1] = 'b';
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -65,13 +65,13 @@ char *MakeTicName()
|
|||||||
*/
|
*/
|
||||||
int Day_Of_Year()
|
int Day_Of_Year()
|
||||||
{
|
{
|
||||||
time_t Now;
|
time_t Now;
|
||||||
struct tm *Tm;
|
struct tm *Tm;
|
||||||
|
|
||||||
Now = time(NULL);
|
Now = time(NULL);
|
||||||
Tm = localtime(&Now);
|
Tm = localtime(&Now);
|
||||||
|
|
||||||
return Tm->tm_yday;
|
return Tm->tm_yday;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -81,93 +81,106 @@ int Day_Of_Year()
|
|||||||
*/
|
*/
|
||||||
int Rearc(char *unarc)
|
int Rearc(char *unarc)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i = 0, j = 0, k = 0;
|
||||||
char temp[PATH_MAX], *cmd = NULL;
|
char temp[PATH_MAX], *cmd = NULL;
|
||||||
|
|
||||||
Syslog('f', "Entering Rearc(%s)", unarc);
|
Syslog('f', "Entering Rearc(%s)", unarc);
|
||||||
|
|
||||||
i = 0;
|
if (!getarchiver(unarc)) {
|
||||||
while (TIC.NewName[i] != '.')
|
return FALSE;
|
||||||
i++;
|
}
|
||||||
|
cmd = xstrcpy(archiver.farc);
|
||||||
|
if (cmd == NULL) {
|
||||||
|
WriteError("Rearc(): No arc command available");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (TIC.NewFile[i] != '.')
|
||||||
i++;
|
i++;
|
||||||
|
i++;
|
||||||
|
|
||||||
j = 0;
|
while (TIC.NewFullName[k] != '.')
|
||||||
for (; i < strlen(TIC.NewName); i++) {
|
k++;
|
||||||
if (TIC.NewName[i] > '9')
|
k++;
|
||||||
TIC.NewName[i] = tolower(unarc[j]);
|
|
||||||
j++;
|
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' , "NewName = \"%s\"", TIC.NewName);
|
Syslog('f' , "NewFile=\"%s\", NewFullName=\"%s\"", TIC.NewFile, TIC.NewFullName);
|
||||||
|
|
||||||
if (!getarchiver(unarc)) {
|
sprintf(temp, "%s/%s .", TIC.Inbound, TIC.NewFile);
|
||||||
return FALSE;
|
if (execute(cmd, temp, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
|
||||||
}
|
|
||||||
|
|
||||||
cmd = xstrcpy(archiver.farc);
|
|
||||||
|
|
||||||
if (cmd == NULL) {
|
|
||||||
WriteError("Rearc(): No arc command available");
|
|
||||||
return FALSE;
|
|
||||||
} else {
|
|
||||||
sprintf(temp, "%s/%s .", TIC.Inbound, TIC.NewName);
|
|
||||||
if (execute(cmd, temp, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
|
|
||||||
/* MUST SET TIC.FileDate to NEW ARCHIVE */
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
WriteError("Rearc(%s) Failed", unarc);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
free(cmd);
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void DeleteVirusWork()
|
void DeleteVirusWork()
|
||||||
{
|
{
|
||||||
char *buf, *temp;
|
char *buf, *temp;
|
||||||
|
|
||||||
buf = calloc(PATH_MAX, sizeof(char));
|
buf = calloc(PATH_MAX, sizeof(char));
|
||||||
temp = calloc(PATH_MAX, sizeof(char));
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
getcwd(buf, PATH_MAX);
|
getcwd(buf, PATH_MAX);
|
||||||
sprintf(temp, "%s/tmp", getenv("MBSE_ROOT"));
|
sprintf(temp, "%s/tmp", getenv("MBSE_ROOT"));
|
||||||
|
|
||||||
if (chdir(temp) == 0) {
|
if (chdir(temp) == 0) {
|
||||||
Syslog('f', "DeleteVirusWork %s/arc", temp);
|
Syslog('f', "DeleteVirusWork %s/arc", temp);
|
||||||
system("rm -r -f arc");
|
system("rm -r -f arc");
|
||||||
system("mkdir arc");
|
system("mkdir arc");
|
||||||
} else
|
} else
|
||||||
WriteError("$Can't chdir to %s", temp);
|
WriteError("$Can't chdir to %s", temp);
|
||||||
|
|
||||||
chdir(buf);
|
chdir(buf);
|
||||||
free(temp);
|
free(temp);
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Bad(char *format, ...)
|
void Bad(char *format, ...)
|
||||||
{
|
{
|
||||||
char outstr[1024];
|
char outstr[1024];
|
||||||
va_list va_ptr;
|
va_list va_ptr;
|
||||||
|
|
||||||
va_start(va_ptr, format);
|
va_start(va_ptr, format);
|
||||||
vsprintf(outstr, format, va_ptr);
|
vsprintf(outstr, format, va_ptr);
|
||||||
va_end(va_ptr);
|
va_end(va_ptr);
|
||||||
|
|
||||||
WriteError(outstr);
|
WriteError(outstr);
|
||||||
MoveBad();
|
MoveBad();
|
||||||
tic_bad++;
|
tic_bad++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ReCalcCrc(char *fn)
|
void ReCalcCrc(char *fn)
|
||||||
{
|
{
|
||||||
TIC.Crc_Int = file_crc(fn, CFG.slow_util && do_quiet);
|
TIC.Crc_Int = file_crc(fn, CFG.slow_util && do_quiet);
|
||||||
sprintf(TIC.TicIn.Crc, "%08lX", TIC.Crc_Int);
|
sprintf(TIC.TicIn.Crc, "%08lX", TIC.Crc_Int);
|
||||||
strcpy(T_File.Crc, TIC.TicIn.Crc);
|
strcpy(T_File.Crc, TIC.TicIn.Crc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -253,27 +266,29 @@ int Get_File_Id()
|
|||||||
|
|
||||||
void UpDateAlias(char *Alias)
|
void UpDateAlias(char *Alias)
|
||||||
{
|
{
|
||||||
char *path;
|
char *path;
|
||||||
FILE *fp;
|
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)) {
|
if (!strlen(CFG.req_magic)) {
|
||||||
WriteError("No magic filename path configured");
|
WriteError("No magic filename path configured");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
path = xstrcpy(CFG.req_magic);
|
path = xstrcpy(CFG.req_magic);
|
||||||
path = xstrcat(path, (char *)"/");
|
path = xstrcat(path, (char *)"/");
|
||||||
path = xstrcat(path, Alias);
|
path = xstrcat(path, Alias);
|
||||||
|
|
||||||
if ((fp = fopen(path, "w")) == NULL) {
|
if ((fp = fopen(path, "w")) == NULL) {
|
||||||
WriteError("$Can't create %s", path);
|
WriteError("$Can't create %s", path);
|
||||||
return;
|
|
||||||
}
|
|
||||||
fprintf(fp, "%s\n", TIC.NewName);
|
|
||||||
fclose(fp);
|
|
||||||
free(path);
|
free(path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(fp, "%s\n", TIC.NewFile);
|
||||||
|
fclose(fp);
|
||||||
|
free(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user