Ejemplo n.º 1
0
const char*  set_keyvalue(const char* xmlstr, const char* catelog_name, const char* key_name, const char* value)
{
	if ((!catelog_name) || (!key_name) || (!value))
	{
		DbgPrint("get_keyvalue input parameter error");
		return (NULL);
	}

	mxml_node_t *xml;

	if (xmlstr == NULL)
	{
		xml = mxmlNewXML("1.0");
	}
	else
	{
		xml = mxmlLoadString(NULL, xmlstr, MXML_TEXT_CALLBACK);
	}

	if (xml == NULL)
	{
		DbgPrint("xml load err: %s", xmlstr);
		return (NULL);
	}

	mxml_node_t *catelog = mxmlFindElement(xml, xml, catelog_name, NULL, NULL, MXML_DESCEND);

	if (catelog == NULL)
	{
		catelog = mxmlNewElement(xml, catelog_name);
	}

	mxml_node_t *node = mxmlFindElement(catelog,catelog,key_name,NULL,NULL,MXML_DESCEND);
	if (node)
	{
		mxmlSetText(node, 0, value);
	}
	else
	{
		node = mxmlNewElement(catelog, key_name);
		mxmlNewText(node, 0, value);
	}

	mxmlSetWrapMargin(2);
	char* system_xmlstr = strdup_tls(mxmlSaveAllocString(xml, MXML_TEXT_CALLBACK));
	mxmlDelete(xml);

	return (system_xmlstr);
}
Ejemplo n.º 2
0
bool IAPointsSerializer::guardarXMLIAPoints(string nombreFichero)
{
    if (_xml != nullptr)
    {
        mxmlSetWrapMargin(0);
        _fp = fopen(nombreFichero.c_str(), "w");
        if (_fp)
        {
            mxmlSaveFile(_xml, _fp, retornoCarro_Callback); // retornoCarro_Callback, será llamado por mxmlSaveFile por cada etiqueta escrita
            fclose(_fp);                                    // así hacemos más legible el fichero xml en caso de necesitar editarlo a mano.
        }

        return true;
    }

    return false;
}
Ejemplo n.º 3
0
static int
preparePalData (gamePalette pals[], int palCount)
{
	xml = mxmlNewXML("1.0");
	mxmlSetWrapMargin(0); // disable line wrapping

	data = mxmlNewElement(xml, "palette");
	mxmlElementSetAttr(data, "app", APPNAME);
	mxmlElementSetAttr(data, "version", APPVERSION);
	for (int i=0; i<palCount; i++)
		createXMLPalette(&pals[i], false);

	int datasize = mxmlSaveString(xml, (char *)savebuffer, SAVEBUFFERSIZE, XMLSavePalCallback);

	mxmlDelete(xml);

	return datasize;
}
Ejemplo n.º 4
0
static int preparePrefsData() {
	xml = mxmlNewXML("1.0");
	mxmlSetWrapMargin(0); // disable line wrapping

	data = mxmlNewElement(xml, "file");
	mxmlElementSetAttr(data, "app", APPNAME);
	mxmlElementSetAttr(data, "version", APPVERSION);

	createXMLSection("Menu", "Menu Settings");

	createXMLSetting("ExitAction", "Exit Action", toStr(XMPlayerCfg.exit_action));
	createXMLSetting("language", "Language", toStr(XMPlayerCfg.language));
	createXMLSetting("sort_order", "Sort Order", toStr(XMPlayerCfg.sort_order));

	int datasize = mxmlSaveString(xml, (char *) savebuffer, SAVEBUFFERSIZE, XMLSaveCallback);

	mxmlDelete(xml);
	
	printf("XMPlayerCfg.language : %d\n",XMPlayerCfg.language);

	return datasize;
}
Ejemplo n.º 5
0
static int
preparePrefsData ()
{
	xml = mxmlNewXML("1.0");
	mxmlSetWrapMargin(0); // disable line wrapping

	data = mxmlNewElement(xml, "file");
	mxmlElementSetAttr(data, "app", APPNAME);
	mxmlElementSetAttr(data, "version", APPVERSION);

	createXMLSection("File", "File Settings");

	createXMLSetting("AutoLoad", "Auto Load", toStr(GCSettings.AutoLoad));
	createXMLSetting("AutoSave", "Auto Save", toStr(GCSettings.AutoSave));
	createXMLSetting("LoadMethod", "Load Method", toStr(GCSettings.LoadMethod));
	createXMLSetting("SaveMethod", "Save Method", toStr(GCSettings.SaveMethod));
	createXMLSetting("LoadFolder", "Load Folder", GCSettings.LoadFolder);
	createXMLSetting("LastFileLoaded", "Last File Loaded", GCSettings.LastFileLoaded);
	createXMLSetting("SaveFolder", "Save Folder", GCSettings.SaveFolder);
	createXMLSetting("AppendAuto", "Append Auto to .SAV Files", toStr(GCSettings.AppendAuto));
	//createXMLSetting("CheatFolder", "Cheats Folder", GCSettings.CheatFolder);
	createXMLSetting("ScreenshotsFolder", "Screenshots Folder", GCSettings.ScreenshotsFolder);
	createXMLSetting("BorderFolder", "SGB Borders Folder", GCSettings.BorderFolder);
	createXMLSetting("CoverFolder", "Covers Folder", GCSettings.CoverFolder);
	createXMLSetting("ArtworkFolder", "Artworks Folder", GCSettings.ArtworkFolder);
	createXMLSetting("ImageFolder", "Image Folder", GCSettings.ImageFolder);

	createXMLSection("Network", "Network Settings");

	createXMLSetting("smbip", "Share Computer IP", GCSettings.smbip);
	createXMLSetting("smbshare", "Share Name", GCSettings.smbshare);
	createXMLSetting("smbuser", "Share Username", GCSettings.smbuser);
	createXMLSetting("smbpwd", "Share Password", GCSettings.smbpwd);

	createXMLSection("Video", "Video Settings");

	createXMLSetting("videomode", "Video Mode", toStr(GCSettings.videomode));
	createXMLSetting("gbaZoomHor", "GBA Horizontal Zoom Level", FtoStr(GCSettings.gbaZoomHor));
	createXMLSetting("gbaZoomVert", "GBA Vertical Zoom Level", FtoStr(GCSettings.gbaZoomVert));
	createXMLSetting("gbZoomHor", "GB Horizontal Zoom Level", FtoStr(GCSettings.gbZoomHor));
	createXMLSetting("gbZoomVert", "GB Vertical Zoom Level", FtoStr(GCSettings.gbZoomVert));
	createXMLSetting("gbFixed", "GB Fixed Pixel Ratio", toStr(GCSettings.gbFixed));
	createXMLSetting("gbaFixed", "GBA Fixed Pixel Ratio", toStr(GCSettings.gbaFixed));
	createXMLSetting("render", "Video Filtering", toStr(GCSettings.render));
	createXMLSetting("scaling", "Aspect Ratio Correction", toStr(GCSettings.scaling));
	createXMLSetting("xshift", "Horizontal Video Shift", toStr(GCSettings.xshift));
	createXMLSetting("yshift", "Vertical Video Shift", toStr(GCSettings.yshift));
	createXMLSetting("colorize", "Colorize Mono Gameboy", toStr(GCSettings.colorize));
	createXMLSetting("gbaFrameskip", "GBA Frameskip", toStr(GCSettings.gbaFrameskip));

	createXMLSection("Menu", "Menu Settings");

	createXMLSetting("WiimoteOrientation", "Wiimote Orientation", toStr(GCSettings.WiimoteOrientation));
	createXMLSetting("ExitAction", "Exit Action", toStr(GCSettings.ExitAction));
	createXMLSetting("MusicVolume", "Music Volume", toStr(GCSettings.MusicVolume));
	createXMLSetting("SFXVolume", "Sound Effects Volume", toStr(GCSettings.SFXVolume));
	createXMLSetting("Rumble", "Rumble", toStr(GCSettings.Rumble));
	createXMLSetting("language", "Language", toStr(GCSettings.language));
	createXMLSetting("PreviewImage", "Preview Image", toStr(GCSettings.PreviewImage));

	createXMLSection("Emulation", "Emulation Settings");

	createXMLSetting("BasicPalette", "Basic Color Palette for GB", toStr(GCSettings.BasicPalette));
	
	createXMLSection("Controller", "Controller Settings");

	createXMLSetting("WiiControls", "Match Wii Game", toStr(GCSettings.WiiControls));
	createXMLController(btnmap[CTRLR_GCPAD], "gcpadmap", "GameCube Pad");
	createXMLController(btnmap[CTRLR_WIIMOTE], "wmpadmap", "Wiimote");
	createXMLController(btnmap[CTRLR_CLASSIC], "ccpadmap", "Classic Controller");
	createXMLController(btnmap[CTRLR_NUNCHUK], "ncpadmap", "Nunchuk");

	createXMLSection("Emulation", "Emulation Settings");

	createXMLSetting("OffsetMinutesUTC", "Offset from UTC (minutes)", toStr(GCSettings.OffsetMinutesUTC));
	createXMLSetting("GBHardware", "Hardware (GB/GBC)", toStr(GCSettings.GBHardware));
	createXMLSetting("SGBBorder", "Border (GB/GBC)", toStr(GCSettings.SGBBorder));

	int datasize = mxmlSaveString(xml, (char *)savebuffer, SAVEBUFFERSIZE, XMLSaveCallback);

	mxmlDelete(xml);

	return datasize;
}
Ejemplo n.º 6
0
int main (int argc, char *argv[])
{
	Log log;
	FILE *inFp = 0;
	FILE *outFp = 0; 
	mxml_node_t 	*outTree = 0;	// hold the xml input to ICAT
	mxml_node_t 	*inTree = 0;	// Hold the parameter list
	try
	{
		// Check if my assumption of type size are correct. 
		// ************************************************

		if(sizeof(short) != 2 || sizeof(int) != 4 )
			log.set("Compiler Test", "The integer sizes are not as expected", "(short 2 bytes; int 4 bytes)").printLevel(NXING_LOG_WARNING);
		if(sizeof(float) != 4 ||sizeof(double) != 8)
			log.set("Compiler Test", "The float sizes are not as expected", "(float 4 bytes; double 8 bytes)").printLevel(NXING_LOG_WARNING);

		char mappingFl[NXING_BIG_SIZE] = "";	
		char nexusFl[NXING_BIG_SIZE]   = "";
		char outputFl[NXING_BIG_SIZE]  = "";	
		
		if(argc < 3)
		{
			throw log.set("main", "Not enough input parameters!", "Needs 2 input files, mapping file and the NeXus file.", "And one output file.", NXING_ERR_WRONG_INPUT);
		}
		else 
		{
			if(argv[1] != 0) strcpy(mappingFl, argv[1]);	
			if(argv[2] != 0) strcpy(nexusFl, argv[2]);
			if(argv[3] != 0) strcpy(outputFl, argv[3]);
			else strcpy(outputFl, "output.xml");	
		}
		log.set("main", "input - mapping", mappingFl).printLevel(NXING_LOG_NORMAL);
		log.set("main", "input - nexus  ", nexusFl).printLevel(NXING_LOG_NORMAL);
		log.set("main", "input - output ", outputFl).printLevel(NXING_LOG_NORMAL);
		
		
		// Read input XML Parameters. 
		// **************************'
#ifndef MXML_WRAP
		mxmlSetWrapMargin(0);
#endif
		inFp = fopen(mappingFl, "r");
		if( inFp == 0 ) throw log.set("main", "Can't open the parameter file!", mappingFl, "", NXING_ERR_CANT_OPEN_PARAM);
		mxml_node_t 	*inNode;	// hold the node to read from.
		inTree = mxmlLoadFile(NULL, inFp, MXML_TEXT_CALLBACK);
		fclose(inFp);
		inFp = 0;
		if(inTree != 0) log.set("main", "The mapping file has been read!", mappingFl).printLevel(NXING_LOG_ALL);

		
		// Create XML output to ICAT. 
		// **************************
		outFp = fopen(outputFl, "w");
		if( outFp == 0 ) throw log.set("main", "Can't open the output file!", outputFl, "", NXING_ERR_CANT_OPEN_OUTPUT);
	
		if(inTree->type == MXML_ELEMENT  && (strncmp(inTree->value.element.name, "?xml", 4) == 0)){	
			outTree = mxmlNewElement(MXML_NO_PARENT,  inTree->value.element.name);
		}
		
		log.set("main", "Output Created, first tag added!", inTree->value.element.name).printLevel(NXING_LOG_DEBUG);
		//

		// Open the neXus file.
		// ********************
		NxClass nx(nexusFl);
		//if(nx.isNotOK) throw log.set("Can't open the neXus file!", nexusFl, nx.status);
		log.set("main", "NeXµs file read!", nexusFl, "", nx.status).printLevel(NXING_LOG_DEBUG);

		/*
	 	 * Parse the parameter file, read the neXus file and populate the XML output. 
		 */
		 log.set("main", "Parsing the mapping file!").printLevel(NXING_LOG_DEBUG);
		 inNode = mxmlWalkNext(inTree, inTree, MXML_DESCEND);
		 parseXml(inNode, &outTree, nx);

	
		/* 
		 * Save the output file
		 */  	
		mxmlSaveFile(outTree, outFp, whitespace_cb); 
		log.set("main", "Output file Saved!", outputFl).printLevel(NXING_LOG_DEBUG);

		/* 
		 * Close the files
		 */
		fclose(outFp);
		/*
	     * Delete the xml Trees
	     */
		mxmlDelete(inTree);
	 	mxmlDelete(outTree);
		exit(0);
	}
	catch(Log log)
	{
		log.printLevel(NXING_LOG_ERROR);
		if(inFp  != 0) fclose(inFp);		
		if(outFp != 0) fclose(outFp);
		
		if(inTree  != 0) mxmlDelete(inTree);
	 	if(outTree != 0) mxmlDelete(outTree);
		exit(0);
	}	
}
Ejemplo n.º 7
0
void Child::run() {
	LocalCapture* localCapture = NULL;
	pthread_t durationThreadID, stopThreadID, senderThreadID;

	prctl(PR_SET_NAME, (unsigned long)&"gatord-child", 0, 0, 0);

	// Disable line wrapping when generating xml files; carriage returns and indentation to be added manually
	mxmlSetWrapMargin(0);

	// Instantiate the Sender - must be done first, after which error messages can be sent
	sender = new Sender(socket);

	if (mNumConnections > 1) {
		logg->logError(__FILE__, __LINE__, "Session already in progress");
		handleException();
	}

	// Populate gSessionData with the configuration
	{ ConfigurationXML configuration; }

	// Set up the driver; must be done after gSessionData->mPerfCounterType[] is populated
	if (!gSessionData->perf.isSetup()) {
		primarySource = new DriverSource(&senderSem, &startProfile);
	} else {
		primarySource = new PerfSource(&senderSem, &startProfile);
	}

	// Initialize all drivers
	for (Driver *driver = Driver::getHead(); driver != NULL; driver = driver->getNext()) {
		driver->resetCounters();
	}

	// Set up counters using the associated driver's setup function
	for (int i = 0; i < MAX_PERFORMANCE_COUNTERS; i++) {
		Counter & counter = gSessionData->mCounters[i];
		if (counter.isEnabled()) {
			counter.getDriver()->setupCounter(counter);
		}
	}

	// Start up and parse session xml
	if (socket) {
		// Respond to Streamline requests
		StreamlineSetup ss(socket);
	} else {
		char* xmlString;
		xmlString = util->readFromDisk(gSessionData->mSessionXMLPath);
		if (xmlString == 0) {
			logg->logError(__FILE__, __LINE__, "Unable to read session xml file: %s", gSessionData->mSessionXMLPath);
			handleException();
		}
		gSessionData->parseSessionXML(xmlString);
		localCapture = new LocalCapture();
		localCapture->createAPCDirectory(gSessionData->mTargetPath);
		localCapture->copyImages(gSessionData->mImages);
		localCapture->write(xmlString);
		sender->createDataFile(gSessionData->mAPCDir);
		free(xmlString);
	}

	if (gSessionData->kmod.isMaliCapture() && (gSessionData->mSampleRate == 0)) {
		logg->logError(__FILE__, __LINE__, "Mali counters are not supported with Sample Rate: None.");
		handleException();
	}

	// Must be after session XML is parsed
	if (!primarySource->prepare()) {
		if (gSessionData->perf.isSetup()) {
			logg->logError(__FILE__, __LINE__, "Unable to prepare gator driver for capture");
		} else {
			logg->logError(__FILE__, __LINE__, "Unable to communicate with the perf API, please ensure that CONFIG_TRACING and CONFIG_CONTEXT_SWITCH_TRACER are enabled. Please refer to README_Streamline.txt for more information.");
		}
		handleException();
	}

	// Sender thread shall be halted until it is signaled for one shot mode
	sem_init(&haltPipeline, 0, gSessionData->mOneShot ? 0 : 2);

	// Must be initialized before senderThread is started as senderThread checks externalSource
	externalSource = new ExternalSource(&senderSem);
	if (!externalSource->prepare()) {
		logg->logError(__FILE__, __LINE__, "Unable to prepare external source for capture");
		handleException();
	}
	externalSource->start();

	// Create the duration, stop, and sender threads
	bool thread_creation_success = true;
	if (gSessionData->mDuration > 0 && pthread_create(&durationThreadID, NULL, durationThread, NULL)) {
		thread_creation_success = false;
	} else if (socket && pthread_create(&stopThreadID, NULL, stopThread, NULL)) {
		thread_creation_success = false;
	} else if (pthread_create(&senderThreadID, NULL, senderThread, NULL)) {
		thread_creation_success = false;
	}

	bool startUSSource = false;
	for (int i = 0; i < ARRAY_LENGTH(gSessionData->usDrivers); ++i) {
		if (gSessionData->usDrivers[i]->countersEnabled()) {
			startUSSource = true;
		}
	}
	if (startUSSource) {
		userSpaceSource = new UserSpaceSource(&senderSem);
		if (!userSpaceSource->prepare()) {
			logg->logError(__FILE__, __LINE__, "Unable to prepare userspace source for capture");
			handleException();
		}
		userSpaceSource->start();
	}

	if (gSessionData->ftraceDriver.countersEnabled()) {
		ftraceSource = new FtraceSource(&senderSem);
		if (!ftraceSource->prepare()) {
			logg->logError(__FILE__, __LINE__, "Unable to prepare userspace source for capture");
			handleException();
		}
		ftraceSource->start();
	}

	if (gSessionData->mAllowCommands && (gSessionData->mCaptureCommand != NULL)) {
		pthread_t thread;
		if (pthread_create(&thread, NULL, commandThread, NULL)) {
			thread_creation_success = false;
		}
	}

	if (!thread_creation_success) {
		logg->logError(__FILE__, __LINE__, "Failed to create gator threads");
		handleException();
	}

	// Wait until thread has started
	sem_wait(&senderThreadStarted);

	// Start profiling
	primarySource->run();

	if (ftraceSource != NULL) {
		ftraceSource->join();
	}
	if (userSpaceSource != NULL) {
		userSpaceSource->join();
	}
	externalSource->join();

	// Wait for the other threads to exit
	pthread_join(senderThreadID, NULL);

	// Shutting down the connection should break the stop thread which is stalling on the socket recv() function
	if (socket) {
		logg->logMessage("Waiting on stop thread");
		socket->shutdownConnection();
		pthread_join(stopThreadID, NULL);
	}

	// Write the captured xml file
	if (gSessionData->mLocalCapture) {
		CapturedXML capturedXML;
		capturedXML.write(gSessionData->mAPCDir);
	}

	logg->logMessage("Profiling ended.");

	delete ftraceSource;
	delete userSpaceSource;
	delete externalSource;
	delete primarySource;
	delete sender;
	delete localCapture;
}
Ejemplo n.º 8
0
static int
preparePrefsData ()
{
	xml = mxmlNewXML("1.0");
	mxmlSetWrapMargin(0); // disable line wrapping

	data = mxmlNewElement(xml, "file");
	mxmlElementSetAttr(data, "app", APPNAME);
	mxmlElementSetAttr(data, "version", APPVERSION);

	createXMLSection("File", "File Settings");

	createXMLSetting("AutoLoad", "Auto Load", toStr(GCSettings.AutoLoad));
	createXMLSetting("AutoSave", "Auto Save", toStr(GCSettings.AutoSave));
	createXMLSetting("LoadMethod", "Load Method", toStr(GCSettings.LoadMethod));
	createXMLSetting("SaveMethod", "Save Method", toStr(GCSettings.SaveMethod));
	createXMLSetting("LoadFolder", "Load Folder", GCSettings.LoadFolder);
	createXMLSetting("SaveFolder", "Save Folder", GCSettings.SaveFolder);
	createXMLSetting("CheatFolder", "Cheats Folder", GCSettings.CheatFolder);
	createXMLSetting("gamegenie", "Game Genie", toStr(GCSettings.gamegenie));

	createXMLSection("Network", "Network Settings");

	createXMLSetting("netplayIp", "Netplay IP", GCSettings.netplayIp);
	createXMLSetting("netplayPort", "Netplay Port", GCSettings.netplayPort);
	createXMLSetting("netplayPwd", "Netplay Password", GCSettings.netplayPwd);
	createXMLSetting("netplayNameX", "Netplay Player/Host Name", GCSettings.netplayNameX);
	createXMLSetting("netplayNameY", "Netplay Player Name", GCSettings.netplayNameY);
	createXMLSetting("netplayNameZ", "Netplay Player Name", GCSettings.netplayNameZ);
	createXMLSetting("smbip", "Share Computer IP", GCSettings.smbip);
	createXMLSetting("smbshare", "Share Name", GCSettings.smbshare);
	createXMLSetting("smbuser", "Share Username", GCSettings.smbuser);
	createXMLSetting("smbpwd", "Share Password", GCSettings.smbpwd);

	createXMLSection("Video", "Video Settings");

	createXMLSetting("videomode", "Video Mode", toStr(GCSettings.videomode));
	createXMLSetting("currpal", "Palette", toStr(GCSettings.currpal));
	createXMLSetting("timing", "Timing", toStr(GCSettings.timing));
	createXMLSetting("spritelimit", "Sprite Limit", toStr(GCSettings.spritelimit));
	createXMLSetting("zoomHor", "Horizontal Zoom Level", FtoStr(GCSettings.zoomHor));
	createXMLSetting("zoomVert", "Vertical Zoom Level", FtoStr(GCSettings.zoomVert));
	createXMLSetting("render", "Video Filtering", toStr(GCSettings.render));
	createXMLSetting("widescreen", "Aspect Ratio Correction", toStr(GCSettings.widescreen));
	createXMLSetting("hideoverscan", "Video Cropping", toStr(GCSettings.hideoverscan));
	createXMLSetting("xshift", "Horizontal Video Shift", toStr(GCSettings.xshift));
	createXMLSetting("yshift", "Vertical Video Shift", toStr(GCSettings.yshift));

	createXMLSection("Menu", "Menu Settings");

	createXMLSetting("WiimoteOrientation", "Wiimote Orientation", toStr(GCSettings.WiimoteOrientation));
	createXMLSetting("ExitAction", "Exit Action", toStr(GCSettings.ExitAction));
	createXMLSetting("MusicVolume", "Music Volume", toStr(GCSettings.MusicVolume));
	createXMLSetting("SFXVolume", "Sound Effects Volume", toStr(GCSettings.SFXVolume));
	createXMLSetting("Rumble", "Rumble", toStr(GCSettings.Rumble));
	createXMLSetting("language", "Language", toStr(GCSettings.language));

	createXMLSection("Controller", "Controller Settings");

	createXMLSetting("Controller", "Controller", toStr(GCSettings.Controller));
	createXMLSetting("crosshair", "Zapper Crosshair", toStr(GCSettings.crosshair));

	createXMLController(btnmap[CTRL_PAD][CTRLR_GCPAD], "btnmap_pad_gcpad", "NES Pad - GameCube Controller");
	createXMLController(btnmap[CTRL_PAD][CTRLR_WIIMOTE], "btnmap_pad_wiimote", "NES Pad - Wiimote");
	createXMLController(btnmap[CTRL_PAD][CTRLR_CLASSIC], "btnmap_pad_classic", "NES Pad - Classic Controller");
	createXMLController(btnmap[CTRL_PAD][CTRLR_NUNCHUK], "btnmap_pad_nunchuk", "NES Pad - Nunchuk + Wiimote");
	createXMLController(btnmap[CTRL_ZAPPER][CTRLR_GCPAD], "btnmap_zapper_gcpad", "Zapper - GameCube Controller");
	createXMLController(btnmap[CTRL_ZAPPER][CTRLR_WIIMOTE], "btnmap_zapper_wiimote", "Zapper - Wiimote");

	int datasize = mxmlSaveString(xml, (char *)savebuffer, SAVEBUFFERSIZE, XMLSaveCallback);

	mxmlDelete(xml);

	return datasize;
}
Ejemplo n.º 9
0
static int
preparePrefsData ()
{
	xml = mxmlNewXML("1.0");
	mxmlSetWrapMargin(0); // disable line wrapping

	data = mxmlNewElement(xml, "file");
	mxmlElementSetAttr(data, "app", APPNAME);
	mxmlElementSetAttr(data, "version", APPVERSION);

	createXMLSection("File", "File Settings");

	createXMLSetting("AutoLoad", "Auto Load", toStr(GCSettings.AutoLoad));
	createXMLSetting("AutoSave", "Auto Save", toStr(GCSettings.AutoSave));
	createXMLSetting("LoadMethod", "Load Method", toStr(GCSettings.LoadMethod));
	createXMLSetting("SaveMethod", "Save Method", toStr(GCSettings.SaveMethod));
	createXMLSetting("LoadFolder", "Load Folder", GCSettings.LoadFolder);
	createXMLSetting("LastFileLoaded", "Last File Loaded", GCSettings.LastFileLoaded);
	createXMLSetting("SaveFolder", "Save Folder", GCSettings.SaveFolder);
	createXMLSetting("CheatFolder", "Cheats Folder", GCSettings.CheatFolder);
	createXMLSetting("ScreenshotsFolder", "Screenshots Folder", GCSettings.ScreenshotsFolder);

	createXMLSection("Network", "Network Settings");

	createXMLSetting("smbip", "Share Computer IP", GCSettings.smbip);
	createXMLSetting("smbshare", "Share Name", GCSettings.smbshare);
	createXMLSetting("smbuser", "Share Username", GCSettings.smbuser);
	createXMLSetting("smbpwd", "Share Password", GCSettings.smbpwd);

	createXMLSection("Video", "Video Settings");

	createXMLSetting("videomode", "Video Mode", toStr(GCSettings.videomode));
	createXMLSetting("zoomHor", "Horizontal Zoom Level", FtoStr(GCSettings.zoomHor));
	createXMLSetting("zoomVert", "Vertical Zoom Level", FtoStr(GCSettings.zoomVert));
	createXMLSetting("render", "Video Filtering", toStr(GCSettings.render));
	createXMLSetting("widescreen", "Aspect Ratio Correction", toStr(GCSettings.widescreen));
	createXMLSetting("crosshair", "Crosshair", toStr(GCSettings.crosshair));
	createXMLSetting("FilterMethod", "Filter Method", toStr(GCSettings.FilterMethod));
	createXMLSetting("xshift", "Horizontal Video Shift", toStr(GCSettings.xshift));
	createXMLSetting("yshift", "Vertical Video Shift", toStr(GCSettings.yshift));

	createXMLSection("Menu", "Menu Settings");

	createXMLSetting("WiimoteOrientation", "Wiimote Orientation", toStr(GCSettings.WiimoteOrientation));
	createXMLSetting("ExitAction", "Exit Action", toStr(GCSettings.ExitAction));
	createXMLSetting("MusicVolume", "Music Volume", toStr(GCSettings.MusicVolume));
	createXMLSetting("SFXVolume", "Sound Effects Volume", toStr(GCSettings.SFXVolume));
	createXMLSetting("Rumble", "Rumble", toStr(GCSettings.Rumble));
	createXMLSetting("language", "Language", toStr(GCSettings.language));

	createXMLSection("Controller", "Controller Settings");

	createXMLSetting("Controller", "Controller", toStr(GCSettings.Controller));

	createXMLController(btnmap[CTRL_PAD][CTRLR_GCPAD], "btnmap_pad_gcpad", "SNES Pad - GameCube Controller");
	createXMLController(btnmap[CTRL_PAD][CTRLR_WIIMOTE], "btnmap_pad_wiimote", "SNES Pad - Wiimote");
	createXMLController(btnmap[CTRL_PAD][CTRLR_CLASSIC], "btnmap_pad_classic", "SNES Pad - Classic Controller");
	createXMLController(btnmap[CTRL_PAD][CTRLR_NUNCHUK], "btnmap_pad_nunchuk", "SNES Pad - Nunchuk + Wiimote");
	createXMLController(btnmap[CTRL_SCOPE][CTRLR_GCPAD], "btnmap_scope_gcpad", "Superscope - GameCube Controller");
	createXMLController(btnmap[CTRL_SCOPE][CTRLR_WIIMOTE], "btnmap_scope_wiimote", "Superscope - Wiimote");
	createXMLController(btnmap[CTRL_MOUSE][CTRLR_GCPAD], "btnmap_mouse_gcpad", "Mouse - GameCube Controller");
	createXMLController(btnmap[CTRL_MOUSE][CTRLR_WIIMOTE], "btnmap_mouse_wiimote", "Mouse - Wiimote");
	createXMLController(btnmap[CTRL_JUST][CTRLR_GCPAD], "btnmap_just_gcpad", "Justifier - GameCube Controller");
	createXMLController(btnmap[CTRL_JUST][CTRLR_WIIMOTE], "btnmap_just_wiimote", "Justifier - Wiimote");

	int datasize = mxmlSaveString(xml, (char *)savebuffer, SAVEBUFFERSIZE, XMLSaveCallback);

	mxmlDelete(xml);

	return datasize;
}
Ejemplo n.º 10
0
int main_2(int argc, const char * argv[])
{
    mxml_node_t * xml; /*<?xml ... ?>*/
    mxml_node_t * data; /*<data>*/
    mxml_node_t * node; /*<node>*/
    mxml_node_t * group; /*group*/
/*xml*/
    xml = mxmlNewXML("1.0");
/*data*/
    data = mxmlNewElement(xml, "data");
    /*3个node*/
    node = mxmlNewElement(data, "node");
    mxmlNewText(node, 0, "val1");
    
    node = mxmlNewElement(data, "node");
    mxmlNewText(node, 0, "val2");
    
    node = mxmlNewElement(data, "node");
    mxmlNewText(node, 0, "val3");
    /*group*/
    group = mxmlNewElement(data, "group");
    /*group 下的三个node*/
    node = mxmlNewElement(group, "node");
    mxmlNewText(node, 0, "val4");
    
    node = mxmlNewElement(group, "node");
    mxmlNewText(node, 0, "val5");
    
    node = mxmlNewElement(group, "node");
    mxmlNewText(node, 0, "val6");
    
    /*2个node*/
    node = mxmlNewElement(data, "node");
    mxmlNewText(node, 0, "val7");
    
    node = mxmlNewElement(data, "node");
    mxmlNewText(node, 0, "val8");
    
/*自动折行控制------似乎不顶用!!!!!!*/
    mxmlSetWrapMargin(100);/*设置100列折行*/
    mxmlSetWrapMargin(0);/*取消自动折行*/
    
/*保存*/
    /*保存到文件*/
    FILE * fp;
    fp = fopen("/Users/zhangliang/Desktop/Project/C/Mini-XML/Mini-XML/testxml2.xml", "w");
    mxmlSaveFile(xml, fp, MXML_NO_CALLBACK);
    fclose(fp);
    
    
    /*保存到字符串中*/
    char buffer[4096];
    char * ptr;
    
    mxmlSaveString(xml, buffer, sizeof(buffer), MXML_NO_CALLBACK);
    
    ptr = mxmlSaveAllocString(xml, MXML_NO_CALLBACK);
    
    printf("buffer: %s\n", buffer);
    printf("alloc : %s\n", ptr);
    free(ptr);
    
    
    
    return 0;
}