Added definition of 'affirmative' for bools in PXML
[pandora-libraries.git] / include / pnd_pxml.h
1
2 #ifndef h_pnd_pxml_h
3 #define h_pnd_pxml_h
4
5 #ifdef __cplusplus
6 extern "C" {
7 #endif
8
9 // this code is for very basic PXML.xml file parsing
10
11 #define PXML_FILENAME "PXML.xml" /* a specification defined name */
12 #define PXML_TAGHEAD "<PXML" /* case insensitive; allow for trailing attributes */
13 #define PXML_TAGFOOT "</PXML>" /* case insensitive */
14
15 // use this handle to interact with PXML; this hides the mechanics of parsing a PXML file so that
16 // it can be upgraded with impacting applications
17 typedef void* pnd_pxml_handle;
18
19 /* pxml_fetch() will return NULL on fail, otherwise a valid handle which may be further queried
20  */
21 pnd_pxml_handle pnd_pxml_fetch ( char *fullpath );
22 pnd_pxml_handle pnd_pxml_fetch_buffer ( char *filename, char *buffer );
23 void pnd_pxml_delete ( pnd_pxml_handle h );
24
25 /* overrides() allow for customization of a PXML that persists; ie: An application might be sitting
26  * on an SD card and popped out while we need to edit its personalized category; more to point, the
27  * PXML itself could be in a read-only SD or packed into an ISO, or just sitting in a directory.
28  * Rather than have a _second_ PXML in the same place or have to write back to read-only media or
29  * worry about losing customizations when an app is temporarily deleted, we can just keep the
30  * overrides themselves in NAND.
31  */
32 /* merge_override() will attempt to locate an override of the given PXML, and will modify the
33  * PXML in-place to include any overrides found.
34  * Returns >0 if a merge was done, 0 if no merge was done, and <0 on error
35  * NOTE: For searchpath, should query configs for PND_PXML_OVERRIDES_KEY (or use PND_PXML_OVERRIDES_SEARCHPATH)
36  */
37 signed char pnd_pxml_merge_override ( pnd_pxml_handle h, char *searchpath );
38
39 /* these accessor functions will return READ ONLY char*s; do not free them or modify them.
40  */
41 char *pnd_pxml_get_app_name_en ( pnd_pxml_handle h );
42 char *pnd_pxml_get_app_name_de ( pnd_pxml_handle h );
43 char *pnd_pxml_get_app_name_it ( pnd_pxml_handle h );
44 char *pnd_pxml_get_app_name_fr ( pnd_pxml_handle h );
45 char *pnd_pxml_get_app_name ( pnd_pxml_handle h, char *iso_lang );
46 char *pnd_pxml_get_unique_id ( pnd_pxml_handle h );
47 char *pnd_pxml_get_standalone ( pnd_pxml_handle h );
48 char *pnd_pxml_get_icon ( pnd_pxml_handle h );
49 char *pnd_pxml_get_description_en ( pnd_pxml_handle h );
50 char *pnd_pxml_get_description_de ( pnd_pxml_handle h );
51 char *pnd_pxml_get_description_it ( pnd_pxml_handle h );
52 char *pnd_pxml_get_description_fr ( pnd_pxml_handle h );
53 char *pnd_pxml_get_description ( pnd_pxml_handle h, char *iso_lang);
54 char *pnd_pxml_get_previewpic1 ( pnd_pxml_handle h );
55 char *pnd_pxml_get_previewpic2 ( pnd_pxml_handle h );
56 char *pnd_pxml_get_author_name ( pnd_pxml_handle h );
57 char *pnd_pxml_get_author_website ( pnd_pxml_handle h );
58 char *pnd_pxml_get_version_major ( pnd_pxml_handle h );
59 char *pnd_pxml_get_version_minor ( pnd_pxml_handle h );
60 char *pnd_pxml_get_version_release ( pnd_pxml_handle h );
61 char *pnd_pxml_get_version_build ( pnd_pxml_handle h );
62 char *pnd_pxml_get_exec ( pnd_pxml_handle h );
63 char *pnd_pxml_get_exec_option_no_x11 ( pnd_pxml_handle h );
64 char *pnd_pxml_get_main_category ( pnd_pxml_handle h );
65 char *pnd_pxml_get_subcategory1 ( pnd_pxml_handle h );
66 char *pnd_pxml_get_subcategory2 ( pnd_pxml_handle h );
67 char *pnd_pxml_get_altcategory ( pnd_pxml_handle h );
68 char *pnd_pxml_get_altsubcategory1 ( pnd_pxml_handle h );
69 char *pnd_pxml_get_altsubcategory2 ( pnd_pxml_handle h );
70 char *pnd_pxml_get_osversion_major ( pnd_pxml_handle h );
71 char *pnd_pxml_get_osversion_minor ( pnd_pxml_handle h );
72 char *pnd_pxml_get_osversion_release ( pnd_pxml_handle h );
73 char *pnd_pxml_get_osversion_build ( pnd_pxml_handle h );
74 char *pnd_pxml_get_associationitem1_name ( pnd_pxml_handle h );
75 char *pnd_pxml_get_associationitem1_filetype ( pnd_pxml_handle h );
76 char *pnd_pxml_get_associationitem1_parameter ( pnd_pxml_handle h );
77 char *pnd_pxml_get_associationitem2_name ( pnd_pxml_handle h );
78 char *pnd_pxml_get_associationitem2_filetype ( pnd_pxml_handle h );
79 char *pnd_pxml_get_associationitem2_parameter ( pnd_pxml_handle h );
80 char *pnd_pxml_get_associationitem3_name ( pnd_pxml_handle h );
81 char *pnd_pxml_get_associationitem3_filetype ( pnd_pxml_handle h );
82 char *pnd_pxml_get_associationitem3_parameter ( pnd_pxml_handle h );
83 char *pnd_pxml_get_clockspeed ( pnd_pxml_handle h );
84 char *pnd_pxml_get_background ( pnd_pxml_handle h );
85 char *pnd_pxml_get_startdir ( pnd_pxml_handle h );
86 char *pnd_pxml_get_mkdir ( pnd_pxml_handle h );
87
88 // for 'set' functions, pass NULL value to delete existing value without setting new one
89 void pnd_pxml_set_app_name ( pnd_pxml_handle h, char *v );
90
91 /* utilities
92  */
93 unsigned char pnd_is_pxml_valid_app ( pnd_pxml_handle h ); // returns 1 when pxml seems like a valid application
94 unsigned char pnd_pxml_is_affirmative ( char *v ); // return 1 for 'Y' or '!'
95
96 typedef struct
97 {
98         char *language;
99         char *string;
100 } pnd_localized_string_t;
101
102 typedef struct
103 {
104         pnd_localized_string_t *titles;
105         int titles_c;
106         int titles_alloc_c;
107         char *unique_id;
108         char *standalone;
109         char *icon;
110         pnd_localized_string_t *descriptions;
111         int descriptions_c;
112         int descriptions_alloc_c;
113         char *previewpic1;
114         char *previewpic2;
115         char *author_name;
116         char *author_website;
117         char *version_major;
118         char *version_minor;
119         char *version_release;
120         char *version_build;
121         char *exec;
122         char *main_category;
123         char *subcategory1;
124         char *subcategory2;
125         char *altcategory;
126         char *altsubcategory1;
127         char *altsubcategory2;
128         char *osversion_major;
129         char *osversion_minor;
130         char *osversion_release;
131         char *osversion_build;
132         char *associationitem1_name;
133         char *associationitem1_filetype;
134         char *associationitem1_parameter;
135         char *associationitem2_name;
136         char *associationitem2_filetype;
137         char *associationitem2_parameter;
138         char *associationitem3_name;
139         char *associationitem3_filetype;
140         char *associationitem3_parameter;
141         char *clockspeed;
142         char *background;
143         char *startdir;
144         char *exec_no_x11;
145         char *package_name;
146         char *package_release_date;
147         char *mkdir_sp; // a colon separated list of paths to be mkdir'd (silently fail) when pnd is autodiscovered. path is always relative to the root of the hosting device.
148
149 }  pnd_pxml_t;
150
151 #ifdef __cplusplus
152 } /* "C" */
153 #endif
154
155 #endif