示例#1
0
bool TreeImportExport::importTreeList(std::map<DWORD_PTR, ImportModuleThunk> & moduleList, DWORD_PTR * addressOEP, DWORD_PTR * addressIAT, DWORD * sizeIAT)
{
	moduleList.clear();
	*addressOEP = *addressIAT = 0;
	*sizeIAT = 0;

	TiXmlDocument doc;
	if(!readXmlFile(doc, xmlPath))
	{
		Scylla::windowLog.log(L"Load Tree :: Error parsing xml %S: %S\r\n", doc.Value(), doc.ErrorDesc());
		return false;
	}

	TiXmlElement * targetElement = doc.FirstChildElement();
	if (!targetElement)
	{
		Sylla::windowLog.log(L"Load Tree :: Error getting first child element in xml %S\r\n", doc.Value());
		return false;
	}

	*addressOEP = ConvertStringToDwordPtr(targetElement->Attribute("oep_va"));
	*addressIAT = ConvertStringToDwordPtr(targetElement->Attribute("iat_va"));
	*sizeIAT = (DWORD)ConvertStringToDwordPtr(targetElement->Attribute("iat_size"));

	parseAllElementModules(targetElement, moduleList);

	return true;
}
示例#2
0
	/// Visit a document.
	virtual bool VisitEnter( const TiXmlDocument& doc )
	{ 
		//mDepth++;
		std::string str = doc.Value();
		mStack.push(str);
		return true; 
	}
示例#3
0
std::string xml_elem::doc_name() const
{
	TiXmlDocument* doc = elem->GetDocument();
	// extra-Paranoia... should never happen
	if (!doc) throw xml_error(std::string("can't get document name for node ") + elem->Value(), "???");
	return doc->Value();
}
示例#4
0
	/// Visit a document.
	virtual bool VisitExit( const TiXmlDocument& doc )			
	{ 
		std::string str = doc.Value();
		if(str != mStack.top())
		{
			OUTSTRING("... %s xml file has not document end\n");
		}
		mStack.pop();
		return true; 
	}
