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