2009-10-01 01:10:58 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* HomebrewXML Class
|
|
|
|
* for USB Loader GX
|
|
|
|
***************************************************************************/
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "xml/xml.h"
|
|
|
|
|
|
|
|
#include "HomebrewXML.h"
|
|
|
|
|
2010-09-17 18:15:18 +02:00
|
|
|
#define ENTRIE_SIZE 8192
|
2009-10-01 01:10:58 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
int HomebrewXML::LoadHomebrewXMLData( const char* filename )
|
2010-09-17 18:15:18 +02:00
|
|
|
{
|
2009-10-01 01:10:58 +02:00
|
|
|
mxml_node_t *nodedataHB = NULL;
|
|
|
|
mxml_node_t *nodetreeHB = NULL;
|
|
|
|
|
|
|
|
/* Load XML file */
|
|
|
|
FILE *filexml;
|
2010-09-19 01:16:05 +02:00
|
|
|
filexml = fopen( filename, "rb" );
|
|
|
|
if ( !filexml )
|
2009-10-01 01:10:58 +02:00
|
|
|
return -1;
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
nodetreeHB = mxmlLoadFile( NULL, filexml, MXML_OPAQUE_CALLBACK );
|
|
|
|
fclose( filexml );
|
2009-10-01 01:10:58 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
if ( nodetreeHB == NULL )
|
2009-10-01 01:10:58 +02:00
|
|
|
return -2;
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
nodedataHB = mxmlFindElement( nodetreeHB, nodetreeHB, "app", NULL, NULL, MXML_DESCEND );
|
|
|
|
if ( nodedataHB == NULL )
|
2009-10-01 01:10:58 +02:00
|
|
|
return -5;
|
|
|
|
|
2010-09-17 18:15:18 +02:00
|
|
|
char * Entrie = new char[ENTRIE_SIZE];
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
GetTextFromNode( nodedataHB, nodedataHB, ( char* ) "name", NULL, NULL, MXML_DESCEND, Entrie, ENTRIE_SIZE );
|
2010-09-17 18:15:18 +02:00
|
|
|
Name = Entrie;
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
GetTextFromNode( nodedataHB, nodedataHB, ( char* ) "coder", NULL, NULL, MXML_DESCEND, Entrie, ENTRIE_SIZE );
|
2010-09-17 18:15:18 +02:00
|
|
|
Coder = Entrie;
|
2009-10-01 01:10:58 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
GetTextFromNode( nodedataHB, nodedataHB, ( char* ) "version", NULL, NULL, MXML_DESCEND, Entrie, ENTRIE_SIZE );
|
2010-09-17 18:15:18 +02:00
|
|
|
Version = Entrie;
|
2009-10-01 01:10:58 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
GetTextFromNode( nodedataHB, nodedataHB, ( char* ) "short_description", NULL, NULL, MXML_DESCEND, Entrie, ENTRIE_SIZE );
|
2010-09-17 18:15:18 +02:00
|
|
|
ShortDescription = Entrie;
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
GetTextFromNode( nodedataHB, nodedataHB, ( char* ) "long_description", NULL, NULL, MXML_DESCEND, Entrie, ENTRIE_SIZE );
|
2010-09-17 18:15:18 +02:00
|
|
|
LongDescription = Entrie;
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
GetTextFromNode( nodedataHB, nodedataHB, ( char* ) "release_date", NULL, NULL, MXML_DESCEND, Entrie, ENTRIE_SIZE );
|
2010-09-17 18:15:18 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
int len = ( strlen( Entrie ) - 6 ); //length of the date string without the 200000 at the end
|
|
|
|
if ( len == 8 )
|
|
|
|
snprintf( Entrie, ENTRIE_SIZE, "%c%c/%c%c/%c%c%c%c", Entrie[4], Entrie[5], Entrie[6], Entrie[7], Entrie[0], Entrie[1], Entrie[2], Entrie[3] );
|
|
|
|
else if ( len == 6 )
|
|
|
|
snprintf( Entrie, ENTRIE_SIZE, "%c%c/%c%c%c%c", Entrie[4], Entrie[5], Entrie[0], Entrie[1], Entrie[2], Entrie[3] );
|
2010-09-17 18:15:18 +02:00
|
|
|
else
|
2010-09-19 01:16:05 +02:00
|
|
|
snprintf( Entrie, ENTRIE_SIZE, "%s", Entrie );
|
2010-09-17 18:15:18 +02:00
|
|
|
|
|
|
|
Releasedate = Entrie;
|
2009-10-01 01:10:58 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
free( nodedataHB );
|
|
|
|
free( nodetreeHB );
|
2009-10-01 01:10:58 +02:00
|
|
|
|
2010-09-17 18:15:18 +02:00
|
|
|
delete [] Entrie;
|
|
|
|
|
2009-10-01 01:10:58 +02:00
|
|
|
return 1;
|
|
|
|
}
|