Пример #1
0
BOOL DLLCALL load_cfg(scfg_t* cfg, char* text[], BOOL prep, char* error)
{
	int		i;
#ifdef SBBS
	long	line=0L;
	FILE 	*instream;
	char	str[256],fname[13];
#endif

	if(cfg->size!=sizeof(scfg_t)) {
		sprintf(error,"cfg->size (%"PRIu32") != sizeof(scfg_t) (%d)"
			,cfg->size,sizeof(scfg_t));
		return(FALSE);
	}

	free_cfg(cfg);	/* free allocated config parameters */

	cfg->prepped=FALSE;	/* reset prepped flag */

	if(cfg->node_num<1)
		cfg->node_num=1;

	backslash(cfg->ctrl_dir);
	if(read_main_cfg(cfg, error)==FALSE)
		return(FALSE);

	if(prep)
		for(i=0;i<cfg->sys_nodes;i++) 
			prep_dir(cfg->ctrl_dir, cfg->node_path[i], sizeof(cfg->node_path[i]));

	SAFECOPY(cfg->node_dir,cfg->node_path[cfg->node_num-1]);
	prep_dir(cfg->ctrl_dir, cfg->node_dir, sizeof(cfg->node_dir));
	if(read_node_cfg(cfg, error)==FALSE)
		return(FALSE);
	if(read_msgs_cfg(cfg, error)==FALSE)
		return(FALSE);
	if(read_file_cfg(cfg, error)==FALSE)
		return(FALSE);
	if(read_xtrn_cfg(cfg, error)==FALSE)
		return(FALSE);
	if(read_chat_cfg(cfg, error)==FALSE)
		return(FALSE);
	if(read_attr_cfg(cfg, error)==FALSE)
		return(FALSE);

#ifdef SBBS
	if(text!=NULL) {

		/* Free existing text if allocated */
		free_text(text);

		strcpy(fname,"text.dat");
		sprintf(str,"%s%s",cfg->ctrl_dir,fname);
		if((instream=fnopen(NULL,str,O_RDONLY))==NULL) {
			sprintf(error,"%d opening %s",errno,str);
			return(FALSE); 
		}
		for(i=0;i<TOTAL_TEXT;i++)
			if((text[i]=readtext(&line,instream,i))==NULL) {
				i--;
				break;
			}
		fclose(instream);

		if(i<TOTAL_TEXT) {
			sprintf(error,"line %d in %s: Less than TOTAL_TEXT (%u) strings defined in %s."
				,i,fname
				,TOTAL_TEXT,fname);
			return(FALSE); 
		}
	}
#endif

    /* Override com-port settings */
    cfg->com_base=0xf;	/* All nodes use FOSSIL */
    cfg->com_port=1;	/* All nodes use "COM1" */

	if(prep)
		prep_cfg(cfg);

	/* Auto-toggle daylight savings time in US time-zones */
	sys_timezone(cfg);

	return(TRUE);
}
Пример #2
0
void node_menu()
{
	char	str[81],savnode=0;
	int 	i,j;
	static int node_menu_dflt, node_bar;

while(1) {
	for(i=0;i<cfg.sys_nodes;i++)
		sprintf(opt[i],"Node %d",i+1);
	opt[i][0]=0;
	j=WIN_ORG|WIN_ACT|WIN_INSACT|WIN_DELACT;
	if(cfg.sys_nodes>1)
		j|=WIN_DEL|WIN_GET;
	if(cfg.sys_nodes<MAX_NODES && cfg.sys_nodes<MAX_OPTS)
		j|=WIN_INS;
	if(savnode)
		j|=WIN_PUT;
uifc.helpbuf=
	"Node List:\n"
	"\n"
	"This is the list of configured nodes in your system.\n"
	"\n"
	"To add a node, hit  INS .\n"
	"\n"
	"To delete a node, hit  DEL .\n"
	"\n"
	"To configure a node, select it using the arrow keys and hit  ENTER .\n"
	"\n"
	"To copy a node's configuration to another node, first select the source\n"
	"node with the arrow keys and hit  F5 . Then select the destination\n"
	"node and hit  F6 .\n"
;

	i=uifc.list(j,0,0,13,&node_menu_dflt,&node_bar,"Nodes",opt);
	if(i==-1) {
		if(savnode) {
			free_node_cfg(&cfg);
			savnode=0; }
		return; }

	if((i&MSK_ON)==MSK_DEL) {
		strcpy(opt[0],"Yes");
		strcpy(opt[1],"No");
		opt[2][0]=0;
		sprintf(str,"Delete Node %d",cfg.sys_nodes);
		i=1;
uifc.helpbuf=
	"Delete Node:\n"
	"\n"
	"If you are positive you want to delete this node, select Yes. Otherwise,\n"
	"select No or hit  ESC .\n"
;
		i=uifc.list(WIN_MID,0,0,0,&i,0,str,opt);
		if(!i) {
			--cfg.sys_nodes;
/*			free(cfg.node_path[cfg.sys_nodes]); */
			cfg.new_install=new_install;
			write_main_cfg(&cfg,backup_level);
            refresh_cfg(&cfg);
        }
		continue; }
	if((i&MSK_ON)==MSK_INS) {
		strcpy(cfg.node_dir,cfg.node_path[cfg.sys_nodes-1]);
		i=cfg.sys_nodes+1;
		uifc.pop("Reading NODE.CNF...");
		read_node_cfg(&cfg,error);
		uifc.pop(0);
		sprintf(str,"../node%d/",i);
		sprintf(tmp,"Node %d Path",i);
uifc.helpbuf=
	"Node Path:\n"
	"\n"
	"This is the path to this node's private directory where its separate\n"
	"configuration and data files are stored.\n"
	"\n"
	"The drive and directory of this path can be set to any valid DOS\n"
	"directory that can be accessed by ALL nodes and MUST NOT be on a RAM disk\n"
	"or other volatile media.\n"
	"\n"
	"If you want to abort the creation of this new node, hit  ESC .\n"
;
		j=uifc.input(WIN_MID,0,0,tmp,str,50,K_EDIT);
		uifc.changes=0;
		if(j<2)
			continue;
		truncsp(str);
		strcpy(cfg.node_path[i-1],str);
		if(str[strlen(str)-1]=='\\' || str[strlen(str)-1]=='/')
			str[strlen(str)-1]=0;
		MKDIR(str);
		cfg.node_num=++cfg.sys_nodes;
		SAFEPRINTF(cfg.node_name,"Node %u",cfg.node_num);
		SAFECOPY(cfg.node_phone,"N/A");
		cfg.new_install=new_install;
		write_node_cfg(&cfg,backup_level);
		write_main_cfg(&cfg,backup_level);
		free_node_cfg(&cfg);
        refresh_cfg(&cfg);
		continue;
    }
	if((i&MSK_ON)==MSK_GET) {
		if(savnode)
			free_node_cfg(&cfg);
		i&=MSK_OFF;
		strcpy(cfg.node_dir,cfg.node_path[i]);
		uifc.pop("Reading NODE.CNF...");
		read_node_cfg(&cfg,error);
		uifc.pop(0);
		savnode=1;
		continue; }
	if((i&MSK_ON)==MSK_PUT) {
		i&=MSK_OFF;
		strcpy(cfg.node_dir,cfg.node_path[i]);
		cfg.node_num=i+1;
		write_node_cfg(&cfg,backup_level);
        refresh_cfg(&cfg);
		uifc.changes=1;
		continue;
    }

	if(savnode) {
		free_node_cfg(&cfg);
		savnode=0; }
	strcpy(cfg.node_dir,cfg.node_path[i]);
	prep_dir(cfg.ctrl_dir, cfg.node_dir, sizeof(cfg.node_dir));

	uifc.pop("Reading NODE.CNF...");
	read_node_cfg(&cfg,error);
	uifc.pop(0);
	if(cfg.node_num!=i+1) { 	/* Node number isn't right? */
		cfg.node_num=i+1;		/* so fix it */
		write_node_cfg(&cfg,backup_level); } /* and write it back */
	node_cfg();

	free_node_cfg(&cfg); }
}