diff --git a/src/sbbs3/download.cpp b/src/sbbs3/download.cpp index ebb75fd269251af6bcfb8ba20c5c643e14a8da37..178bd4f5984fa56c5416248fd623c5847dc67406 100644 --- a/src/sbbs3/download.cpp +++ b/src/sbbs3/download.cpp @@ -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; } diff --git a/src/sbbs3/sbbs.h b/src/sbbs3/sbbs.h index d9b0dad0df3b9e7c5612686cd4aea4b0e545f3e2..c9d323c8986e98fc40e7eb3b6961ce6877761951 100644 --- a/src/sbbs3/sbbs.h +++ b/src/sbbs3/sbbs.h @@ -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);