Commit 710bb23c authored by rswindell's avatar rswindell
Browse files

Added support for custom/extended node status text.

parent 229766b4
......@@ -782,6 +782,19 @@ int opennodedat(scfg_t* cfg)
return nopen(fname, O_RDWR|O_DENYNONE);
}
/****************************************************************************/
/****************************************************************************/
int opennodeext(scfg_t* cfg)
{
char fname[MAX_PATH+1];
if(!VALID_CFG(cfg))
return -1;
SAFEPRINTF(fname, "%snode.exb", cfg->ctrl_dir);
return nopen(fname, O_RDWR|O_DENYNONE);
}
/****************************************************************************/
/* Reads the data for node number 'number' into the structure 'node' */
/* from node.dab */
......@@ -944,7 +957,22 @@ static char* node_connection_desc(ushort conn, char* str)
return str;
}
char* nodestatus(scfg_t* cfg, node_t* node, char* buf, size_t buflen)
char* getnodeext(scfg_t* cfg, int num, char* buf)
{
int f;
if(!VALID_CFG(cfg) || num < 1)
return "";
if((f = opennodeext(cfg)) < 1)
return "";
lseek(f, (num-1) * 128, SEEK_SET);
read(f, buf, 128);
close(f);
buf[127] = 0;
return buf;
}
char* nodestatus(scfg_t* cfg, node_t* node, char* buf, size_t buflen, int num)
{
char str[256];
char tmp[128];
......@@ -990,6 +1018,10 @@ char* nodestatus(scfg_t* cfg, node_t* node, char* buf, size_t buflen)
break;
case NODE_QUIET:
case NODE_INUSE:
if(node->misc & NODE_EXT) {
getnodeext(cfg, num, str);
break;
}
username(cfg,node->useron,str);
strcat(str," ");
switch(node->action) {
......@@ -1165,7 +1197,7 @@ void printnodedat(scfg_t* cfg, uint number, node_t* node)
{
char status[128];
printf("Node %2d: %s\n",number,nodestatus(cfg,node,status,sizeof(status)));
printf("Node %2d: %s\n",number,nodestatus(cfg,node,status,sizeof(status),number));
}
/****************************************************************************/
......
......@@ -83,9 +83,10 @@ DLLEXPORT uint getage(scfg_t*, char *birthdate);
DLLEXPORT char* username(scfg_t*, int usernumber, char * str);
DLLEXPORT char* usermailaddr(scfg_t*, char* addr, const char* name);
DLLEXPORT int opennodedat(scfg_t*);
DLLEXPORT int opennodeext(scfg_t*);
DLLEXPORT int getnodedat(scfg_t*, uint number, node_t *node, BOOL lockit, int* file);
DLLEXPORT int putnodedat(scfg_t*, uint number, node_t *node, BOOL closeit, int file);
DLLEXPORT char* nodestatus(scfg_t*, node_t* node, char* buf, size_t buflen);
DLLEXPORT char* nodestatus(scfg_t*, node_t* node, char* buf, size_t buflen, int num);
DLLEXPORT void printnodedat(scfg_t*, uint number, node_t* node);
DLLEXPORT int is_user_online(scfg_t*, uint usernumber);
DLLEXPORT void packchatpass(char *pass, 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