Skip to content
Snippets Groups Projects
echocfg.c 81.7 KiB
Newer Older

/* $Id$ */

/****************************************************************************
 * @format.tab-size 4		(Plain Text/Source Code File Header)			*
 * @format.use-tabs true	(see http://www.synchro.net/ptsc_hdr.html)		*
 *																			*
 * Copyright Rob Swindell - http://www.synchro.net/copyright.html			*
 *																			*
 * This program is free software; you can redistribute it and/or			*
 * modify it under the terms of the GNU General Public License				*
 * as published by the Free Software Foundation; either version 2			*
 * of the License, or (at your option) any later version.					*
 * See the GNU General Public License for more details: gpl.txt or			*
 * http://www.fsf.org/copyleft/gpl.html										*
 *																			*
 * Anonymous FTP access to the most recent released source is available at	*
 * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net	*
 *																			*
 * Anonymous CVS access to the development source and modification history	*
 * is available at cvs.synchro.net:/cvsroot/sbbs, example:					*
 * cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login			*
 *     (just hit return, no password is necessary)							*
 * cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src		*
 *																			*
 * For Synchronet coding style and modification guidelines, see				*
 * http://www.synchro.net/source.html										*
 *																			*
 * You are encouraged to submit any modifications (preferably in Unix diff	*
 * format) via e-mail to mods@synchro.net									*
 *																			*
 * Note: If this box doesn't appear square, then you need to fix your tabs.	*
 ****************************************************************************/

/* Portions written by Allen Christiansen 1994-1996 						*/

#include <stdio.h>
#undef JAVASCRIPT
/* XPDEV Headers */
#include "gen_defs.h"

#define __COLORS
#include "ciolib.h"
#include "uifc.h"
#include "sbbs.h"
rswindell's avatar
rswindell committed
sbbsecho_cfg_t cfg;
/* These correlate with the LOG_* definitions in syslog.h/gen_defs.h */
static char* logLevelStringList[] 
	= {"Emergency", "Alert", "Critical", "Error", "Warning", "Notice", "Informational", "Debugging", NULL};
