Commit 7cd6cc9d authored by rswindell's avatar rswindell
Browse files

Introduce "Any" as a possible (and default) "Node number" setting for

network hub call-outs and timed-events.
parent 54fecd19
/* exec.cpp */
// vi: tabstop=4
/* Synchronet command shell/module interpretter */
......
......@@ -2839,7 +2839,7 @@ void event_thread(void* arg)
sbbs->putnodedat(i,&node);
if(sbbs->cfg.node_daily[0]) {
sbbs->cfg.node_num=i;
strcpy(sbbs->cfg.node_dir, sbbs->cfg.node_path[i-1]);
SAFECOPY(sbbs->cfg.node_dir, sbbs->cfg.node_path[i-1]);
sbbs->lprintf(LOG_INFO,"Running node %d daily event",i);
sbbs->online=ON_LOCAL;
......@@ -2861,14 +2861,14 @@ void event_thread(void* arg)
/* QWK Networking Call-out semaphores */
for(i=0;i<sbbs->cfg.total_qhubs;i++) {
if(sbbs->cfg.qhub[i]->node<first_node
|| sbbs->cfg.qhub[i]->node>last_node)
if(sbbs->cfg.qhub[i]->node != NODE_ANY
&& (sbbs->cfg.qhub[i]->node<first_node || sbbs->cfg.qhub[i]->node>last_node))
continue;
if(sbbs->cfg.qhub[i]->last==-1) // already signaled
continue;
SAFEPRINTF2(str,"%sqnet/%s.now",sbbs->cfg.data_dir,sbbs->cfg.qhub[i]->id);
if(fexistcase(str)) {
strcpy(str,sbbs->cfg.qhub[i]->id);
SAFECOPY(str,sbbs->cfg.qhub[i]->id);
eprintf(LOG_INFO,"Semaphore signaled for QWK Network Hub: %s",strupr(str));
sbbs->cfg.qhub[i]->last=-1;
}
......@@ -2876,8 +2876,8 @@ void event_thread(void* arg)
/* Timed Event semaphores */
for(i=0;i<sbbs->cfg.total_events;i++) {
if((sbbs->cfg.event[i]->node<first_node
|| sbbs->cfg.event[i]->node>last_node)
if(sbbs->cfg.event[i]->node != NODE_ANY
&& (sbbs->cfg.event[i]->node<first_node || sbbs->cfg.event[i]->node>last_node)
&& !(sbbs->cfg.event[i]->misc&EVENT_EXCL))
continue; // ignore non-exclusive events for other instances
if(sbbs->cfg.event[i]->misc&EVENT_DISABLED)
......@@ -2886,7 +2886,7 @@ void event_thread(void* arg)
continue;
SAFEPRINTF2(str,"%s%s.now",sbbs->cfg.data_dir,sbbs->cfg.event[i]->code);
if(fexistcase(str)) {
strcpy(str,sbbs->cfg.event[i]->code);
SAFECOPY(str,sbbs->cfg.event[i]->code);
eprintf(LOG_INFO,"Semaphore signaled for Timed Event: %s",strupr(str));
sbbs->cfg.event[i]->last=-1;
}
......@@ -2896,8 +2896,8 @@ void event_thread(void* arg)
/* QWK Networking Call-out Events */
sbbs->event_code = "QNET";
for(i=0;i<sbbs->cfg.total_qhubs && !sbbs->terminated;i++) {
if(sbbs->cfg.qhub[i]->node<first_node ||
sbbs->cfg.qhub[i]->node>last_node)
if(sbbs->cfg.qhub[i]->node != NODE_ANY
&& (sbbs->cfg.qhub[i]->node<first_node || sbbs->cfg.qhub[i]->node>last_node))
continue;
if(check_semaphores) {
......@@ -2992,10 +2992,13 @@ void event_thread(void* arg)
close(file);
if(sbbs->cfg.qhub[i]->call[0]) {
if(sbbs->cfg.qhub[i]->node == NODE_ANY)
sbbs->cfg.node_num = startup->first_node;
else
sbbs->cfg.node_num=sbbs->cfg.qhub[i]->node;
if(sbbs->cfg.node_num<1)
sbbs->cfg.node_num=1;
strcpy(sbbs->cfg.node_dir, sbbs->cfg.node_path[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->online=ON_LOCAL;
sbbs->console|=CON_L_ECHO;
......@@ -3013,8 +3016,8 @@ void event_thread(void* arg)
/* PostLink Networking Call-out Events */
sbbs->event_code = "PostLink";
for(i=0;i<sbbs->cfg.total_phubs && !sbbs->terminated;i++) {
if(sbbs->cfg.phub[i]->node<first_node
|| sbbs->cfg.phub[i]->node>last_node)
if(sbbs->cfg.phub[i]->node != NODE_ANY
&& (sbbs->cfg.phub[i]->node<first_node || sbbs->cfg.phub[i]->node>last_node))
continue;
/* PostLink call out based on time */
tmptime=sbbs->cfg.phub[i]->last;
......@@ -3039,10 +3042,13 @@ void event_thread(void* arg)
close(file);
if(sbbs->cfg.phub[i]->call[0]) {
if(sbbs->cfg.phub[i]->node == NODE_ANY)
sbbs->cfg.node_num = startup->first_node;
else
sbbs->cfg.node_num=sbbs->cfg.phub[i]->node;
if(sbbs->cfg.node_num<1)
sbbs->cfg.node_num=1;
strcpy(sbbs->cfg.node_dir, sbbs->cfg.node_path[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->online=ON_LOCAL;
sbbs->console|=CON_L_ECHO;
......@@ -3057,15 +3063,15 @@ void event_thread(void* arg)
/* Timed Events */
for(i=0;i<sbbs->cfg.total_events && !sbbs->terminated;i++) {
if(!sbbs->cfg.event[i]->node
|| sbbs->cfg.event[i]->node>sbbs->cfg.sys_nodes)
if(sbbs->cfg.event[i]->node != NODE_ANY
&& (!sbbs->cfg.event[i]->node || sbbs->cfg.event[i]->node>sbbs->cfg.sys_nodes))
continue; // ignore events for invalid nodes
if(sbbs->cfg.event[i]->misc&EVENT_DISABLED)
continue;
if((sbbs->cfg.event[i]->node<first_node
|| sbbs->cfg.event[i]->node>last_node)
if(sbbs->cfg.event[i]->node != NODE_ANY
&& (sbbs->cfg.event[i]->node<first_node || sbbs->cfg.event[i]->node>last_node)
&& !(sbbs->cfg.event[i]->misc&EVENT_EXCL))
continue; // ignore non-exclusive events for other instances
......@@ -3088,7 +3094,7 @@ void event_thread(void* arg)
&& (sbbs->cfg.event[i]->months==0
|| sbbs->cfg.event[i]->months&(1<<now_tm.tm_mon))))
{
if(sbbs->cfg.event[i]->misc&EVENT_EXCL) { /* exclusive event */
if(sbbs->cfg.event[i]->node != NODE_ANY && (sbbs->cfg.event[i]->misc&EVENT_EXCL)) { /* exclusive event */
if(sbbs->cfg.event[i]->node<first_node
|| sbbs->cfg.event[i]->node>last_node) {
......@@ -3191,8 +3197,8 @@ void event_thread(void* arg)
continue;
}
#endif
if(sbbs->cfg.event[i]->node<first_node
|| sbbs->cfg.event[i]->node>last_node) {
if(sbbs->cfg.event[i]->node != NODE_ANY
&& (sbbs->cfg.event[i]->node<first_node || sbbs->cfg.event[i]->node>last_node)) {
sbbs->lprintf(LOG_NOTICE,"Changing node status for nodes %d through %d to WFC"
,first_node,last_node);
sbbs->cfg.event[i]->last=(time32_t)now;
......@@ -3205,17 +3211,20 @@ void event_thread(void* arg)
}
}
else {
if(sbbs->cfg.event[i]->node == NODE_ANY)
sbbs->cfg.node_num = startup->first_node;
else
sbbs->cfg.node_num=sbbs->cfg.event[i]->node;
if(sbbs->cfg.node_num<1)
sbbs->cfg.node_num=1;
strcpy(sbbs->cfg.node_dir, sbbs->cfg.node_path[sbbs->cfg.node_num-1]);
SAFECOPY(sbbs->cfg.node_dir, sbbs->cfg.node_path[sbbs->cfg.node_num-1]);
SAFEPRINTF2(str,"%s%s.now",sbbs->cfg.data_dir,sbbs->cfg.event[i]->code);
if(fexistcase(str)) {
if(remove(str))
sbbs->errormsg(WHERE, ERR_REMOVE, str, 0);
}
if(sbbs->cfg.event[i]->misc&EVENT_EXCL) {
if(sbbs->cfg.event[i]->node != NODE_ANY && (sbbs->cfg.event[i]->misc&EVENT_EXCL)) {
sbbs->getnodedat(sbbs->cfg.event[i]->node,&node,1);
node.status=NODE_EVENT_RUNNING;
sbbs->putnodedat(sbbs->cfg.event[i]->node,&node);
......@@ -3304,7 +3313,7 @@ sbbs_t::sbbs_t(ushort node_num, union xp_sockaddr *addr, size_t addr_len, const
cfg.node_num = node_num; // Restore the node_num passed to the constructor
if(node_num>0) {
strcpy(cfg.node_dir, cfg.node_path[node_num-1]);
SAFECOPY(cfg.node_dir, cfg.node_path[node_num-1]);
prep_dir(cfg.node_dir, cfg.temp_dir, sizeof(cfg.temp_dir));
SAFEPRINTF2(syspage_semfile, "%ssyspage.%u", cfg.ctrl_dir, node_num);
remove(syspage_semfile);
......
......@@ -385,6 +385,8 @@ typedef enum { /* Values for xtrn_t.event */
#define EVENT_INIT (1<<2) /* Always run event after init */
#define EVENT_DISABLED (1<<3) /* Disabled */
#define NODE_ANY 0 /* special qhub/event_t.node value */
/* Bits in xtrn_t.misc */
#define MULTIUSER (1<<0) /* allow multi simultaneous users */
#define XTRN_ANSI (1<<1) /* LEGACY (not used) */
......
/* $Id$ */
// vi: tabstop=4
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
......@@ -253,7 +254,7 @@ void net_cfg()
SAFECOPY(cfg.qhub[i]->pack,"%@zip -jD %f %s");
SAFECOPY(cfg.qhub[i]->unpack,"%@unzip -Coj %f %s -d %g");
SAFECOPY(cfg.qhub[i]->call,"*qnet-ftp %s hub.address YOURPASS");
cfg.qhub[i]->node=1;
cfg.qhub[i]->node = NODE_ANY;
cfg.qhub[i]->days=(uchar)0xff; /* all days */
uifc.changes=1;
continue;
......@@ -805,7 +806,11 @@ void qhub_edit(int num)
sprintf(opt[i++],"%-27.27s%.40s","Pack Command Line",cfg.qhub[num]->pack);
sprintf(opt[i++],"%-27.27s%.40s","Unpack Command Line",cfg.qhub[num]->unpack);
sprintf(opt[i++],"%-27.27s%.40s","Call-out Command Line",cfg.qhub[num]->call);
sprintf(opt[i++],"%-27.27s%u","Call-out Node",cfg.qhub[num]->node);
if(cfg.qhub[num]->node == NODE_ANY)
SAFECOPY(str, "Any");
else
SAFEPRINTF(str, "%u", cfg.qhub[num]->node);
sprintf(opt[i++],"%-27.27s%s","Call-out Node", str);
sprintf(opt[i++],"%-27.27s%s","Call-out Days",daystr(cfg.qhub[num]->days));
if(cfg.qhub[num]->freq) {
sprintf(str,"%u times a day",1440/cfg.qhub[num]->freq);
......@@ -915,16 +920,23 @@ void qhub_edit(int num)
,cfg.qhub[num]->call,sizeof(cfg.qhub[num]->call)-1,K_EDIT);
break;
case 4:
sprintf(str,"%u",cfg.qhub[num]->node);
if(cfg.qhub[num]->node == NODE_ANY)
SAFECOPY(str, "Any");
else
SAFEPRINTF(str, "%u", cfg.qhub[num]->node);
uifc.helpbuf=
"`Node to Perform Call-out:`\n"
"\n"
"This is the number of the node to perform the call-out for this QWK\n"
"network hub.\n"
;
uifc.input(WIN_MID|WIN_SAV,0,0
,"Node to Perform Call-out",str,3,K_EDIT|K_NUMBER);
if(uifc.input(WIN_MID|WIN_SAV,0,0
,"Node to Perform Call-out",str,3,K_EDIT) > 0) {
if(isdigit(*str))
cfg.qhub[num]->node=atoi(str);
else
cfg.qhub[num]->node = NODE_ANY;
}
break;
case 5:
j=0;
......
/* $Id$ */
// vi: tabstop=4
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
......@@ -49,7 +50,7 @@ static bool new_timed_event(unsigned new_event_num)
return false;
}
memset(new_event, 0, sizeof(*new_event));
new_event->node = 1;
new_event->node = NODE_ANY;
new_event->days = (uchar)0xff;
event_t** new_event_list = realloc(cfg.event, sizeof(event_t *)*(cfg.total_events + 1));
......@@ -483,7 +484,11 @@ void tevents_cfg()
sprintf(opt[k++],"%-32.32s%.40s","Command Line",cfg.event[i]->cmd);
sprintf(opt[k++],"%-32.32s%s","Enabled"
,cfg.event[i]->misc&EVENT_DISABLED ? "No":"Yes");
sprintf(opt[k++],"%-32.32s%u","Execution Node",cfg.event[i]->node);
if(cfg.event[i]->node == NODE_ANY)
SAFECOPY(str, "Any");
else
SAFEPRINTF(str, "%u", cfg.event[i]->node);
sprintf(opt[k++],"%-32.32s%s","Execution Node", str);
sprintf(opt[k++],"%-32.32s%s","Execution Months"
,monthstr(cfg.event[i]->months));
sprintf(opt[k++],"%-32.32s%s","Execution Days of Month"
......@@ -590,10 +595,17 @@ void tevents_cfg()
"\n"
"This is the node number to execute the timed event.\n"
;
sprintf(str,"%u",cfg.event[i]->node);
uifc.input(WIN_MID|WIN_SAV,0,0,"Node Number"
,str,3,K_EDIT|K_NUMBER);
if(cfg.event[i]->node == NODE_ANY)
SAFECOPY(str, "Any");
else
SAFEPRINTF(str, "%u", cfg.event[i]->node);
if(uifc.input(WIN_MID|WIN_SAV,0,0,"Node Number"
,str,3,K_EDIT) > 0) {
if(isdigit(*str))
cfg.event[i]->node=atoi(str);
else
cfg.event[i]->node = NODE_ANY;
}
break;
case 5:
uifc.helpbuf=
......
/* Synchronet configuration structure (scfg_t) definition */
// vi: tabstop=4
/* $Id$ */
......
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