Skip to content
Snippets Groups Projects
Commit f0c29b98 authored by rswindell's avatar rswindell
Browse files

Quick hack for Alterego to support custom/extended node status text.

parent 5d9ffefe
No related branches found
No related tags found
No related merge requests found
......@@ -119,8 +119,21 @@ function user_age_and_gender(user, options)
return output;
}
function extended_status(num)
{
var f = new File(system.ctrl_dir + "node.exb");
if(!f.open("rb"))
return "!error " + f.error + " opening " + f.name;
f.position = num * 128;
var str = f.read(128);
f.close();
return str;
}
// Returns a string describing the node status, suitable for printing on a single line
//
// num is zero-based
//
// options values supported/used:
// .include_age
// .include_gender
......@@ -131,9 +144,10 @@ function user_age_and_gender(user, options)
// .gender_separator
// .connection_prefix
// .errors_prefix
function node_status(node, is_sysop, options)
function node_status(node, is_sysop, options, num)
{
var node_status = node.status;
var misc = node.misc;
var output = '';
switch(node_status) {
......@@ -143,11 +157,15 @@ function node_status(node, is_sysop, options)
/* Fall-through */
case NODE_INUSE:
{
if(misc&NODE_EXT) {
output += extended_status(num);
break;
}
var user = new User(node.useron);
if(options.username_prefix)
output += options.username_prefix;
if(js.global.bbs && (node.misc&NODE_ANON) && !is_sysop)
if(js.global.bbs && (misc&NODE_ANON) && !is_sysop)
output += bbs.text(UNKNOWN_USER);
else
output += user.alias;
......@@ -187,7 +205,7 @@ function node_status(node, is_sysop, options)
if(options.username_prefix)
output += options.username_prefix;
if(js.global.bbs && (node.misc&NODE_ANON) && !is_sysop)
if(js.global.bbs && (misc&NODE_ANON) && !is_sysop)
output += bbs.text(UNKNOWN_USER);
else
output += system.username(node.useron);
......@@ -308,7 +326,7 @@ function nodelist(print, active, listself, is_sysop, options)
} else
others++;
var line = format(options.format, n + 1, node_status(node, is_sysop, options));
var line = format(options.format, n + 1, node_status(node, is_sysop, options, n));
if(print)
writeln(line);
else
......
......@@ -91,7 +91,7 @@ while(bbs.online && !(console.aborted)) {
write(bbs.text(NodeLstHdr));
}
writeln(format(nodelist_options.format, n + 1
,presence.node_status(node, user.is_sysop, nodelist_options)));
,presence.node_status(node, user.is_sysop, nodelist_options, n)));
users[n] = node.useron;
shown++;
}
......
......@@ -74,6 +74,7 @@ enum {
char tmp[256];
int nodefile;
int nodeexb;
#if defined(_WIN32) /* Microsoft-supplied cls() routine - ugh! */
......@@ -239,6 +240,16 @@ static char* node_connection_desc(ushort conn, char* str)
return str;
}
static char* extended_status(int num, char* str)
{
if(nodeexb < 0)
return "No extended status file open";
lseek(nodeexb, num * 128, SEEK_SET);
read(nodeexb, str, 128);
str[127] = 0;
return str;
}
/****************************************************************************/
/* Displays the information for node number 'number' contained in 'node' */
/****************************************************************************/
......@@ -280,6 +291,10 @@ void printnodedat(int number, node_t node)
break;
case NODE_QUIET:
case NODE_INUSE:
if(node.misc&NODE_EXT) {
printf("%s", extended_status(number,tmp));
break;
}
printf("User #%d",node.useron);
printf(" ");
switch(node.action) {
......@@ -494,6 +509,9 @@ int main(int argc, char **argv)
printf("\7\nError %d opening %s.\n",errno,str);
exit(1); }
sprintf(str,"%snode.exb",ctrl_dir);
nodeexb=sopen(str,O_RDWR|O_BINARY,SH_DENYNO);
sys_nodes=filelength(nodefile)/sizeof(node_t);
if(!sys_nodes) {
printf("%s reflects 0 nodes!\n",str);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment