bool CNewfileDlg::ShowFileList() { m_tree.DeleteAllItems(); HTREEITEM hRootItem = m_tree.InsertItem(_T("文件")); ndxml_root *xml = ndxml_getnode(&m_xmlRoot, "script_file_manager"); if (!xml){ AfxMessageBox(_T("文件损坏")); return false; } int num = ndxml_num(xml); for (int i = 0; i < num; i++) { ndxml *node = ndxml_getnodei(xml, i); if (!node ) continue; const char *dispName = ndxml_getattr_val(node, "name"); if (!dispName) { dispName = ndxml_getval(node); } HTREEITEM hNode = m_tree.InsertItem(dispName, hRootItem, TVI_LAST); m_tree.SetItemData(hNode, (DWORD_PTR)node); } m_tree.Expand(hRootItem, TVE_EXPAND); return true; }
void CNewfileDlg::OnBnClickedButtonDeltet() { // TODO: Add your control notification handler code here HTREEITEM hCurItem = m_tree.GetSelectedItem(); if (hCurItem){ ndxml *xml = (ndxml*)(m_tree.GetItemData(hCurItem)); if (!xml) { return; } ndxml_root *xmlfiles = ndxml_getnode(&m_xmlRoot, "script_file_manager"); if (!xmlfiles){ return; } int num = ndxml_num(xmlfiles); for (int i = 0; i < num; i++) { ndxml *node = ndxml_getnodei(xmlfiles, i); if (node == xml) { if (IDYES != AfxMessageBox("是否要删除?", MB_YESNO)) { return; } nd_rmfile(ndxml_getval(node)); ndxml_delxml(node, xmlfiles); SaveXmlFile(); ShowFileList(); return; } } } }
bool startDialog::compile() { std::string script_root = getPathFromConfig("script_root"); /* if (!nd_absolute_filename(script_root.c_str(), tmpbuf, sizeof(tmpbuf))) { nd_logerror("can not found file %s\n", script_root.c_str()); return false; } char tmpbuf[ND_FILE_PATH_SIZE]; std::string absPath = tmpbuf; absPath = nd_getpath(absPath.c_str(), tmpbuf, sizeof(tmpbuf)); */ ndxml_root xmlEntry; ndxml_initroot(&xmlEntry); if (-1 == ndxml_load_ex(script_root.c_str(), &xmlEntry, apoEditorSetting::getInstant()->m_encodeName.c_str())) { return false; } ndxml_root *xml = ndxml_getnode(&xmlEntry, "script_file_manager"); if (!xml){ return false; } char projPath[ND_FILE_PATH_SIZE]; nd_getpath(script_root.c_str(), projPath, sizeof(projPath)); WorkingPathSwitchHelper __pathHelper(projPath); bool ret = true; int num = ndxml_num(xml); for (int i = 0; i < num; i++) { ndxml *node = ndxml_getnodei(xml, i); if (!node) continue; std::string scriptPath = ndxml_getval(node); if (scriptPath.size() > 0) { scriptPath += "/"; } scriptPath += ndxml_getattr_val(node, "main_file"); if (!compileScript(scriptPath.c_str(),__pathHelper.workingPath())) { ret = false; break; } } ndxml_destroy(&xmlEntry); return true; }
int read_config(ndxml *xmlroot, const char *name, struct server_config *scfg) { ndxml *xml_sub,*xml_listen ; int base_port = read_base_port(xmlroot) ; memset(scfg, 0, sizeof(scfg)) ; if (0==base_port) { return -1; } xml_sub = ndxml_refsub(xmlroot,name) ; if (!xml_sub){ T_ERROR("read base port error") ; } if(-1== read_instance_info(xml_sub, &scfg->i_cfg)) { return -1 ; } xml_listen = ndxml_refsub(xml_sub,"listen") ; if (!xml_listen){ T_ERROR("read base port error") ; } if(-1== read_listen_cfg(xml_listen, base_port,&scfg->l_cfg) ) { return -1 ; } // scfg->reliable_num = 0; xml_listen = ndxml_refsub(xml_sub,"reliable_host") ; if (xml_listen){ read_iplist(xml_listen, scfg->reliable_hosts, MAX_RELIABLE_HOST ) ; for(int i=0; i<MAX_RELIABLE_HOST; i++) { union { ndip_t ip ; NDUINT8 buf[4] ; }readip,ipmask; readip.ip = scfg->reliable_hosts[i] ; if (readip.ip ==0){ break ; } ipmask.ip = 0xffffffff; for (int x=0; x<4; x++) { if (0xff== readip.buf[x]){ ipmask.buf[x] = 0 ; } } scfg->reliable_ipmask[i] = ipmask.ip; scfg->reliable_num++; } //get netmask } //read connectors xml_listen = ndxml_refsub(xml_sub,"connectors") ; if (xml_listen){ for (int i=0; i< ND_CONNECT_OTHER_HOSTR_NUM && i<ndxml_num(xml_listen); i++) { ndxml *pnode = ndxml_getnodei(xml_listen, i) ; if(0== read_connect_cfg(pnode, base_port, &scfg->i_cfg.connectors[i]) ) { const char *pname = ndxml_getattr_val(pnode, "name") ; if (pname && pname[0]) { strncpy(scfg->i_cfg.connectors[i].connector_name, pname,sizeof(scfg->i_cfg.connectors[i].connector_name)) ; } else { pname = ndxml_getname(pnode) ; strncpy(scfg->i_cfg.connectors[i].connector_name, pname,sizeof(scfg->i_cfg.connectors[i].connector_name)) ; } } } } return 0 ; }