rswindell's avatar
rswindell committed
void global_settings(void)
{
	static int global_opt;

	while(1) {
		int i = 0;
		char str[128];
		char duration[64];
		sprintf(opt[i++], "%-25s %s", "Mailer Type"
			,cfg.flo_mailer ? "Binkley/FLO":"ArcMail/Attach");
		sprintf(opt[i++], "%-25s %s", "Log Level", logLevelStringList[cfg.log_level]);
		sprintf(opt[i++], "%-25s %s", "Log Timestamp Format", cfg.logtime);
		sprintf(opt[i++], "%-25s %s", "Strict Packet Passwords", cfg.strict_packet_passwords ? "Enabled" : "Disabled");
		sprintf(opt[i++], "%-25s %s", "BSY Mutex File Timeout", duration_to_vstr(cfg.bsy_timeout, duration, sizeof(duration)));
		sprintf(opt[i++], "%-25s %s", "BSO Lock Attempt Delay", duration_to_vstr(cfg.bso_lock_delay, duration, sizeof(duration)));
		sprintf(opt[i++], "%-25s %lu", "BSO Lock Attempt Limit", cfg.bso_lock_attempts);
rswindell's avatar
rswindell committed
		sprintf(opt[i++], "%-25s %u", "Config File Backups", cfg.cfgfile_backups);
		sprintf(opt[i++], "%-25s %s", "BinkP Capabilities", cfg.binkp_caps);
		sprintf(opt[i++], "%-25s %s", "BinkP Sysop Name", cfg.binkp_sysop);
rswindell's avatar
rswindell committed
		opt[i][0] = 0;
		uifc.helpbuf=
			"~ Global Settings ~\n"
			"\n"
			"`Mailer Type` should normally be set to `Binkley/FLO` to enable SBBSecho's\n"
			"    \"Binkley-Style Outbound\" operating mode (a.k.a. `BSO` or `FLO` mode).\n"
			"    If you are using an `Attach`, `ArcMail`, or `FrontDoor` style FidoNet\n"
			"    mailer, then set this setting to `ArcMail/Attach`, but know that most\n"
			"    modern FidoNet mailers are Binkley-Style and therefore that mode of\n"
			"    operation in SBBSecho is more widely tested and supported.\n"
			"\n"
			"`Log Level` should normally be set to `Informational` but if you're\n"
			"    experiencing problems with SBBSecho and would like more verbose log\n"
			"    output, set this to `Debugging`. If you want less verbose logging,\n"
			"    set to higher-severity levels to reduce the number of log messages.\n"
			"\n"
			"`Log Timestmap Format` defines the format of the date/time-stamps added\n"
			"    along with each log message to the log file (e.g. sbbsecho.log).\n"
			"    The timestamp format is defined using standard C `strftime` notation.\n"
			"    The default format is: `" DEFAULT_LOG_TIME_FMT "`\n"
			"    For SBBSecho v2 timestamp format, use `%m/%d/%y %H:%M:%S`\n"
			"\n"
			"`Strict Packet Passwords`, when enabled, requires that Packet Passwords\n"
			"    must match the password for the linked-node from which the packet\n"
			"    was received, even if that linked-node has no password configured.\n"
			"    If you wish to revert to the SBBSecho v2 behavior with less strict\n"
			"    enforcement of matching packet passwords, disable this option.\n"
			"    Default: Enabled\n"
			"\n"
			"`BSY Mutex File Timeout` determines the maximum age of an existing\n"
			"    mutex file (`*.bsy`) before SBBSecho will act as though the mutex\n"
			"    file was not present.  This setting applies to the global\n"
			"    `sbbsecho.bsy` file as well as the BSO lock (`*.bsy`) files for\n"
			"    individual nodes.\n"
			"    Default: 12 hours\n"
			"\n"
			"`BSO Lock Attempt Delay` determines the amount of time between BSO\n"
			"    node lock attempts (via `*.bsy` files in the relevant outbound\n"
			"    directory).\n"
			"    Default: 10 seconds\n"
			"\n"
			"`BSO Lock Attempt Limit` determines the maximum number of BSO node lock\n"
			"    attempts before SBBSecho will give-up and move on to another node\n"
			"    to process mail.  This value multiplied by the `BSO Lock Attempt\n"
			"    Delay` should be much less than the `BSY Mutex File Timeout` value.\n"
			"    Default: 60 attempts\n"
			"\n"
			"`Config File Backups` determines the number of automatic backups of your\n"
			"    SBBSecho configuration file (e.g. `sbbsecho.ini`) that will be\n"
			"    maintained by FidoNet Config (`echocfg`) and SBBSecho AreaFix.\n"
rswindell's avatar
rswindell committed
			;

		int key = uifc.list(WIN_BOT|WIN_L2R|WIN_ACT|WIN_SAV, 0, 0, 0, &global_opt,0, "Global Settings", opt);

		switch(key) {

			case -1:
				return;

			case 0:
				cfg.flo_mailer = !cfg.flo_mailer;
				break;

			case 1:
	uifc.helpbuf=
	"~ Log Level ~\n"
	"\n"
	"Select the minimum severity of log entries to be logged to the log file.\n"
	"The default/normal setting is `Informational`.";
				int i = cfg.log_level;
				i = uifc.list(WIN_MID|WIN_SAV,0,0,0,&i,0,"Log Level",logLevelStringList);
				if(i>=0 && i<=LOG_DEBUG)
					cfg.log_level=i;
				break;

			case 2:
				uifc.input(WIN_MID|WIN_SAV,0,0
					,"Log Timestamp Format", cfg.logtime, sizeof(cfg.logtime)-1, K_EDIT);
				break;

			case 3:
				cfg.strict_packet_passwords = !cfg.strict_packet_passwords;
				break;

			case 4:
				duration_to_vstr(cfg.bsy_timeout, duration, sizeof(duration));
				if(uifc.input(WIN_MID|WIN_SAV, 0, 0, "BSY Mutex File Timeout", duration, 10, K_EDIT) > 0)
					cfg.bsy_timeout = (ulong)parse_duration(duration);
				break;

rswindell's avatar
rswindell committed
				duration_to_vstr(cfg.bso_lock_delay, duration, sizeof(duration));
				if(uifc.input(WIN_MID|WIN_SAV, 0, 0, "Delay Between BSO Lock Attempts", duration, 10, K_EDIT) > 0)
					cfg.bso_lock_delay = (ulong)parse_duration(duration);
				break;

				sprintf(str, "%lu", cfg.bso_lock_attempts);
rswindell's avatar
rswindell committed
				if(uifc.input(WIN_MID|WIN_SAV, 0, 0, "Maximum BSO Lock Attempts", str, 5, K_EDIT|K_NUMBER) > 0)
					cfg.bso_lock_attempts = atoi(str);
				break;

rswindell's avatar
rswindell committed
				sprintf(str, "%u", cfg.cfgfile_backups);
				if(uifc.input(WIN_MID|WIN_SAV, 0, 0, "Configuration File Backups", str, 5, K_EDIT|K_NUMBER) > 0)
					cfg.cfgfile_backups = atoi(str);
				break;

			case 8:
				uifc.input(WIN_MID|WIN_SAV,0,0
					,"BinkP Capabilities", cfg.binkp_caps, sizeof(cfg.binkp_caps)-1, K_EDIT);
				break;

			case 9:
				uifc.input(WIN_MID|WIN_SAV,0,0
					,"BinkP Sysop Name", cfg.binkp_sysop, sizeof(cfg.binkp_sysop)-1, K_EDIT);
				break;
static bool new_node(unsigned new_nodenum)
{
	nodecfg_t* nodecfg = realloc(cfg.nodecfg, sizeof(nodecfg_t)*(cfg.nodecfgs+1));
	
	if(nodecfg == NULL)
		return false;

	cfg.nodecfg = nodecfg;
	for(unsigned int i=cfg.nodecfgs; i > new_nodenum; i--)
		memcpy(&cfg.nodecfg[i], &cfg.nodecfg[i-1], sizeof(nodecfg_t));

	cfg.nodecfgs++;
	memset(&cfg.nodecfg[new_nodenum], 0, sizeof(nodecfg_t));
	return true;
}

static bool new_arcdef(unsigned new_arcnum)
{
	arcdef_t * arcdef = realloc(cfg.arcdef, sizeof(arcdef_t)*(cfg.arcdefs+1));

	if(arcdef == NULL)
		return false;

	cfg.arcdef = arcdef;

	for(unsigned j=cfg.arcdefs;j>new_arcnum;j--)
		memcpy(&cfg.arcdef[j],&cfg.arcdef[j-1], sizeof(arcdef_t));
	cfg.arcdefs++;
	memset(&cfg.arcdef[new_arcnum], 0, sizeof(arcdef_t));
	return true;
}

static bool new_list(unsigned new_listnum)
{
	echolist_t *listcfg = realloc(cfg.listcfg, sizeof(echolist_t)*(cfg.listcfgs+1));

	if(listcfg == NULL)
		return false;
	cfg.listcfg = listcfg;
	for(unsigned j=cfg.listcfgs;j>new_listnum;j--)
		memcpy(&cfg.listcfg[j],&cfg.listcfg[j-1], sizeof(echolist_t));
	cfg.listcfgs++;
	memset(&cfg.listcfg[new_listnum],0,sizeof(echolist_t));
	return true;
}

static bool new_domain(unsigned new_domnum)
{
	struct fido_domain* new_list = realloc(cfg.domain_list, sizeof(struct fido_domain) * (cfg.domain_count + 1));
	if(new_list == NULL)
		return false;
	cfg.domain_list = new_list;
	for(unsigned i = cfg.domain_count; i > new_domnum; i--)
		memcpy(&cfg.domain_list[i], &cfg.domain_list[i-1], sizeof(struct fido_domain));
	cfg.domain_count++;
	memset(&cfg.domain_list[new_domnum], 0, sizeof(struct fido_domain));
	return true;
}

static char* int_list(int* list, unsigned count)
{
	static char str[128];

	str[0]=0;
	for(unsigned i = 0; i < count; i++) {
		if(i)
			sprintf(str + strlen(str), ",%d", *(list + i));
		else
			sprintf(str, "%d", *list);
	}

	return str;
}

void binkp_settings(nodecfg_t* node)
{

	while(1) {
		char str[128];
		int i = 0;
		sprintf(opt[i++], "%-20s %s", "Host", node->binkp_host);
		sprintf(opt[i++], "%-20s %u", "Port", node->binkp_port);
		sprintf(opt[i++], "%-20s %s", "Poll", node->binkp_poll ? "Yes" : "No");
		sprintf(opt[i++], "%-20s %s", "Allow Plain Auth", node->binkp_allowPlainAuth ? "Yes" : "No");
		sprintf(opt[i++], "%-20s %s", "Allow Plain Text", node->binkp_allowPlainText ? "Yes" : "No");
		sprintf(opt[i++], "%-20s %s", "Source Address", node->binkp_src);
		opt[i][0]=0;
		char title[128];
		SAFEPRINTF(title, "%s BinkP Settings", faddrtoa(&node->addr));
		int k = uifc.list(WIN_RHT|WIN_BOT|WIN_SAV|WIN_ACT,0,0,0,&cur,0, title, opt);
		if(k < 0)
			break;
		switch(k) {
			case 0:
				uifc.input(WIN_MID|WIN_SAV,0,0
					,"Host name or IP address", node->binkp_host, sizeof(node->binkp_host)-1, K_EDIT);
				break;
			case 1:
				sprintf(str, "%u", node->binkp_port);
				if(uifc.input(WIN_MID|WIN_SAV,0,0
					,"TCP Port Number (e.g. 24554)", str, 5, K_EDIT|K_NUMBER) > 0) {
					node->binkp_port = atoi(str);
					uifc.changes = TRUE;
				}
				break;
			case 2:
				k = !node->binkp_poll;
				switch(uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0
					,"Poll This Node Periodically for Inbound Files/Mail",uifcYesNoOpts)) {
					case 0:	node->binkp_poll = true;	uifc.changes=TRUE; break;
					case 1:	node->binkp_poll = false;	uifc.changes=TRUE; break;
				}
				break;
			case 3:
				k = !node->binkp_allowPlainAuth;
				strcpy(opt[0], "CRAM-MD5 or Plain Password");
				strcpy(opt[1], "CRAM-MD5 Only");
				opt[2][0] = 0;
				switch(uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0
					,"Inbound Authentication",opt)) {
					case 0:	node->binkp_allowPlainAuth = true;	uifc.changes=TRUE; break;
					case 1:	node->binkp_allowPlainAuth = false;	uifc.changes=TRUE; break;
				}
				break;
			case 4:
				k = !node->binkp_allowPlainText;
				switch(uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0
					,"Allow Plain-Text (Unencrypted) Sessions",uifcYesNoOpts)) {
					case 0:	node->binkp_allowPlainText = true;	uifc.changes=TRUE; break;
					case 1:	node->binkp_allowPlainText = false;	uifc.changes=TRUE; break;
				}
				break;
			case 5:
				uifc.helpbuf=
				"~ Source Address ~\n\n"
				"This is the FidoNet style address to use as the source address when\n"
				"conducting BinkP sessions with this linked node.";
				uifc.input(WIN_MID|WIN_SAV,0,0
					,"Source Node Address (optional)"
					,node->binkp_src
					,sizeof(node->binkp_src)-1, K_EDIT);
				break;
		}
	}
}

