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 0d73dbc4 authored by rswindell's avatar rswindell
Browse files

Two unrelated changes, but since they touched sbbs.h, I'm committing them

together to keep things atomic:
1. Eliminate eprintf() as sbbs_t::lputs() and sbbs_t::lprintf() do the
   "right thing" (e.g. log to the event log when called from the event_thread).
2. Moved upload_stats() and download_stats() from ftpsrvr.c to getstats.c where
    I plan to make use of them for JS-based upload/download file support.
parent 29ed187e
......@@ -1282,10 +1282,7 @@ int sbbs_t::exec(csi_t *csi)
putmsg(cmdstr((char*)csi->ip,path,csi->str,(char*)buf),P_SAVEATR|P_NOABORT);
break;
case CS_PRINT_LOCAL:
if(online==ON_LOCAL)
eprintf(LOG_INFO,"%s",cmdstr((char*)csi->ip,path,csi->str,(char*)buf));
else
lputs(LOG_INFO,cmdstr((char*)csi->ip,path,csi->str,(char*)buf));
lputs(LOG_INFO,cmdstr((char*)csi->ip,path,csi->str,(char*)buf));
break;
case CS_PRINT_REMOTE:
putcom(cmdstr((char*)csi->ip,path,csi->str,(char*)buf));
......
......@@ -99,10 +99,7 @@ int sbbs_t::exec_misc(csi_t* csi, char *path)
if(op==VAR_PRINTF)
putmsg(cmdstr(p,path,csi->str,buf),P_SAVEATR|P_NOABORT|P_NOATCODES);
else {
if(online==ON_LOCAL)
eprintf(LOG_INFO,"%s",cmdstr(p,path,csi->str,buf));
else
lputs(LOG_INFO,cmdstr(p,path,csi->str,buf));
lputs(LOG_INFO,cmdstr(p,path,csi->str,buf));
}
free(p);
return(0);
......
......@@ -1132,52 +1132,6 @@ BOOL js_generate_index(JSContext* js_cx, JSObject* parent,
#endif /* ifdef JAVASCRIPT */
BOOL upload_stats(ulong bytes)
{
char str[MAX_PATH+1];
int file;
uint32_t val;
sprintf(str,"%sdsts.dab",scfg.ctrl_dir);
if((file=nopen(str,O_RDWR))==-1)
return(FALSE);
lseek(file,20L,SEEK_SET); /* Skip timestamp, logons and logons today */
read(file,&val,4); /* Uploads today */
val++;
lseek(file,-4L,SEEK_CUR);
write(file,&val,4);
read(file,&val,4); /* Upload bytes today */
val+=bytes;
lseek(file,-4L,SEEK_CUR);
write(file,&val,4);
close(file);
return(TRUE);
}
BOOL download_stats(ulong bytes)
{
char str[MAX_PATH+1];
int file;
uint32_t val;
sprintf(str,"%sdsts.dab",scfg.ctrl_dir);
if((file=nopen(str,O_RDWR))==-1)
return(FALSE);
lseek(file,28L,SEEK_SET); /* Skip timestamp, logons and logons today */
read(file,&val,4); /* Downloads today */
val++;
lseek(file,-4L,SEEK_CUR);
write(file,&val,4);
read(file,&val,4); /* Download bytes today */
val+=bytes;
lseek(file,-4L,SEEK_CUR);
write(file,&val,4);
close(file);
return(TRUE);
}
void recverror(SOCKET socket, int rd, int line)
{
if(rd==0)
......@@ -1631,7 +1585,7 @@ static void send_thread(void* arg)
}
}
if(!xfer.tmpfile && !xfer.delfile && !(scfg.dir[f.dir]->misc&DIR_NOSTAT))
download_stats(total);
inc_sys_download_stats(&scfg, 1, total);
}
if(xfer.credits) {
......@@ -1957,7 +1911,7 @@ static void receive_thread(void* arg)
,(ulong)(f.cdt*(scfg.dir[f.dir]->up_pct/100.0)));
}
if(!(scfg.dir[f.dir]->misc&DIR_NOSTAT))
upload_stats(total);
inc_sys_upload_stats(&scfg, 1, total);
}
/* Send ACK */
sockprintf(xfer.ctrl_sock,sess,"226 Upload complete (%lu cps).",cps);
......
......@@ -88,3 +88,49 @@ ulong DLLCALL getposts(scfg_t* cfg, uint subnum)
return(0);
return(l/sizeof(idxrec_t));
}
BOOL inc_sys_upload_stats(scfg_t* cfg, ulong files, ulong bytes)
{
char str[MAX_PATH+1];
int file;
uint32_t val;
sprintf(str,"%sdsts.dab",cfg->ctrl_dir);
if((file=nopen(str,O_RDWR))==-1)
return(FALSE);
lseek(file,20L,SEEK_SET); /* Skip timestamp, logons and logons today */
read(file,&val,4); /* Uploads today */
val+=files;
lseek(file,-4L,SEEK_CUR);
write(file,&val,4);
read(file,&val,4); /* Upload bytes today */
val+=bytes;
lseek(file,-4L,SEEK_CUR);
write(file,&val,4);
close(file);
return(TRUE);
}
BOOL inc_sys_download_stats(scfg_t* cfg, ulong files, ulong bytes)
{
char str[MAX_PATH+1];
int file;
uint32_t val;
sprintf(str,"%sdsts.dab",cfg->ctrl_dir);
if((file=nopen(str,O_RDWR))==-1)
return(FALSE);
lseek(file,28L,SEEK_SET); /* Skip timestamp, logons and logons today */
read(file,&val,4); /* Downloads today */
val+=files;
lseek(file,-4L,SEEK_CUR);
write(file,&val,4);
read(file,&val,4); /* Download bytes today */
val+=bytes;
lseek(file,-4L,SEEK_CUR);
write(file,&val,4);
close(file);
return(TRUE);
}
......@@ -252,14 +252,10 @@ void sbbs_t::errormsg(int line, const char* function, const char *src, const cha
,src, line, function, action, object, access
,extinfo==NULL ? "":"info="
,extinfo==NULL ? "":extinfo);
if(online==ON_LOCAL) {
if(useron.number)
eprintf(LOG_ERR, "<%s> %s", useron.alias, str);
else
eprintf(LOG_ERR, "%s", str);
} else {
lprintf(LOG_ERR, "!%s", str);
if(online == ON_REMOTE) {
int savatr=curatr;
lprintf(LOG_ERR, "!%s", str);
attr(cfg.color[clr_err]);
bprintf("\7\r\n!ERROR %s %s\r\n", action, object); /* tell user about error */
bputs("\r\nThe sysop has been notified.\r\n");
......
......@@ -254,21 +254,6 @@ int lprintf(int level, const char *fmt, ...)
return(lputs(level,sbuf));
}
int eprintf(int level, const char *fmt, ...)
{
va_list argptr;
char sbuf[1024];
va_start(argptr,fmt);
vsnprintf(sbuf,sizeof(sbuf),fmt,argptr);
sbuf[sizeof(sbuf)-1]=0;
va_end(argptr);
strip_ctrl(sbuf, sbuf);
return(eputs(level,truncsp(sbuf)));
}
/* Picks the right log callback function (event or term) based on the sbbs->cfg.node_num value */
/* Prepends the current node number and user alias (if applicable) */
int sbbs_t::lputs(int level, const char* str)
......@@ -931,7 +916,7 @@ js_write(JSContext *cx, uintN argc, jsval *arglist)
if(cstr==NULL)
return(JS_FALSE);
rc=JS_SUSPENDREQUEST(cx);
if(!sbbs->online)
if(sbbs->online != ON_REMOTE)
sbbs->lputs(LOG_INFO, cstr);
else
sbbs->bputs(cstr);
......@@ -1017,7 +1002,7 @@ js_printf(JSContext *cx, uintN argc, jsval *arglist)
}
rc=JS_SUSPENDREQUEST(cx);
if(!sbbs->online)
if(sbbs->online != ON_REMOTE)
sbbs->lputs(LOG_INFO, p);
else
sbbs->bputs(p);
......@@ -1048,8 +1033,8 @@ js_alert(JSContext *cx, uintN argc, jsval *arglist)
return(JS_FALSE);
rc=JS_SUSPENDREQUEST(cx);
if(!sbbs->online)
lputs(LOG_WARNING, cstr);
if(sbbs->online != ON_REMOTE)
sbbs->lputs(LOG_WARNING, cstr);
else {
sbbs->attr(sbbs->cfg.color[clr_err]);
sbbs->bputs(cstr);
......@@ -2534,7 +2519,7 @@ void event_thread(void* arg)
struct tm tm;
char event_code[LEN_CODE+1];
eprintf(LOG_INFO,"BBS Events thread started");
sbbs->lprintf(LOG_INFO,"BBS Events thread started");
sbbs_srand(); /* Seed random number generator */
......@@ -2544,7 +2529,7 @@ void event_thread(void* arg)
#ifdef JAVASCRIPT
if(!(startup->options&BBS_OPT_NO_JAVASCRIPT)) {
if((sbbs->js_cx = sbbs->js_init(&sbbs->js_runtime, &sbbs->js_glob, "event")) == NULL) /* This must be done in the context of the events thread */
lprintf(LOG_ERR,"!JavaScript Initialization FAILURE");
sbbs->lprintf(LOG_ERR,"!JavaScript Initialization FAILURE");
}
#endif
......@@ -2556,7 +2541,7 @@ void event_thread(void* arg)
for(i=0;i<sbbs->cfg.total_events;i++) {
sbbs->cfg.event[i]->last=0;
if(filelength(file)<(long)(sizeof(time32_t)*(i+1))) {
eprintf(LOG_WARNING,"Initializing last run time for event: %s"
sbbs->lprintf(LOG_WARNING,"Initializing last run time for event: %s"
,sbbs->cfg.event[i]->code);
write(file,&sbbs->cfg.event[i]->last,sizeof(sbbs->cfg.event[i]->last));
} else {
......@@ -2580,7 +2565,7 @@ void event_thread(void* arg)
for(i=0;i<sbbs->cfg.total_qhubs;i++) {
sbbs->cfg.qhub[i]->last=0;
if(filelength(file)<(long)(sizeof(time32_t)*(i+1))) {
eprintf(LOG_WARNING,"Initializing last call-out time for QWKnet hub: %s"
sbbs->lprintf(LOG_WARNING,"Initializing last call-out time for QWKnet hub: %s"
,sbbs->cfg.qhub[i]->id);
write(file,&sbbs->cfg.qhub[i]->last,sizeof(sbbs->cfg.qhub[i]->last));
} else {
......@@ -2824,7 +2809,7 @@ void event_thread(void* arg)
sbbs->logentry("!:","Run node daily event");
const char* cmd = sbbs->cmdstr(sbbs->cfg.node_daily,nulstr,nulstr,NULL);
int result = sbbs->external(cmd, EX_OFFLINE);
eprintf(result ? LOG_ERR : LOG_INFO, "Node daily event: '%s' returned %d", cmd, result);
sbbs->lprintf(result ? LOG_ERR : LOG_INFO, "Node daily event: '%s' returned %d", cmd, result);
sbbs->console&=~CON_L_ECHO;
sbbs->online=FALSE;
}
......@@ -2846,7 +2831,7 @@ void event_thread(void* arg)
SAFEPRINTF2(str,"%sqnet/%s.now",sbbs->cfg.data_dir,sbbs->cfg.qhub[i]->id);
if(fexistcase(str)) {
SAFECOPY(str,sbbs->cfg.qhub[i]->id);
eprintf(LOG_INFO,"Semaphore signaled for QWK Network Hub: %s",strupr(str));
sbbs->lprintf(LOG_INFO,"Semaphore signaled for QWK Network Hub: %s",strupr(str));
sbbs->cfg.qhub[i]->last=-1;
}
}
......@@ -2864,7 +2849,7 @@ void event_thread(void* arg)
SAFEPRINTF2(str,"%s%s.now",sbbs->cfg.data_dir,sbbs->cfg.event[i]->code);
if(fexistcase(str)) {
SAFECOPY(str,sbbs->cfg.event[i]->code);
eprintf(LOG_INFO,"Semaphore signaled for Timed Event: %s",strupr(str));
sbbs->lprintf(LOG_INFO,"Semaphore signaled for Timed Event: %s",strupr(str));
sbbs->cfg.event[i]->last=-1;
}
}
......@@ -2884,7 +2869,7 @@ void event_thread(void* arg)
for(j=0;j<(int)g.gl_pathc;j++) {
SAFECOPY(str,g.gl_pathv[j]);
if(flength(str)>0) { /* silently ignore 0-byte QWK packets */
eprintf(LOG_DEBUG,"Inbound QWK Packet detected: %s", str);
sbbs->lprintf(LOG_DEBUG,"Inbound QWK Packet detected: %s", str);
sbbs->online=ON_LOCAL;
sbbs->console|=CON_L_ECHO;
if(sbbs->unpack_qwk(str,i)==false) {
......@@ -2978,14 +2963,14 @@ void event_thread(void* arg)
if(sbbs->cfg.node_num<1)
sbbs->cfg.node_num=1;
SAFECOPY(sbbs->cfg.node_dir, sbbs->cfg.node_path[sbbs->cfg.node_num-1]);
eprintf(LOG_INFO,"QWK Network call-out: %s",sbbs->cfg.qhub[i]->id);
sbbs->lprintf(LOG_INFO,"Call-out: %s",sbbs->cfg.qhub[i]->id);
sbbs->online=ON_LOCAL;
sbbs->console|=CON_L_ECHO;
int result = sbbs->external(
sbbs->cmdstr(sbbs->cfg.qhub[i]->call
,sbbs->cfg.qhub[i]->id,sbbs->cfg.qhub[i]->id,NULL)
,EX_OFFLINE|EX_SH); /* sh for Unix perl scripts */
eprintf(result ? LOG_ERR : LOG_INFO, "QWK Network call-out to: %s returned %d", sbbs->cfg.qhub[i]->id, result);
sbbs->lprintf(result ? LOG_ERR : LOG_INFO, "Call-out to: %s returned %d", sbbs->cfg.qhub[i]->id, result);
sbbs->console&=~CON_L_ECHO;
sbbs->online=FALSE;
}
......@@ -3028,7 +3013,7 @@ void event_thread(void* arg)
if(sbbs->cfg.node_num<1)
sbbs->cfg.node_num=1;
SAFECOPY(sbbs->cfg.node_dir, sbbs->cfg.node_path[sbbs->cfg.node_num-1]);
eprintf(LOG_INFO,"PostLink Network call-out: %s",sbbs->cfg.phub[i]->name);
sbbs->lprintf(LOG_INFO,"PostLink Network call-out: %s",sbbs->cfg.phub[i]->name);
sbbs->online=ON_LOCAL;
sbbs->console|=CON_L_ECHO;
sbbs->external(
......@@ -3217,7 +3202,7 @@ void event_thread(void* arg)
ex_mode|=(sbbs->cfg.event[i]->misc&EX_NATIVE);
sbbs->online=ON_LOCAL;
sbbs->console|=CON_L_ECHO;
eprintf(LOG_INFO,"Running %s%stimed event: %s"
sbbs->lprintf(LOG_INFO,"Running %s%stimed event: %s"
,(ex_mode&EX_NATIVE) ? "native ":""
,(ex_mode&EX_BG) ? "background ":""
,event_code);
......@@ -3228,7 +3213,7 @@ void event_thread(void* arg)
,ex_mode
,sbbs->cfg.event[i]->dir);
if(!(ex_mode&EX_BG))
eprintf(result ? LOG_ERR : LOG_INFO, "Timed event: %s returned %d", event_code, result);
sbbs->lprintf(result ? LOG_ERR : LOG_INFO, "Timed event: %s returned %d", event_code, result);
}
sbbs->console&=~CON_L_ECHO;
sbbs->online=FALSE;
......@@ -3266,7 +3251,7 @@ void event_thread(void* arg)
sbbs->event_thread_running = false;
thread_down();
eprintf(LOG_INFO,"BBS Events thread terminated");
sbbs->lprintf(LOG_INFO,"BBS Events thread terminated");
}
......@@ -4825,7 +4810,7 @@ void sbbs_t::daily_maint(void)
lputs(LOG_INFO, "DAILY: Running system event");
const char* cmd = cmdstr(cfg.sys_daily,nulstr,nulstr,NULL);
int result = external(cmd, EX_OFFLINE);
eprintf(result ? LOG_ERR : LOG_INFO, "Daily event: '%s' returned %d", cmd, result);
lprintf(result ? LOG_ERR : LOG_INFO, "Daily event: '%s' returned %d", cmd, result);
}
status(STATUS_WFC);
lputs(LOG_INFO, "DAILY: System maintenance ended");
......
......@@ -73,7 +73,7 @@ bool sbbs_t::pack_qwk(char *packet, ulong *msgcnt, bool prepack)
if(prepack) {
ex|=EX_OFFLINE;
if(is_user_online(&cfg, useron.number)) { /* Don't pre-pack with user online */
eprintf(LOG_NOTICE, "User #%u is concurrently logged-in, QWK packet creation aborted", useron.number);
lprintf(LOG_NOTICE, "User #%u is concurrently logged-in, QWK packet creation aborted", useron.number);
return(false);
}
}
......@@ -721,7 +721,7 @@ bool sbbs_t::pack_qwk(char *packet, ulong *msgcnt, bool prepack)
if(prepack) {
if(is_user_online(&cfg, useron.number)) { /* Don't pre-pack with user online */
eprintf(LOG_NOTICE, "User #%u is concurrently logged-in, QWK packet creation aborted", useron.number);
lprintf(LOG_NOTICE, "User #%u is concurrently logged-in, QWK packet creation aborted", useron.number);
return(false);
}
}
......
......@@ -73,10 +73,10 @@ bool sbbs_t::pack_rep(uint hubnum)
SAFEPRINTF2(str,"%s%s.REP",cfg.data_dir,hubid_upper);
if(fexistcase(str)) {
eprintf(LOG_INFO,"Updating %s", str);
lprintf(LOG_INFO,"Updating %s", str);
external(cmdstr(cfg.qhub[hubnum]->unpack,str,ALLFILES,NULL),EX_OFFLINE);
} else
eprintf(LOG_INFO,"Creating %s", str);
lprintf(LOG_INFO,"Creating %s", str);
/*************************************************/
/* Create SYSID.MSG, write header and leave open */
/*************************************************/
......@@ -128,7 +128,7 @@ bool sbbs_t::pack_rep(uint hubnum)
mail=loadmail(&smb,&mailmsgs,0,MAIL_YOUR,0);
packedmail=0;
if(mailmsgs) {
eprintf(LOG_INFO,"Packing NetMail for %s", cfg.qhub[hubnum]->id);
lprintf(LOG_INFO,"Packing NetMail for %s", cfg.qhub[hubnum]->id);
for(u=0;u<mailmsgs;u++) {
// bprintf("\b\b\b\b\b%-5lu",u+1);
......@@ -158,7 +158,7 @@ bool sbbs_t::pack_rep(uint hubnum)
smb_freemsgmem(&msg);
YIELD(); /* yield */
}
eprintf(LOG_INFO,"Packed %ld NetMail messages",packedmail);
lprintf(LOG_INFO,"Packed %ld NetMail messages",packedmail);
}
smb_close(&smb); /* Close the e-mail */
if(mailmsgs)
......@@ -173,7 +173,7 @@ bool sbbs_t::pack_rep(uint hubnum)
subscan[j].ptr=last;
subscan[j].last=last;
}
eprintf(LOG_INFO,remove_ctrl_a(text[NScanStatusFmt],tmp)
lprintf(LOG_INFO,remove_ctrl_a(text[NScanStatusFmt],tmp)
,cfg.grp[cfg.sub[j]->grp]->sname
,cfg.sub[j]->lname,0L,msgs);
continue;
......@@ -189,7 +189,7 @@ bool sbbs_t::pack_rep(uint hubnum)
}
post=loadposts(&posts,j,subscan[j].ptr,LP_BYSELF|LP_OTHERS|LP_PRIVATE|LP_REP|LP_VOTES|LP_POLLS,NULL);
eprintf(LOG_INFO,remove_ctrl_a(text[NScanStatusFmt],tmp)
lprintf(LOG_INFO,remove_ctrl_a(text[NScanStatusFmt],tmp)
,cfg.grp[cfg.sub[j]->grp]->sname
,cfg.sub[j]->lname,posts,msgs);
if(!posts) { /* no new messages */
......@@ -198,7 +198,7 @@ bool sbbs_t::pack_rep(uint hubnum)
}
subscan[j].ptr=last; /* set pointer */
eprintf(LOG_INFO,"%s",remove_ctrl_a(text[QWKPackingSubboard],tmp)); /* ptr to last msg */
lprintf(LOG_INFO,"%s",remove_ctrl_a(text[QWKPackingSubboard],tmp)); /* ptr to last msg */
submsgs=0;
for(u=0;u<posts;u++) {
// bprintf("\b\b\b\b\b%-5lu",u+1);
......@@ -237,7 +237,7 @@ bool sbbs_t::pack_rep(uint hubnum)
if(!(u%50))
YIELD(); /* yield */
}
eprintf(LOG_INFO,remove_ctrl_a(text[QWKPackedSubboard],tmp),submsgs,msgcnt);
lprintf(LOG_INFO,remove_ctrl_a(text[QWKPackedSubboard],tmp),submsgs,msgcnt);
free(post);
smb_close(&smb);
YIELD(); /* yield */
......@@ -260,7 +260,7 @@ bool sbbs_t::pack_rep(uint hubnum)
if(isdir(str))
continue;
SAFEPRINTF2(tmp2,"%s%s",cfg.temp_dir,dirent->d_name);
eprintf(LOG_INFO,remove_ctrl_a(text[RetrievingFile],tmp),str);
lprintf(LOG_INFO,remove_ctrl_a(text[RetrievingFile],tmp),str);
if(!mv(str,tmp2,/* copy: */TRUE))
netfiles++;
}
......@@ -270,7 +270,7 @@ bool sbbs_t::pack_rep(uint hubnum)
CRLF;
if(!msgcnt && !netfiles && !packedmail && !voting_data) {
eprintf(LOG_INFO, "%s", remove_ctrl_a(text[QWKNoNewMessages],tmp));
lprintf(LOG_INFO, "%s", remove_ctrl_a(text[QWKNoNewMessages],tmp));
return(true); // Changed from false Mar-11-2005 (needs to be true to save updated ptrs)
}
......@@ -282,7 +282,7 @@ bool sbbs_t::pack_rep(uint hubnum)
i=external(cmdstr(cfg.qhub[hubnum]->pack,str,tmp2,NULL)
,EX_OFFLINE|EX_WILDCARD);
if(!fexistcase(str)) {
eprintf(LOG_WARNING,"%s",remove_ctrl_a(text[QWKCompressionFailed],tmp));
lprintf(LOG_WARNING,"%s",remove_ctrl_a(text[QWKCompressionFailed],tmp));
if(i)
errormsg(WHERE,ERR_EXEC,cmdstr(cfg.qhub[hubnum]->pack,str,tmp2,NULL),i);
else
......@@ -353,7 +353,7 @@ bool sbbs_t::pack_rep(uint hubnum)
smb_close(&smb);
if(mailmsgs)
free(mail);
eprintf(LOG_INFO,"Deleted %ld sent NetMail messages",deleted);
lprintf(LOG_INFO,"Deleted %ld sent NetMail messages",deleted);
}
return(true);
......
......@@ -1113,6 +1113,8 @@ extern "C" {
DLLEXPORT BOOL DLLCALL getstats(scfg_t* cfg, char node, stats_t* stats);
DLLEXPORT ulong DLLCALL getposts(scfg_t* cfg, uint subnum);
DLLEXPORT long DLLCALL getfiles(scfg_t* cfg, uint dirnum);
DLLEXPORT BOOL DLLCALL inc_sys_upload_stats(scfg_t*, ulong files, ulong bytes);
DLLEXPORT BOOL DLLCALL inc_sys_download_stats(scfg_t*, ulong files, ulong bytes);
/* getmail.c */
DLLEXPORT int DLLCALL getmail(scfg_t* cfg, int usernumber, BOOL sent, uint16_t attr);
......@@ -1457,11 +1459,6 @@ char* prep_code(char *str, const char* prefix);
int lprintf(int level, const char *fmt, ...) /* log output */
#if defined(__GNUC__) // Catch printf-format errors
__attribute__ ((format (printf, 2, 3)));
#endif
;
int eprintf(int level, const char *fmt, ...) /* event log */
#if defined(__GNUC__) // Catch printf-format errors
__attribute__ ((format (printf, 2, 3)));
#endif
;
void call_socket_open_callback(BOOL open);
......
......@@ -36,13 +36,13 @@
#include "sbbs.h"
#include "qwk.h"
static void log_qwk_import_stats(ulong msgs, time_t start)
static void log_qwk_import_stats(sbbs_t* sbbs, ulong msgs, time_t start)
{
if(msgs) {
time_t t = time(NULL) - start;
if(t < 1)
t = 1;
eprintf(LOG_INFO,"Imported %lu QWK messages in %lu seconds (%lu msgs/sec)", msgs, (ulong)t, (ulong)(msgs/t));
sbbs->lprintf(LOG_INFO,"Imported %lu QWK messages in %lu seconds (%lu msgs/sec)", msgs, (ulong)t, (ulong)(msgs/t));
}
}
......@@ -131,7 +131,7 @@ bool sbbs_t::unpack_qwk(char *packet,uint hubnum)
/********************/
/* Process messages */
/********************/
eprintf(LOG_INFO,"Importing QWK Network Packet: %s",packet);
lprintf(LOG_INFO,"Importing QWK Network Packet: %s",packet);
ip_can=trashcan_list(&cfg,"ip");
host_can=trashcan_list(&cfg,"host");
......@@ -142,13 +142,13 @@ bool sbbs_t::unpack_qwk(char *packet,uint hubnum)
for(l=QWK_BLOCK_LEN;l<size;l+=blocks*QWK_BLOCK_LEN) {
if(terminated) {
eprintf(LOG_NOTICE,"!Terminated");
lprintf(LOG_NOTICE,"!Terminated");
break;
}
fseek(qwk,l,SEEK_SET);
fread(block,QWK_BLOCK_LEN,1,qwk);
if(block[0]<' ' || block[0]&0x80) {
eprintf(LOG_NOTICE,"!Invalid QWK message status (%02X) at offset %lu in %s"
lprintf(LOG_NOTICE,"!Invalid QWK message status (%02X) at offset %lu in %s"
,block[0], l, packet);
blocks=1;
errors++;
......@@ -165,7 +165,7 @@ bool sbbs_t::unpack_qwk(char *packet,uint hubnum)
}
continue;
}
eprintf(LOG_NOTICE,"!Invalid number of QWK blocks (%d) at offset %lu in %s"
lprintf(LOG_NOTICE,"!Invalid number of QWK blocks (%d) at offset %lu in %s"
,blocks, l+116, packet);
errors++;
blocks=1;
......@@ -179,14 +179,14 @@ bool sbbs_t::unpack_qwk(char *packet,uint hubnum)
if(cfg.max_qwkmsgage && msg.hdr.when_written.time < (uint32_t)now
&& (now-msg.hdr.when_written.time)/(24*60*60) > cfg.max_qwkmsgage) {
eprintf(LOG_NOTICE,"!Filtering QWK message from %s due to age: %u days"
lprintf(LOG_NOTICE,"!Filtering QWK message from %s due to age: %u days"
,msg.from
,(unsigned int)(now-msg.hdr.when_written.time)/(24*60*60));
continue;
}
if(findstr_in_list(msg.from_ip,ip_can)) {
eprintf(LOG_NOTICE,"!Filtering QWK message from %s due to blocked IP: %s"
lprintf(LOG_NOTICE,"!Filtering QWK message from %s due to blocked IP: %s"
,msg.from
,msg.from_ip);
continue;
......@@ -194,21 +194,21 @@ bool sbbs_t::unpack_qwk(char *packet,uint hubnum)
hostname=getHostNameByAddr(msg.from_host);
if(findstr_in_list(hostname,host_can)) {
eprintf(LOG_NOTICE,"!Filtering QWK message from %s due to blocked hostname: %s"
lprintf(LOG_NOTICE,"!Filtering QWK message from %s due to blocked hostname: %s"
,msg.from
,hostname);
continue;
}
if(findstr_in_list(msg.subj,subject_can)) {
eprintf(LOG_NOTICE,"!Filtering QWK message from %s due to filtered subject: %s"
lprintf(LOG_NOTICE,"!Filtering QWK message from %s due to filtered subject: %s"
,msg.from
,msg.subj);
continue;
}
if(!n) { /* NETMAIL */
eprintf(LOG_INFO,"QWK NetMail from %s to %s", cfg.qhub[hubnum]->id, msg.to);
lprintf(LOG_INFO,"QWK NetMail from %s to %s", cfg.qhub[hubnum]->id, msg.to);
if(!stricmp(msg.to,"NETMAIL")) { /* QWK to FidoNet NetMail */
qwktonetmail(qwk,(char *)block,NULL,hubnum+1);
continue;
......@@ -223,7 +223,7 @@ bool sbbs_t::unpack_qwk(char *packet,uint hubnum)
if(!usernum)
usernum=matchuser(&cfg,msg.to,TRUE /* sysop_alias */);
if(!usernum) {
eprintf(LOG_NOTICE,"!QWK NetMail from %s to UNKNOWN USER: %s", cfg.qhub[hubnum]->id, msg.to);
lprintf(LOG_NOTICE,"!QWK NetMail from %s to UNKNOWN USER: %s", cfg.qhub[hubnum]->id, msg.to);
continue;
}
......@@ -275,7 +275,7 @@ bool sbbs_t::unpack_qwk(char *packet,uint hubnum)
smb_unlocksmbhdr(&smb);
bool dupe=false;
if(qwk_import_msg(qwk, (char *)block, blocks, hubnum+1, &smb, usernum, &msg, &dupe)) {
eprintf(LOG_INFO,"Imported QWK mail message from %s to %s #%u", msg.from, msg.to, usernum);
lprintf(LOG_INFO,"Imported QWK mail message from %s to %s #%u", msg.from, msg.to, usernum);
SAFEPRINTF(str,text[UserSentYouMail],msg.from);
putsmsg(&cfg,usernum,str);
tmsgs++;
......@@ -294,7 +294,7 @@ bool sbbs_t::unpack_qwk(char *packet,uint hubnum)
/*********************************/
if((j = resolve_qwkconf(n, hubnum)) == INVALID_SUB) { /* ignore messages for subs not in config */
eprintf(LOG_NOTICE,"!Message from %s on UNKNOWN QWK CONFERENCE NUMBER: %u"
lprintf(LOG_NOTICE,"!Message from %s on UNKNOWN QWK CONFERENCE NUMBER: %u"
,cfg.qhub[hubnum]->id, n);
errors++;
continue;
......@@ -302,7 +302,7 @@ bool sbbs_t::unpack_qwk(char *packet,uint hubnum)
/* TWIT FILTER */
if(findstr_in_list(msg.from,twit_list) || findstr_in_list(msg.to,twit_list)) {
eprintf(LOG_NOTICE,"!Filtering QWK post from %s to %s on %s %s"