2009-10-01 01:10:58 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* HomebrewXML Class
|
|
|
|
* for USB Loader GX
|
|
|
|
***************************************************************************/
|
2010-10-24 21:08:03 +02:00
|
|
|
#include <gctypes.h>
|
2009-10-01 01:10:58 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2010-10-24 21:08:03 +02:00
|
|
|
#include "FileOperations/fileops.h"
|
2011-06-25 21:50:57 +02:00
|
|
|
#include "xml/tinyxml.h"
|
2011-06-14 19:53:19 +02:00
|
|
|
#include "gecko.h"
|
2009-10-01 01:10:58 +02:00
|
|
|
|
|
|
|
#include "HomebrewXML.h"
|
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
#define ENTRIE_SIZE 8192
|
2009-10-01 01:10:58 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
/* qparam filename Filepath of the XML file */
|
|
|
|
int HomebrewXML::LoadHomebrewXMLData(const char* filename)
|
2010-09-17 18:15:18 +02:00
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
Name.clear();
|
|
|
|
Coder.clear();
|
|
|
|
Version.clear();
|
|
|
|
ShortDescription.clear();
|
|
|
|
LongDescription.clear();
|
|
|
|
Releasedate.clear();
|
2009-10-01 01:10:58 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
TiXmlDocument xmlDoc(filename);
|
|
|
|
if(!xmlDoc.LoadFile())
|
|
|
|
return false;
|
2009-10-01 01:10:58 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
TiXmlElement *appNode = xmlDoc.FirstChildElement("app");
|
2012-02-29 20:52:36 +01:00
|
|
|
if(!appNode)
|
|
|
|
return false;
|
2009-10-01 01:10:58 +02:00
|
|
|
|
2011-06-25 21:50:57 +02:00
|
|
|
TiXmlElement *node = NULL;
|
2009-10-01 01:10:58 +02:00
|
|
|
|
2011-06-25 21:50:57 +02:00
|
|
|
node = appNode->FirstChildElement("name");
|
|
|
|
if(node && node->FirstChild() && node->FirstChild()->Value())
|
2011-07-26 00:28:22 +02:00
|
|
|
Name = node->FirstChild()->Value();
|
2010-10-24 21:08:03 +02:00
|
|
|
|
2011-06-25 21:50:57 +02:00
|
|
|
node = appNode->FirstChildElement("coder");
|
|
|
|
if(node && node->FirstChild() && node->FirstChild()->Value())
|
2011-07-26 00:28:22 +02:00
|
|
|
Coder = node->FirstChild()->Value();
|
2009-10-01 01:10:58 +02:00
|
|
|
|
2011-06-25 21:50:57 +02:00
|
|
|
node = appNode->FirstChildElement("version");
|
|
|
|
if(node && node->FirstChild() && node->FirstChild()->Value())
|
2011-07-26 00:28:22 +02:00
|
|
|
Version = node->FirstChild()->Value();
|
2010-09-17 18:15:18 +02:00
|
|
|
|
2011-06-25 21:50:57 +02:00
|
|
|
node = appNode->FirstChildElement("short_description");
|
|
|
|
if(node && node->FirstChild() && node->FirstChild()->Value())
|
2011-07-26 00:28:22 +02:00
|
|
|
ShortDescription = node->FirstChild()->Value();
|
2010-09-17 18:15:18 +02:00
|
|
|
|
2011-06-25 21:50:57 +02:00
|
|
|
node = appNode->FirstChildElement("long_description");
|
|
|
|
if(node && node->FirstChild() && node->FirstChild()->Value())
|
2011-07-26 00:28:22 +02:00
|
|
|
LongDescription = node->FirstChild()->Value();
|
2009-10-01 01:10:58 +02:00
|
|
|
|
2011-06-25 21:50:57 +02:00
|
|
|
char ReleaseText[200];
|
|
|
|
memset(ReleaseText, 0, sizeof(ReleaseText));
|
2009-10-01 01:10:58 +02:00
|
|
|
|
2011-06-25 21:50:57 +02:00
|
|
|
node = appNode->FirstChildElement("release_date");
|
|
|
|
if(node && node->FirstChild() && node->FirstChild()->Value())
|
2011-07-26 00:28:22 +02:00
|
|
|
snprintf(ReleaseText, sizeof(ReleaseText), node->FirstChild()->Value());
|
2010-09-17 18:15:18 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
int len = (strlen(ReleaseText) - 6); //length of the date string without the 200000 at the end
|
|
|
|
if (len == 8)
|
|
|
|
snprintf(ReleaseText, sizeof(ReleaseText), "%c%c/%c%c/%c%c%c%c", ReleaseText[4], ReleaseText[5], ReleaseText[6], ReleaseText[7], ReleaseText[0], ReleaseText[1], ReleaseText[2], ReleaseText[3]);
|
|
|
|
else if (len == 6)
|
|
|
|
snprintf(ReleaseText, sizeof(ReleaseText), "%c%c/%c%c%c%c", ReleaseText[4], ReleaseText[5], ReleaseText[0], ReleaseText[1], ReleaseText[2], ReleaseText[3]);
|
|
|
|
else
|
|
|
|
snprintf(ReleaseText, sizeof(ReleaseText), "%s", ReleaseText);
|
2010-09-17 18:15:18 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
Releasedate = ReleaseText;
|
2009-10-01 01:10:58 +02:00
|
|
|
|
2011-06-25 21:50:57 +02:00
|
|
|
node = appNode->FirstChildElement("arguments");
|
|
|
|
if(!node)
|
|
|
|
return 1;
|
2011-06-14 19:53:19 +02:00
|
|
|
|
2011-06-25 21:50:57 +02:00
|
|
|
TiXmlElement *argNode = node->FirstChildElement("arg");
|
2011-06-14 19:53:19 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
while(argNode)
|
|
|
|
{
|
|
|
|
if(argNode->FirstChild() && argNode->FirstChild()->Value())
|
|
|
|
Arguments.push_back(std::string(argNode->FirstChild()->Value()));
|
2010-09-17 18:15:18 +02:00
|
|
|
|
2011-06-25 21:50:57 +02:00
|
|
|
argNode = argNode->NextSiblingElement();
|
2011-07-26 00:28:22 +02:00
|
|
|
}
|
2010-10-24 21:08:03 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
return 1;
|
2009-10-01 01:10:58 +02:00
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
|
|
|
|
/* Get name */
|
2010-10-24 21:08:03 +02:00
|
|
|
const char * HomebrewXML::GetName() const
|
2010-09-24 02:48:03 +02:00
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
return Name.c_str();
|
2010-09-24 02:48:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set Name */
|
|
|
|
void HomebrewXML::SetName(char * newName)
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
Name = newName;
|
2010-09-24 02:48:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get coder */
|
2010-10-24 21:08:03 +02:00
|
|
|
const char * HomebrewXML::GetCoder() const
|
2010-09-24 02:48:03 +02:00
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
return Coder.c_str();
|
2010-09-24 02:48:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get version */
|
2010-10-24 21:08:03 +02:00
|
|
|
const char * HomebrewXML::GetVersion() const
|
2010-09-24 02:48:03 +02:00
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
return Version.c_str();
|
2010-09-24 02:48:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get releasedate */
|
2010-10-24 21:08:03 +02:00
|
|
|
const char * HomebrewXML::GetReleasedate() const
|
2010-09-24 02:48:03 +02:00
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
return Releasedate.c_str();
|
2010-09-24 02:48:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get shortdescription */
|
2010-10-24 21:08:03 +02:00
|
|
|
const char * HomebrewXML::GetShortDescription() const
|
2010-09-24 02:48:03 +02:00
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
return ShortDescription.c_str();
|
2010-09-24 02:48:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get longdescription */
|
2010-10-24 21:08:03 +02:00
|
|
|
const char * HomebrewXML::GetLongDescription() const
|
2010-09-24 02:48:03 +02:00
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
return LongDescription.c_str();
|
2010-09-24 02:48:03 +02:00
|
|
|
}
|