예제 #1
0
파일: test.cpp 프로젝트: Erdk/RBDOOM-3-BFG
int main()
{
	IrrXMLReader* xml = createIrrXMLReader("config.xml");

	// strings for storing the data we want to get out of the file
	std::string modelFile;
	std::string messageText;
	std::string caption;

	// parse the file until end reached
	while(xml && xml->read())
	{
		switch(xml->getNodeType())
		{
		case EXN_TEXT:
			// in this xml file, the only text which occurs is the messageText
			messageText = xml->getNodeData();
			break;
		case EXN_ELEMENT:
			{
				if (!strcmp("startUpModel", xml->getNodeName()))
					modelFile = xml->getAttributeValue("file");
				else
				if (!strcmp("messageText", xml->getNodeName()))
					caption = xml->getAttributeValue("caption");
			}
			break;
		}
	}

	// delete the xml parser after usage
	delete xml;
	return 0;
}
예제 #2
0
int main()
	{
	IrrXMLReader*xmlr;

	// create the reader using one of the factory functions
	IrrXMLReader* xml = createIrrXMLReader("track.xml");

	if (xml == 0)
			return 0; // file could not be opened

	// parse the file until end reached
	while(xml->read())
		{
		// based on xml->getNodeType(), do something.
		EXML_NODE type=xml->getNodeType();
		cout<<"Type:"<<type<<endl;

		char name[128];
		strcpy(name,xml->getNodeName());
		cout<<"Name:"<<name<<endl;

		char data[128];
		strcpy(data,xml->getNodeData());
		cout<<"Data:"<<data<<endl;

		}

	// delete the xml parser after usage
	delete xml;

	return 1;

	}
예제 #3
0
int updateFinder(const char* TITLE_ID, int env_choose, PSN_Update* game){
	const char *env[3] = {"np","sp-int","prod-qa"};
	int size = strlen(TITLE_ID)*2+49+strlen(env[env_choose])*2;
	char *xml_url = (char*) malloc(size);

	snprintf(xml_url,size,"https://a0.ww.%s.dl.playstation.net/tpl/%s/%s/%s-ver.xml",env[env_choose],env[env_choose],TITLE_ID,TITLE_ID);
	download_game_update(xml_url,CACHE_PATH2"/game-update.xml", progress, NULL);
	free((void*)xml_url);
	
	size = get_size(CACHE_PATH2"/game-update.xml");
	if(size == 16 || size == 241 || size == 0){ //Update not found
		file_delete(CACHE_PATH2"/game-update.xml");
		return 0;
	}
	
	if(get_download_status()==DOWNLOAD_FAILED){
		file_delete(CACHE_PATH2"/game-update.xml");
		return 0;
	}
	
	
	IrrXMLReader* xml = createIrrXMLReader(CACHE_PATH2"/game-update.xml");
	int i=-1;
	PSN_Update game_tmp;
	game_tmp.version = new string  [10];
	game_tmp.link    = new string  [10];
	game_tmp.size    = new uint32_t[10];
	game_tmp.min_ver = new float   [10];
	game_tmp.pkgs	 = 0;
	while(xml && xml->read() && i<10){
		//printf("debug: %s\n", xml->getNodeData());
 		switch(xml->getNodeType())
		{
			case EXN_NONE:
				break;
			case EXN_ELEMENT:
			{
				if (!strcmp("package", xml->getNodeName())){
					++i;
					char tmp[10];
					game_tmp.version[i] = xml->getAttributeValue("version");
					game_tmp.size[i]    = xml->getAttributeValueAsInt("size");
					game_tmp.link[i]    = xml->getAttributeValue("url");
					game_tmp.min_ver[i] = xml->getAttributeValueAsFloat("ps3_system_ver");
					game_tmp.pkgs++;
					break;
				}else if (!strcmp("TITLE", xml->getNodeName())){
					xml->read();
					game_tmp.name = xml->getNodeData();
					break;
				}
			}
			case EXN_ELEMENT_END:
				break;
			case EXN_TEXT:
				break;
			case EXN_COMMENT:
				break;
			case EXN_CDATA:
				break;
			case EXN_UNKNOWN:
				break;
		}
	}
	delete xml;
	game->name    = game_tmp.name.c_str();
	game->version = new string  [game_tmp.pkgs];
	game->link    = new string  [game_tmp.pkgs];
	game->size    = new uint32_t[game_tmp.pkgs];
	game->min_ver = new float   [game_tmp.pkgs];
	game->pkgs    = game_tmp.pkgs;
	for(u8 j=0; j<game_tmp.pkgs; ++j){
		game->version[j] = game_tmp.version[j];
		game->link[j]    = game_tmp.link[j];
		game->size[j]    = game_tmp.size[j];
		game->min_ver[j] = game_tmp.min_ver[j];
	}
	
	delete [] game_tmp.version;
	delete [] game_tmp.link;
	delete [] game_tmp.size;
	
	file_delete(CACHE_PATH2"/game-update.xml");
	return 1;
}
예제 #4
0
int BrewologyLoadStringsFromXML(const char* filename, PSC_Application *App){
	IrrXMLReader* xml = createIrrXMLReader(filename);
	App->n_elem    = 1014;
	App->name      = new string[1020];
	App->version   = new string[1020];
	App->author    = new string[1020];
	App->img_file  = new string[1020];
	App->type_file = new int   [1020];
	App->pkg       = new links [1020];

/*
	App->link      = new string[1020];
	App->pkg_file  = new string[1020];
	App->file_size = new u32   [1020];
*/
	int i=-1;
	bool name_app = false;
	App->downloaded = false;
	while(xml && xml->read()){
 		switch(xml->getNodeType())
		{
			case EXN_NONE:
				break;
			case EXN_ELEMENT:
			{
				if (!strcmp("error", xml->getNodeName())){
					xml->read();
					xml->read();
					update = xml->getNodeData();
					return PSC_OLDVERSION;
				}
				if (!strcmp("homebrew", xml->getNodeName())){
					++i;
					App->type_file[i] = PSC_PACKAGE;
					break;
				}else if (!strcmp("name", xml->getNodeName())){ //homebrew name
					xml->read();
					App->name[i] = xml->getNodeData();
					break;
				}else if (!strcmp("author", xml->getNodeName())){
					xml->read();
					App->author[i] = xml->getNodeData();
					break;
				}else if (!strcmp("icon", xml->getNodeName())){
					xml->read();
					App->img_file[i] = xml->getNodeData();
					break;
				}else if (!strcmp("pkgs", xml->getNodeName())){
					string name[50];
					string link[50];
					u32    size[50];
					u8     pkg=0;
					do{
						switch(xml->getNodeType()){
							case EXN_ELEMENT:
							{
								if (!strcmp("name", xml->getNodeName())){
									xml->read();
									name[pkg] = xml->getNodeData();
								}else if (!strcmp("version", xml->getNodeName())){
									xml->read();
									App->version[i] = xml->getNodeData();
									break;
								}else if (!strcmp("size", xml->getNodeName())){
									xml->read();
									size[pkg] = atoi(xml->getNodeData());
								}else if (!strcmp("location", xml->getNodeName())){
									xml->read();
									link[pkg] = xml->getNodeData();
									++pkg;
								}
							}break;
							case EXN_ELEMENT_END:
							{
								if(!strcmp("pkgs", xml->getNodeName()))
									goto back;
							}break;
						}
					}while(pkg<50 && xml->read());
					back:
					
					App->pkg[i].pkg_num = pkg;
					App->pkg[i].link    = new string [pkg];
					App->pkg[i].name    = new string [pkg];
					App->pkg[i].size    = new u32    [pkg];
					
					for(u8 j=0; j<pkg; ++j){
						App->pkg[i].link[j] = link[j];
						App->pkg[i].size[j] = size[j];
						App->pkg[i].name[j] = name[j];
						App->pkg[i].name[j] += ".pkg";
					}
					
					break;
				}

				break;
			}
			case EXN_ELEMENT_END:
				break;
			case EXN_TEXT:
				break;
			case EXN_COMMENT:
				break;
			case EXN_CDATA:
				break;
			case EXN_UNKNOWN:
				break;
		}
	}
	i++;
	App->n_elem = i;
	for(;i < 1020;++i){
		App->name[i]        = "";
		App->author[i]      = "";
		App->version[i]     = "";
	//	App->link[i]        = "";
	//	App->pkg_file[i]    = "";
		App->img_file[i]    = "";
	//	App->file_size[i]   =  0;
		App->type_file[i]   = -1;
		App->pkg[i].pkg_num =  0;
		
	}

	delete xml;
	return 1;
}