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 memset ( p, '\0', sizeof(pnd_pxml_t) );
21 pnd_pxml_load ( fullpath, p );
26 void pnd_pxml_delete ( pnd_pxml_handle h ) {
27 pnd_pxml_t *p = (pnd_pxml_t*) h;
29 if ( p -> title_en ) {
30 free ( p -> title_en );
40 if ( p -> main_category ) {
41 free ( p -> main_category );
43 if ( p -> unique_id ) {
44 free ( p -> unique_id );
46 if ( p -> clockspeed ) {
47 free ( p -> clockspeed );
53 char *pnd_pxml_get_app_name ( pnd_pxml_handle h ) {
54 pnd_pxml_t *p = (pnd_pxml_t*) h;
55 return ( p -> title_en );
58 char *pnd_pxml_get_icon_path ( pnd_pxml_handle h ) {
59 pnd_pxml_t *p = (pnd_pxml_t*) h;
63 char *pnd_pxml_get_clockspeed ( pnd_pxml_handle h ) {
64 pnd_pxml_t *p = (pnd_pxml_t*) h;
65 return ( p -> clockspeed );
68 void pnd_pxml_set_app_name ( pnd_pxml_handle h, char *v ) {
69 pnd_pxml_t *p = (pnd_pxml_t*) h;
70 if ( p -> title_en ) {
71 free ( p -> title_en );
76 p -> title_en = strdup ( v );
82 char *pnd_pxml_get_unique_id ( pnd_pxml_handle h ) {
83 pnd_pxml_t *p = (pnd_pxml_t*) h;
84 return ( p -> unique_id );
87 char *pnd_pxml_get_primary_category ( pnd_pxml_handle h ) {
88 pnd_pxml_t *p = (pnd_pxml_t*) h;
89 return ( p -> main_category );
92 char *pnd_pxml_get_exec_path ( pnd_pxml_handle h ) {
93 pnd_pxml_t *p = (pnd_pxml_t*) h;
97 unsigned char pnd_is_pxml_valid_app ( pnd_pxml_handle h ) {
98 pnd_pxml_t *p = (pnd_pxml_t*) h;
100 // for now, lets just verify the exec-path is valid
101 //printf ( "exec is '%s'\n", p -> exec );
104 if ( stat ( p -> exec, &buf ) == 0 ) {
105 return ( 1 ); // path is present
111 signed char pnd_pxml_merge_override ( pnd_pxml_handle h, char *searchpath ) {
112 // the pxml includes a unique-id; use this value to attempt to find an
113 // override in the given searchpath
114 signed char retval = 0;
115 pnd_pxml_handle mergeh;
121 strncat ( buffer, "/", FILENAME_MAX );
122 strncat ( buffer, pnd_pxml_get_unique_id ( h ), FILENAME_MAX );
123 strncat ( buffer, ".xml", FILENAME_MAX );
124 //printf ( " Path to seek merges: '%s'\n", buffer );
126 mergeh = pnd_pxml_fetch ( buffer );
130 if ( pnd_pxml_get_app_name ( mergeh ) ) {
131 pnd_pxml_set_app_name ( h, pnd_pxml_get_app_name ( mergeh ) );
134 pnd_pxml_delete ( mergeh );