Skip to content
Snippets Groups Projects
echocfg.c 41.2 KiB
Newer Older
							memcpy(&cfg.listcfg[j],&cfg.listcfg[j+1]
								,sizeof(echolist_t));
						if((cfg.listcfg=(echolist_t *)realloc(cfg.listcfg
							,sizeof(echolist_t)*(cfg.listcfgs)))==NULL) {
							printf("\nMemory Allocation Error\n");
							exit(1); }
						continue; }
					if((i&MSK_ON)==MSK_GET) {
						i&=MSK_OFF;
						memcpy(&savlistcfg,&cfg.listcfg[i],sizeof(echolist_t));
						continue; }
					if((i&MSK_ON)==MSK_PUT) {
						i&=MSK_OFF;
						memcpy(&cfg.listcfg[i],&savlistcfg,sizeof(echolist_t));
						continue; }
					while(1) {
						j=0;
						sprintf(opt[j++],"%-20.20s %.19s","Echo List Path/Name"
							,cfg.listcfg[i].listpath);
						sprintf(opt[j++],"%-20.20s %s","Hub Address"
							,(cfg.listcfg[i].forward.zone) ?
							 wcfaddrtoa(&cfg.listcfg[i].forward) : "None");
						sprintf(opt[j++],"%-20.20s %s","Forward Password"
							,(cfg.listcfg[i].password[0]) ?
							 cfg.listcfg[i].password : "None");
						sprintf(opt[j++],"%-20.20s %s","Forward Requests"
							,(cfg.listcfg[i].misc&NOFWD) ? "No" : "Yes");
						str[0]=0;
						for(k=0;k<cfg.listcfg[i].numflags;k++) {
							strcat(str,cfg.listcfg[i].flag[k].flag);
							strcat(str," "); }
						sprintf(opt[j++],"%-20.20s %s","Echo List Flags",str);
						opt[j][0]=0;
						k=uifc.list(WIN_MID|WIN_ACT,0,0,60,&nodeop,0,"Echo List",opt);
						if(k==-1)
						switch(k) {
							case 0:
								strcpy(str,cfg.listcfg[i].listpath);
								if(uifc.input(WIN_MID|WIN_SAV,0,0
									,"Echo List Path/Name",str,50
									,K_EDIT)<1)
									continue;
								strcpy(cfg.listcfg[i].listpath,str);
								break;
							case 1:
								if(cfg.listcfg[i].forward.zone)
									strcpy(str,wcfaddrtoa(&cfg.listcfg[i].forward));
								else
								uifc.input(WIN_MID|WIN_SAV,0,0
									,"Hub Address",str
									,25,K_EDIT);
								if(str[0])
									cfg.listcfg[i].forward=atofaddr(str);
								else
									memset(&cfg.listcfg[i].forward,0
										,sizeof(faddr_t));
								break;
							case 2:
								uifc.input(WIN_MID|WIN_SAV,0,0
									,"Password to use when forwarding requests"
									,cfg.listcfg[i].password,25,K_EDIT|K_UPPER);
								break;
							case 3:
								cfg.listcfg[i].misc^=NOFWD;
								if(cfg.listcfg[i].misc&NOFWD)
									cfg.listcfg[i].password[0]=0;
								break;
							case 4:
								while(1) {
									for(j=0;j<cfg.listcfg[i].numflags;j++)
										strcpy(opt[j],cfg.listcfg[i].flag[j].flag);
									opt[j][0]=0;
									x=uifc.list(WIN_SAV|WIN_INS|WIN_DEL|WIN_ACT|
										WIN_XTR|WIN_INSACT|WIN_DELACT|WIN_RHT
										,0,0,0,&x,0,"Echo List Flags",opt);
									if(x==-1)
										break;
									if((x&MSK_ON)==MSK_INS) {
										x&=MSK_OFF;
										str[0]=0;
	uifc.helpbuf=
	" Echo List Flag \r\n\r\n"
	"These flags determine which nodes have access to the current\r\n"
	"echolist file\r\n";
										if(uifc.input(WIN_MID|WIN_SAV,0,0
											,"Echo List Flag",str,4
											,K_EDIT|K_UPPER)<1)
											continue;
										if((cfg.listcfg[i].flag=(flag_t *)
											realloc(cfg.listcfg[i].flag
											,sizeof(flag_t)*
											(cfg.listcfg[i].numflags+1)))==NULL) {
											printf("\nMemory Allocation Error\n");
											exit(1); }
										for(j=cfg.listcfg[i].numflags;j>x;j--)
											memcpy(&cfg.listcfg[i].flag[j]
												,&cfg.listcfg[i].flag[j-1]
												,sizeof(flag_t));
										cfg.listcfg[i].numflags++;
										memset(&cfg.listcfg[i].flag[x].flag
											,0,sizeof(flag_t));
										strcpy(cfg.listcfg[i].flag[x].flag,str);
										continue; }
									if((x&MSK_ON)==MSK_DEL) {
										x&=MSK_OFF;
										cfg.listcfg[i].numflags--;
										if(cfg.listcfg[i].numflags<=0) {
											cfg.listcfg[i].numflags=0;
											continue; }
										for(j=x;j<cfg.listcfg[i].numflags;j++)
											strcpy(cfg.listcfg[i].flag[j].flag
												,cfg.listcfg[i].flag[j+1].flag);
										if((cfg.listcfg[i].flag=(flag_t *)
											realloc(cfg.listcfg[i].flag
											,sizeof(flag_t)*
											(cfg.listcfg[i].numflags)))==NULL) {
											printf("\nMemory Allocation Error\n");
											exit(1); }
									strcpy(str,cfg.listcfg[i].flag[x].flag);
	uifc.helpbuf=
	" Echo List Flag \r\n\r\n"
	"These flags determine which nodes have access to the current\r\n"
	"echolist file\r\n";
										uifc.input(WIN_MID|WIN_SAV,0,0,"Echo List Flag"
											,str,4,K_EDIT|K_UPPER);
										strcpy(cfg.listcfg[i].flag[x].flag,str);
										continue; }
								break;
								} } }
				break;
			case -1:
	uifc.helpbuf=
	" Save Configuration File \r\n\r\n"
	"Select Yes to save the config file, No to quit without saving,\r\n"
	"or hit  ESC  to go back to the menu.\r\n\r\n";
				i=0;
				strcpy(opt[0],"Yes");
				strcpy(opt[1],"No");
				opt[2][0]=0;
				i=uifc.list(WIN_MID,0,0,0,&i,0,"Save Config File",opt);
				if(i==-1) break;
				if(i) {uifc.bail(); exit(0);}
				if((stream=fnopen(NULL,cfg.cfgfile,O_CREAT|O_TRUNC|O_WRONLY|O_TEXT))==NULL) {
					uifc.bail();
					printf("Error %d opening %s\n",errno,cfg.cfgfile);
					exit(1); 
				if(!cfg.check_path)
					fprintf(stream,"NOPATHCHECK\n");
				if(!node_swap)
					fprintf(stream,"NOSWAP\n");
				if(cfg.notify)
					fprintf(stream,"NOTIFY %u\n",cfg.notify);
				if(misc&SECURE)
					fprintf(stream,"SECURE_ECHOMAIL\n");
				if(misc&KILL_EMPTY_MAIL)
					fprintf(stream,"KILL_EMPTY\n");
				if(misc&STORE_SEENBY)
					fprintf(stream,"STORE_SEENBY\n");
				if(misc&STORE_PATH)
					fprintf(stream,"STORE_PATH\n");
				if(misc&STORE_KLUDGE)
					fprintf(stream,"STORE_KLUDGE\n");
				if(misc&FUZZY_ZONE)
					fprintf(stream,"FUZZY_ZONE\n");
				if(misc&FLO_MAILER)
					fprintf(stream,"FLO_MAILER\n");
				if(misc&ELIST_ONLY)
					fprintf(stream,"ELIST_ONLY\n");
				if(misc&STRIP_LF)
					fprintf(stream,"STRIP_LF\n");
				if(misc&TRUNC_BUNDLES)
					fprintf(stream,"TRUNC_BUNDLES\n");
				if(cfg.areafile[0])
					fprintf(stream,"AREAFILE %s\n",cfg.areafile);
				if(cfg.logfile[0])
					fprintf(stream,"LOGFILE %s\n",cfg.logfile);
				if(cfg.log!=LOG_DEFAULTS) {
					if(cfg.log==0xffffffffUL)
						fprintf(stream,"LOG ALL\n");
					else if(cfg.log==0L)
						fprintf(stream,"LOG NONE\n");
					else
						fprintf(stream,"LOG %08lX\n",cfg.log); }
				fprintf(stream,"LOG_LEVEL %u\n",cfg.log_level);
				if(cfg.inbound[0])
					fprintf(stream,"INBOUND %s\n",cfg.inbound);
				if(cfg.secure[0])
					fprintf(stream,"SECURE_INBOUND %s\n",cfg.secure);
				if(cfg.outbound[0])
					fprintf(stream,"OUTBOUND %s\n",cfg.outbound);
				if(cfg.maxbdlsize!=DFLT_BDL_SIZE)
					fprintf(stream,"ARCSIZE %lu\n",cfg.maxbdlsize);
				if(cfg.maxpktsize!=DFLT_PKT_SIZE)
					fprintf(stream,"PKTSIZE %lu\n",cfg.maxpktsize);
				for(i=j=0;i<cfg.nodecfgs;i++)
					if(cfg.nodecfg[i].attr&SEND_NOTIFY) {
						if(!j) fprintf(stream,"SEND_NOTIFY");
						fprintf(stream," %s",wcfaddrtoa(&cfg.nodecfg[i].faddr));
						j++; }
				if(j) fprintf(stream,"\n");
				for(i=j=0;i<cfg.nodecfgs;i++)
					if(cfg.nodecfg[i].attr&ATTR_HOLD) {
						if(!j) fprintf(stream,"HOLD");
						fprintf(stream," %s",wcfaddrtoa(&cfg.nodecfg[i].faddr));
						j++; }
				if(j) fprintf(stream,"\n");
				for(i=j=0;i<cfg.nodecfgs;i++)
					if(cfg.nodecfg[i].attr&ATTR_DIRECT) {
						if(!j) fprintf(stream,"DIRECT");
						fprintf(stream," %s",wcfaddrtoa(&cfg.nodecfg[i].faddr));
						j++; }
				if(j) fprintf(stream,"\n");
				for(i=j=0;i<cfg.nodecfgs;i++)
					if(cfg.nodecfg[i].attr&ATTR_CRASH) {
						if(!j) fprintf(stream,"CRASH");
						fprintf(stream," %s",wcfaddrtoa(&cfg.nodecfg[i].faddr));
						j++; }
				if(j) fprintf(stream,"\n");
				for(i=j=0;i<cfg.nodecfgs;i++)
					if(cfg.nodecfg[i].attr&ATTR_PASSIVE) {
						if(!j) fprintf(stream,"PASSIVE");
						fprintf(stream," %s",wcfaddrtoa(&cfg.nodecfg[i].faddr));
						j++; }
				if(j) fprintf(stream,"\n");
				for(i=0;i<cfg.nodecfgs;i++)
					if(cfg.nodecfg[i].pktpwd[0])
						fprintf(stream,"PKTPWD %s %s\n"
							,wcfaddrtoa(&cfg.nodecfg[i].faddr),cfg.nodecfg[i].pktpwd);
				for(i=0;i<cfg.nodecfgs;i++)
					if(cfg.nodecfg[i].pkt_type)
						fprintf(stream,"PKTTYPE %s %s\n"
							,cfg.nodecfg[i].pkt_type==PKT_TWO_TWO ? "2.2":"2"
							,wcfaddrtoa(&cfg.nodecfg[i].faddr));
				for(i=0;i<cfg.arcdefs;i++)
					fprintf(stream,"PACKER %s %u %s\n  PACK %s\n"
						"  UNPACK %s\nEND\n"
						,cfg.arcdef[i].name
						,cfg.arcdef[i].byteloc
						,cfg.arcdef[i].hexid
						,cfg.arcdef[i].pack
						,cfg.arcdef[i].unpack
						);
				for(i=0;i<cfg.arcdefs;i++) {
					for(j=k=0;j<cfg.nodecfgs;j++)
						if(cfg.nodecfg[j].arctype==i) {
							if(!k)
								fprintf(stream,"%-10s %s","USEPACKER"
									,cfg.arcdef[i].name);
							k++;
							fprintf(stream," %s",wcfaddrtoa(&cfg.nodecfg[j].faddr)); }
					if(k)
						fprintf(stream,"\n"); }
				for(i=j=0;i<cfg.nodecfgs;i++)
					if(cfg.nodecfg[i].arctype==0xffff) {
						if(!j)
							fprintf(stream,"%-10s %s","USEPACKER","NONE");
						j++;
						fprintf(stream," %s",wcfaddrtoa(&cfg.nodecfg[i].faddr)); }
				if(j)
					fprintf(stream,"\n");
				for(i=0;i<cfg.listcfgs;i++) {
					fprintf(stream,"%-10s","ECHOLIST");
					if(cfg.listcfg[i].password[0])
						fprintf(stream," FORWARD %s %s"
							,wcfaddrtoa(&cfg.listcfg[i].forward)
							,cfg.listcfg[i].password);
					else if(cfg.listcfg[i].misc&NOFWD &&
						cfg.listcfg[i].forward.zone)
						fprintf(stream," HUB %s"
							,wcfaddrtoa(&cfg.listcfg[i].forward));
					fprintf(stream," %s",cfg.listcfg[i].listpath);
					for(j=0;j<cfg.listcfg[i].numflags;j++)
						fprintf(stream," %s",cfg.listcfg[i].flag[j].flag);
					fprintf(stream,"\n"); }
				for(i=0;i<cfg.nodecfgs;i++)
					if(cfg.nodecfg[i].password[0]) {
						fprintf(stream,"%-10s %s %s","AREAFIX"
							,wcfaddrtoa(&cfg.nodecfg[i].faddr)
							,cfg.nodecfg[i].password);
						for(j=0;j<cfg.nodecfg[i].numflags;j++)
							fprintf(stream," %s",cfg.nodecfg[i].flag[j].flag);
						fprintf(stream,"\n"); }
				for(i=0;i<cfg.nodecfgs;i++)
					if(cfg.nodecfg[i].route.zone) {
						fprintf(stream,"%-10s %s","ROUTE_TO"
							,wcfaddrtoa(&cfg.nodecfg[i].route));
						fprintf(stream," %s"
							,wcfaddrtoa(&cfg.nodecfg[i].faddr));
						for(j=i+1;j<cfg.nodecfgs;j++)
							if(!memcmp(&cfg.nodecfg[j].route,&cfg.nodecfg[i].route
								,sizeof(faddr_t))) {
								fprintf(stream," %s"
									,wcfaddrtoa(&cfg.nodecfg[j].faddr));
								cfg.nodecfg[j].route.zone=0; }
						fprintf(stream,"\n"); }
				fclose(stream);
				uifc.bail();
				exit(0);
		}