mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-29 06:34:17 +01:00
1cc7d3acd6
* Added initial (untested!) support for the zip file format, which is supported by the HBC * Began working on compressed wad files. Uncompressing fails for now, so uploading WAD files should be done with the previous version of Wiiload. * Fixed issue 902 (hence the large commit).
68 lines
2.3 KiB
C++
68 lines
2.3 KiB
C++
/****************************************************************************
|
|
* HomebrewXML Class
|
|
* for USB Loader GX
|
|
***************************************************************************/
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include "xml/xml.h"
|
|
|
|
#include "HomebrewXML.h"
|
|
|
|
HomebrewXML::HomebrewXML() {
|
|
strcpy(name,"");
|
|
strcpy(coder,"");
|
|
strcpy(version,"");
|
|
strcpy(releasedate,"");
|
|
strcpy(shortdescription,"");
|
|
strcpy(longdescription,"");
|
|
}
|
|
|
|
HomebrewXML::~HomebrewXML() {
|
|
}
|
|
|
|
int HomebrewXML::LoadHomebrewXMLData(const char* filename) {
|
|
mxml_node_t *nodedataHB = NULL;
|
|
mxml_node_t *nodetreeHB = NULL;
|
|
char tmp1[40];
|
|
|
|
/* Load XML file */
|
|
FILE *filexml;
|
|
filexml = fopen(filename, "rb");
|
|
if (!filexml) {
|
|
return -1;
|
|
}
|
|
|
|
nodetreeHB = mxmlLoadFile(NULL, filexml, MXML_OPAQUE_CALLBACK);
|
|
fclose(filexml);
|
|
|
|
if (nodetreeHB == NULL) {
|
|
return -2;
|
|
}
|
|
|
|
nodedataHB = mxmlFindElement(nodetreeHB, nodetreeHB, "app", NULL, NULL, MXML_DESCEND);
|
|
if (nodedataHB == NULL) {
|
|
return -5;
|
|
}
|
|
|
|
GetTextFromNode(nodedataHB, nodedataHB, (char*) "name", NULL, NULL, MXML_DESCEND, name,sizeof(name));
|
|
GetTextFromNode(nodedataHB, nodedataHB, (char*) "coder", NULL, NULL, MXML_DESCEND, coder,sizeof(coder));
|
|
GetTextFromNode(nodedataHB, nodedataHB, (char*) "version", NULL, NULL, MXML_DESCEND, version,sizeof(version));
|
|
GetTextFromNode(nodedataHB, nodedataHB, (char*) "release_date", NULL, NULL, MXML_DESCEND, tmp1,sizeof(tmp1));
|
|
GetTextFromNode(nodedataHB, nodedataHB, (char*) "short_description", NULL, NULL, MXML_DESCEND, shortdescription,sizeof(shortdescription));
|
|
GetTextFromNode(nodedataHB, nodedataHB, (char*) "long_description", NULL, NULL, MXML_DESCEND, longdescription,sizeof(longdescription));
|
|
|
|
int len = (strlen(tmp1)-6); //length of the date string without the 200000 at the end
|
|
|
|
if (len == 8)
|
|
snprintf(releasedate, sizeof(releasedate), "%c%c/%c%c/%c%c%c%c", tmp1[4],tmp1[5],tmp1[6],tmp1[7],tmp1[0],tmp1[1],tmp1[2],tmp1[3]);
|
|
else if (len == 6)
|
|
snprintf(releasedate, sizeof(releasedate), "%c%c/%c%c%c%c", tmp1[4],tmp1[5],tmp1[0],tmp1[1],tmp1[2],tmp1[3]);
|
|
else snprintf(releasedate, sizeof(releasedate), "%s", tmp1);
|
|
|
|
free(nodedataHB);
|
|
free(nodetreeHB);
|
|
|
|
return 1;
|
|
}
|