b2c97ac240c2c82a48d1d0492db71d70de4a6715
[pandora-libraries.git] / lib / pnd_tinyxml.cpp
1 #include "tinyxml/tinyxml.h"
2 #include "../include/pnd_pxml.h"
3
4 extern "C" {
5
6 void pnd_pxml_load(const char* pFilename, pnd_pxml_t *app)
7 {
8
9         TiXmlDocument doc(pFilename);
10         if (!doc.LoadFile()) return;
11
12         TiXmlHandle hDoc(&doc);
13         TiXmlElement* pElem;
14         TiXmlHandle hRoot(0);
15
16         pElem=hDoc.FirstChildElement().Element();
17         if (!pElem) return;
18         hRoot=TiXmlHandle(pElem);
19
20         pElem = hRoot.FirstChild( "title" ).FirstChildElement("en").Element();
21         if ( pElem )
22         {
23                 app->title_en = strdup(pElem->GetText());
24         }
25
26         pElem = hRoot.FirstChild( "title" ).FirstChildElement("de").Element();
27         if ( pElem )
28         {
29                 app->title_de = strdup(pElem->GetText());
30         }
31
32         pElem = hRoot.FirstChild( "title" ).FirstChildElement("it").Element();
33         if ( pElem )
34         {
35                 app->title_it = strdup(pElem->GetText());
36         }
37         
38         pElem = hRoot.FirstChild( "title" ).FirstChildElement("fr").Element();
39         if ( pElem )
40         {
41                 app->title_fr = strdup(pElem->GetText());
42         }
43
44         pElem=hRoot.FirstChild("unique_id").Element();
45         if (pElem)
46         {       
47                 app->unique_id = strdup(pElem->GetText());
48         }
49
50         pElem=hRoot.FirstChild("standalone").Element();
51         if (pElem)
52         {       
53                 app->standalone = strdup(pElem->GetText());
54         }
55
56         pElem=hRoot.FirstChild("icon").Element();
57         if (pElem)
58         {       
59                 char anotherbuffer [ FILENAME_MAX ];
60                 strcpy ( anotherbuffer, pFilename );
61                 char *s = strstr ( anotherbuffer, PXML_FILENAME );
62                 strcpy ( s, strdup(pElem->GetText()));
63                 app->icon = strdup(anotherbuffer);
64         }
65
66         pElem = hRoot.FirstChild( "description" ).FirstChildElement("en").Element();
67         if ( pElem )
68         {
69                 app->description_en = strdup(pElem->GetText());
70         }
71
72         pElem = hRoot.FirstChild( "description" ).FirstChildElement("de").Element();
73         if ( pElem )
74         {
75                 app->description_de = strdup(pElem->GetText());
76         }
77
78         pElem = hRoot.FirstChild( "description" ).FirstChildElement("it").Element();
79         if ( pElem )
80         {
81                 app->description_it = strdup(pElem->GetText());
82         }
83         
84         pElem = hRoot.FirstChild( "description" ).FirstChildElement("fr").Element();
85         if ( pElem )
86         {
87                 app->description_fr = strdup(pElem->GetText());
88         }
89
90         pElem = hRoot.FirstChild( "previewpic" ).FirstChildElement("pic1").Element();
91         if ( pElem )
92         {
93                 app->previewpic1 = strdup(pElem->GetText());
94         }
95
96         pElem = hRoot.FirstChild( "previewpic" ).FirstChildElement("pic2").Element();
97         if ( pElem )
98         {
99                 app->previewpic2 = strdup(pElem->GetText());
100         }
101
102         pElem = hRoot.FirstChild( "author" ).FirstChildElement("name").Element();
103         if ( pElem )
104         {
105                 app->author_name = strdup(pElem->GetText());
106         }
107
108         pElem = hRoot.FirstChild( "author" ).FirstChildElement("website").Element();
109         if ( pElem )
110         {
111                 app->author_website = strdup(pElem->GetText());;
112         }
113
114         pElem = hRoot.FirstChild( "version" ).FirstChildElement("major").Element();
115         if ( pElem )
116         {
117                 app->version_major = strdup(pElem->GetText());
118         }       
119
120         pElem = hRoot.FirstChild( "version" ).FirstChildElement("minor").Element();
121         if ( pElem )
122         {
123                 app->version_minor = strdup(pElem->GetText());
124         }       
125
126         pElem = hRoot.FirstChild( "version" ).FirstChildElement("release").Element();
127         if ( pElem )
128         {
129                 app->version_release = strdup(pElem->GetText());
130         }       
131
132         pElem = hRoot.FirstChild( "version" ).FirstChildElement("build").Element();
133         if ( pElem )
134         {
135                 app->version_build = strdup(pElem->GetText());
136         }
137
138         pElem=hRoot.FirstChild("exec").Element();
139         if (pElem)
140         {       
141                 char anotherbuffer [ FILENAME_MAX ];
142                 strcpy ( anotherbuffer, pFilename );
143                 char *s = strstr ( anotherbuffer, PXML_FILENAME );
144                 strcpy ( s, strdup(pElem->GetText()));
145                 app->exec = strdup(anotherbuffer);
146         }       
147
148         pElem = hRoot.FirstChild( "category" ).FirstChildElement("main").Element();
149         if ( pElem )
150         {
151                 app->main_category = strdup(pElem->GetText());
152         }
153
154         pElem = hRoot.FirstChild( "category" ).FirstChildElement("subcategory1").Element();
155         if ( pElem )
156         {
157                 app->subcategory1 = strdup(pElem->GetText());
158         }
159
160         pElem = hRoot.FirstChild( "category" ).FirstChildElement("subcategory2").Element();
161         if ( pElem )
162         {
163                 app->subcategory2 = strdup(pElem->GetText());
164         }
165
166         pElem = hRoot.FirstChild( "altcategory" ).FirstChildElement("main").Element();
167         if ( pElem )
168         {
169                 app->altcategory = strdup(pElem->GetText());
170         }
171
172         pElem = hRoot.FirstChild( "altcategory" ).FirstChildElement("subcategory1").Element();
173         if ( pElem )
174         {
175                 app->altsubcategory1 = strdup(pElem->GetText());
176         }
177
178         pElem = hRoot.FirstChild( "altcategory" ).FirstChildElement("subcategory2").Element();
179         if ( pElem )
180         {
181                 app->altsubcategory2 = strdup(pElem->GetText());
182         }
183
184         pElem = hRoot.FirstChild( "osversion" ).FirstChildElement("major").Element();
185         if ( pElem )
186         {
187                 app->osversion_major = strdup(pElem->GetText());
188         }       
189
190         pElem = hRoot.FirstChild( "osversion" ).FirstChildElement("minor").Element();
191         if ( pElem )
192         {
193                 app->osversion_minor = strdup(pElem->GetText());
194         }       
195
196         pElem = hRoot.FirstChild( "osversion" ).FirstChildElement("release").Element();
197         if ( pElem )
198         {
199                 app->osversion_release = strdup(pElem->GetText());
200         }       
201
202         pElem = hRoot.FirstChild( "osversion" ).FirstChildElement("build").Element();
203         if ( pElem )
204         {
205                 app->osversion_build = strdup(pElem->GetText());
206         }
207
208         pElem = hRoot.FirstChild( "associationitem1" ).FirstChildElement("name").Element();
209         if ( pElem )
210         {
211                 app->associationitem1_name = strdup(pElem->GetText());
212         }
213
214         pElem = hRoot.FirstChild( "associationitem1" ).FirstChildElement("filetype").Element();
215         if ( pElem )
216         {
217                 app->associationitem1_filetype = strdup(pElem->GetText());
218         }
219
220         pElem = hRoot.FirstChild( "associationitem1" ).FirstChildElement("parameter").Element();
221         if ( pElem )
222         {
223                 app->associationitem1_parameter = strdup(pElem->GetText());
224         }
225
226         pElem = hRoot.FirstChild( "associationitem2" ).FirstChildElement("name").Element();
227         if ( pElem )
228         {
229                 app->associationitem2_name = strdup(pElem->GetText());
230         }
231
232         pElem = hRoot.FirstChild( "associationitem2" ).FirstChildElement("filetype").Element();
233         if ( pElem )
234         {
235                 app->associationitem2_filetype = strdup(pElem->GetText());
236         }
237
238         pElem = hRoot.FirstChild( "associationitem2" ).FirstChildElement("parameter").Element();
239         if ( pElem )
240         {
241                 app->associationitem2_parameter = strdup(pElem->GetText());
242         }
243
244         pElem = hRoot.FirstChild( "associationitem3" ).FirstChildElement("name").Element();
245         if ( pElem )
246         {
247                 app->associationitem3_name = strdup(pElem->GetText());
248         }
249
250         pElem = hRoot.FirstChild( "associationitem3" ).FirstChildElement("filetype").Element();
251         if ( pElem )
252         {
253                 app->associationitem3_filetype = strdup(pElem->GetText());
254         }
255
256         pElem = hRoot.FirstChild( "associationitem3" ).FirstChildElement("parameter").Element();
257         if ( pElem )
258         {
259                 app->associationitem3_parameter = strdup(pElem->GetText());
260         }
261
262         pElem=hRoot.FirstChild("clockspeed").Element();
263         if (pElem)
264         {       
265                 app->clockspeed = strdup(pElem->GetText());
266         }
267
268         pElem=hRoot.FirstChild("background").Element();
269         if (pElem)
270         {       
271                 app->background = strdup(pElem->GetText());
272         }
273
274         pElem=hRoot.FirstChild("startdir").Element();
275         if (pElem)
276         {       
277                 app->startdir = strdup(pElem->GetText());
278         }
279 }
280
281 }
282