示例#5
0
char* XMLMementoWriter::WriteToBuf(Memento *pm) 
{
	TiXmlDocument doc;
	Write(pm,doc);
	//char* newbuf = new char[40000];
	//memset(newbuf,0,sizeof(char) * 40000);
	//doc.Value();
	//char* charBuf = newbuf;
	//delete []newbuf;
	return (char*)doc.Value();
}
void BulletMLParserTinyXML::parseImpl(TiXmlDocument& doc) {
	if (doc.Error()) {
		throw BulletMLError(doc.Value() + ": " + doc.ErrorDesc());
	}

    TiXmlNode* node;
    for (node = doc.FirstChild(); node; node = node->NextSibling()) {
		if (node->ToElement() != 0) {
			getTree(node);
			break;
		}
    }
}
示例#7
0
int main(int argc, char *argv[]) {

	if(argc==1){
		printf("Error: No input file provided.\n\n");
		printf("Uzebox graphics converter version %i.%i.\n",VERSION_MAJ,VERSION_MIN);
		printf("Usage: gconv <configuration.xml>");
		exit( 1 );
	}

    printf("\n*** Gconvert version %i.%i ***\n",VERSION_MAJ,VERSION_MIN);

	char *path=NULL;
	size_t size=0;
	path=getcwd(path,size);
	printf("Current working directory: %s\n",path);

	//load the xform definition file
	printf("Loading transformation file: %s ...\n",argv[1]);
	TiXmlDocument doc (argv[1]);
	xform.xformFile=argv[1];

	doc.LoadFile();
	if ( doc.Error() )
	{
		printf( "Error in %s: %s\n", doc.Value(), doc.ErrorDesc() );
		exit( 1 );
	}

	//parse configuration
	parseXml(&doc);

	//generate include file
	if(!process()){
		exit(1);
	}



	return 0;
}
bool RequestBaseTask::HandleResult(const char* buf, int size, string &errnum, string &errmsg, TiXmlDocument &doc, bool* bContinue) {
	bool bFlag = false;
	bool bIsParseSuccess = false;
	if( bContinue != NULL ) {
		*bContinue = true;
	}

	/* try to parse xml */
	TiXmlElement* itemElement;
	doc.Parse(buf);
	const char *p = NULL;

	if ( !doc.Error() ) {
		TiXmlNode *rootNode = doc.FirstChild(COMMON_ROOT);
		if( rootNode != NULL ) {
			TiXmlNode *resultNode = rootNode->FirstChild(COMMON_RESULT);
			if( resultNode != NULL ) {
				bIsParseSuccess = true;

				TiXmlNode *statusNode = resultNode->FirstChild(COMMON_STATUS);
				if( statusNode != NULL ) {
					itemElement = statusNode->ToElement();
					if ( itemElement != NULL ) {
						p = itemElement->GetText();
						if( p != NULL && 1 == atoi(p) ) {
							bFlag = true;
						}
					}
				}

				TiXmlNode *errcodeNode = resultNode->FirstChild(COMMON_ERRCODE);
				if( errcodeNode != NULL ) {
					itemElement = errcodeNode->ToElement();
					if ( itemElement != NULL ) {
						p = itemElement->GetText();
						if( p != NULL ) {
							errnum = p;
							if( mpErrcodeHandler != NULL ) {
								bool bc = mpErrcodeHandler->ErrcodeHandle(this, errnum);
								if( bContinue != NULL ) {
									*bContinue = bc;
								}
							}
						}
					}
				}

				TiXmlNode *errmsgNode = resultNode->FirstChild(COMMON_ERRMSG);
				if( errmsgNode != NULL ) {
					itemElement = errmsgNode->ToElement();
					if ( itemElement != NULL ) {
						p = itemElement->GetText();
						if( p != NULL ) {
							errmsg = p;
						}
					}
				}
			}
		}
	}

	// parse protocol fail
	if (!bIsParseSuccess) {
		errnum = LOCAL_ERROR_CODE_PARSEFAIL;
		errmsg = LOCAL_ERROR_CODE_PARSEFAIL_DESC;
	}

	FileLog("httprequest", "RequestBaseTask::HandleResult( "
			"Value() : %s, "
			"ErrorDesc() : %s, "
			"ErrorRow() : %d, "
			"ErrorCol() : %d "
			")",
			doc.Value(),
			doc.ErrorDesc(),
			doc.ErrorRow(),
			doc.ErrorCol()
			);
	mErrCode = errnum;
	return bFlag;
}
bool WorkspaceLoader::Open(const wxString& filename, wxString& Title)
{
    TiXmlDocument doc;
    if (!TinyXML::LoadDocument(filename, &doc))
        return false;

//    ProjectManager* pMan = Manager::Get()->GetProjectManager();
//    LogManager* pMsg = Manager::Get()->GetLogManager();

    if (!GetpMan() || !GetpMsg())
        return false;

    // BUG: Race condition. to be fixed by Rick.
    // If I click close AFTER pMan and pMsg are calculated,
    // I get a segfault.
    // I modified classes projectmanager and logmanager,
    // so that when self==NULL, they do nothing
    // (constructors, destructors and static functions excempted from this)
    // This way, we'll use the *manager::Get() functions to check for nulls.

    TiXmlElement* root = doc.FirstChildElement("CodeBlocks_workspace_file");
    if (!root)
    {
        // old tag
        root = doc.FirstChildElement("Code::Blocks_workspace_file");
        if (!root)
        {
            GetpMsg()->DebugLog(_T("Not a valid Code::Blocks workspace file..."));
            return false;
        }
    }
    TiXmlElement* wksp = root->FirstChildElement("Workspace");
    if (!wksp)
    {
        GetpMsg()->DebugLog(_T("No 'Workspace' element in file..."));
        return false;
    }

    Title = cbC2U(wksp->Attribute("title")); // Conversion to unicode is automatic (see wxString::operator= )

    TiXmlElement* proj = wksp->FirstChildElement("Project");
    if (!proj)
    {
        GetpMsg()->DebugLog(_T("Workspace file contains no projects..."));
        return false;
    }

    // first loop to load projects
    while (proj)
    {
        if(Manager::isappShuttingDown() || !GetpMan() || !GetpMsg())
            return false;
        wxString projectFilename = UnixFilename(cbC2U(proj->Attribute("filename")));
        if (projectFilename.IsEmpty())
        {
            GetpMsg()->DebugLog(_T("'Project' node exists, but no filename?!?"));
        }
        else
        {
            wxFileName fname(projectFilename);
            wxFileName wfname(filename);
            fname.MakeAbsolute(wfname.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR));
            int active = 0;
            int ret = proj->QueryIntAttribute("active", &active);
            switch (ret)
            {
                case TIXML_SUCCESS:
                    if (active == 1)
					{
						cbProject* pProject = GetpMan()->LoadProject(fname.GetFullPath(), true); // activate it
						if(!pProject)
						{
							cbMessageBox(_("Unable to open ") + projectFilename,
							 _("Opening WorkSpace") + filename, wxICON_WARNING);
						}
					}
                    break;
                case TIXML_WRONG_TYPE:
                    GetpMsg()->DebugLog(F(_T("Error %s: %s"), doc.Value(), doc.ErrorDesc()));
                    GetpMsg()->DebugLog(_T("Wrong attribute type (expected 'int')"));
                    break;
                default:
					cbProject* pProject = GetpMan()->LoadProject(fname.GetFullPath(), false); // don't activate it
					if(!pProject)
					{
						cbMessageBox(_("Unable to open ") + projectFilename,
						 _("Opening WorkSpace") + filename, wxICON_WARNING);
					}
                    break;
            }
        }
        proj = proj->NextSiblingElement("Project");
    }

    // second loop to setup dependencies
    proj = wksp->FirstChildElement("Project");
    while (proj)
    {
        cbProject* thisprj = 0;
        wxString projectFilename = UnixFilename(cbC2U(proj->Attribute("filename")));
        if (projectFilename.IsEmpty())
        {
            GetpMsg()->DebugLog(_T("'Project' node exists, but no filename?!?"));
            thisprj = 0;
        }
        else
        {
            wxFileName fname(projectFilename);
            wxFileName wfname(filename);
            fname.MakeAbsolute(wfname.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR));
            thisprj = Manager::Get()->GetProjectManager()->IsOpen(fname.GetFullPath());
        }

        if (thisprj)
        {
            TiXmlElement* dep = proj->FirstChildElement("Depends");
            while (dep)
            {
                wxFileName fname(UnixFilename(cbC2U(dep->Attribute("filename"))));
                wxFileName wfname(filename);
                fname.MakeAbsolute(wfname.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR));
                cbProject* depprj = Manager::Get()->GetProjectManager()->IsOpen(fname.GetFullPath());
                if (depprj)
                    Manager::Get()->GetProjectManager()->AddProjectDependency(thisprj, depprj);
                dep = dep->NextSiblingElement("Depends");
            }
        }
        proj = proj->NextSiblingElement("Project");
    }

    return true;
}
示例#10
0
文件: gen.cpp 项目: aseprite/aseprite
static void run(int argc, const char* argv[])
{
  PO po;
  PO::Option& inputOpt = po.add("input").requiresValue("<filename>");
  PO::Option& widgetId = po.add("widgetid").requiresValue("<id>");
  PO::Option& prefH = po.add("pref-h");
  PO::Option& prefCpp = po.add("pref-cpp");
  PO::Option& theme = po.add("theme");
  PO::Option& strings = po.add("strings");
  PO::Option& commandIds = po.add("command-ids");
  PO::Option& widgetsDir = po.add("widgets-dir").requiresValue("<dir>");
  PO::Option& stringsDir = po.add("strings-dir").requiresValue("<dir>");
  PO::Option& guiFile = po.add("gui-file").requiresValue("<filename>");
  po.parse(argc, argv);

  // Try to load the XML file
  TiXmlDocument* doc = nullptr;

  std::string inputFilename = po.value_of(inputOpt);
  if (!inputFilename.empty() &&
      base::get_file_extension(inputFilename) == "xml") {
    base::FileHandle inputFile(base::open_file(inputFilename, "rb"));
    doc = new TiXmlDocument();
    doc->SetValue(inputFilename.c_str());
    if (!doc->LoadFile(inputFile.get())) {
      std::cerr << doc->Value() << ":"
                << doc->ErrorRow() << ":"
                << doc->ErrorCol() << ": "
                << "error " << doc->ErrorId() << ": "
                << doc->ErrorDesc() << "\n";

      throw std::runtime_error("invalid input file");
    }
  }

  if (doc) {
    // Generate widget class
    if (po.enabled(widgetId))
      gen_ui_class(doc, inputFilename, po.value_of(widgetId));
    // Generate preference header file
    else if (po.enabled(prefH))
      gen_pref_header(doc, inputFilename);
    // Generate preference c++ file
    else if (po.enabled(prefCpp))
      gen_pref_impl(doc, inputFilename);
    // Generate theme class
    else if (po.enabled(theme))
      gen_theme_class(doc, inputFilename);
  }
  // Generate strings.ini.h file
  else if (po.enabled(strings)) {
    gen_strings_class(inputFilename);
  }
  // Generate command_ids.ini.h file
  else if (po.enabled(commandIds)) {
    gen_command_ids(inputFilename);
  }
  // Check all translation files (en.ini, es.ini, etc.)
  else if (po.enabled(widgetsDir) &&
           po.enabled(stringsDir)) {
    check_strings(po.value_of(widgetsDir),
                  po.value_of(stringsDir),
                  po.value_of(guiFile));
  }
}
示例#11
0
bool MantisBot::CheckForGoogleCodeChanges(const __ConfigProject& conf)
{
    char tmp[HTTP_BUFFER_SIZE];
    std::string buffer;
    ssize_t len;

    // Download the feed from the specified Google Code URL
    HTTPClient http(m_config.data.googlecode.address, m_httpGoogleCodeAddr, m_httpGoogleCodeBindAddr, false);
    http.Connect(conf.path);
    http.Send();

    if (!http.Ok()) return false;

    if (http.ResponseStatus() != 200)
    {
        printf("Unable to connect to the web page (%s%s): %d %s\n",
                m_config.data.googlecode.address, conf.path,
                http.ResponseStatus(), http.StatusText());
        return false;
    }

    // Grab the feed data
    HTTPStream& stream = http.GetStream();
    if (!stream.Ok()) return false;
    while (stream.Eof() == false)
    {
        len = stream.Read(tmp, HTTP_BUFFER_SIZE);
        if ( len > 0 )
            buffer.append(tmp, len);
    }
    
    // We got the feed, now start processing it's XML contents
    TiXmlDocument xml;
    TiXmlNode *feed, *node;
    xml.Parse(buffer.c_str());
    if (xml.Error())
    {
        printf("Unable to parse XML feed in %s: %s\n", xml.Value(), xml.ErrorDesc());
        return false;
    }
    feed = xml.FirstChild("feed");
    if (!feed) return false;
    node = feed->FirstChild("entry");

    // Loop through the entry nodes
    size_t index;
    int currentId, newestId = -1;
    std::string strAuthor, strDescription, strLink;
    const char *attr;
    while (node)
    {
        TiXmlNode *data = node->FirstChild("title");
        if (!data) return false;
        TiXmlElement *elem = data->ToElement ();
        if (!elem) return false;

        std::string strText = elem->GetText ();

        // Revision
        index = strText.find("Revision ") + 9;
        currentId = atoi(strText.substr(index, strText.find(":",index) - index).c_str());

        // Description
        index = strText.find(":",index) + 2;
        strDescription = strText.substr(index);
        TrimSpaces(strDescription);

        // Author
        data = node->FirstChild("author");
        if (!data) return false;
        data = data->FirstChild("name");
        if (!data) return false;
        elem = data->ToElement ();
        if (!elem) return false;
        strAuthor = elem->GetText ();
        
        // Link
        data = node->FirstChild("link");
        if (!data) return false;
        elem = data->ToElement ();
        if (!elem) return false;
        attr = elem->Attribute ("href");
        if (!attr) return false;
        strLink = std::string ( attr );

        // First entry will always be the newest
        if (newestId == -1) {
            newestId = currentId;
            // If this is our first run, store the newest entry id
            if ( m_lastGoogleCodeId.find(conf.alias) == m_lastGoogleCodeId.end() )
                m_lastGoogleCodeId[conf.alias] = newestId;
        }

        // If this entry is newer than the last stored id
        if (currentId > m_lastGoogleCodeId[conf.alias])
        {   // This is a new entry
            SendTextToChannels(
                IRCText(
                    "[%U%s%U] %C02%Br%d%B%C %C12(%s)%C %C10%s%C %C03-%C "
                    "%C14%s%C",
                    conf.alias, currentId, strAuthor.c_str (), strDescription.c_str (),
                    strLink.c_str ()
                )
            );
            if ( conf.autofix )
              CheckForAutofixIssue ( strAuthor, strDescription, strLink );
        }
        // Advance to next sibling
        node = node->NextSiblingElement ();
    }
    m_lastGoogleCodeId[conf.alias] = newestId;
    
    return true;
}