Commit 5fd5ae24 authored by rswindell's avatar rswindell
Browse files

SBBSecho should be able to run withOUT an area file (areas.bbs file).

This requires that the AutoAddSubs=true in sbbsecho.ini (the default) and if
you don't want an area file created/updated with new subs, just set new option
AutoAddToAreaFile=false.
Both of these options default to true which is the same as the previous
behavior: if you have a link that configured to hub for a msg group, any subs
not already in the area list/file will be considered new and added dynamically.
So what's new here is that you can set SBBSecho not to create or update an
area file and SBBSecho will run just fine if no area file exists or contains no
area definitions.
Incremented version to 3.09.
parent 0adab6d2
......@@ -1754,10 +1754,10 @@ int main(int argc, char **argv)
" (`---`) existing in outgoing EchoMail message text to `===`.\n"
" This setting defaults to `No`.\n"
"\n"
"`Automatically Add New Subs to Area File`, when set to `Yes`, enables\n"
"`Automatically Add New Subs to Area List`, when enabled, instructs\n"
" SBBSecho to detect newly added Sub-boards in any Message Groups that\n"
" are listed with a `Linked Node` as their hub/uplink and add those\n"
" Sub-boards as new areas in your Area File.\n"
" are listed with a `Linked Node` as their hub/uplink and add those new\n"
" Sub-boards as new areas to your Area List and optionally, Area File.\n"
"\n"
"`Allow Nodes to Add Areas from Area File` when set to `Yes` allows linked\n"
" nodes to add areas listed in your Area File (e.g. `areas.bbs`).\n"
......@@ -1805,8 +1805,8 @@ int main(int argc, char **argv)
,cfg.echomail_notify ? "Yes":"No");
snprintf(opt[i++],MAX_OPLN-1,"%-45.45s%-3.3s","Convert Existing Tear Lines"
,cfg.convert_tear ? "Yes":"No");
snprintf(opt[i++],MAX_OPLN-1,"%-45.45s%-3.3s","Automatically Add New Subs "
"to Area File",cfg.auto_add_subs ? "Yes":"No");
snprintf(opt[i++],MAX_OPLN-1,"%-45.45s%s","Automatically Add New Subs "
"to Area List", cfg.auto_add_subs ? (cfg.auto_add_to_areafile ? "List/File":"List Only"):"No");
snprintf(opt[i++],MAX_OPLN-1,"%-45.45s%-3.3s","Allow Nodes to Add Areas "
"from Area File",cfg.add_from_echolists_only ? "No":"Yes");
snprintf(opt[i++],MAX_OPLN-1,"%-45.45s%u","Maximum Backups to Maintain of Area File"
......@@ -1887,11 +1887,22 @@ int main(int argc, char **argv)
}
break;
case 6:
k = !cfg.auto_add_subs;
i=0;
strncpy(opt[i++], "Area List (memory) Only", MAX_OPLN-1);
strncpy(opt[i++], "Area List and Area File", MAX_OPLN-1);
strncpy(opt[i++], "No", MAX_OPLN-1);
opt[i][0] = 0;
if(!cfg.auto_add_subs)
k = 2;
else if(cfg.auto_add_to_areafile)
k = 1;
else
k = 0;
switch(uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0
,"Automatically Add New Sub-boards to Area File",uifcYesNoOpts)) {
case 0: cfg.auto_add_subs = true; break;
case 1: cfg.auto_add_subs = false; break;
,"Automatically Add New Sub-boards to Area List",opt)) {
case 0: cfg.auto_add_subs = true; cfg.auto_add_to_areafile = false; break;
case 1: cfg.auto_add_subs = true; cfg.auto_add_to_areafile = true; break;
case 2: cfg.auto_add_subs = false; break;
}
break;
case 7:
......
......@@ -228,6 +228,7 @@ void get_default_echocfg(sbbsecho_cfg_t* cfg)
cfg->areafile_backups = 100;
cfg->cfgfile_backups = 100;
cfg->auto_add_subs = true;
cfg->auto_add_to_areafile = true;
cfg->min_free_diskspace = 10*1024*1024;
}
......@@ -295,6 +296,7 @@ bool sbbsecho_read_ini(sbbsecho_cfg_t* cfg)
cfg->max_echomail_age = (ulong)iniGetDuration(ini, ROOT_SECTION, "MaxEchomailAge", cfg->max_echomail_age);
SAFECOPY(cfg->areamgr, iniGetString(ini, ROOT_SECTION, "AreaManager", "SYSOP", value));
cfg->auto_add_subs = iniGetBool(ini, ROOT_SECTION, "AutoAddSubs", cfg->auto_add_subs);
cfg->auto_add_to_areafile = iniGetBool(ini, ROOT_SECTION, "AutoAddToAreaFile", cfg->auto_add_to_areafile);
/* NetMail options: */
SAFECOPY(cfg->default_recipient, iniGetString(ini, ROOT_SECTION, "DefaultRecipient", "", value));
......@@ -527,6 +529,7 @@ bool sbbsecho_write_ini(sbbsecho_cfg_t* cfg)
iniSetBool(&ini, ROOT_SECTION, "TruncateBundles" ,cfg->trunc_bundles ,NULL);
iniSetBool(&ini, ROOT_SECTION, "AreaAddFromEcholistsOnly",cfg->add_from_echolists_only ,NULL);
iniSetBool(&ini, ROOT_SECTION, "AutoAddSubs" ,cfg->auto_add_subs ,NULL);
iniSetBool(&ini, ROOT_SECTION, "AutoAddToAreaFile" ,cfg->auto_add_to_areafile ,NULL);
iniSetDuration(&ini, ROOT_SECTION, "BsyTimeout" ,cfg->bsy_timeout ,NULL);
iniSetDuration(&ini, ROOT_SECTION, "BsoLockDelay" ,cfg->bso_lock_delay ,NULL);
iniSetLongInt(&ini, ROOT_SECTION, "BsoLockAttempts" ,cfg->bso_lock_attempts ,NULL);
......
......@@ -1882,32 +1882,9 @@ void alter_areas(str_list_t add_area, str_list_t del_area, fidoaddr_t addr, cons
free(outname);
}
bool add_sub_to_areafile(sub_t* sub, fidoaddr_t uplink)
bool add_sub_to_arealist(sub_t* sub, fidoaddr_t uplink)
{
FILE* fp;
lprintf(LOG_INFO, "Adding sub-board to Area File with uplink (%s): %s"
,smb_faddrtoa(&uplink, NULL), sub->code);
/* Back-up Area File (at most, once per invocation) */
static ulong added;
if(added++ == 0)
backup(cfg.areafile, cfg.areafile_backups, /* ren: */FALSE);
fp = fopen(cfg.areafile, fexist(cfg.areafile) ? "r+" : "w+");
if(fp == NULL) {
lprintf(LOG_ERR, "Error %d opening %s", errno, cfg.areafile);
return false;
}
/* Make sure the line we add is on a line of its own: */
int ch = EOF;
int last_ch = '\n';
while(!feof(fp)) {
if((ch = fgetc(fp)) != EOF)
last_ch = ch;
}
if(last_ch != '\n')
fputc('\n', fp);
FILE* fp = NULL;
/* Replace spaces in the sub short-name with underscores (for use as the echotag) */
char echotag[FIDO_AREATAG_LEN+1];
......@@ -1919,9 +1896,35 @@ bool add_sub_to_areafile(sub_t* sub, fidoaddr_t uplink)
REPLACE_CHARS(echotag, ' ', '_', p);
}
strupr(echotag);
fprintf(fp, "%-*s %-*s %s\n"
,LEN_EXTCODE, sub->code, FIDO_AREATAG_LEN, echotag, smb_faddrtoa(&uplink, NULL));
fclose(fp);
lprintf(LOG_INFO, "Adding sub-board (%s) to Area %s with tag %s, uplink: %s"
,sub->code, cfg.auto_add_to_areafile ? "File" : "List", echotag, smb_faddrtoa(&uplink, NULL));
if(cfg.auto_add_to_areafile) {
/* Back-up Area File (at most, once per invocation) */
static ulong added;
if(added++ == 0)
backup(cfg.areafile, cfg.areafile_backups, /* ren: */FALSE);
fp = fopen(cfg.areafile, fexist(cfg.areafile) ? "r+" : "w+");
if(fp == NULL) {
lprintf(LOG_ERR, "Error %d opening %s", errno, cfg.areafile);
return false;
}
/* Make sure the line we add is on a line of its own: */
int ch = EOF;
int last_ch = '\n';
while(!feof(fp)) {
if((ch = fgetc(fp)) != EOF)
last_ch = ch;
}
if(last_ch != '\n')
fputc('\n', fp);
fprintf(fp, "%-*s %-*s %s\n"
,LEN_EXTCODE, sub->code, FIDO_AREATAG_LEN, echotag, smb_faddrtoa(&uplink, NULL));
fclose(fp);
}
return new_area(echotag, sub->subnum, &uplink);
}
......@@ -6238,104 +6241,101 @@ int main(int argc, char **argv)
atexit(cleanup);
/******* READ IN AREAS.BBS FILE *********/
fexistcase(cfg.areafile);
printf("Reading %s",cfg.areafile);
if((stream=fopen(cfg.areafile,"r"))==NULL) {
lprintf(LOG_ERR,"ERROR %u (%s) line %d opening %s",errno,strerror(errno),__LINE__,cfg.areafile);
bail(1);
return -1;
}
cfg.areas=0; /* Total number of areas in AREAS.BBS */
cfg.area=NULL;
while(!terminated) {
if(!fgets(str,sizeof(str),stream))
break;
truncsp(str);
p=str;
SKIP_WHITESPACE(p); /* Find first printable char */
if(*p==';' || !*p) /* Ignore blank lines or start with ; */
continue;
int areanum = cfg.areas;
if(!new_area(/* tag: */NULL, /* Pass-through by default: */INVALID_SUB, /* link: */NULL)) {
lprintf(LOG_ERR,"ERROR allocating memory for area #%u.",cfg.areas + 1);
bail(1);
return -1;
}
sprintf(tmp_code,"%-.*s",LEN_EXTCODE,p);
tp=tmp_code;
FIND_WHITESPACE(tp);
*tp=0;
for(i=0;i<scfg.total_subs;i++)
if(!stricmp(tmp_code,scfg.sub[i]->code))
break;
if(i<scfg.total_subs)
cfg.area[areanum].sub = i;
else if(stricmp(tmp_code,"P")) {
printf("\n");
lprintf(LOG_WARNING,"%s: Unrecognized internal code, assumed passthru",tmp_code);
}
FIND_WHITESPACE(p); /* Skip code */
SKIP_WHITESPACE(p); /* Skip white space */
SAFECOPY(area_tag,p); /* Area tag */
truncstr(area_tag,"\t ");
strupr(area_tag);
if(area_tag[0]=='*') /* UNKNOWN-ECHO area */
cfg.badecho=areanum;
if(areanum > 0 && area_is_valid(find_area(area_tag))) {
printf("\n");
lprintf(LOG_WARNING, "DUPLICATE AREA (%s) in area file (%s), IGNORED!", area_tag, cfg.areafile);
cfg.areas--;
continue;
}
if((cfg.area[areanum].tag=strdup(area_tag))==NULL) {
printf("\n");
lprintf(LOG_ERR,"ERROR allocating memory for area #%u tag."
,areanum+1);
bail(1);
return -1;
}
FIND_WHITESPACE(p); /* Skip tag */
SKIP_WHITESPACE(p); /* Skip white space */
fexistcase(cfg.areafile);
if((stream = fopen(cfg.areafile,"r")) != NULL) {
printf("Reading %s",cfg.areafile);
while(!terminated) {
if(!fgets(str,sizeof(str),stream))
break;
truncsp(str);
p=str;
SKIP_WHITESPACE(p); /* Find first printable char */
if(*p==';' || !*p) /* Ignore blank lines or start with ; */
continue;
int areanum = cfg.areas;
if(!new_area(/* tag: */NULL, /* Pass-through by default: */INVALID_SUB, /* link: */NULL)) {
lprintf(LOG_ERR,"ERROR allocating memory for area #%u.",cfg.areas + 1);
bail(1);
return -1;
}
sprintf(tmp_code,"%-.*s",LEN_EXTCODE,p);
tp=tmp_code;
FIND_WHITESPACE(tp);
*tp=0;
for(i=0;i<scfg.total_subs;i++)
if(!stricmp(tmp_code,scfg.sub[i]->code))
break;
if(i<scfg.total_subs)
cfg.area[areanum].sub = i;
else if(stricmp(tmp_code,"P")) {
printf("\n");
lprintf(LOG_WARNING,"%s: Unrecognized internal code, assumed passthru",tmp_code);
}
while(*p && *p!=';') {
if(!isdigit(*p)) {
FIND_WHITESPACE(p); /* Skip code */
SKIP_WHITESPACE(p); /* Skip white space */
SAFECOPY(area_tag,p); /* Area tag */
truncstr(area_tag,"\t ");
strupr(area_tag);
if(area_tag[0]=='*') /* UNKNOWN-ECHO area */
cfg.badecho=areanum;
if(areanum > 0 && area_is_valid(find_area(area_tag))) {
printf("\n");
lprintf(LOG_WARNING, "Invalid Area File line, expected link address(es) after echo-tag: '%s'", str);
break;
lprintf(LOG_WARNING, "DUPLICATE AREA (%s) in area file (%s), IGNORED!", area_tag, cfg.areafile);
cfg.areas--;
continue;
}
if((cfg.area[areanum].link=(fidoaddr_t *)
realloc(cfg.area[areanum].link
,sizeof(fidoaddr_t)*(cfg.area[areanum].links+1)))==NULL) {
if((cfg.area[areanum].tag=strdup(area_tag))==NULL) {
printf("\n");
lprintf(LOG_ERR,"ERROR allocating memory for area #%u links."
lprintf(LOG_ERR,"ERROR allocating memory for area #%u tag."
,areanum+1);
bail(1);
return -1;
}
fidoaddr_t link = atofaddr(p);
cfg.area[areanum].link[cfg.area[areanum].links] = link;
if(findnodecfg(&cfg, link, /* exact: */false) == NULL) {
printf("\n");
lprintf(LOG_WARNING, "Configuration for %s-linked-node (%s) not found in %s"
,cfg.area[areanum].tag, faddrtoa(&link), cfg.cfgfile);
} else
cfg.area[areanum].links++;
FIND_WHITESPACE(p); /* Skip address */
SKIP_WHITESPACE(p); /* Skip white space */
}
#if 0
if(cfg.area[areanum].sub!=INVALID_SUB || cfg.area[areanum].links)
cfg.areas++; /* Don't allocate if no tossing */
#endif
FIND_WHITESPACE(p); /* Skip tag */
SKIP_WHITESPACE(p); /* Skip white space */
while(*p && *p!=';') {
if(!isdigit(*p)) {
printf("\n");
lprintf(LOG_WARNING, "Invalid Area File line, expected link address(es) after echo-tag: '%s'", str);
break;
}
if((cfg.area[areanum].link=(fidoaddr_t *)
realloc(cfg.area[areanum].link
,sizeof(fidoaddr_t)*(cfg.area[areanum].links+1)))==NULL) {
printf("\n");
lprintf(LOG_ERR,"ERROR allocating memory for area #%u links."
,areanum+1);
bail(1);
return -1;
}
fidoaddr_t link = atofaddr(p);
cfg.area[areanum].link[cfg.area[areanum].links] = link;
if(findnodecfg(&cfg, link, /* exact: */false) == NULL) {
printf("\n");
lprintf(LOG_WARNING, "Configuration for %s-linked-node (%s) not found in %s"
,cfg.area[areanum].tag, faddrtoa(&link), cfg.cfgfile);
} else
cfg.area[areanum].links++;
FIND_WHITESPACE(p); /* Skip address */
SKIP_WHITESPACE(p); /* Skip white space */
}
#if 0
if(cfg.area[areanum].sub!=INVALID_SUB || cfg.area[areanum].links)
cfg.areas++; /* Don't allocate if no tossing */
#endif
}
fclose(stream);
printf("\n");
lprintf(LOG_DEBUG, "Read %u areas from %s", cfg.areas, cfg.areafile);
}
fclose(stream);
printf("\n");
lprintf(LOG_DEBUG, "Read %u areas from %s", cfg.areas, cfg.areafile);
if(cfg.badecho >= 0)
lprintf(LOG_DEBUG, "Bad-echo area: %s", scfg.sub[cfg.area[cfg.badecho].sub]->code);
......@@ -6357,7 +6357,7 @@ int main(int argc, char **argv)
,/* Case-sensitive: */false) >= 0)
break;
if(hub < cfg.nodecfgs)
add_sub_to_areafile(scfg.sub[subnum], cfg.nodecfg[hub].addr);
add_sub_to_arealist(scfg.sub[subnum], cfg.nodecfg[hub].addr);
}
}
......
......@@ -42,7 +42,7 @@
#include "fidodefs.h"
#define SBBSECHO_VERSION_MAJOR 3
#define SBBSECHO_VERSION_MINOR 8
#define SBBSECHO_VERSION_MINOR 9
#define SBBSECHO_PRODUCT_CODE 0x12FF /* from http://ftsc.org/docs/ftscprod.013 */
......@@ -212,6 +212,7 @@ typedef struct {
bool ignore_netmail_local_attr;
bool relay_filtered_msgs;
bool auto_add_subs;
bool auto_add_to_areafile;
bool use_outboxes;
ulong bsy_timeout;
ulong bso_lock_attempts;
......
Supports Markdown
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