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 3a0825c6 authored by rswindell's avatar rswindell

Created sbbs_t::count_nodes() which just returns the number of "in-use" nodes,

optionally including the current (your) node.
New @-codes:
"ANODES" (active-nodes count), aliases: "ANODE" and "AN"
"ONODES" (other-active-nodes count), aliases: "ONODE" and "ON"

Make "NN" an alias for "NODE" and "TN" and alias for "TNODE".
Add "TNODES" alias for "TNODE" as well, for symmetry.
parent 578a5d75
......@@ -321,15 +321,22 @@ const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen, long* pmode)
if(!strcmp(sp,"LOCATION"))
return(cfg.sys_location);
if(!strcmp(sp,"NODE")) {
if(strcmp(sp,"NODE") == 0 || strcmp(sp,"NN") == 0) {
safe_snprintf(str,maxlen,"%u",cfg.node_num);
return(str);
}
if(!strcmp(sp,"TNODE")) {
if(strcmp(sp, "TNODES") == 0 || strcmp(sp, "TNODE") == 0 || strcmp(sp, "TN") == 0) {
safe_snprintf(str,maxlen,"%u",cfg.sys_nodes);
return(str);
}
if(strcmp(sp, "ANODES") == 0 || strcmp(sp, "ANODE") == 0 || strcmp(sp, "AN") == 0) {
safe_snprintf(str, maxlen, "%u", count_nodes(/* self: */true));
return str;
}
if(strcmp(sp, "ONODES") == 0 || strcmp(sp, "ONODE") == 0 || strcmp(sp, "ON") == 0) {
safe_snprintf(str, maxlen, "%u", count_nodes(/* self: */false));
return str;
}
if(strcmp(sp, "PAGER") == 0)
return (thisnode.misc&NODE_POFF) ? text[Off] : text[On];
......
......@@ -661,3 +661,20 @@ void sbbs_t::printnodedat(uint number, node_t* node)
attr(LIGHTGRAY);
CRLF;
}
uint sbbs_t::count_nodes(bool self)
{
uint count = 0;
for(int i=1; i<=cfg.sys_nodes && i<=cfg.sys_lastnode; i++) {
node_t node;
if(getnodedat(i, &node, false) != 0)
continue;
if(!self && i==cfg.node_num)
continue;
if(node.status != NODE_INUSE)
continue;
count++;
}
return count;
}
......@@ -819,6 +819,7 @@ public:
void nodesync(bool clearline = false);
user_t nodesync_user;
bool nodesync_inside;
uint count_nodes(bool self = true);
/* putnode.cpp */
int putnodedat(uint number, node_t * node);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment