Esempio n. 1
0
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;
			}
		}

	}
}
Esempio n. 2
0
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;
}
Esempio n. 3
0
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;
}
Esempio n. 4
0
const char *startDialog::getScriptSetting(ndxml *scriptXml, const char *settingName)
{
	ndxml *moduleInfo = ndxml_getnode(scriptXml, "moduleInfo");
	if (moduleInfo){
		ndxml *node = ndxml_getnode(moduleInfo, settingName);
		if (node){
			return ndxml_getval(node);
		}
	}
	return NULL;
}
Esempio n. 5
0
void CNewfileDlg::OnBnClickedOk()
{
	// TODO: Add your control notification handler code here
	m_selFile = 0;
	HTREEITEM hCurItem = m_tree.GetSelectedItem();
	if (hCurItem){
		ndxml *xml = (ndxml*)(m_tree.GetItemData(hCurItem));
		if (xml) {
			m_selFile = ndxml_getval(xml);
		}
	}
	if (!m_selFile){
		AfxMessageBox(_T("请选择要编辑的文件!"));
		return;
	}
	CDialog::OnOK();
}
Esempio n. 6
0
const char *startDialog::_getFromIocfg(const char *cfgName,const char *rootName)
{
	//return	apoEditorSetting::getInstant()->getValueFromSetting(cfgName);
	apoEditorSetting *setting = apoEditorSetting::getInstant();

	if (!rootName) {
		rootName ="project_config";
	}

	ndxml *node = ndxml_getnode(setting->getIoConfig(), rootName);
	if (node) {
		ndxml *cfgxml = ndxml_getnode(node, cfgName);
		if (cfgxml) {
			return ndxml_getval(cfgxml);
		}
	}
	return NULL;


}
Esempio n. 7
0
int read_iplist(ndxml *xmlnode, ndip_t *ipbuf, int num )
{
	int real_num = 0;
	for (int i=0; i<ndxml_getsub_num(xmlnode) && real_num<num; i++){
		ndip_t ip =0;
		ndxml *xmlip = ndxml_refsubi(xmlnode,i) ;
		const char *p = ndxml_getval(xmlip) ;
		if (p) {
			if (0 == ndstricmp(p, "localhost")) {
				ip = 0x0100007f;
			}
			else if(0!=ndstr_get_ip(p, &ip) ) {
				ip =nd_inet_aton(p) ;
			}
			if (ip){
				ipbuf[real_num++] = ip ;
			}
		}
	}
	return 0;

}