int main(int argc, char **argv)
{
	char str[256],*p;
rswindell's avatar
rswindell committed
	int i,j,k,x,dflt,nodeop=0,packop=0,listop=0;
	echolist_t savlistcfg;
	nodecfg_t savnodecfg;
	arcdef_t savarcdef;
	int		ciolib_mode=CIOLIB_MODE_AUTO;
rswindell's avatar
rswindell committed
	unsigned int u;
	char	sysop_aliases[256];
	sbbsecho_cfg_t orig_cfg;
	ZERO_VAR(savlistcfg);
	ZERO_VAR(savnodecfg);
	ZERO_VAR(savarcdef);
	fprintf(stderr,"\nSynchronet FidoNet Configuration  Version %u.%02u  Copyright %s "
		"Rob Swindell\n\n",SBBSECHO_VERSION_MAJOR, SBBSECHO_VERSION_MINOR, __DATE__+7);
rswindell's avatar
rswindell committed
	memset(&cfg,0,sizeof(cfg));
	str[0]=0;
	for(i=1;i<argc;i++) {
		if(argv[i][0]=='-')
			switch(toupper(argv[i][1])) {
rswindell's avatar
rswindell committed
					printf("NOTICE: The -d option is deprecated, use -id instead\n");
					SLEEP(2000);
                    door_mode=TRUE;
                    break;
                case 'L':
                    uifc.scrn_len=atoi(argv[i]+2);
                    break;
                case 'E':
                    uifc.esc_delay=atoi(argv[i]+2);
                    break;
					switch(toupper(argv[i][2])) {
						case 'A':
							ciolib_mode=CIOLIB_MODE_ANSI;
							break;
						case 'C':
							ciolib_mode=CIOLIB_MODE_CURSES;
							break;
						case 0:
rswindell's avatar
rswindell committed
							printf("NOTICE: The -i option is deprecated, use -if instead\n");
							SLEEP(2000);
						case 'F':
							ciolib_mode=CIOLIB_MODE_CURSES_IBM;
							break;
						case 'X':
							ciolib_mode=CIOLIB_MODE_X;
							break;
						case 'W':
							ciolib_mode=CIOLIB_MODE_CONIO;
							break;
						case 'D':
		                    door_mode=TRUE;
		                    break;
						default:
							goto USAGE;
					}
				case 'K':	/* Keyboard-only mode (no mouse support) */
					uifc.mode |= UIFC_NOMOUSE;
					break;
		        case 'M':   /* Monochrome mode */
        			uifc.mode|=UIFC_MONO;
                    break;
                case 'C':
        			uifc.mode|=UIFC_COLOR;
                    break;
                case 'V':
                    textmode(atoi(argv[i]+2));
                default:
					USAGE:
rswindell's avatar
rswindell committed
                    printf("usage: echocfg [path/to/sbbsecho.ini] [options]"
                        "\n\noptions:\n\n"
rswindell's avatar
rswindell committed
						"-k  =  keyboard mode only (no mouse support)\n"
                        "-c  =  force color mode\n"
						"-m  =  force monochrome mode\n"
                        "-e# =  set escape delay to #msec\n"
						"-iX =  set interface mode to X (default=auto) where X is one of:\n"
#ifdef __unix__
rswindell's avatar
rswindell committed
						"       X = X11 mode\n"
						"       C = Curses mode\n"
						"       F = Curses mode with forced IBM charset\n"
rswindell's avatar
rswindell committed
						"       W = Win32 native mode\n"
rswindell's avatar
rswindell committed
						"       A = ANSI mode\n"
						"       D = standard input/output/door mode\n"
                        "-v# =  set video mode to # (default=auto)\n"
                        "-l# =  set screen lines to # (default=auto-detect)\n"
			SAFECOPY(str,argv[i]);
		p=getenv("SBBSCTRL");
		if(!p) {
			p=getenv("SBBSNODE");
			if(!p) {
				goto USAGE;
			backslash(str);
			SAFECAT(str,"../ctrl/sbbsecho.ini"); 
			backslash(str);
			SAFECAT(str,"sbbsecho.ini"); 
rswindell's avatar
rswindell committed
	SAFECOPY(cfg.cfgfile,str);
rswindell's avatar
rswindell committed
	if(!sbbsecho_read_ini(&cfg)) {
		fprintf(stderr, "ERROR %d (%s) reading %s\n", errno, strerror(errno), cfg.cfgfile);
		exit(1);
	}
	orig_cfg = cfg;
rswindell's avatar
rswindell committed
	if((opt=(char **)malloc(sizeof(char *)*1000))==NULL) {
		puts("memory allocation error\n");
rswindell's avatar
rswindell committed
	for(i=0;i<1000;i++)
		if((opt[i]=(char *)malloc(MAX_OPLN+1))==NULL) {
			puts("memory allocation error\n");
	uifc.size=sizeof(uifc);
	if(!door_mode) {
		i=initciolib(ciolib_mode);
		if(i!=0) {
    		printf("ciolib library init returned error %d\n",i);
    		exit(1);
		}
    	i=uifcini32(&uifc);  /* curses/conio/X/ANSI */
	}
    	i=uifcinix(&uifc);  /* stdio */

	if(i!=0) {
		printf("uifc library init returned error %d\n",i);
		exit(1);
	}

rswindell's avatar
rswindell committed
	uifc.timedisplay = NULL;
	sprintf(str,"Synchronet FidoNet Config v%u.%02u",SBBSECHO_VERSION_MAJOR, SBBSECHO_VERSION_MINOR);
	uifc.scrn(str);
rswindell's avatar
rswindell committed
	p=cfg.cfgfile;
	if(strlen(p) + strlen(str) + 4 > uifc.scrn_width)
		p=getfname(cfg.cfgfile);
	uifc.printf(uifc.scrn_width-(strlen(p)+1),1,uifc.bclr|(uifc.cclr<<4),p);
rswindell's avatar
rswindell committed
	/* Remember current menu item selections using these vars: */
	int netmail_opt = 0;
	int echomail_opt = 0;
	int path_opt = 0;
	int node_opt = 0;
rswindell's avatar
rswindell committed
	int archive_opt = 0;
	int echolist_opt = 0;
rswindell's avatar
rswindell committed
		if(memcmp(&cfg, &orig_cfg, sizeof(cfg)) != 0)
			uifc.changes = TRUE;
rswindell's avatar
rswindell committed
	"This program allows you to easily configure the Synchronet BBS\n"
	"FidoNet-style EchoMail program known as `SBBSecho` and the FidoNet/BinkP\n"
	"mailer known as `BinkIT`.  Alternatively, you may edit the configuration\n"
	"file (e.g. `ctrl/sbbsecho.ini`) using an ASCII/plain-text editor.\n"
rswindell's avatar
rswindell committed
	"\n"
	"For detailed documentation, see `http://wiki.synchro.net/util:sbbsecho`\n"
	"                            and `http://wiki.synchro.net/module:binkit`\n"
rswindell's avatar
rswindell committed
	"\n"
	"The `Global Settings` sub-menu is where FidoNet configuration settings\n"
rswindell's avatar
rswindell committed
	"are located which are neither NetMail nor EchoMail specific, but more\n"
	"general to the operation of the tosser (SBBSecho) and mailer (BinkIT).\n"
rswindell's avatar
rswindell committed
	"\n"
	"The `Linked Nodes` sub-menu is where you configure your FidoNet-style\n"
	"links: other FidoNet-style nodes/systems you regularly connect with\n"
	"to exchange mail/files.\n"
	"\n"
	"The `Archive Types` sub-menu is where you configure your archive\n"
	"programs (a.k.a. \"packers\") used for the packing and unpacking of\n"
	"EchoMail bundle files (usually in 'zip' format).\n"
	"\n"
	"The `NetMail Settings` sub-menu is where you configure settings specific\n"
	"to NetMail (private one-on-one networked mail).\n"
	"\n"
	"The `EchoMail Settings` sub-menu is where you configure settings specific\n"
	"to EchoMail (public group discussions in topical message areas, echoes).\n"
	"\n"
	"The `Paths and Filenames` sub-menu is where you configure your system's\n"
	"directory and file paths used by SBBSecho.\n"
	"\n"
	"The `EchoLists` sub-menu is for configuring additional (optional)\n"
	"lists of FidoNet-style message areas (echoes) in `BACKBONE.NA` file\n"
	"format.  These lists, if configured, are used in addition to your main\n"
	"`Area File` (e.g. areas.bbs) for advanced AreaFix/AreaMgr operations."
rswindell's avatar
rswindell committed
	;
rswindell's avatar
rswindell committed
		sprintf(opt[i++],"Global Settings...");
rswindell's avatar
rswindell committed
		sprintf(opt[i++],"Linked Nodes...");
		sprintf(opt[i++],"Archive Types...");
		sprintf(opt[i++],"NetMail Settings...");
		sprintf(opt[i++],"EchoMail Settings...");
rswindell's avatar
rswindell committed
		sprintf(opt[i++],"Paths and Filenames...");
rswindell's avatar
rswindell committed
		sprintf(opt[i++],"EchoLists...");
rswindell's avatar
rswindell committed
		if(uifc.changes)
			snprintf(opt[i++],MAX_OPLN-1,"Save Changes to %s", getfname(cfg.cfgfile));
rswindell's avatar
rswindell committed
		opt[i][0]=0;
rswindell's avatar
rswindell committed
		switch(uifc.list(WIN_ORG|WIN_MID|WIN_ACT|WIN_ESC,0,0,0,&dflt,0
rswindell's avatar
rswindell committed
				global_settings();
rswindell's avatar
rswindell committed
					uifc.helpbuf=
rswindell's avatar
rswindell committed
	"~ Linked Nodes ~\n\n"
	"From this menu you can configure the settings for your linked\n"
	"FidoNet-style nodes (uplinks and downlinks).\n"
	"\n"
	"A single node configuration can represent one node or a collection\n"
	"of nodes, by using the `ALL` wildcard word.\n"
	"\n"
	"The hexadecimal numbers in parentheses are provided as an aide when\n"
	"correlating FidoNet files and BSO directories with node numbers."
rswindell's avatar
rswindell committed
	;

rswindell's avatar
rswindell committed
					for(u=0;u<cfg.nodecfgs;u++) {
						char hexaddr[16] = "";
						if(cfg.nodecfg[u].addr.zone != 0xffff) {
							if(!faddr_contains_wildcard(&cfg.nodecfg[u].addr))
								sprintf(hexaddr, "(%04hx%04hx)", cfg.nodecfg[u].addr.net,cfg.nodecfg[u].addr.node);
							else
								sprintf(hexaddr, "(.%03X)", cfg.nodecfg[u].addr.zone);
						}
						snprintf(opt[u], MAX_OPLN-1, "%-16s %-10s  %s"
rswindell's avatar
rswindell committed
							,faddrtoa(&cfg.nodecfg[u].addr), hexaddr
							,cfg.nodecfg[u].name[0] ? cfg.nodecfg[u].name : cfg.nodecfg[u].comment);
					}
					int mode = WIN_SAV | WIN_INS | WIN_DEL | WIN_ACT 
						| WIN_INSACT | WIN_DELACT | WIN_XTR;
					if(cfg.nodecfgs)
						mode |= WIN_COPY | WIN_CUT;
					i=uifc.list(mode,0,0,0,&node_opt,NULL,"Linked Nodes",opt);
					int msk = i&MSK_ON;
					i &= MSK_OFF;
					if (msk == MSK_INS) {
						str[0]=0;
	uifc.helpbuf=
rswindell's avatar
rswindell committed
	"~ Address ~\n\n"
	"This is the FidoNet style address of the node you wish to add (3D or 4D).\n"
	"The `ALL` wildcard may be usd for portions of the address.\n"
	;
rswindell's avatar
rswindell committed
						if(uifc.input(WIN_MID|WIN_SAV,0,0
							,"Node Address (ALL wildcard allowed)",str
							,25,K_EDIT)<1)
							continue;
							printf("\nMemory Allocation Error\n");
rswindell's avatar
rswindell committed
						cfg.nodecfg[i].addr=atofaddr(str);
						uifc.changes=TRUE;
					if (msk == MSK_DEL || msk == MSK_CUT) {
						if(msk == MSK_CUT)
							memcpy(&savnodecfg, &cfg.nodecfg[i], sizeof(nodecfg_t));
						cfg.nodecfgs--;
						if(cfg.nodecfgs<=0) {
							cfg.nodecfgs=0;
						for(u=i;u<cfg.nodecfgs;u++)
							memcpy(&cfg.nodecfg[u],&cfg.nodecfg[u+1]
								,sizeof(nodecfg_t));
rswindell's avatar
rswindell committed
						uifc.changes=TRUE;
						memcpy(&savnodecfg,&cfg.nodecfg[i],sizeof(nodecfg_t));
					if (msk == MSK_PASTE) {
						if(!new_node(i))
							continue;
						memcpy(&cfg.nodecfg[i],&savnodecfg,sizeof(nodecfg_t));
rswindell's avatar
rswindell committed
						uifc.changes=TRUE;
					while(1) {
	uifc.helpbuf=
rswindell's avatar
rswindell committed
	"~ Linked Node Settings ~\n"
	"\n"
	"`Address` is the FidoNet-style address in the Zone:Net/Node (3D) or\n"
	"    Zone:Net/Node.Point (4D) format. The wildcard word '`ALL`' may be used\n"
	"    in place of one of the fields to create a node configuration which\n"
	"    will apply to *all* nodes matching that address pattern.\n"
	"    e.g. '`1:ALL`' matches all nodes within FidoNet Zone 1.\n"
	"\n"
rswindell's avatar
rswindell committed
	"`Name` is name of the system operator of the configured node. This is\n"
	"    as the destination name for AreaFix Notification NetMail messages.\n"
	"\n"
rswindell's avatar
rswindell committed
	"`Comment` is a note to yourself about this node. Setting this to the\n"
rswindell's avatar
rswindell committed
	"    BBS name or official FidoNet title corresponding with the configured\n"
	"    node can be a helpful reminder to yourself later.\n"
rswindell's avatar
rswindell committed
	"\n"
	"`Archive Type` is the name of an archive type corresponding with one of\n"
	"    your configured archive types or '`None`'.  This archive type will\n"
	"    be used when creating EchoMail bundles or if `None`, raw/uncompressed\n"
	"    EchoMail packets will be sent to this node.\n"
	"    This setting may be managed by the node using AreaFix requests.\n"
	"\n"
	"`Packet Type` is the type of outbound packet generated for this node.\n"
	"    Incoming packet types are automatically detected from among the list\n"
	"    of supported packet types (`2`, `2.2`, `2e`, and `2+`).\n"
	"    The default outbound packet type is `2+`.\n"
	"\n"
	"`Packet Password` is an optional password that may be added to outbound\n"
	"    packets for this node.  Incoming packet passwords are compared with\n"
	"    this password value.  If this password is blank/empty and `Strict\n"
	"    Packet Passwords` are enabled, then incoming packets from this node\n"
	"    must also have no password.  Packet passwords are case insensitive.\n"
	"    This setting may be managed by the node using AreaFix requests.\n"
	"\n"
	"`Session Password` is the password that will be used for authenticated\n"
	"    BinkP sessions with this node. Session passwords are case sensitive.\n"
	"    This password is only used by BinkIT (if you choose to use it).\n"
	"\n"
rswindell's avatar
rswindell committed
	"`TIC File Password` is an optional password that may be configured here\n"
	"    (and in your `sbbsecho.ini` file) for use by `tickit.js` when creating\n"
rswindell's avatar
rswindell committed
	"    or authenticating `.TIC` files.\n"
	"    This setting may be managed by the node using AreaFix requests.\n"
	"\n"
rswindell's avatar
rswindell committed
	"`AreaFix Support` is a toggle that determines whether or not this node\n"
	"    may send AreaFix NetMail requests to your system to perform remote\n"
	"    area management.\n"
	"\n"
	"`AreaFix Password` is an optional password used to authenticate inbound\n"
	"    AreaFix NetMail requests (Remote Area Management) from this node.\n"
rswindell's avatar
rswindell committed
	"    AreaFix Passwords are case insensitive.\n"
	"    This setting may be managed by the node using AreaFix requests.\n"
	"\n"
rswindell's avatar
rswindell committed
	"`EchoList Keys` is a list of keys which enable AreaFix access to one or\n"
rswindell's avatar
rswindell committed
	"    more additional EchoLists.\n"
	"\n"
	"`Status` is the default mode for sending mail to this node: `Normal`, `Hold`\n"
	"    (wait for pickup) or `Crash` (immediate).\n"
	"\n"
	"`Direct` determines whether to connect to this node directly (whenever\n"
	"    possible) when sending mail to this node.\n"
	"\n"
	"`Passive` is used to temporarily disable (pause) the packing and sending\n"
	"    of EchoMail for this node.  The opposite of Passive is `Active`.\n"
	"    This setting may be managed by the node using AreaFix requests.\n"
	"\n"
	"`Send Notify List` is used to flag nodes that you want notified via\n"
	"    NetMail of their current AreaFix settings whenever SBBSecho is run\n"
	"    with the '`G`' option.\n"
	"\n"
	"`Uplink for Message Groups` is an optional list of Message Groups (short\n"
	"    names) for which this node is a hub/uplink for your system.  This\n"
	"    setting is used in combination with the `Auto Add Sub-boards` feature\n"
	"    to auto-link hubs with the newly added areas in your Area File.\n"
	"\n"
	"`Route To` is only used in Binkley-Style Outbound (BSO/FLO) operating\n"
	"    mode and is used to set the FTN address to route mail for this node.\n"
	"\n"
	"`Inbox Directory` is only used in BSO operating mode and is an optional\n"
	"    alternate directory to search for incoming files from this node\n"
	"    (e.g. used in combination with BinkD's ibox setting).\n"
	"\n"
	"`Outbox Directory` is only used in BSO operating mode and is an optional\n"
	"    alternate directory to place outbound files for this node (e.g. used\n"
	"    in combination with BinkD's obox setting).\n"
	"\n"
	"`BinkP Settings` are settings specific to BinkP/BinkIT mailer operation.\n"
rswindell's avatar
rswindell committed
	;
rswindell's avatar
rswindell committed
						snprintf(opt[j++],MAX_OPLN-1,"%-30.30s %s","Address"
							,faddrtoa(&cfg.nodecfg[i].addr));
						snprintf(opt[j++],MAX_OPLN-1,"%-30.30s %s","Domain"
							,cfg.nodecfg[i].domain);
rswindell's avatar
rswindell committed
						snprintf(opt[j++],MAX_OPLN-1,"%-30.30s %s","Name"
							,cfg.nodecfg[i].name);
rswindell's avatar
rswindell committed
						snprintf(opt[j++],MAX_OPLN-1,"%-30.30s %s","Comment"
							,cfg.nodecfg[i].comment);
						snprintf(opt[j++],MAX_OPLN-1,"%-30.30s %s","Archive Type"
							,cfg.nodecfg[i].archive ==  SBBSECHO_ARCHIVE_NONE ?
							"None":cfg.nodecfg[i].archive->name);
						snprintf(opt[j++],MAX_OPLN-1,"%-30.30s %s","Packet Type"
							,pktTypeStringList[cfg.nodecfg[i].pkt_type]);
						snprintf(opt[j++],MAX_OPLN-1,"%-30.30s %s","Packet Password"
							,cfg.nodecfg[i].pktpwd);
						snprintf(opt[j++],MAX_OPLN-1,"%-30.30s %s","Session Password"
							,cfg.nodecfg[i].sesspwd);
						snprintf(opt[j++],MAX_OPLN-1,"%-30.30s %s","TIC File Password"
							,cfg.nodecfg[i].ticpwd);
rswindell's avatar
rswindell committed
						snprintf(opt[j++],MAX_OPLN-1,"%-30.30s %s","AreaFix Support"
							,cfg.nodecfg[i].areafix ? "Yes" : "No");
						snprintf(opt[j++],MAX_OPLN-1,"%-30.30s %s","AreaFix Password"
							,cfg.nodecfg[i].password);
rswindell's avatar
rswindell committed
						snprintf(opt[j++],MAX_OPLN-1,"%-30.30s %s","EchoList Keys"
rswindell's avatar
rswindell committed
							,strListCombine(cfg.nodecfg[i].keys,str,sizeof(str),","));
						snprintf(opt[j++],MAX_OPLN-1,"%-30.30s %s","Status"
							,mailStatusStringList[cfg.nodecfg[i].status]);
						snprintf(opt[j++],MAX_OPLN-1,"%-30.30s %s","Direct"
							,cfg.nodecfg[i].direct ? "Yes":"No");
						snprintf(opt[j++],MAX_OPLN-1,"%-30.30s %s","Passive"
							,cfg.nodecfg[i].passive ? "Yes":"No");
						snprintf(opt[j++],MAX_OPLN-1,"%-30.30s %s","Send Notify List"
							,cfg.nodecfg[i].send_notify ? "Yes" : "No");
rswindell's avatar
rswindell committed
						snprintf(opt[j++],MAX_OPLN-1,"%-30.30s %s","Uplink for Message Groups"
							,strListCombine(cfg.nodecfg[i].grphub,str,sizeof(str),","));
rswindell's avatar
rswindell committed
						if(cfg.flo_mailer) {
							snprintf(opt[j++],MAX_OPLN-1,"%-30.30s %s","Route To"
								,cfg.nodecfg[i].route.zone
rswindell's avatar
rswindell committed
								? faddrtoa(&cfg.nodecfg[i].route) : "Disabled");
							if(!faddr_contains_wildcard(&cfg.nodecfg[i].addr)) {
								snprintf(opt[j++],MAX_OPLN-1,"%-30.30s %s", "Inbox Directory", cfg.nodecfg[i].inbox);
								snprintf(opt[j++],MAX_OPLN-1,"%-30.30s %s", "Outbox Directory", cfg.nodecfg[i].outbox);
								strcpy(opt[j++], "BinkP Settings...");
rswindell's avatar
rswindell committed
						}
rswindell's avatar
rswindell committed
						SAFEPRINTF(str, "Linked Node - %s"
rswindell's avatar
rswindell committed
							,cfg.nodecfg[i].name[0] ? cfg.nodecfg[i].name : faddrtoa(&cfg.nodecfg[i].addr));
						k=uifc.list(WIN_MID|WIN_ACT|WIN_SAV,0,0,0,&nodeop,&node_bar,str,opt);
						if(k==-1)
							break;
						switch(k) {
rswindell's avatar
rswindell committed
							case __COUNTER__:
rswindell's avatar
rswindell committed
	"~ Address ~\n\n"
	"This is the FidoNet style address of this linked node.\n";
								SAFECOPY(str,faddrtoa(&cfg.nodecfg[i].addr));
rswindell's avatar
rswindell committed
								if(uifc.input(WIN_MID|WIN_SAV,0,0
									,"Node Address (ALL wildcard allowed)",str
rswindell's avatar
rswindell committed
									,25,K_EDIT|K_UPPER)>0)
									cfg.nodecfg[i].addr=atofaddr(str);
rswindell's avatar
rswindell committed
							case __COUNTER__:
	uifc.helpbuf=
	"~ Domain ~\n\n"
	"This is the domain portion of the 5D FTN address of this linked node\n"
	"(e.g. '`fidonet`').  FTN domains are limited to 8 characters and must not\n"
	"contain the characters '@' or '.'";
								uifc.input(WIN_MID|WIN_SAV,0,0
									,"Domain"
									,cfg.nodecfg[i].domain, sizeof(cfg.nodecfg[i].domain)-1
									,K_EDIT);
								break;
							case __COUNTER__:
	uifc.helpbuf=
rswindell's avatar
rswindell committed
	"~ Name ~\n\n"
	"This is an optional NetMail destination name for the node (e.g. the sysop's name).\n"
	"This is used for AreaFix Notification NetMail messages.\n";
								uifc.input(WIN_MID|WIN_SAV,0,0
									,"Name"
									,cfg.nodecfg[i].name,sizeof(cfg.nodecfg[i].name)-1
									,K_EDIT);
								break;
							case __COUNTER__:
rswindell's avatar
rswindell committed
	"~ Comment ~\n\n"
	"This is an optional comment for the node (e.g. the sysop's name).\n"
	"This is used for informational purposes only.\n";
rswindell's avatar
rswindell committed
								uifc.input(WIN_MID|WIN_SAV,0,0
									,"Comment"
									,cfg.nodecfg[i].comment,sizeof(cfg.nodecfg[i].comment)-1
									,K_EDIT);
								break;
rswindell's avatar
rswindell committed
							case __COUNTER__:
rswindell's avatar
rswindell committed
	uifc.helpbuf=
rswindell's avatar
rswindell committed
	"~ Archive Type ~\n\n"
	"This is the archive type that will be used for compressing packets\n"
	"into archive bundles for this node.\n";
rswindell's avatar
rswindell committed
								int cur=cfg.arcdefs;
								for(u=0;u<cfg.arcdefs;u++) {
									if(cfg.nodecfg[i].archive == &cfg.arcdef[u])
										cur=u;
									strcpy(opt[u],cfg.arcdef[u].name);
rswindell's avatar
rswindell committed
								}
								strcpy(opt[u++],"None");
								opt[u][0]=0;
rswindell's avatar
rswindell committed
								k=uifc.list(WIN_RHT|WIN_SAV,0,0,0,&cur,0
									,"Archive Type",opt);
								if(k==-1)
									break;
								if((unsigned)k>=cfg.arcdefs)
rswindell's avatar
rswindell committed
									cfg.nodecfg[i].archive = SBBSECHO_ARCHIVE_NONE;
rswindell's avatar
rswindell committed
									cfg.nodecfg[i].archive = &cfg.arcdef[k];
								uifc.changes=TRUE;
rswindell's avatar
rswindell committed
							case __COUNTER__:
rswindell's avatar
rswindell committed
	"~ Packet Type ~\n\n"
	"This is the packet header type that will be used in mail packets\n"
	"created for this node.  SBBSecho defaults to creating `Type-2+` packets.\n"
	"\n"
	"`Type-2  ` packets are defined in FTS-0001.16 (Stone Age)\n"
	"`Type-2e ` packets are defined in FSC-0039.04 (Sometimes called 2+)\n"
	"`Type-2+ ` packets are defined in FSC-0048.02 (4D address support)\n"
	"`Type-2.2` packets are defined in FSC-0045.01 (5D address support)\n"
								j=cfg.nodecfg[i].pkt_type;
								k=uifc.list(WIN_RHT|WIN_SAV,0,0,0,&j,0,"Packet Type"
rswindell's avatar
rswindell committed
									,pktTypeStringList);
								if(k==-1)
									break;
								cfg.nodecfg[i].pkt_type=k;
rswindell's avatar
rswindell committed
								uifc.changes=TRUE;
rswindell's avatar
rswindell committed
							case __COUNTER__:
rswindell's avatar
rswindell committed
	"~ Packet Password ~\n\n"
	"This is an optional password that SBBSecho will place into packets\n"
	"destined for this node.\n"
	"\n"
	"Packet passwords are `case-insensitive`";
								uifc.input(WIN_MID|WIN_SAV,0,0
									,"Packet Password (optional)"
rswindell's avatar
rswindell committed
									,cfg.nodecfg[i].pktpwd,sizeof(cfg.nodecfg[i].pktpwd)-1
									,K_EDIT|K_UPPER);
rswindell's avatar
rswindell committed
							case __COUNTER__:
	"~ Session Password ~\n\n"
	"This is an optional password that BinkIT will use for authenticated\n"
	"BinkP sessions with this node.\n"
	"\n"
	"Session passwords are `case-sensitive`";
								uifc.input(WIN_MID|WIN_SAV,0,0
									,"Session Password"
									,cfg.nodecfg[i].sesspwd,sizeof(cfg.nodecfg[i].sesspwd)-1
									,K_EDIT);
								break;
							case __COUNTER__:
	uifc.helpbuf=
rswindell's avatar
rswindell committed
	"~ TIC File Password ~\n\n"
	"This is an optional password that tickit.js will use for creating\n"
rswindell's avatar
rswindell committed
	"and authenticating `.TIC` files to/from this node.\n";
								uifc.input(WIN_MID|WIN_SAV,0,0
									,"TIC File Password (optional)"
									,cfg.nodecfg[i].ticpwd,sizeof(cfg.nodecfg[i].ticpwd)-1
									,K_EDIT|K_UPPER);
								break;
rswindell's avatar
rswindell committed
							case __COUNTER__:
	uifc.helpbuf=
	"~ AreaFix Support ~\n\n"
rswindell's avatar
rswindell committed
	"If you wish for this node to be able to remotely query or change their\n"
	"configuration via `AreaFix` NetMail messages, set to option to `Yes`.\n";
rswindell's avatar
rswindell committed
								k = cfg.nodecfg[i].areafix;
								switch(uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0
									,"AreaFix Support",uifcYesNoOpts)) {
									case 0:	cfg.nodecfg[i].areafix = true;	uifc.changes=TRUE; break;
									case 1:	cfg.nodecfg[i].areafix = false;	uifc.changes=TRUE; break;
								}
								break;
							case __COUNTER__:
rswindell's avatar
rswindell committed
	"~ AreaFix Password ~\n\n"
	"This is the password that will be used by this node when doing remote\n"
	"AreaManager / AreaFix functions.\n";
								uifc.input(WIN_MID|WIN_SAV,0,0
									,"AreaFix Password"
rswindell's avatar
rswindell committed
									,cfg.nodecfg[i].password,sizeof(cfg.nodecfg[i].password)-1
									,K_EDIT|K_UPPER);
rswindell's avatar
rswindell committed
							case __COUNTER__:
rswindell's avatar
rswindell committed
	"~ EchoList Keys ~\n\n"
rswindell's avatar
rswindell committed
	"These are a named-keys to be given to this node allowing access to one\n"
	"or more of the configured `EchoLists` for remote area-add requests.\n";
rswindell's avatar
rswindell committed
									for(j=0; cfg.nodecfg[i].keys!=NULL && cfg.nodecfg[i].keys[j]!=NULL ;j++)
										strcpy(opt[j],cfg.nodecfg[i].keys[j]);
									opt[j][0]=0;
									k=uifc.list(WIN_SAV|WIN_INS|WIN_DEL|WIN_ACT|
										WIN_XTR|WIN_INSACT|WIN_DELACT|WIN_RHT
rswindell's avatar
rswindell committed
										,0,0,0,&k,0,"EchoList Keys",opt);
									if(k==-1)
										break;
									if((k&MSK_ON)==MSK_INS) {
										k&=MSK_OFF;
										if(uifc.input(WIN_MID|WIN_SAV,0,0
rswindell's avatar
rswindell committed
											,"EchoList Key",str,SBBSECHO_MAX_KEY_LEN
rswindell's avatar
rswindell committed
											,K_UPPER)<1)
rswindell's avatar
rswindell committed
										strListInsert(&cfg.nodecfg[i].keys, str, k);
										uifc.changes=TRUE;

									if((k&MSK_ON)==MSK_DEL) {
										k&=MSK_OFF;
rswindell's avatar
rswindell committed
										strListRemove(&cfg.nodecfg[i].keys, k);
										uifc.changes=TRUE;
rswindell's avatar
rswindell committed
									SAFECOPY(str,cfg.nodecfg[i].keys[k]);
rswindell's avatar
rswindell committed
									uifc.input(WIN_MID|WIN_SAV,0,0,"EchoList Key"
rswindell's avatar
rswindell committed
										,str,SBBSECHO_MAX_KEY_LEN,K_EDIT|K_UPPER);
									strListReplace(cfg.nodecfg[i].keys, k, str);
									uifc.changes=TRUE;
rswindell's avatar
rswindell committed
							case __COUNTER__:
rswindell's avatar
rswindell committed
	uifc.helpbuf=
rswindell's avatar
rswindell committed
	"~ Mail Status ~\n\n"
	"Set the mail status for this node: `Normal`, `Hold`, or `Crash`.\n";
rswindell's avatar
rswindell committed
								j=cfg.nodecfg[i].status;
								k=uifc.list(WIN_RHT|WIN_SAV,0,0,0,&j,0,"Mail Status"
									,mailStatusStringList);
								if(k==-1)
									break;
								if(cfg.nodecfg[i].status!=k) {
									cfg.nodecfg[i].status=k;
									uifc.changes=TRUE;