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"
13 void pnd_pxml_load(const char* pFilename, pnd_pxml_t *app);
15 pnd_pxml_handle pnd_pxml_fetch ( char *fullpath ) {
17 pnd_pxml_t *p = malloc ( sizeof(pnd_pxml_t) );
19 pnd_pxml_load(fullpath, p);
24 void pnd_pxml_delete ( pnd_pxml_handle h ) {
25 pnd_pxml_t *p = (pnd_pxml_t*) h;
27 if ( p -> title_en ) {
28 free ( p -> title_en );
38 if ( p -> main_category ) {
39 free ( p -> main_category );
41 if ( p -> unique_id ) {
42 free ( p -> unique_id );
44 if ( p -> clockspeed ) {
45 free ( p -> clockspeed );
51 char *pnd_pxml_get_app_name ( pnd_pxml_handle h ) {
52 pnd_pxml_t *p = (pnd_pxml_t*) h;
53 return ( p -> title_en );
56 char *pnd_pxml_get_icon_path ( pnd_pxml_handle h ) {
57 pnd_pxml_t *p = (pnd_pxml_t*) h;
61 char *pnd_pxml_get_clockspeed ( pnd_pxml_handle h ) {
62 pnd_pxml_t *p = (pnd_pxml_t*) h;
63 return ( p -> clockspeed );
66 void pnd_pxml_set_app_name ( pnd_pxml_handle h, char *v ) {
67 pnd_pxml_t *p = (pnd_pxml_t*) h;
68 if ( p -> title_en ) {
69 free ( p -> title_en );
74 p -> title_en = strdup ( v );
80 char *pnd_pxml_get_unique_id ( pnd_pxml_handle h ) {
81 pnd_pxml_t *p = (pnd_pxml_t*) h;
82 return ( p -> unique_id );
85 char *pnd_pxml_get_primary_category ( pnd_pxml_handle h ) {
86 pnd_pxml_t *p = (pnd_pxml_t*) h;
87 return ( p -> main_category );
90 char *pnd_pxml_get_exec_path ( pnd_pxml_handle h ) {
91 pnd_pxml_t *p = (pnd_pxml_t*) h;
95 unsigned char pnd_is_pxml_valid_app ( pnd_pxml_handle h ) {
96 pnd_pxml_t *p = (pnd_pxml_t*) h;
98 // for now, lets just verify the exec-path is valid
99 //printf ( "exec is '%s'\n", p -> exec );
102 if ( stat ( p -> exec, &buf ) == 0 ) {
103 return ( 1 ); // path is present
109 signed char pnd_pxml_merge_override ( pnd_pxml_handle h, char *searchpath ) {
110 // the pxml includes a unique-id; use this value to attempt to find an
111 // override in the given searchpath
112 signed char retval = 0;
113 pnd_pxml_handle mergeh;
119 strncat ( buffer, "/", FILENAME_MAX );
120 strncat ( buffer, pnd_pxml_get_unique_id ( h ), FILENAME_MAX );
121 strncat ( buffer, ".xml", FILENAME_MAX );
122 //printf ( " Path to seek merges: '%s'\n", buffer );
124 mergeh = pnd_pxml_fetch ( buffer );
128 if ( pnd_pxml_get_app_name ( mergeh ) ) {
129 pnd_pxml_set_app_name ( h, pnd_pxml_get_app_name ( mergeh ) );
132 pnd_pxml_delete ( mergeh );