Skip to content
Snippets Groups Projects
Commit a4c36610 authored by rswindell's avatar rswindell
Browse files

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
Branches
Tags
No related merge requests found
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * @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 * * This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License * * modify it under the terms of the GNU General Public License *
...@@ -306,14 +306,12 @@ void sbbs_t::autohangup() ...@@ -306,14 +306,12 @@ void sbbs_t::autohangup()
CRLF; CRLF;
} }
bool sbbs_t::checkdszlog(file_t* f) bool sbbs_t::checkdszlog(const char* fpath)
{ {
char path[MAX_PATH+1]; char path[MAX_PATH+1];
char str[MAX_PATH+128];
char fname[MAX_PATH+1];
char rpath[MAX_PATH+1]; char rpath[MAX_PATH+1];
char str[MAX_PATH+128];
char* p; char* p;
char* rname;
char code; char code;
ulong bytes; ulong bytes;
FILE* fp; FILE* fp;
...@@ -323,11 +321,8 @@ bool sbbs_t::checkdszlog(file_t* f) ...@@ -323,11 +321,8 @@ bool sbbs_t::checkdszlog(file_t* f)
if((fp=fopen(path,"r"))==NULL) if((fp=fopen(path,"r"))==NULL)
return(false); return(false);
unpadfname(f->name,fname); SAFECOPY(rpath, fpath);
fexistcase(rpath);
getfilepath(&cfg,f,rpath);
fexistcase(rpath); /* incase of long filename */
rname=getfname(rpath);
while(!ferror(fp)) { while(!ferror(fp)) {
if(!fgets(str,sizeof(str),fp)) if(!fgets(str,sizeof(str),fp))
...@@ -358,7 +353,7 @@ bool sbbs_t::checkdszlog(file_t* f) ...@@ -358,7 +353,7 @@ bool sbbs_t::checkdszlog(file_t* f)
FIND_WHITESPACE(p); // Skip block size FIND_WHITESPACE(p); // Skip block size
SKIP_WHITESPACE(p); SKIP_WHITESPACE(p);
p=getfname(p); /* DSZ stores fullpath, BiModem doesn't */ 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 */ /* E for Error or L for Lost Carrier or s for Skipped */
/* or only sent 0 bytes! */ /* or only sent 0 bytes! */
if(code!='E' && code!='L' && code!='s' && bytes!=0) 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) ...@@ -380,9 +375,11 @@ bool sbbs_t::checkprotresult(prot_t* prot, int error, file_t* f)
char str[512]; char str[512];
char tmp[128]; char tmp[128];
bool success; bool success;
char fpath[MAX_PATH+1];
getfilepath(&cfg,f,fpath);
if(prot->misc&PROT_DSZLOG) if(prot->misc&PROT_DSZLOG)
success=checkdszlog(f); success=checkdszlog(fpath);
else else
success=(error==0); success=(error==0);
...@@ -455,7 +452,8 @@ bool sbbs_t::sendfile(char* fname, char prot, const char* desc) ...@@ -455,7 +452,8 @@ bool sbbs_t::sendfile(char* fname, char prot, const char* desc)
char keys[128]; char keys[128];
char ch; char ch;
size_t i; size_t i;
bool result=false; int error;
bool result;
if(prot > ' ') if(prot > ' ')
ch=toupper(prot); ch=toupper(prot);
...@@ -475,9 +473,15 @@ bool sbbs_t::sendfile(char* fname, char prot, const char* desc) ...@@ -475,9 +473,15 @@ bool sbbs_t::sendfile(char* fname, char prot, const char* desc)
for(i=0;i<cfg.total_prots;i++) for(i=0;i<cfg.total_prots;i++)
if(cfg.prot[i]->mnemonic==ch && chk_ar(cfg.prot[i]->ar,&useron,&client)) if(cfg.prot[i]->mnemonic==ch && chk_ar(cfg.prot[i]->ar,&useron,&client))
break; break;
if(i<cfg.total_prots) { if(i >= cfg.total_prots)
if(protocol(cfg.prot[i],XFER_DOWNLOAD,fname,fname,false)==0) return false;
result=true; 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); off_t length = flength(fname);
logon_dlb += length; /* Update stats */ logon_dlb += length; /* Update stats */
logon_dls++; logon_dls++;
...@@ -491,7 +495,11 @@ bool sbbs_t::sendfile(char* fname, char prot, const char* desc) ...@@ -491,7 +495,11 @@ bool sbbs_t::sendfile(char* fname, char prot, const char* desc)
,useron.alias, desc == NULL ? "file" : desc, fname, bytes); ,useron.alias, desc == NULL ? "file" : desc, fname, bytes);
logline("D-",str); logline("D-",str);
autohangup(); 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: ...@@ -822,7 +822,7 @@ public:
const char* protcmdline(prot_t* prot, enum XFER_TYPE type); const char* protcmdline(prot_t* prot, enum XFER_TYPE type);
void seqwait(uint devnum); void seqwait(uint devnum);
void autohangup(void); void autohangup(void);
bool checkdszlog(file_t*); bool checkdszlog(const char*);
bool checkprotresult(prot_t*, int error, file_t*); bool checkprotresult(prot_t*, int error, file_t*);
bool sendfile(char* fname, char prot=0, const char* description = NULL); bool sendfile(char* fname, char prot=0, const char* description = NULL);
bool recvfile(char* fname, char prot=0); bool recvfile(char* fname, char prot=0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment