예제 #1
0
int mpkgconfig::set_cdrommountpoint(string cdromMountPoint)
{
    XMLNode tmp;
    tmp=getXMLConfig();
    tmp.getChildNode("cdrom_mountpoint").deleteNodeContent(1);
    tmp.addChild("cdrom_mountpoint");
    tmp.getChildNode("cdrom_mountpoint").addText(cdromMountPoint.c_str());
    return setXMLConfig(tmp);
}
예제 #2
0
int mpkgconfig::set_scriptsdir(string newscriptsdir)
{
    XMLNode tmp;
    tmp=getXMLConfig();
    tmp.getChildNode("scripts_dir").deleteNodeContent(1);
    tmp.addChild("scripts_dir");
    tmp.getChildNode("scripts_dir").addText(newscriptsdir.c_str());
    return setXMLConfig(tmp);
}
예제 #3
0
int mpkgconfig::set_syscache(string newsyscache)
{
    XMLNode tmp;
    tmp=getXMLConfig();
    tmp.getChildNode("sys_cache").deleteNodeContent(1);
    tmp.addChild("sys_cache");
    tmp.getChildNode("sys_cache").addText(newsyscache.c_str());
    return setXMLConfig(tmp);
}
예제 #4
0
int mpkgconfig::set_dburl(string newdburl)
{
    XMLNode tmp;
    tmp=getXMLConfig();
    tmp.getChildNode("database_url").deleteNodeContent(1);
    tmp.addChild("database_url");
    tmp.getChildNode("database_url").addText(newdburl.c_str());
    return setXMLConfig(tmp);
}
예제 #5
0
int mpkgconfig::set_runscripts(bool dorun)
{
    XMLNode tmp;
    tmp=getXMLConfig();
    tmp.getChildNode("run_scripts").deleteNodeContent(1);
    tmp.addChild("run_scripts");
    if (dorun) tmp.getChildNode("run_scripts").addText("yes");
    else tmp.getChildNode("run_scripts").addText("no");
    return setXMLConfig(tmp);
}
예제 #6
0
int mpkgconfig::set_cdromdevice(string cdromDevice)
{
    XMLNode tmp;
    tmp=getXMLConfig();
    tmp.getChildNode("cdrom_device").deleteNodeContent(1);
    tmp.addChild("cdrom_device");
    mDebug("setting cd device to " + cdromDevice);
    tmp.getChildNode("cdrom_device").addText(cdromDevice.c_str());
    return setXMLConfig(tmp);
}
예제 #7
0
int mpkgconfig::set_checkFiles(unsigned int value)
{
    XMLNode tmp;
    tmp=getXMLConfig();
    tmp.getChildNode("checkFileConflicts").deleteNodeContent(1);
    tmp.addChild("checkFileConflicts");
    if (value == CHECKFILES_PREINSTALL) tmp.getChildNode("checkFileConflicts").addText("preinstall");
    if (value == CHECKFILES_POSTINSTALL) tmp.getChildNode("checkFileConflicts").addText("postinstall");
    if (value == CHECKFILES_DISABLE) tmp.getChildNode("checkFileConflicts").addText("disable");

    return setXMLConfig(tmp);
}
예제 #8
0
int mpkgconfig::set_disabled_repositorylist(vector <string> newrepositorylist)
{
    mError("WARNING! You should NOT use set_disabled_repositorylist!");
    return -1;
    XMLNode tmp;
    tmp=getXMLConfig();
    tmp.getChildNode("repository_list").deleteNodeContent(1);
    tmp.addChild("repository_list");
    for (unsigned int i=0; i<newrepositorylist.size(); i++)
    {
        tmp.getChildNode("repository_list").addChild("disabled_repository");
        tmp.getChildNode("repository_list").getChildNode("disabled_repository", i).addText(newrepositorylist[i].c_str());
    }
    return setXMLConfig(tmp);
}
예제 #9
0
int mpkgconfig::set_repositorylist(vector<string> newrepositorylist, vector<string> drList)
{
    XMLNode tmp;
    tmp=getXMLConfig();
    tmp.getChildNode("repository_list").deleteNodeContent(1);
    tmp.addChild("repository_list");
    for (unsigned int i=0; i<newrepositorylist.size(); i++)
    {
        tmp.getChildNode("repository_list").addChild("repository");
        tmp.getChildNode("repository_list").getChildNode("repository", i).addText(newrepositorylist[i].c_str());
    }
    for (unsigned int i=0; i<drList.size(); i++)
    {
        tmp.getChildNode("repository_list").addChild("disabled_repository");
        tmp.getChildNode("repository_list").getChildNode("disabled_repository", i).addText(drList[i].c_str());
    }
    return setXMLConfig(tmp);
}
예제 #10
0
int mpkgconfig::initConfig()
{
    XMLNode tmp=getXMLConfig();
    return setXMLConfig(tmp);
}
예제 #11
0
u32 ADVANsCEne::convertDB(const char *in_filaname)
{
	const char *saveTypeNames[] = {	"Eeprom - 4 kbit",		// EEPROM 4kbit
									"Eeprom - 64 kbit",		// EEPROM 64kbit
									"Eeprom - 512 kbit",	// EEPROM 512kbit
									"Fram - 256 kbit",		// FRAM 256kbit !
									"Flash - 2 mbit",		// FLASH 2Mbit
									"Flash - 4 mbit",		// FLASH 4Mbit
									"Flash - 8 mbit",		// FLASH 8Mbit
									"Flash - 16 mbit",		// FLASH 16Mbit !
									"Flash - 32 mbit",		// FLASH 32Mbit !
									"Flash - 64 mbit",		// FLASH 64Mbit
									"Flash - 128 mbit",		// FLASH 128Mbit !
									"Flash - 256 mbit",		// FLASH 256Mbit !
									"Flash - 512 mbit"		// FLASH 512Mbit !
	};

	TiXmlDocument	*xml = NULL;
	TiXmlElement	*el = NULL;
	TiXmlElement	*el_serial = NULL;
	TiXmlElement	*el_games = NULL;
	TiXmlElement	*el_crc32 = NULL;
	TiXmlElement	*el_saveType = NULL;
	FILE			*fp;
	u32				crc32 = 0;
	u32				reserved = 0;

	printf("Converting DB...\n");
	if (getXMLConfig(in_filaname))
	{
		if (!datName) return 0;
		if (strcmp(datName, _ADVANsCEne_BASE_NAME) != 0) return 0;
	}

	fp = fopen(database_path, "wb");
	if (!fp) return 0;

	// Header
	fwrite(_ADVANsCEne_BASE_ID, 1, strlen(_ADVANsCEne_BASE_ID), fp);
	fputc(_ADVANsCEne_BASE_VERSION_MAJOR, fp);
	fputc(_ADVANsCEne_BASE_VERSION_MINOR, fp);
	if (datVersion) 
		fwrite(datVersion, 1, strlen(datVersion), fp);
	else
		fputc(0, fp);
	time_t __time = time(NULL);
	fwrite(&__time, 1, sizeof(time_t), fp);

	xml = new TiXmlDocument();
	if (!xml) { fclose(fp); return 0; }
	if (!xml->LoadFile(in_filaname)) { fclose(fp); return 0; }
	el = xml->FirstChildElement("dat");
	if (!el) { fclose(fp); return 0; }
	el_games = el->FirstChildElement("games");
	if (!el_games) { fclose(fp); return 0; }
	el = el_games->FirstChildElement("game");
	if (!el) { fclose(fp); return 0; }
	u32 count = 0;
	while (el)
	{
		el_serial = el->FirstChildElement("serial");
		if (fwrite(el_serial->GetText(), 1, 8, fp) != 8)
		{
			fclose(fp); return 0;
		}
		// CRC32
		el_crc32 = el->FirstChildElement("files"); 
		sscanf_s(el_crc32->FirstChildElement("romCRC")->GetText(), "%x", &crc32);
		if (fwrite(&crc32, 1, sizeof(u32), fp) != sizeof(u32))
		{
			fclose(fp); return 0;
		}
		// Save type
		el_saveType = el->FirstChildElement("saveType"); 
		if (el_saveType)
		{
			const char *tmp = el_saveType->GetText();
			if (tmp)
			{
				if (strcmp(tmp, "None")  == 0)
					fputc(0xFE, fp);
				else
				{
					bool bUnknown = true;
					for (u8 i = 0; i < MAX_SAVE_TYPES; i++)
					{
						if (strcmp(saveTypeNames[i], "") == 0) continue;
						if (strcasecmp(tmp, saveTypeNames[i]) == 0)
						{
							fputc(i, fp);
							bUnknown = false;
							break;
						}
					}
					if (bUnknown)
						fputc(0xFF, fp);	// Unknown
				}
			}
			else
				fputc(0xFF, fp);	// Unknown
		}
		fwrite(&reserved, 1, sizeof(u32), fp);
		fwrite(&reserved, 1, sizeof(u32), fp);
		count++;
		el = el->NextSiblingElement("game");
	}
	delete xml;
	fclose(fp);
	if (count > 0) 
		printf("done\n");
	else
		printf("error\n");
	printf("ADVANsCEne converter: %i found\n", count);
	return count;
}
예제 #12
0
파일: mc.cpp 프로젝트: Bernieboy/nds4ios
u32 ADVANsCEne::convertDB(const char *in_filaname)
{
	//these strings are contained in the xml file, verbatim, so they function as enum values
	//we leave the strings here rather than pooled elsewhere to remind us that theyre part of the advanscene format.
	const char *saveTypeNames[] = {
		"Eeprom - 4 kbit",		// EEPROM 4kbit
		"Eeprom - 64 kbit",		// EEPROM 64kbit
		"Eeprom - 512 kbit",	// EEPROM 512kbit
		"Fram - 256 kbit",		// FRAM 256kbit !
		"Flash - 2 mbit",		// FLASH 2Mbit
		"Flash - 4 mbit",		// FLASH 4Mbit
		"Flash - 8 mbit",		// FLASH 8Mbit
		"Flash - 16 mbit",		// FLASH 16Mbit !
		"Flash - 32 mbit",		// FLASH 32Mbit !
		"Flash - 64 mbit",		// FLASH 64Mbit
		"Flash - 128 mbit",		// FLASH 128Mbit !
		"Flash - 256 mbit",		// FLASH 256Mbit !
		"Flash - 512 mbit"		// FLASH 512Mbit !
	};

	TiXmlDocument	*xml = NULL;
	TiXmlElement	*el = NULL;
	TiXmlElement	*el_serial = NULL;
	TiXmlElement	*el_games = NULL;
	TiXmlElement	*el_crc32 = NULL;
	TiXmlElement	*el_saveType = NULL;
	FILE			*fp;
	u32				crc32 = 0;
	u32				reserved = 0;

	lastImportErrorMessage = "";

	printf("Converting DB...\n");
	if (getXMLConfig(in_filaname))
	{
		if (datName.size()==0) return 0;
		if (datName != _ADVANsCEne_BASE_NAME) return 0;
	}

	fp = fopen(database_path, "wb");
	if (!fp) return 0;

	// Header
	fwrite(_ADVANsCEne_BASE_ID, 1, strlen(_ADVANsCEne_BASE_ID), fp);
	fputc(_ADVANsCEne_BASE_VERSION_MAJOR, fp);
	fputc(_ADVANsCEne_BASE_VERSION_MINOR, fp);
	if (datVersion.size()) 
		fwrite(&datVersion[0], 1, datVersion.size(), fp);
	else
		fputc(0, fp);
	time_t __time = time(NULL);
	fwrite(&__time, 1, sizeof(time_t), fp);

	xml = new TiXmlDocument();
	if (!xml) { fclose(fp); return 0; }
	if (!xml->LoadFile(in_filaname)) { fclose(fp); return 0; }
	el = xml->FirstChildElement("dat");
	if (!el) { fclose(fp); return 0; }
	el_games = el->FirstChildElement("games");
	if (!el_games) { fclose(fp); return 0; }
	el = el_games->FirstChildElement("game");
	if (!el) { fclose(fp); return 0; }
	u32 count = 0;
	while (el)
	{
		TiXmlElement* title = el->FirstChildElement("title");
		if(title)
		{
			//just a little diagnostic
			//printf("Importing %s\n",title->GetText());
		}
		else { fclose(fp); return 0; }

		el_serial = el->FirstChildElement("serial");
		
		if(!el_serial)
		{
			lastImportErrorMessage = "Missing <serial> element. Did you use the right xml file? We need the RtoolDS one.";
			fclose(fp); 
			return 0;
		}
		if (fwrite(el_serial->GetText(), 1, 8, fp) != 8)
		{
			lastImportErrorMessage = "Error writing output file";
			fclose(fp); return 0;
		}


		// CRC32
		el_crc32 = el->FirstChildElement("files"); 
		sscanf_s(el_crc32->FirstChildElement("romCRC")->GetText(), "%x", &crc32);
		if (fwrite(&crc32, 1, sizeof(u32), fp) != sizeof(u32))
		{
			fclose(fp); return 0;
		}
		// Save type
		el_saveType = el->FirstChildElement("saveType"); 
		if (el_saveType)
		{
			const char *tmp = el_saveType->GetText();
			if (tmp)
			{
				if (strcmp(tmp, "None")  == 0)
					fputc(0xFE, fp);
				else
				{
					bool bUnknown = true;
					for (u8 i = 0; i < MAX_SAVE_TYPES; i++)
					{
						if (strcmp(saveTypeNames[i], "") == 0) continue;
						if (strcasecmp(tmp, saveTypeNames[i]) == 0)
						{
							fputc(i, fp);
							bUnknown = false;
							break;
						}
					}
					if (bUnknown)
						fputc(0xFF, fp);	// Unknown
				}
			}
			else
				fputc(0xFF, fp);	// Unknown
		}
		fwrite(&reserved, 1, sizeof(u32), fp);
		fwrite(&reserved, 1, sizeof(u32), fp);
		count++;
		el = el->NextSiblingElement("game");
	}
	printf("\n");
	delete xml;
	fclose(fp);
	if (count > 0) 
		printf("done\n");
	else
		printf("error\n");
	printf("ADVANsCEne converter: %i found\n", count);
	return count;
}