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 57a6b425 authored by rswindell's avatar rswindell

Simplified the use of sbbs_t::protocol (handles selecting correct command-line

etc).
parent 9916db01
......@@ -167,7 +167,7 @@ void sbbs_t::batchmenu()
sprintf(str,"%sBATCHDN.LST",cfg.node_dir);
sprintf(tmp2,"%sBATCHUP.LST",cfg.node_dir);
start=time(NULL);
protocol(xfrprot,cmdstr(cfg.prot[xfrprot]->bicmd,str,tmp2,NULL),true);
protocol(cfg.prot[xfrprot],XFER_BIDIR,str,tmp2,true);
end=time(NULL);
for(i=0;i<batdn_total;i++)
if(cfg.dir[batdn_dir[i]]->seqdev) {
......@@ -310,7 +310,7 @@ void sbbs_t::batchmenu()
if(online==ON_REMOTE) {
delfiles(cfg.temp_dir,ALLFILES);
start=time(NULL);
protocol(xfrprot,cmdstr(cfg.prot[xfrprot]->batulcmd,str,nulstr,NULL),true);
protocol(cfg.prot[xfrprot],XFER_BATCH_UPLOAD,str,nulstr,true);
end=time(NULL);
if(!(cfg.dir[xfrdir]->misc&DIR_ULTIME))
starttime+=end-start;
......@@ -461,7 +461,7 @@ BOOL sbbs_t::start_batch_download()
putnodedat(cfg.node_num,&thisnode); /* calculate ETA */
}
start=time(NULL);
error=protocol(xfrprot,cmdstr(cfg.prot[xfrprot]->batdlcmd,str,list,NULL),false);
error=protocol(cfg.prot[xfrprot],XFER_BATCH_DOWNLOAD,str,list,false);
end=time(NULL);
if(cfg.prot[xfrprot]->misc&PROT_DSZLOG || !error)
batch_download(xfrprot);
......
......@@ -172,13 +172,32 @@ void sbbs_t::notdownloaded(ulong size, time_t start, time_t end)
}
}
char* sbbs_t::protcmdline(prot_t* prot, enum XFER_TYPE type)
{
switch(type) {
case XFER_UPLOAD:
return(prot->ulcmd);
case XFER_DOWNLOAD:
return(prot->dlcmd);
case XFER_BATCH_UPLOAD:
return(prot->batulcmd);
case XFER_BATCH_DOWNLOAD:
return(prot->batdlcmd);
case XFER_BIDIR:
return(prot->bicmd);
}
return("invalid transfer type");
}
/****************************************************************************/
/* Handles start and stop routines for transfer protocols */
/****************************************************************************/
int sbbs_t::protocol(uint prot, char *cmdline, bool cd)
int sbbs_t::protocol(prot_t* prot, enum XFER_TYPE type
,char *fpath, char *fspec, bool cd)
{
char protlog[256],*p;
char* cmdline;
char msg[256];
int i;
long ex_mode;
......@@ -201,6 +220,7 @@ int sbbs_t::protocol(uint prot, char *cmdline, bool cd)
p=cfg.temp_dir;
else
p=NULL;
cmdline=cmdstr(protcmdline(prot,type),fpath,fspec,NULL);
sprintf(msg,"Transferring %s",cmdline);
spymsg(msg);
sys_status|=SS_FILEXFER; /* disable spy during file xfer */
......@@ -211,7 +231,7 @@ int sbbs_t::protocol(uint prot, char *cmdline, bool cd)
}
send_telnet_cmd(TELNET_WILL,TELNET_BINARY);
ex_mode=0;
if(cfg.prot[prot]->misc&PROT_NATIVE)
if(prot->misc&PROT_NATIVE)
ex_mode|=EX_NATIVE;
#ifdef __unix__ /* file xfer progs must use stdio on Unix */
ex_mode|=(EX_INR|EX_OUTR|EX_BIN);
......
......@@ -142,7 +142,7 @@ bool sbbs_t::email(int usernumber, char *top, char *subj, long mode)
&& chk_ar(cfg.prot[x]->ar,&useron))
break;
if(x<cfg.total_prots) /* This should be always */
protocol(x,cmdstr(cfg.prot[x]->ulcmd,str2,nulstr,NULL),true);
protocol(cfg.prot[x],XFER_UPLOAD,str2,nulstr,true);
}
sprintf(tmp,"%s%s",cfg.temp_dir,title);
if(!fexistcase(str2) && fexistcase(tmp))
......
......@@ -375,7 +375,7 @@ int sbbs_t::exec_function(csi_t *csi)
if(cfg.prot[i]->mnemonic==ch && chk_ar(cfg.prot[i]->ar,&useron))
break;
if(i<cfg.total_prots) {
if(protocol(i,cmdstr(cfg.prot[i]->dlcmd,csi->str,csi->str,str),false)==0)
if(protocol(cfg.prot[i],XFER_DOWNLOAD,csi->str,csi->str,false)==0)
csi->logic=LOGIC_TRUE;
autohangup();
}
......@@ -403,7 +403,7 @@ int sbbs_t::exec_function(csi_t *csi)
if(cfg.prot[i]->mnemonic==ch && chk_ar(cfg.prot[i]->ar,&useron))
break;
if(i<cfg.total_prots) {
if(protocol(i,cmdstr(cfg.prot[i]->ulcmd,csi->str,csi->str,str),true)==0)
if(protocol(cfg.prot[i],XFER_UPLOAD,csi->str,csi->str,true)==0)
csi->logic=LOGIC_TRUE;
autohangup();
}
......
......@@ -966,9 +966,8 @@ int sbbs_t::exec_misc(csi_t* csi, char *path)
break;
csi->logic=LOGIC_FALSE;
if(i<cfg.total_prots)
if(protocol(i,cmdstr(j==SEND_FILE_VIA
? cfg.prot[i]->dlcmd : cfg.prot[i]->ulcmd,str,str,buf)
,true)==0)
if(protocol(cfg.prot[i],j==SEND_FILE_VIA ? XFER_DOWNLOAD : XFER_UPLOAD
,str,str,true)==0)
csi->logic=LOGIC_TRUE;
return(0);
case SEND_FILE_VIA_VAR:
......@@ -984,9 +983,9 @@ int sbbs_t::exec_misc(csi_t* csi, char *path)
if(!pp || !(*pp))
return(0);
if(i<cfg.total_prots)
if(protocol(i,cmdstr(j==SEND_FILE_VIA_VAR
? cfg.prot[i]->dlcmd : cfg.prot[i]->ulcmd,*pp,*pp,buf)
,true)==0)
if(protocol(cfg.prot[i]
,j==SEND_FILE_VIA_VAR ? XFER_DOWNLOAD : XFER_UPLOAD
,*pp,*pp,true)==0)
csi->logic=LOGIC_TRUE;
return(0);
......
......@@ -252,7 +252,7 @@ bool sbbs_t::netmail(char *into, char *title, long mode)
&& chk_ar(cfg.prot[x]->ar,&useron))
break;
if(x<cfg.total_prots) /* This should be always */
protocol(x,cmdstr(cfg.prot[x]->ulcmd,subj,nulstr,NULL),true);
protocol(cfg.prot[x],XFER_UPLOAD,subj,nulstr,true);
}
sprintf(tmp,"%s%s",cfg.temp_dir,title);
if(!fexistcase(subj) && fexistcase(tmp))
......
......@@ -1291,7 +1291,7 @@ int sbbs_t::listfileinfo(uint dirnum, char *filespec, long mode)
thisnode.aux=(tm.tm_hour*60)+tm.tm_min;
putnodedat(cfg.node_num,&thisnode); /* calculate ETA */
start=time(NULL);
error=protocol(i,cmdstr(cfg.prot[i]->dlcmd,path,nulstr,NULL),false);
error=protocol(cfg.prot[i],XFER_DOWNLOAD,path,nulstr,false);
end=time(NULL);
if(cfg.dir[f.dir]->misc&DIR_TFREE)
starttime+=end-start;
......
......@@ -130,7 +130,7 @@ bool sbbs_t::inetmail(char *into, char *subj, long mode)
&& chk_ar(cfg.prot[x]->ar,&useron))
break;
if(x<cfg.total_prots) /* This should be always */
protocol(x,cmdstr(cfg.prot[x]->ulcmd,str2,nulstr,NULL),true);
protocol(cfg.prot[x],XFER_UPLOAD,str2,nulstr,true);
}
sprintf(tmp,"%s%s",cfg.temp_dir,title);
if(!fexistcase(str2) && fexistcase(tmp))
......
......@@ -596,7 +596,7 @@ void sbbs_t::qwk_sec()
padfname(tmp2,fd.name);
sprintf(str,"%sBATCHDN.LST",cfg.node_dir);
sprintf(tmp2,"%sBATCHUP.LST",cfg.node_dir);
error=protocol(i,cmdstr(cfg.prot[i]->bicmd,str,tmp2,NULL),true);
error=protocol(cfg.prot[i],XFER_BIDIR,str,tmp2,true);
batdn_total=batup_total=0;
if(!checkprotresult(cfg.prot[i],error,&fd)) {
last_ns_time=ns_time;
......@@ -685,7 +685,7 @@ void sbbs_t::qwk_sec()
sprintf(str,"%s%s.qwk",cfg.temp_dir,cfg.sys_id);
sprintf(tmp2,"%s.qwk",cfg.sys_id);
padfname(tmp2,fd.name);
error=protocol(i,cmdstr(cfg.prot[i]->dlcmd,str,nulstr,NULL),false);
error=protocol(cfg.prot[i],XFER_DOWNLOAD,str,nulstr,false);
if(!checkprotresult(cfg.prot[i],error,&fd)) {
last_ns_time=ns_time;
for(i=0;i<cfg.total_subs;i++)
......@@ -755,7 +755,7 @@ void sbbs_t::qwk_sec()
if(i>=cfg.total_prots) /* This shouldn't happen */
continue;
sprintf(str,"%s%s.rep",cfg.temp_dir,cfg.sys_id);
protocol(i,cmdstr(cfg.prot[i]->ulcmd,str,nulstr,NULL),true);
protocol(cfg.prot[i],XFER_UPLOAD,str,nulstr,true);
unpack_rep();
delfiles(cfg.temp_dir,ALLFILES);
//autohangup();
......
......@@ -268,7 +268,7 @@ void sbbs_t::readmail(uint usernumber, int which)
&& chk_ar(cfg.prot[i]->ar,&useron))
break;
if(i<cfg.total_prots) {
error=protocol(i,cmdstr(cfg.prot[i]->dlcmd,str2,nulstr,NULL),false);
error=protocol(cfg.prot[i],XFER_DOWNLOAD,str2,nulstr,false);
if(checkprotresult(cfg.prot[i],error,&fd)) {
if(which==MAIL_YOUR)
remove(str2);
......
......@@ -590,7 +590,8 @@ public:
/* download.cpp */
void downloadfile(file_t* f);
void notdownloaded(ulong size, time_t start, time_t end);
int protocol(uint prot, char *cmdline, bool cd);
int protocol(prot_t* prot, enum XFER_TYPE, char *fpath, char *fspec, bool cd);
char* protcmdline(prot_t* prot, enum XFER_TYPE type);
void seqwait(uint devnum);
void autohangup(void);
bool checkdszlog(file_t*);
......
......@@ -176,7 +176,7 @@ void sbbs_t::temp_xfer()
putnodedat(cfg.node_num,&thisnode); /* calculate ETA */
start=time(NULL);
error=protocol(i,cmdstr(cfg.prot[i]->dlcmd,str,nulstr,NULL),false);
error=protocol(cfg.prot[i],XFER_DOWNLOAD,str,nulstr,false);
end=time(NULL);
if(cfg.dir[temp_dirnum]->misc&DIR_TFREE)
starttime+=end-start;
......
......@@ -499,7 +499,7 @@ bool sbbs_t::upload(uint dirnum)
break;
if(i<cfg.total_prots) {
start=time(NULL);
protocol(i,cmdstr(cfg.prot[i]->ulcmd,str,nulstr,NULL),true);
protocol(cfg.prot[i],XFER_UPLOAD,str,nulstr,true);
end=time(NULL);
if(!(cfg.dir[dirnum]->misc&DIR_ULTIME)) /* Don't deduct upload time */
starttime+=end-start;
......
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