--- sbbs/src/sbbs3/getnode.cpp 2018/04/24 16:41:23 1.1 +++ sbbs/src/sbbs3/getnode.cpp 2018/04/24 16:43:01 1.1.1.2 @@ -2,13 +2,13 @@ /* Synchronet node information retrieval functions */ -/* $Id: getnode.cpp,v 1.1 2018/04/24 16:41:23 root Exp $ */ +/* $Id: getnode.cpp,v 1.1.1.2 2018/04/24 16:43:01 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 2003 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 * @@ -91,12 +91,15 @@ int sbbs_t::getnodedat(uint number, node if(count==LOOP_NODEDAB) { errormsg(WHERE,rd==sizeof(node_t) ? ERR_LOCK : ERR_READ,"node.dab",number+1); + if(nodefile!=-1) + close(nodefile); + nodefile=-1; return(-2); } if(count>(LOOP_NODEDAB/2)) { sprintf(str,"NODE.DAB (node %d) COLLISION - Count: %d" ,number+1, count); - logline("!!",str); + logline(LOG_WARNING,"!!",str); } return(0); @@ -129,7 +132,7 @@ void sbbs_t::nodesync() if(sys_status&SS_USERON) { if(thisnode.status==NODE_WFC) { - errorlog("NODE STATUS FIXUP"); + lprintf(LOG_ERR, "Node %d NODE STATUS FIXUP", cfg.node_num); if(getnodedat(cfg.node_num,&thisnode,true)==0) { thisnode.status=NODE_INUSE; putnodedat(cfg.node_num,&thisnode); @@ -142,7 +145,7 @@ void sbbs_t::nodesync() unixtodstr(&cfg,now,today); if(strcmp(str,today)) { /* New day, clear "today" user vars */ sys_status|=SS_NEWDAY; // So we don't keep doing this over&over - resetdailyuserdat(&cfg,&useron); + resetdailyuserdat(&cfg, &useron,/* write: */true); } } if(thisnode.misc&NODE_UDAT && !(useron.rest&FLAG('G'))) { /* not guest */ @@ -152,10 +155,12 @@ void sbbs_t::nodesync() putnodedat(cfg.node_num,&thisnode); } } - if(thisnode.misc&NODE_MSGW) - getsmsg(useron.number); /* getsmsg clears MSGW flag */ - if(thisnode.misc&NODE_NMSG) - getnmsg(); /* getnmsg clears NMSG flag */ + if(!(sys_status&SS_MOFF)) { + if(thisnode.misc&NODE_MSGW) + getsmsg(useron.number); /* getsmsg clears MSGW flag */ + if(thisnode.misc&NODE_NMSG) + getnmsg(); /* getnmsg clears NMSG flag */ + } } if(cfg.sync_mod[0]) @@ -163,7 +168,7 @@ void sbbs_t::nodesync() if(thisnode.misc&NODE_INTR) { bputs(text[NodeLocked]); - logline(nulstr,"Interrupted"); + logline(LOG_NOTICE,nulstr,"Interrupted"); hangup(); nodesync_inside=0; return; @@ -184,9 +189,11 @@ void sbbs_t::nodesync() if(sys_status&SS_USERON && online && (timeleft/60)<(5-timeleft_warn) && !SYSOP) { timeleft_warn=5-(timeleft/60); - attr(LIGHTGRAY); - bprintf(text[OnlyXminutesLeft] - ,((ushort)timeleft/60)+1,(timeleft/60) ? "s" : nulstr); + if(!(sys_status&SS_MOFF)) { + attr(LIGHTGRAY); + bprintf(text[OnlyXminutesLeft] + ,((ushort)timeleft/60)+1,(timeleft/60) ? "s" : nulstr); + } } attr(atr); /* replace original attributes */ @@ -216,7 +223,7 @@ int sbbs_t::getnmsg() **/ return(errno); } - length=filelength(file); + length=(long)filelength(file); if(!length) { close(file); return(0); @@ -305,6 +312,18 @@ int sbbs_t::getsmsg(int usernumber) char str[MAX_PATH+1], *buf; int file; long length; + node_t node; + int i; + + for(i=1;i<=cfg.sys_nodes;i++) { /* clear msg waiting flag */ + if(getnodedat(i,&node,true)==0) { + if(node.useron==usernumber + && (node.status==NODE_INUSE || node.status==NODE_QUIET) + && node.misc&NODE_MSGW) + node.misc&=~NODE_MSGW; + putnodedat(i,&node); + } + } sprintf(str,"%smsgs/%4.4u.msg",cfg.data_dir,usernumber); if(flength(str)<1L) @@ -313,7 +332,7 @@ int sbbs_t::getsmsg(int usernumber) errormsg(WHERE,ERR_OPEN,str,O_RDWR); return(errno); } - length=filelength(file); + length=(long)filelength(file); if((buf=(char *)malloc(length+1))==NULL) { close(file); errormsg(WHERE,ERR_ALLOC,str,length+1); @@ -333,12 +352,6 @@ int sbbs_t::getsmsg(int usernumber) || sys_status&SS_IN_CTRLP) { CRLF; } - if(thisnode.misc&NODE_MSGW) { - if(getnodedat(cfg.node_num,&thisnode,true)==0) { - thisnode.misc&=~NODE_MSGW; - putnodedat(cfg.node_num,&thisnode); - } - } putmsg(buf,P_NOATCODES); free(buf); @@ -388,6 +401,25 @@ void sbbs_t::nodelist(void) } } +static char* node_connection_desc(sbbs_t* sbbs, ushort conn, char* str) +{ + switch(conn) { + case NODE_CONNECTION_LOCAL: + return (char*)" Locally"; /* obsolete */ + case NODE_CONNECTION_TELNET: + return sbbs->text[NodeConnectionTelnet]; + case NODE_CONNECTION_RLOGIN: + return sbbs->text[NodeConnectionRLogin]; + case NODE_CONNECTION_SSH: + return sbbs->text[NodeConnectionSSH]; + default: + sprintf(str,sbbs->text[NodeConnectionModem],conn); + break; + } + + return str; +} + /****************************************************************************/ /* Displays the information for node number 'number' contained in 'node' */ /****************************************************************************/ @@ -402,41 +434,34 @@ void sbbs_t::printnodedat(uint number, n attr(cfg.color[clr_nodestatus]); switch(node->status) { case NODE_WFC: - bputs("Waiting for call"); + bputs(text[NodeStatusWaitingForCall]); break; case NODE_OFFLINE: - bputs("Offline"); + bputs(text[NodeStatusOffline]); break; case NODE_NETTING: - bputs("Networking"); + bputs("Networking"); /* obsolete */ break; case NODE_LOGON: - bputs("At logon prompt"); + bputs(text[NodeStatusLogon]); + bputs(node_connection_desc(this, node->connection, tmp)); break; case NODE_EVENT_WAITING: - bputs("Waiting for all nodes to become inactive"); + bputs(text[NodeStatusEventWaiting]); break; case NODE_EVENT_LIMBO: - bprintf("Waiting for node %d to finish external event",node->aux); + bprintf(text[NodeStatusEventLimbo],node->aux); break; case NODE_EVENT_RUNNING: - bputs("Running external event"); + bputs(text[NodeStatusEventRunning]); break; case NODE_NEWUSER: - attr(cfg.color[clr_nodeuser]); - bputs("New user"); - attr(cfg.color[clr_nodestatus]); - bputs(" applying for access "); - if(!node->connection) - bputs("Locally"); - else if(node->connection==0xffff) - bprintf("via telnet"); - else - bprintf("at %ubps",node->connection); + bputs(text[NodeStatusNewUser]); + bputs(node_connection_desc(this, node->connection, tmp)); break; case NODE_QUIET: if(!SYSOP) { - bputs("Waiting for call"); + bputs(text[NodeStatusWaitingForCall]); break; } case NODE_INUSE: @@ -447,7 +472,7 @@ void sbbs_t::printnodedat(uint number, n } attr(cfg.color[clr_nodeuser]); if(node->misc&NODE_ANON && !SYSOP) - bputs("UNKNOWN USER"); + bputs(text[UNKNOWN_USER]); else bputs(username(&cfg,node->useron,tmp)); attr(cfg.color[clr_nodestatus]); @@ -483,7 +508,7 @@ void sbbs_t::printnodedat(uint number, n else { bputs("running "); i=node->aux-1; - if(SYSOP || chk_ar(cfg.xtrn[i]->ar,&useron)) + if(SYSOP || chk_ar(cfg.xtrn[i]->ar,&useron,&client)) bputs(cfg.xtrn[node->aux-1]->name); else bputs("external program"); @@ -555,12 +580,7 @@ void sbbs_t::printnodedat(uint number, n default: bputs(ultoa(node->action,tmp,10)); break; } - if(!node->connection) - bputs(" locally"); - else if(node->connection==0xffff) - bprintf(" via telnet"); - else - bprintf(" at %ubps",node->connection); + bputs(node_connection_desc(this, node->connection, tmp)); if(node->action==NODE_DLNG) { if(cfg.sys_misc&SM_MILITARY) { hour=node->aux/60;