Skip to content
Snippets Groups Projects
echocfg.c 85.1 KiB
Newer Older
rswindell's avatar
rswindell committed
									,"Unpack Command Line"
									,cfg.arcdef[i].unpack,sizeof(cfg.arcdef[i].unpack)-1
rswindell's avatar
rswindell committed

rswindell's avatar
rswindell committed
			case 6:
	"~ Domains ~\n\n"
	;
				i=0;
				while(1) {
					for(u=0; u < cfg.domain_count; u++)
						snprintf(opt[u], MAX_OPLN-1, "%-*s  %s"
							,FIDO_DOMAIN_LEN, cfg.domain_list[u].name, cfg.domain_list[u].dns_suffix);
					opt[u][0]=0;
rswindell's avatar
rswindell committed
					int mode = WIN_SAV | WIN_INS | WIN_DEL | WIN_ACT
						| WIN_INSACT | WIN_DELACT | WIN_XTR;
					if(cfg.domain_count)
						mode |= WIN_COPY | WIN_CUT;
					if(savedomain.name[0])
						mode |= WIN_PASTE | WIN_PASTEXTR;
					i=uifc.list(mode,0,0,0,&domain_opt,0,"Domains",opt);
					if(i==-1)
						break;
					int msk = i&MSK_ON;
					i &= MSK_OFF;
					if (msk == MSK_INS) {
						str[0]=0;
	uifc.helpbuf=
	"~ Domain ~\n\n"
	;
						if(uifc.input(WIN_MID|WIN_SAV,0,0
							,"FTN Domain Name", str, FIDO_DOMAIN_LEN, K_EDIT)<1)
							continue;
						if(!new_domain(i)) {
							printf("\nMemory Allocation Error\n");
rswindell's avatar
rswindell committed
							exit(1);
rswindell's avatar
rswindell committed
						continue;
					}

					if (msk == MSK_DEL || msk == MSK_CUT) {
						if(msk == MSK_CUT)
							memcpy(&savedomain, &cfg.domain_list[i], sizeof(savedomain));
						cfg.domain_count--;
						if(cfg.domain_count <= 0) {
							cfg.domain_count = 0;
rswindell's avatar
rswindell committed
							continue;
						}
						for(u=i; u < cfg.domain_count; u++)
							memcpy(&cfg.domain_list[u], &cfg.domain_list[u+1], sizeof(struct fido_domain));
rswindell's avatar
rswindell committed
						continue;
					}
					if (msk == MSK_COPY) {
						memcpy(&savedomain, &cfg.domain_list[i], sizeof(savedomain));
rswindell's avatar
rswindell committed
						continue;
					}
					if (msk == MSK_PASTE) {
						if(!new_domain(i))
							continue;
						memcpy(&cfg.domain_list[i], &savedomain, sizeof(savedomain));
rswindell's avatar
rswindell committed
						continue;
					}
					if (msk != 0)
						continue;
					while(1) {
						j=0;
						uifc.helpbuf=
						"Configuring a Domain"
						;
						snprintf(opt[j++],MAX_OPLN-1,"%-30.30s %s","Name"
							,cfg.domain_list[i].name);
						snprintf(opt[j++],MAX_OPLN-1,"%-30.30s %s","Zones"
							,int_list(cfg.domain_list[i].zone_list, cfg.domain_list[i].zone_count));
						snprintf(opt[j++],MAX_OPLN-1,"%-30.30s %s","DNS Suffix"
							,cfg.domain_list[i].dns_suffix);
						snprintf(opt[j++],MAX_OPLN-1,"%-30.30s %s","Outbound Root"
							,cfg.domain_list[i].root);
						snprintf(opt[j++],MAX_OPLN-1,"%-30.30s %s","NodeList"
							,cfg.domain_list[i].nodelist);
						opt[j][0]=0;
						SAFEPRINTF(str, "Domain - %s", cfg.domain_list[i].name);
						k=uifc.list(WIN_ACT|WIN_SAV|WIN_RHT|WIN_BOT,0,0,0,&listop,0,str,opt);
						if(k==-1)
							break;
						switch(k) {
							case 0:
								uifc.input(WIN_MID|WIN_SAV,0,0
									,"Domain Name"
									,cfg.domain_list[i].name,sizeof(cfg.domain_list[i].name)-1
									,K_EDIT);
								break;
							case 1:
								SAFECOPY(str, int_list(cfg.domain_list[i].zone_list, cfg.domain_list[i].zone_count));
								if(uifc.input(WIN_MID|WIN_SAV, 0, 0
									,"Zone List (comma-separated)"
									,str, 40, K_EDIT) >= 0) {
									FREE_AND_NULL(cfg.domain_list[i].zone_list);
									cfg.domain_list[i].zone_list = parseIntList(str, ",", &cfg.domain_list[i].zone_count);
									uifc.changes = TRUE;
								}
								break;
							case 2:
								uifc.input(WIN_MID|WIN_SAV,0,0
									,"DNS Suffix"
									,cfg.domain_list[i].dns_suffix,sizeof(cfg.domain_list[i].dns_suffix)-1
									,K_EDIT);
								break;
							case 3:
								uifc.input(WIN_MID|WIN_SAV,0,0
									,"Outbound Root Directory"
									,cfg.domain_list[i].root,sizeof(cfg.domain_list[i].root)-1
									,K_EDIT);
								break;
							case 4:
								uifc.input(WIN_MID|WIN_SAV,0,0
									,"NodeList"
									,cfg.domain_list[i].nodelist,sizeof(cfg.domain_list[i].nodelist)-1
									,K_EDIT);
								break;
rswindell's avatar
rswindell committed
	"~ EchoLists ~\n\n"
	"This feature allows you to specify lists of echoes, in `BACKBONE.NA`\n"
	"format, which are utilized in `addition` to your Area File (e.g. \n"
	"`areas.bbs`) for advanced AreaFix (Area Management) operations.\n";
					for(u=0;u<cfg.listcfgs;u++)
rswindell's avatar
rswindell committed
						snprintf(opt[u],MAX_OPLN-1,"%s",cfg.listcfg[u].listpath);
rswindell's avatar
rswindell committed
					int mode = WIN_SAV | WIN_INS | WIN_DEL | WIN_ACT
						| WIN_INSACT | WIN_DELACT | WIN_XTR;
					if(cfg.listcfgs)
						mode |= WIN_COPY | WIN_CUT;
rswindell's avatar
rswindell committed
					i=uifc.list(mode,0,0,0,&echolist_opt,0,"EchoLists",opt);
					int msk = i&MSK_ON;
					i &= MSK_OFF;
					if (msk == MSK_INS) {
						str[0]=0;
	uifc.helpbuf=
rswindell's avatar
rswindell committed
	"~ EchoList ~\n\n"
	"This is the path and filename of the echolist file you wish\n"
	"to add.\n";
						if(uifc.input(WIN_MID|WIN_SAV,0,0
rswindell's avatar
rswindell committed
							,"EchoList Path/Name",str,50,K_EDIT)<1)
							printf("\nMemory Allocation Error\n");
rswindell's avatar
rswindell committed
							exit(1);
						SAFECOPY(cfg.listcfg[i].listpath,str);
rswindell's avatar
rswindell committed
						continue;
					if (msk == MSK_DEL || msk == MSK_CUT) {
						if(msk == MSK_CUT)
							memcpy(&savlistcfg, &cfg.listcfg[i], sizeof(echolist_t));
						cfg.listcfgs--;
						if(cfg.listcfgs<=0) {
							cfg.listcfgs=0;
rswindell's avatar
rswindell committed
							continue;
						for(u=i;u<cfg.listcfgs;u++)
							memcpy(&cfg.listcfg[u],&cfg.listcfg[u+1]
								,sizeof(echolist_t));
rswindell's avatar
rswindell committed
						continue;
						memcpy(&savlistcfg,&cfg.listcfg[i],sizeof(echolist_t));
rswindell's avatar
rswindell committed
						continue;
					if (msk == MSK_PASTE) {
						if(!new_list(i))
							continue;
						memcpy(&cfg.listcfg[i],&savlistcfg,sizeof(echolist_t));
rswindell's avatar
rswindell committed
						continue;
rswindell's avatar
rswindell committed
						uifc.helpbuf=
rswindell's avatar
rswindell committed
						"Configuring an EchoList"
rswindell's avatar
rswindell committed
						;
						snprintf(opt[j++],MAX_OPLN-1,"%-30.30s %s","EchoList Path/Name"
							,cfg.listcfg[i].listpath);
rswindell's avatar
rswindell committed
						snprintf(opt[j++],MAX_OPLN-1,"%-30.30s %s","Required Key"
							,strListCombine(cfg.listcfg[i].keys, str, sizeof(str), ","));
rswindell's avatar
rswindell committed
						snprintf(opt[j++],MAX_OPLN-1,"%-30.30s %s","Hub Address"
							,(cfg.listcfg[i].hub.zone) ?
							 faddrtoa(&cfg.listcfg[i].hub) : "None");
rswindell's avatar
rswindell committed
						snprintf(opt[j++],MAX_OPLN-1,"%-30.30s %s","Forward AreaMgr Requests"
rswindell's avatar
rswindell committed
							,cfg.listcfg[i].forward ? "Yes" : "No");
rswindell's avatar
rswindell committed
						if(cfg.listcfg[i].forward) {
							snprintf(opt[j++],MAX_OPLN-1,"%-30.30s %s","AreaMgr Name"
								,cfg.listcfg[i].areamgr);
							snprintf(opt[j++],MAX_OPLN-1,"%-30.30s %s","AreaMgr Password"
								,cfg.listcfg[i].password);
						}
rswindell's avatar
rswindell committed
						SAFEPRINTF(str, "EchoList - %s", getfname(cfg.listcfg[i].listpath));
						k=uifc.list(WIN_ACT|WIN_SAV|WIN_RHT|WIN_BOT,0,0,0,&listop,0,str,opt);
rswindell's avatar
rswindell committed
								uifc.input(WIN_MID|WIN_SAV,0,0
									,"EchoList Path/Name"
									,cfg.listcfg[i].listpath,sizeof(cfg.listcfg[i].listpath)-1
									,K_EDIT);
								uifc.helpbuf=
rswindell's avatar
rswindell committed
								"~ Required Key ~\n\n"
								"These keys determine which linked nodes have access to the selected\n"
								"echolist file via AreaFix requests (e.g. query, add, remove).\n"
								"\n"
								"A linked node need only have one of the required keys to have access\n"
								"the echolist."
								;
rswindell's avatar
rswindell committed
									for(u=0; cfg.listcfg[i].keys!=NULL && cfg.listcfg[i].keys[u] != NULL;u++)
										strcpy(opt[u],cfg.listcfg[i].keys[u]);
									x=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,&x,0,"Required Key (any one of)",opt);
									if(x==-1)
										break;
									if((x&MSK_ON)==MSK_INS) {
										x&=MSK_OFF;
										str[0]=0;
										if(uifc.input(WIN_MID|WIN_SAV,0,0
rswindell's avatar
rswindell committed
											,"EchoList Key",str,SBBSECHO_MAX_KEY_LEN
											,K_EDIT|K_UPPER)<1)
											continue;
rswindell's avatar
rswindell committed
										strListInsert(&cfg.listcfg[i].keys,str,x);
rswindell's avatar
rswindell committed
										continue;
									if((x&MSK_ON)==MSK_DEL) {
										x&=MSK_OFF;
rswindell's avatar
rswindell committed
										strListRemove(&cfg.listcfg[i].keys,x);
rswindell's avatar
rswindell committed
										continue;
rswindell's avatar
rswindell committed
									SAFECOPY(str,cfg.listcfg[i].keys[x]);
rswindell's avatar
rswindell committed
										uifc.input(WIN_MID|WIN_SAV,0,0,"EchoList Keys"
rswindell's avatar
rswindell committed
											,str,SBBSECHO_MAX_KEY_LEN,K_EDIT|K_UPPER);
										strListReplace(cfg.listcfg[i].keys,x,str);
rswindell's avatar
rswindell committed
										continue;
rswindell's avatar
rswindell committed
							case 2:
								if(cfg.listcfg[i].hub.zone)
									SAFECOPY(str,faddrtoa(&cfg.listcfg[i].hub));
rswindell's avatar
rswindell committed
								else
									str[0]=0;
								uifc.input(WIN_MID|WIN_SAV,0,0
									,"Hub Address",str
									,25,K_EDIT);
								if(str[0])
									cfg.listcfg[i].hub=atofaddr(str);
								else
									memset(&cfg.listcfg[i].hub,0
										,sizeof(faddr_t));
								break;
							case 3:
								cfg.listcfg[i].forward = !cfg.listcfg[i].forward;
								break;
							case 4:
								uifc.input(WIN_MID|WIN_SAV,0,0
									,"Name to use when forwarding AreaMgr requests"
									,cfg.listcfg[i].areamgr,sizeof(cfg.listcfg[i].areamgr)-1
									,K_EDIT);
								break;
							case 5:
								uifc.input(WIN_MID|WIN_SAV,0,0
									,"Password to use when forwarding AreaMgr requests"
									,cfg.listcfg[i].password,sizeof(cfg.listcfg[i].password)-1
									,K_EDIT|K_UPPER);
								break;
rswindell's avatar
rswindell committed
				if(!sbbsecho_write_ini(&cfg))
					uifc.msg("Error saving configuration file");
				else {
					orig_cfg = cfg;
					uifc.changes = FALSE;
rswindell's avatar
rswindell committed
				break;
			case -1:
				if(uifc.changes) {
		uifc.helpbuf=
rswindell's avatar
rswindell committed
		"~ Save Configuration File ~\n\n"
		"Select `Yes` to save the config file, `No` to quit without saving,\n"
		"or hit ~ ESC ~ to go back to the menu.\n\n";
rswindell's avatar
rswindell committed
					i=0;
					i=uifc.list(WIN_MID,0,0,0,&i,0,"Save Config File",uifcYesNoOpts);
rswindell's avatar
rswindell committed
					if(i==-1) break;
					if(i) {uifc.bail(); exit(0);}
					if(!sbbsecho_write_ini(&cfg))
						uifc.msg("Error saving configuration file");