Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 18260b07 authored by rswindell's avatar rswindell

Cleaned-up the checking of external protocol result/dsz.log stuff.

parent 7e4ecd12
......@@ -662,13 +662,8 @@ void sbbs_t::batch_download(int xfrprot)
strcpy(f.name,batdn_name[i]);
f.datoffset=batdn_offset[i];
f.size=batdn_size[i];
/* Removed 05/18/95
if(cfg.dir[f.dir]->misc&DIR_TFREE && cur_cps) Looks like it gave back double
starttime+=f.size/(ulong)cur_cps;
*/
f.altpath=batdn_alt[i];
if(xfrprot==-1 || (cfg.prot[xfrprot]->misc&PROT_DSZLOG && checkprotlog(&f))
|| !(cfg.prot[xfrprot]->misc&PROT_DSZLOG)) {
if(xfrprot==-1 || checkprotresult(cfg.prot[xfrprot],0,&f)) {
if(cfg.dir[f.dir]->misc&DIR_TFREE && cur_cps)
starttime+=f.size/(ulong)cur_cps;
downloadfile(&f);
......
......@@ -292,24 +292,61 @@ void sbbs_t::autohangup()
CRLF;
}
bool sbbs_t::checkdszlog(file_t* f)
{
char* p;
char path[MAX_PATH+1];
char str[512];
char fname[128];
FILE* fp;
sprintf(path,"%sPROTOCOL.LOG",cfg.node_dir);
if((fp=fopen(path,"r"))==NULL)
return(false);
unpadfname(f->name,fname);
p=lastchar(fname);
if(*p=='.') /* DSZ log uses FILE instead of FILE. */
*p=0; /* when there isn't an extension. */
strupr(fname);
while(!ferror(fp)) {
if(!fgets(str,sizeof(str),fp))
break;
truncstr(str,"\r\n"); /* chop off CRLF */
strupr(str);
if(strstr(str,fname)) { /* Only check for name, Bimodem doesn't put path */
if(str[0]=='E' || str[0]=='L' || (str[6]==' ' && str[7]=='0'))
break; /* E for Error or L for Lost Carrier */
fclose(fp); /* or only sent 0 bytes! */
return(true);
}
}
fclose(fp);
return(false);
}
/****************************************************************************/
/* Checks dsz compatible log file for errors in transfer */
/* Returns 1 if the file in the struct file_t was successfuly transfered */
/****************************************************************************/
bool sbbs_t::checkprotlog(file_t* f)
bool sbbs_t::checkprotresult(prot_t* prot, int error, file_t* f)
{
char str[256],size[128];
char tmp[512];
int file;
FILE * stream;
char str[512];
char tmp[128];
bool success;
if(prot->misc&PROT_DSZLOG)
success=checkdszlog(f);
else
success=(error==0);
sprintf(str,"%sPROTOCOL.LOG",cfg.node_dir);
if((stream=fnopen(&file,str,O_RDONLY))==NULL) {
if(!success) {
bprintf(text[FileNotSent],f->name);
if(f->dir<cfg.total_dirs)
sprintf(str,"%s attempted to download %s (%s) from %s %s"
,useron.alias
,f->name,ultoac(f->size,size)
,f->name,ultoac(f->size,tmp)
,cfg.lib[cfg.dir[f->dir]->lib]->sname,cfg.dir[f->dir]->sname);
else if(f->dir==cfg.total_dirs)
sprintf(str,"%s attempted to download QWK packet"
......@@ -318,39 +355,9 @@ bool sbbs_t::checkprotlog(file_t* f)
sprintf(str,"%s attempted to download attached file: %s"
,useron.alias,f->name);
logline("D!",str);
return(0);
}
unpadfname(f->name,tmp);
if(tmp[strlen(tmp)-1]=='.') /* DSZ log uses FILE instead of FILE. */
tmp[strlen(tmp)-1]=0; /* when there isn't an extension. */
strupr(tmp);
while(!ferror(stream)) {
if(!fgets(str,256,stream))
break;
if(str[strlen(str)-2]==CR)
str[strlen(str)-2]=0; /* chop off CRLF */
strupr(str);
if(strstr(str,tmp)) { /* Only check for name, Bimodem doesn't put path */
// logline(nulstr,str); now handled by protocol()
if(str[0]=='E' || str[0]=='L' || (str[6]==SP && str[7]=='0'))
break; /* E for Error or L for Lost Carrier */
fclose(stream); /* or only sent 0 bytes! */
return(true);
}
return(false);
}
fclose(stream);
bprintf(text[FileNotSent],f->name);
if(f->dir<cfg.total_dirs)
sprintf(str,"%s attempted to download %s (%s) from %s %s"
,useron.alias
,f->name
,ultoac(f->size,tmp)
,cfg.lib[cfg.dir[f->dir]->lib]->sname
,cfg.dir[f->dir]->sname);
else
sprintf(str,"%s attempted to download QWK packet",useron.alias);
logline("D!",str);
return(false);
return(true);
}
......
......@@ -1295,19 +1295,15 @@ int sbbs_t::listfileinfo(uint dirnum, char *filespec, long mode)
end=time(NULL);
if(cfg.dir[f.dir]->misc&DIR_TFREE)
starttime+=end-start;
if(cfg.prot[i]->misc&PROT_DSZLOG) {
if(checkprotlog(&f))
downloadfile(&f);
else
notdownloaded(f.size,start,end); }
else {
if(!error)
downloadfile(&f);
else {
bprintf(text[FileNotSent],f.name);
notdownloaded(f.size,start,end); } }
if(checkprotresult(cfg.prot[i],error,&f))
downloadfile(&f);
else
notdownloaded(f.size,start,end);
delfiles(cfg.temp_dir,ALLFILES);
autohangup(); } } }
autohangup();
}
}
}
closefile(&f); }
if(filespec[0] && !strchr(filespec,'*') && !strchr(filespec,'?'))
break;
......
......@@ -388,8 +388,7 @@ void sbbs_t::qwk_success(ulong msgcnt, char bi, char prepack)
/****************************************************************************/
void sbbs_t::qwk_sec()
{
char str[256],tmp2[256],ch,bi=0
,*AttemptedToDownloadQWKpacket="Attempted to download QWK packet";
char str[256],tmp2[256],ch,bi=0;
char tmp[512];
int error;
int s;
......@@ -599,25 +598,16 @@ void sbbs_t::qwk_sec()
sprintf(tmp2,"%sBATCHUP.LST",cfg.node_dir);
error=protocol(cmdstr(cfg.prot[i]->bicmd,str,tmp2,NULL),true);
batdn_total=batup_total=0;
if(cfg.prot[i]->misc&PROT_DSZLOG) {
if(!checkprotlog(&fd)) {
logline("D!",AttemptedToDownloadQWKpacket);
last_ns_time=ns_time;
for(i=0;i<cfg.total_subs;i++)
subscan[i].ptr=sav_ptr[i]; } /* re-load saved pointers */
else {
qwk_success(msgcnt,1,0);
for(i=0;i<cfg.total_subs;i++)
sav_ptr[i]=subscan[i].ptr; } }
else if(error) {
logline("D!",AttemptedToDownloadQWKpacket);
if(!checkprotresult(cfg.prot[i],error,&fd)) {
last_ns_time=ns_time;
for(i=0;i<cfg.total_subs;i++)
subscan[i].ptr=sav_ptr[i]; }
subscan[i].ptr=sav_ptr[i]; /* re-load saved pointers */
}
else {
qwk_success(msgcnt,1,0);
for(i=0;i<cfg.total_subs;i++)
sav_ptr[i]=subscan[i].ptr; }
sav_ptr[i]=subscan[i].ptr;
}
sprintf(str,"%s%s.qwk",cfg.temp_dir,cfg.sys_id);
if(fexistcase(str))
remove(str);
......@@ -696,29 +686,23 @@ void sbbs_t::qwk_sec()
sprintf(tmp2,"%s.qwk",cfg.sys_id);
padfname(tmp2,fd.name);
error=protocol(cmdstr(cfg.prot[i]->dlcmd,str,nulstr,NULL),false);
if(cfg.prot[i]->misc&PROT_DSZLOG) {
if(!checkprotlog(&fd)) {
last_ns_time=ns_time;
for(i=0;i<cfg.total_subs;i++)
subscan[i].ptr=sav_ptr[i]; } /* re-load saved pointers */
else {
qwk_success(msgcnt,0,0);
for(i=0;i<cfg.total_subs;i++)
sav_ptr[i]=subscan[i].ptr; } }
else if(error) {
logline("D!",AttemptedToDownloadQWKpacket);
if(!checkprotresult(cfg.prot[i],error,&fd)) {
last_ns_time=ns_time;
for(i=0;i<cfg.total_subs;i++)
subscan[i].ptr=sav_ptr[i]; }
else {
subscan[i].ptr=sav_ptr[i]; /* re-load saved pointers */
} else {
qwk_success(msgcnt,0,0);
for(i=0;i<cfg.total_subs;i++)
sav_ptr[i]=subscan[i].ptr; }
autohangup(); }
sav_ptr[i]=subscan[i].ptr;
}
autohangup();
}
else { /* if not valid protocol (hungup?) */
for(i=0;i<cfg.total_subs;i++)
subscan[i].ptr=sav_ptr[i];
last_ns_time=ns_time; } }
last_ns_time=ns_time;
}
}
else if(ch=='U') { /* Upload REP Packet */
/*
......
......@@ -269,29 +269,33 @@ void sbbs_t::readmail(uint usernumber, int which)
break;
if(i<cfg.total_prots) {
error=protocol(cmdstr(cfg.prot[i]->dlcmd,str2,nulstr,NULL),false);
if((cfg.prot[i]->misc&PROT_DSZLOG
&& checkprotlog(&fd))
|| (!(cfg.prot[i]->misc&PROT_DSZLOG) && !error)) {
if(which==MAIL_YOUR)
remove(str2);
logon_dlb+=length; /* Update stats */
logon_dls++;
useron.dls=(ushort)adjustuserrec(&cfg,useron.number
,U_DLS,5,1);
useron.dlb=adjustuserrec(&cfg,useron.number
,U_DLB,10,length);
bprintf(text[FileNBytesSent]
,fd.name,ultoac(length,tmp));
sprintf(str3
,"%s downloaded attached file: %s"
,useron.alias
,fd.name);
logline("D-",str3); }
autohangup(); } } } }
if(!p)
break;
tp=p+1;
while(*tp==SP) tp++; }
if(checkprotresult(cfg.prot[i],error,&fd)) {
if(which==MAIL_YOUR)
remove(str2);
logon_dlb+=length; /* Update stats */
logon_dls++;
useron.dls=(ushort)adjustuserrec(&cfg,useron.number
,U_DLS,5,1);
useron.dlb=adjustuserrec(&cfg,useron.number
,U_DLB,10,length);
bprintf(text[FileNBytesSent]
,fd.name,ultoac(length,tmp));
sprintf(str3
,"%s downloaded attached file: %s"
,useron.alias
,fd.name);
logline("D-",str3);
}
autohangup();
}
}
}
}
if(!p)
break;
tp=p+1;
while(*tp==SP) tp++;
}
sprintf(str,"%sfile/%04u.in",cfg.data_dir,usernumber);
rmdir(str); }
if(which==MAIL_YOUR && !(msg.hdr.attr&MSG_READ)) {
......
......@@ -592,7 +592,8 @@ public:
int protocol(char *cmdline, bool cd);
void seqwait(uint devnum);
void autohangup(void);
bool checkprotlog(file_t* f);
bool checkdszlog(file_t*);
bool checkprotresult(prot_t*, int error, file_t*);
/* file.cpp */
void fileinfo(file_t* f);
......
......@@ -180,18 +180,12 @@ void sbbs_t::temp_xfer()
end=time(NULL);
if(cfg.dir[temp_dirnum]->misc&DIR_TFREE)
starttime+=end-start;
if(cfg.prot[i]->misc&PROT_DSZLOG) {
if(checkprotlog(&f))
downloadfile(&f);
else
notdownloaded(f.size,start,end); }
else {
if(!error)
downloadfile(&f);
else {
bprintf(text[FileNotSent],f.name);
notdownloaded(f.size,start,end); } }
autohangup(); }
if(checkprotresult(cfg.prot[i],error,&f))
downloadfile(&f);
else
notdownloaded(f.size,start,end);
autohangup();
}
removefiledat(&cfg,&f);
break;
case 'E':
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment