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

sbbs_t::sendfile() (used by JS bbs.send_file() and Baja FILE_SEND) would not

check the protocol.log (e.g. DSZ.LOG) for successful transfer even when the
protocol was so-configured in SCFG. Fixed.
Additionally, while sendfile() would return a proper boolean result based on
the errorlevel returned by the protocol driver process, the log and console
output would report success and statistics adjusted as though the xfer
was successful, regardless.
parent 13678f34
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2015 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -306,14 +306,12 @@ void sbbs_t::autohangup()
CRLF;
}
bool sbbs_t::checkdszlog(file_t* f)
bool sbbs_t::checkdszlog(const char* fpath)
{
char path[MAX_PATH+1];
char str[MAX_PATH+128];
char fname[MAX_PATH+1];
char rpath[MAX_PATH+1];
char str[MAX_PATH+128];
char* p;
char* rname;
char code;
ulong bytes;
FILE* fp;
......@@ -323,11 +321,8 @@ bool sbbs_t::checkdszlog(file_t* f)
if((fp=fopen(path,"r"))==NULL)
return(false);
unpadfname(f->name,fname);
getfilepath(&cfg,f,rpath);
fexistcase(rpath); /* incase of long filename */
rname=getfname(rpath);
SAFECOPY(rpath, fpath);
fexistcase(rpath);
while(!ferror(fp)) {
if(!fgets(str,sizeof(str),fp))
......@@ -358,7 +353,7 @@ bool sbbs_t::checkdszlog(file_t* f)
FIND_WHITESPACE(p); // Skip block size
SKIP_WHITESPACE(p);
p=getfname(p); /* DSZ stores fullpath, BiModem doesn't */
if(stricmp(p,fname)==0 || stricmp(p,rname)==0) {
if(stricmp(p, getfname(fpath))==0 || stricmp(p, getfname(rpath))==0) {
/* E for Error or L for Lost Carrier or s for Skipped */
/* or only sent 0 bytes! */
if(code!='E' && code!='L' && code!='s' && bytes!=0)
......@@ -380,9 +375,11 @@ bool sbbs_t::checkprotresult(prot_t* prot, int error, file_t* f)
char str[512];
char tmp[128];
bool success;
char fpath[MAX_PATH+1];
getfilepath(&cfg,f,fpath);
if(prot->misc&PROT_DSZLOG)
success=checkdszlog(f);
success=checkdszlog(fpath);
else
success=(error==0);
......@@ -455,7 +452,8 @@ bool sbbs_t::sendfile(char* fname, char prot, const char* desc)
char keys[128];
char ch;
size_t i;
bool result=false;
int error;
bool result;
if(prot > ' ')
ch=toupper(prot);
......@@ -475,9 +473,15 @@ bool sbbs_t::sendfile(char* fname, char prot, const char* desc)
for(i=0;i<cfg.total_prots;i++)
if(cfg.prot[i]->mnemonic==ch && chk_ar(cfg.prot[i]->ar,&useron,&client))
break;
if(i<cfg.total_prots) {
if(protocol(cfg.prot[i],XFER_DOWNLOAD,fname,fname,false)==0)
result=true;
if(i >= cfg.total_prots)
return false;
error = protocol(cfg.prot[i],XFER_DOWNLOAD,fname,fname,false);
if(cfg.prot[i]->misc&PROT_DSZLOG)
result = checkdszlog(fname);
else
result = (error == 0);
if(result) {
off_t length = flength(fname);
logon_dlb += length; /* Update stats */
logon_dls++;
......@@ -491,7 +495,11 @@ bool sbbs_t::sendfile(char* fname, char prot, const char* desc)
,useron.alias, desc == NULL ? "file" : desc, fname, bytes);
logline("D-",str);
autohangup();
} else {
char str[128];
bprintf(text[FileNotSent], getfname(fname));
sprintf(str,"%s attempted to download attached file: %s", useron.alias, fname);
logline(LOG_NOTICE,"D!",str);
}
return(result);
return result;
}
......@@ -822,7 +822,7 @@ public:
const char* protcmdline(prot_t* prot, enum XFER_TYPE type);
void seqwait(uint devnum);
void autohangup(void);
bool checkdszlog(file_t*);
bool checkdszlog(const char*);
bool checkprotresult(prot_t*, int error, file_t*);
bool sendfile(char* fname, char prot=0, const char* description = NULL);
bool recvfile(char* fname, char prot=0);
......
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