2 #include "tinyxml/tinyxml.h"
3 #include "../include/pnd_pxml.h"
4 #include "pnd_tinyxml.h"
8 unsigned char pnd_pxml_load ( const char* pFilename, pnd_pxml_t *app ) {
13 f = fopen ( pFilename, "r" );
19 fseek ( f, 0, SEEK_END );
23 fseek ( f, 0, SEEK_SET );
25 b = (char*) malloc ( len );
32 fread ( b, 1, len, f );
34 return ( pnd_pxml_parse ( pFilename, b, len, app ) );
37 unsigned char pnd_pxml_parse ( const char *pFilename, char *buffer, unsigned int length, pnd_pxml_t *app ) {
39 //TiXmlDocument doc(pFilename);
40 //if (!doc.LoadFile()) return;
46 TiXmlHandle hDoc(&doc);
50 pElem=hDoc.FirstChildElement().Element();
51 if (!pElem) return ( 0 );
52 hRoot=TiXmlHandle(pElem);
54 pElem = hRoot.FirstChild( "title" ).FirstChildElement("en").Element();
57 app->title_en = strdup(pElem->GetText());
60 pElem = hRoot.FirstChild( "title" ).FirstChildElement("de").Element();
63 app->title_de = strdup(pElem->GetText());
66 pElem = hRoot.FirstChild( "title" ).FirstChildElement("it").Element();
69 app->title_it = strdup(pElem->GetText());
72 pElem = hRoot.FirstChild( "title" ).FirstChildElement("fr").Element();
75 app->title_fr = strdup(pElem->GetText());
78 pElem=hRoot.FirstChild("unique_id").Element();
81 app->unique_id = strdup(pElem->GetText());
84 pElem=hRoot.FirstChild("standalone").Element();
87 app->standalone = strdup(pElem->GetText());
90 pElem=hRoot.FirstChild("icon").Element();
93 char anotherbuffer [ FILENAME_MAX ];
94 strcpy ( anotherbuffer, pFilename );
95 char *s = strstr ( anotherbuffer, PXML_FILENAME );
97 strcpy ( s, strdup(pElem->GetText()));
98 app->icon = strdup(anotherbuffer);
102 pElem = hRoot.FirstChild( "description" ).FirstChildElement("en").Element();
105 app->description_en = strdup(pElem->GetText());
108 pElem = hRoot.FirstChild( "description" ).FirstChildElement("de").Element();
111 app->description_de = strdup(pElem->GetText());
114 pElem = hRoot.FirstChild( "description" ).FirstChildElement("it").Element();
117 app->description_it = strdup(pElem->GetText());
120 pElem = hRoot.FirstChild( "description" ).FirstChildElement("fr").Element();
123 app->description_fr = strdup(pElem->GetText());
126 pElem = hRoot.FirstChild( "previewpic" ).FirstChildElement("pic1").Element();
129 app->previewpic1 = strdup(pElem->GetText());
132 pElem = hRoot.FirstChild( "previewpic" ).FirstChildElement("pic2").Element();
135 app->previewpic2 = strdup(pElem->GetText());
138 pElem = hRoot.FirstChild( "author" ).FirstChildElement("name").Element();
141 app->author_name = strdup(pElem->GetText());
144 pElem = hRoot.FirstChild( "author" ).FirstChildElement("website").Element();
147 app->author_website = strdup(pElem->GetText());;
150 pElem = hRoot.FirstChild( "version" ).FirstChildElement("major").Element();
153 app->version_major = strdup(pElem->GetText());
156 pElem = hRoot.FirstChild( "version" ).FirstChildElement("minor").Element();
159 app->version_minor = strdup(pElem->GetText());
162 pElem = hRoot.FirstChild( "version" ).FirstChildElement("release").Element();
165 app->version_release = strdup(pElem->GetText());
168 pElem = hRoot.FirstChild( "version" ).FirstChildElement("build").Element();
171 app->version_build = strdup(pElem->GetText());
174 pElem=hRoot.FirstChild("exec").Element();
177 char anotherbuffer [ FILENAME_MAX ];
178 strcpy ( anotherbuffer, pFilename );
179 char *s = strstr ( anotherbuffer, PXML_FILENAME );
181 strcpy ( s, strdup(pElem->GetText()));
182 app->exec = strdup(anotherbuffer);
183 } else if ( ( s = strrchr ( anotherbuffer, '/' ) ) ) {
185 strcpy ( s, strdup(pElem->GetText()));
186 app->exec = strdup(anotherbuffer);
190 pElem = hRoot.FirstChild( "category" ).FirstChildElement("main").Element();
193 app->main_category = strdup(pElem->GetText());
196 pElem = hRoot.FirstChild( "category" ).FirstChildElement("subcategory1").Element();
199 app->subcategory1 = strdup(pElem->GetText());
202 pElem = hRoot.FirstChild( "category" ).FirstChildElement("subcategory2").Element();
205 app->subcategory2 = strdup(pElem->GetText());
208 pElem = hRoot.FirstChild( "altcategory" ).FirstChildElement("main").Element();
211 app->altcategory = strdup(pElem->GetText());
214 pElem = hRoot.FirstChild( "altcategory" ).FirstChildElement("subcategory1").Element();
217 app->altsubcategory1 = strdup(pElem->GetText());
220 pElem = hRoot.FirstChild( "altcategory" ).FirstChildElement("subcategory2").Element();
223 app->altsubcategory2 = strdup(pElem->GetText());
226 pElem = hRoot.FirstChild( "osversion" ).FirstChildElement("major").Element();
229 app->osversion_major = strdup(pElem->GetText());
232 pElem = hRoot.FirstChild( "osversion" ).FirstChildElement("minor").Element();
235 app->osversion_minor = strdup(pElem->GetText());
238 pElem = hRoot.FirstChild( "osversion" ).FirstChildElement("release").Element();
241 app->osversion_release = strdup(pElem->GetText());
244 pElem = hRoot.FirstChild( "osversion" ).FirstChildElement("build").Element();
247 app->osversion_build = strdup(pElem->GetText());
250 pElem = hRoot.FirstChild( "associationitem1" ).FirstChildElement("name").Element();
253 app->associationitem1_name = strdup(pElem->GetText());
256 pElem = hRoot.FirstChild( "associationitem1" ).FirstChildElement("filetype").Element();
259 app->associationitem1_filetype = strdup(pElem->GetText());
262 pElem = hRoot.FirstChild( "associationitem1" ).FirstChildElement("parameter").Element();
265 app->associationitem1_parameter = strdup(pElem->GetText());
268 pElem = hRoot.FirstChild( "associationitem2" ).FirstChildElement("name").Element();
271 app->associationitem2_name = strdup(pElem->GetText());
274 pElem = hRoot.FirstChild( "associationitem2" ).FirstChildElement("filetype").Element();
277 app->associationitem2_filetype = strdup(pElem->GetText());
280 pElem = hRoot.FirstChild( "associationitem2" ).FirstChildElement("parameter").Element();
283 app->associationitem2_parameter = strdup(pElem->GetText());
286 pElem = hRoot.FirstChild( "associationitem3" ).FirstChildElement("name").Element();
289 app->associationitem3_name = strdup(pElem->GetText());
292 pElem = hRoot.FirstChild( "associationitem3" ).FirstChildElement("filetype").Element();
295 app->associationitem3_filetype = strdup(pElem->GetText());
298 pElem = hRoot.FirstChild( "associationitem3" ).FirstChildElement("parameter").Element();
301 app->associationitem3_parameter = strdup(pElem->GetText());
304 pElem=hRoot.FirstChild("clockspeed").Element();
307 app->clockspeed = strdup(pElem->GetText());
310 pElem=hRoot.FirstChild("background").Element();
313 app->background = strdup(pElem->GetText());
316 pElem=hRoot.FirstChild("startdir").Element();
319 app->startdir = strdup(pElem->GetText());