2 #include <stdio.h> /* for FILE */
3 #include <stdlib.h> /* for malloc */
4 #include <string.h> /* for string ops */
6 #include <sys/types.h> /* for stat */
7 #include <sys/stat.h> /* for stat */
8 #include <unistd.h> /* for stat */
11 #include "pnd_pathiter.h"
12 #include "pnd_tinyxml.h"
14 pnd_pxml_handle pnd_pxml_fetch ( char *fullpath ) {
16 pnd_pxml_t *p = malloc ( sizeof(pnd_pxml_t) );
18 memset ( p, '\0', sizeof(pnd_pxml_t) );
20 if ( ! pnd_pxml_load ( fullpath, p ) ) {
27 pnd_pxml_handle pnd_pxml_fetch_buffer ( char *filename, char *buffer ) {
29 pnd_pxml_t *p = malloc ( sizeof(pnd_pxml_t) );
31 memset ( p, '\0', sizeof(pnd_pxml_t) );
33 if ( ! pnd_pxml_parse ( filename, buffer, strlen ( buffer ), p ) ) {
40 void pnd_pxml_delete ( pnd_pxml_handle h ) {
41 pnd_pxml_t *p = (pnd_pxml_t*) h;
43 if ( p -> title_en ) {
44 free ( p -> title_en );
46 if ( p -> title_de ) {
47 free ( p -> title_de );
49 if ( p -> title_it ) {
50 free ( p -> title_it );
52 if ( p -> title_fr ) {
53 free ( p -> title_fr );
55 if ( p -> unique_id ) {
56 free ( p -> unique_id );
58 if ( p -> standalone ) {
59 free ( p -> standalone );
64 if ( p -> description_en ) {
65 free ( p -> description_en );
67 if ( p -> description_de ) {
68 free ( p -> description_de );
70 if ( p -> description_it ) {
71 free ( p -> description_it );
73 if ( p -> description_fr ) {
74 free ( p -> description_fr );
76 if ( p -> previewpic1 ) {
77 free ( p -> previewpic1 );
79 if ( p -> previewpic2 ) {
80 free ( p -> previewpic2 );
82 if ( p -> author_name ) {
83 free ( p -> author_name );
85 if ( p -> author_website ) {
86 free ( p -> author_website );
88 if ( p -> version_major ) {
89 free ( p -> version_major );
91 if ( p -> version_minor ) {
92 free ( p -> version_minor );
94 if ( p -> version_release ) {
95 free ( p -> version_release );
97 if ( p -> version_build ) {
98 free ( p -> version_build );
103 if ( p -> main_category ) {
104 free ( p -> main_category );
106 if ( p -> subcategory1 ) {
107 free ( p -> subcategory1 );
109 if ( p -> subcategory2 ) {
110 free ( p -> subcategory2 );
112 if ( p -> altcategory ) {
113 free ( p -> altcategory );
115 if ( p -> altsubcategory1 ) {
116 free ( p -> altsubcategory1 );
118 if ( p -> altsubcategory2 ) {
119 free ( p -> altsubcategory2 );
121 if ( p -> osversion_major ) {
122 free ( p -> osversion_major );
124 if ( p -> osversion_minor ) {
125 free ( p -> osversion_minor );
127 if ( p -> osversion_release ) {
128 free ( p -> osversion_release );
130 if ( p -> osversion_build ) {
131 free ( p -> osversion_build );
133 if ( p -> associationitem1_name ) {
134 free ( p -> associationitem1_name );
136 if ( p -> associationitem1_filetype ) {
137 free ( p -> associationitem1_filetype );
139 if ( p -> associationitem1_parameter ) {
140 free ( p -> associationitem1_parameter );
142 if ( p -> associationitem2_name ) {
143 free ( p -> associationitem2_name );
145 if ( p -> associationitem2_filetype ) {
146 free ( p -> associationitem2_filetype );
148 if ( p -> associationitem2_parameter ) {
149 free ( p -> associationitem2_parameter );
151 if ( p -> associationitem3_name ) {
152 free ( p -> associationitem3_name );
154 if ( p -> associationitem1_filetype ) {
155 free ( p -> associationitem3_filetype );
157 if ( p -> associationitem1_parameter ) {
158 free ( p -> associationitem3_parameter );
160 if ( p -> clockspeed ) {
161 free ( p -> clockspeed );
163 if ( p -> background ) {
164 free ( p -> background );
166 if ( p -> startdir ) {
167 free ( p -> startdir );
173 void pnd_pxml_set_app_name ( pnd_pxml_handle h, char *v ) {
174 pnd_pxml_t *p = (pnd_pxml_t*) h;
175 if ( p -> title_en ) {
176 free ( p -> title_en );
177 p -> title_en = NULL;
181 p -> title_en = strdup ( v );
187 unsigned char pnd_is_pxml_valid_app ( pnd_pxml_handle h ) {
188 pnd_pxml_t *p = (pnd_pxml_t*) h;
190 // for now, lets just verify the exec-path is valid
192 //printf ( "exec is '%s'\n", p -> exec );
196 // even this is complicated by pnd_run.sh semantics .. can't check if it exists
197 // during discovery, since it is not mounted yet..
200 if ( stat ( p -> exec, &buf ) == 0 ) {
201 return ( 1 ); // path is present
208 signed char pnd_pxml_merge_override ( pnd_pxml_handle h, char *searchpath ) {
209 // the pxml includes a unique-id; use this value to attempt to find an
210 // override in the given searchpath
211 signed char retval = 0;
212 pnd_pxml_handle mergeh;
218 strncat ( buffer, "/", FILENAME_MAX );
219 strncat ( buffer, pnd_pxml_get_unique_id ( h ), FILENAME_MAX );
220 strncat ( buffer, ".xml", FILENAME_MAX );
221 //printf ( " Path to seek merges: '%s'\n", buffer );
223 mergeh = pnd_pxml_fetch ( buffer );
227 if ( pnd_pxml_get_app_name_en ( mergeh ) ) {
228 pnd_pxml_set_app_name ( h, pnd_pxml_get_app_name_en ( mergeh ) );
231 pnd_pxml_delete ( mergeh );
240 char *pnd_pxml_get_app_name_en ( pnd_pxml_handle h ) {
241 pnd_pxml_t *p = (pnd_pxml_t*) h;
242 return ( p -> title_en );
245 char *pnd_pxml_get_app_name_de ( pnd_pxml_handle h ) {
246 pnd_pxml_t *p = (pnd_pxml_t*) h;
247 return ( p -> title_de );
250 char *pnd_pxml_get_app_name_it ( pnd_pxml_handle h ) {
251 pnd_pxml_t *p = (pnd_pxml_t*) h;
252 return ( p -> title_it );
255 char *pnd_pxml_get_app_name_fr ( pnd_pxml_handle h ) {
256 pnd_pxml_t *p = (pnd_pxml_t*) h;
257 return ( p -> title_fr );
260 char *pnd_pxml_get_unique_id ( pnd_pxml_handle h ) {
261 pnd_pxml_t *p = (pnd_pxml_t*) h;
262 return ( p -> unique_id );
265 char *pnd_pxml_get_standalone ( pnd_pxml_handle h ) {
266 pnd_pxml_t *p = (pnd_pxml_t*) h;
267 return ( p -> standalone );
270 char *pnd_pxml_get_icon ( pnd_pxml_handle h ) {
271 pnd_pxml_t *p = (pnd_pxml_t*) h;
272 return ( p -> icon );
275 char *pnd_pxml_get_description_en ( pnd_pxml_handle h ) {
276 pnd_pxml_t *p = (pnd_pxml_t*) h;
277 return ( p -> description_en );
280 char *pnd_pxml_get_description_de ( pnd_pxml_handle h ) {
281 pnd_pxml_t *p = (pnd_pxml_t*) h;
282 return ( p -> description_de );
285 char *pnd_pxml_get_description_it ( pnd_pxml_handle h ) {
286 pnd_pxml_t *p = (pnd_pxml_t*) h;
287 return ( p -> description_it );
290 char *pnd_pxml_get_description_fr ( pnd_pxml_handle h ) {
291 pnd_pxml_t *p = (pnd_pxml_t*) h;
292 return ( p -> description_fr );
295 char *pnd_pxml_get_previewpic1 ( pnd_pxml_handle h ) {
296 pnd_pxml_t *p = (pnd_pxml_t*) h;
297 return ( p -> previewpic1 );
300 char *pnd_pxml_get_previewpic2 ( pnd_pxml_handle h ) {
301 pnd_pxml_t *p = (pnd_pxml_t*) h;
302 return ( p -> previewpic2 );
305 char *pnd_pxml_get_author_name ( pnd_pxml_handle h ) {
306 pnd_pxml_t *p = (pnd_pxml_t*) h;
307 return ( p -> author_name );
310 char *pnd_pxml_get_author_website ( pnd_pxml_handle h ) {
311 pnd_pxml_t *p = (pnd_pxml_t*) h;
312 return ( p -> author_website );
315 char *pnd_pxml_get_version_major ( pnd_pxml_handle h ) {
316 pnd_pxml_t *p = (pnd_pxml_t*) h;
317 return ( p -> version_major );
320 char *pnd_pxml_get_version_minor ( pnd_pxml_handle h ) {
321 pnd_pxml_t *p = (pnd_pxml_t*) h;
322 return ( p -> version_minor );
325 char *pnd_pxml_get_version_release ( pnd_pxml_handle h ) {
326 pnd_pxml_t *p = (pnd_pxml_t*) h;
327 return ( p -> version_release );
330 char *pnd_pxml_get_version_build ( pnd_pxml_handle h ) {
331 pnd_pxml_t *p = (pnd_pxml_t*) h;
332 return ( p -> version_build );
335 char *pnd_pxml_get_exec ( pnd_pxml_handle h ) {
336 pnd_pxml_t *p = (pnd_pxml_t*) h;
337 return ( p -> exec );
340 char *pnd_pxml_get_main_category ( pnd_pxml_handle h ) {
341 pnd_pxml_t *p = (pnd_pxml_t*) h;
342 return ( p -> main_category );
345 char *pnd_pxml_get_subcategory1 ( pnd_pxml_handle h ) {
346 pnd_pxml_t *p = (pnd_pxml_t*) h;
347 return ( p -> subcategory1 );
350 char *pnd_pxml_get_subcategory2 ( pnd_pxml_handle h ) {
351 pnd_pxml_t *p = (pnd_pxml_t*) h;
352 return ( p -> subcategory2 );
355 char *pnd_pxml_get_altcategory ( pnd_pxml_handle h ) {
356 pnd_pxml_t *p = (pnd_pxml_t*) h;
357 return ( p -> altcategory );
360 char *pnd_pxml_get_altsubcategory1 ( pnd_pxml_handle h ) {
361 pnd_pxml_t *p = (pnd_pxml_t*) h;
362 return ( p -> altsubcategory1 );
365 char *pnd_pxml_get_altsubcategory2 ( pnd_pxml_handle h ) {
366 pnd_pxml_t *p = (pnd_pxml_t*) h;
367 return ( p -> altsubcategory2 );
370 char *pnd_pxml_get_osversion_major ( pnd_pxml_handle h ) {
371 pnd_pxml_t *p = (pnd_pxml_t*) h;
372 return ( p -> osversion_major );
375 char *pnd_pxml_get_osversion_minor ( pnd_pxml_handle h ) {
376 pnd_pxml_t *p = (pnd_pxml_t*) h;
377 return ( p -> osversion_minor );
380 char *pnd_pxml_get_osversion_release ( pnd_pxml_handle h ) {
381 pnd_pxml_t *p = (pnd_pxml_t*) h;
382 return ( p -> osversion_release );
385 char *pnd_pxml_get_osversion_build ( pnd_pxml_handle h ) {
386 pnd_pxml_t *p = (pnd_pxml_t*) h;
387 return ( p -> osversion_build );
390 char *pnd_pxml_get_associationitem1_name ( pnd_pxml_handle h ) {
391 pnd_pxml_t *p = (pnd_pxml_t*) h;
392 return ( p -> associationitem1_name );
395 char *pnd_pxml_get_associationitem1_filetype ( pnd_pxml_handle h ) {
396 pnd_pxml_t *p = (pnd_pxml_t*) h;
397 return ( p -> associationitem1_filetype );
400 char *pnd_pxml_get_associationitem1_parameter ( pnd_pxml_handle h ) {
401 pnd_pxml_t *p = (pnd_pxml_t*) h;
402 return ( p -> associationitem1_parameter );
405 char *pnd_pxml_get_associationitem2_name ( pnd_pxml_handle h ) {
406 pnd_pxml_t *p = (pnd_pxml_t*) h;
407 return ( p -> associationitem2_name );
410 char *pnd_pxml_get_associationitem2_filetype ( pnd_pxml_handle h ) {
411 pnd_pxml_t *p = (pnd_pxml_t*) h;
412 return ( p -> associationitem2_filetype );
415 char *pnd_pxml_get_associationitem2_parameter ( pnd_pxml_handle h ) {
416 pnd_pxml_t *p = (pnd_pxml_t*) h;
417 return ( p -> associationitem2_parameter );
420 char *pnd_pxml_get_associationitem3_name ( pnd_pxml_handle h ) {
421 pnd_pxml_t *p = (pnd_pxml_t*) h;
422 return ( p -> associationitem3_name );
425 char *pnd_pxml_get_associationitem3_filetype ( pnd_pxml_handle h ) {
426 pnd_pxml_t *p = (pnd_pxml_t*) h;
427 return ( p -> associationitem3_filetype );
430 char *pnd_pxml_get_associationitem3_parameter ( pnd_pxml_handle h ) {
431 pnd_pxml_t *p = (pnd_pxml_t*) h;
432 return ( p -> associationitem3_parameter );
435 char *pnd_pxml_get_clockspeed ( pnd_pxml_handle h ) {
436 pnd_pxml_t *p = (pnd_pxml_t*) h;
437 return ( p -> clockspeed );
440 char *pnd_pxml_get_background ( pnd_pxml_handle h ) {
441 pnd_pxml_t *p = (pnd_pxml_t*) h;
442 return ( p -> background );
445 char *pnd_pxml_get_startdir ( pnd_pxml_handle h ) {
446 pnd_pxml_t *p = (pnd_pxml_t*) h;
447 return ( p -> startdir );