--- sbbs/src/sbbs3/download.cpp 2018/04/24 16:41:23 1.1 +++ sbbs/src/sbbs3/download.cpp 2018/04/24 16:42:50 1.1.1.2 @@ -2,13 +2,13 @@ /* Synchronet file download routines */ -/* $Id: download.cpp,v 1.1 2018/04/24 16:41:23 root Exp $ */ +/* $Id: download.cpp,v 1.1.1.2 2018/04/24 16:42:50 root Exp $ */ /**************************************************************************** * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * - * Copyright 2006 Rob Swindell - http://www.synchro.net/copyright.html * + * Copyright 2011 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 * @@ -44,12 +44,13 @@ /****************************************************************************/ void sbbs_t::downloadfile(file_t* f) { - char str[256],fname[13]; - char tmp[512]; - int i,file; - long length,mod; - ulong l; - user_t uploader; + char str[256],fname[13]; + char tmp[512]; + int i,file; + long mod; + long length; + ulong l; + user_t uploader; getfiledat(&cfg,f); /* Get current data - right after download */ if((length=f->size)<0L) @@ -68,7 +69,7 @@ void sbbs_t::downloadfile(file_t* f) /* Update Downloader's Info */ /****************************/ user_downloaded(&cfg, &useron, 1, length); - if(!is_download_free(&cfg,f->dir,&useron)) + if(!is_download_free(&cfg,f->dir,&useron,&client)) subtract_cdt(&cfg,&useron,f->cdt); /**************************/ /* Update Uploader's Info */ @@ -106,7 +107,7 @@ void sbbs_t::downloadfile(file_t* f) errormsg(WHERE,ERR_OPEN,str,O_RDWR); return; } - length=filelength(file); + length=(long)filelength(file); if(length%F_IXBSIZE) { close(file); errormsg(WHERE,ERR_LEN,str,length); @@ -118,7 +119,7 @@ void sbbs_t::downloadfile(file_t* f) for(l=0;l<(ulong)length;l+=F_IXBSIZE) { read(file,str,F_IXBSIZE); /* Look for the filename in the IXB file */ str[11]=0; - if(!strcmp(fname,str)) + if(!stricmp(fname,str)) break; } if(l>=(ulong)length) { @@ -164,14 +165,13 @@ void sbbs_t::notdownloaded(ulong size, t if(cfg.leech_pct && cur_cps /* leech detection */ && end-start>=cfg.leech_sec && end-start>=(double)(size/cur_cps)*(double)cfg.leech_pct/100.0) { - sprintf(str,"Possible use of leech protocol (leech=%u downloads=%u)" - ,useron.leech+1,useron.dls); - errorlog(str); + lprintf(LOG_ERR, "Node %d Possible use of leech protocol (leech=%u downloads=%u)" + ,cfg.node_num, useron.leech+1,useron.dls); useron.leech=(uchar)adjustuserrec(&cfg,useron.number,U_LEECH,2,1); } } -char* sbbs_t::protcmdline(prot_t* prot, enum XFER_TYPE type) +const char* sbbs_t::protcmdline(prot_t* prot, enum XFER_TYPE type) { switch(type) { case XFER_UPLOAD: @@ -205,11 +205,13 @@ int sbbs_t::protocol(prot_t* prot, enum sprintf(protlog,"%sPROTOCOL.LOG",cfg.node_dir); remove(protlog); /* Deletes the protocol log */ if(useron.misc&AUTOHANG) - autohang=1; - else + autohang=true; + else if(text[HangUpAfterXferQ][0]) autohang=yesno(text[HangUpAfterXferQ]); + else + autohang=false; if(sys_status&SS_ABORT || !online) { /* if ctrl-c or hangup */ - autohang=0; + autohang=false; return(-1); } bputs(text[StartXferNow]); @@ -229,7 +231,7 @@ int sbbs_t::protocol(prot_t* prot, enum ex_mode|=EX_NATIVE; #ifdef __unix__ /* file xfer progs must use stdio on Unix */ if(!(prot->misc&PROT_SOCKET)) - ex_mode|=(EX_INR|EX_OUTR|EX_BIN); + ex_mode|=(EX_STDIO|EX_BIN); #endif i=external(cmdline,ex_mode,p); @@ -247,7 +249,7 @@ int sbbs_t::protocol(prot_t* prot, enum if(!fgets(protlog,sizeof(protlog),stream)) break; truncsp(protlog); - logline(nulstr,protlog); + logline(LOG_DEBUG,nulstr,protlog); } fclose(stream); } @@ -397,7 +399,7 @@ bool sbbs_t::checkprotresult(prot_t* pro else if(f->dir==cfg.total_dirs+1) sprintf(str,"%s attempted to download attached file: %s" ,useron.alias,f->name); - logline("D!",str); + logline(LOG_NOTICE,"D!",str); return(false); } return(true); @@ -462,7 +464,7 @@ bool sbbs_t::sendfile(char* fname, char mnemonics(text[ProtocolOrQuit]); strcpy(keys,"Q"); for(i=0;idlcmd[0] && chk_ar(cfg.prot[i]->ar,&useron)) + if(cfg.prot[i]->dlcmd[0] && chk_ar(cfg.prot[i]->ar,&useron,&client)) sprintf(keys+strlen(keys),"%c",cfg.prot[i]->mnemonic); ch=(char)getkeys(keys,0); @@ -471,7 +473,7 @@ bool sbbs_t::sendfile(char* fname, char return(false); } for(i=0;imnemonic==ch && chk_ar(cfg.prot[i]->ar,&useron)) + if(cfg.prot[i]->mnemonic==ch && chk_ar(cfg.prot[i]->ar,&useron,&client)) break; if(i