void DLLCALL free_cfg(scfg_t* cfg) { free_node_cfg(cfg); free_main_cfg(cfg); free_msgs_cfg(cfg); free_file_cfg(cfg); free_chat_cfg(cfg); free_xtrn_cfg(cfg); free_attr_cfg(cfg); }
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); } }