d1c88629eebd32df03f9b88919257953528fedfa
[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 #define PXML_MAXAPPS 50 /* max number of <application>'s within a single PXML */ /* TODO: make this realloc() and dynamicly grow instead.. */
16
17 // for DaveC, we will support same-path-as-.pnd file override, that is simple format and not XML
18 #define PXML_SAMEPATH_OVERRIDE_FILEEXT ".ovr" /* ./foo/bar.pnd could have overrides in ./foo/bar.ovr */
19
20 // use this handle to interact with PXML; this hides the mechanics of parsing a PXML file so that
21 // it can be upgraded with impacting applications
22 typedef void* pnd_pxml_handle;
23
24 /* pxml_fetch() will return NULL on fail, otherwise a valid handle which may be further queried
25  */
26 pnd_pxml_handle *pnd_pxml_fetch ( char *fullpath );                         // fetch from file
27 pnd_pxml_handle *pnd_pxml_fetch_buffer ( char *filename, char *buffer );    // fetch from a buffer
28 void pnd_pxml_delete ( pnd_pxml_handle h );
29
30 /* overrides() allow for customization of a PXML that persists; ie: An application might be sitting
31  * on an SD card and popped out while we need to edit its personalized category; more to point, the
32  * PXML itself could be in a read-only SD or packed into an ISO, or just sitting in a directory.
33  * Rather than have a _second_ PXML in the same place or have to write back to read-only media or
34  * worry about losing customizations when an app is temporarily deleted, we can just keep the
35  * overrides themselves in NAND.
36  */
37 /* merge_override() will attempt to locate an override of the given PXML, and will modify the
38  * PXML in-place to include any overrides found.
39  * Returns >0 if a merge was done, 0 if no merge was done, and <0 on error
40  * NOTE: For searchpath, should query configs for PND_PXML_OVERRIDES_KEY (or use PND_PXML_OVERRIDES_SEARCHPATH)
41  */
42 signed char pnd_pxml_merge_override ( pnd_pxml_handle h, char *searchpath );
43
44 /* these accessor functions will return READ ONLY char*s; do not free them or modify them.
45  */
46
47 char *pnd_pxml_get_package_id ( pnd_pxml_handle h );
48 char *pnd_pxml_get_app_name_en ( pnd_pxml_handle h );
49 char *pnd_pxml_get_app_name_de ( pnd_pxml_handle h );
50 char *pnd_pxml_get_app_name_it ( pnd_pxml_handle h );
51 char *pnd_pxml_get_app_name_fr ( pnd_pxml_handle h );
52 char *pnd_pxml_get_app_name ( pnd_pxml_handle h, char *iso_lang );
53 char *pnd_pxml_get_unique_id ( pnd_pxml_handle h );
54 char *pnd_pxml_get_appdata_dirname ( pnd_pxml_handle h );
55 char *pnd_pxml_get_standalone ( pnd_pxml_handle h );
56 char *pnd_pxml_get_icon ( pnd_pxml_handle h );
57 char *pnd_pxml_get_description_en ( pnd_pxml_handle h );
58 char *pnd_pxml_get_description_de ( pnd_pxml_handle h );
59 char *pnd_pxml_get_description_it ( pnd_pxml_handle h );
60 char *pnd_pxml_get_description_fr ( pnd_pxml_handle h );
61 char *pnd_pxml_get_description ( pnd_pxml_handle h, char *iso_lang);
62 char *pnd_pxml_get_previewpic1 ( pnd_pxml_handle h );
63 char *pnd_pxml_get_previewpic2 ( pnd_pxml_handle h );
64 char *pnd_pxml_get_author_name ( pnd_pxml_handle h );
65 char *pnd_pxml_get_author_website ( pnd_pxml_handle h );
66 char *pnd_pxml_get_version_major ( pnd_pxml_handle h );
67 char *pnd_pxml_get_version_minor ( pnd_pxml_handle h );
68 char *pnd_pxml_get_version_release ( pnd_pxml_handle h );
69 char *pnd_pxml_get_version_build ( pnd_pxml_handle h );
70 char *pnd_pxml_get_exec ( pnd_pxml_handle h );
71 char *pnd_pxml_get_execargs ( pnd_pxml_handle h );
72 char *pnd_pxml_get_exec_option_no_x11 ( pnd_pxml_handle h );
73 char *pnd_pxml_get_main_category ( pnd_pxml_handle h );
74 char *pnd_pxml_get_subcategory1 ( pnd_pxml_handle h );
75 char *pnd_pxml_get_subcategory2 ( pnd_pxml_handle h );
76 char *pnd_pxml_get_altcategory ( pnd_pxml_handle h );
77 char *pnd_pxml_get_altsubcategory1 ( pnd_pxml_handle h );
78 char *pnd_pxml_get_altsubcategory2 ( pnd_pxml_handle h );
79 char *pnd_pxml_get_osversion_major ( pnd_pxml_handle h );
80 char *pnd_pxml_get_osversion_minor ( pnd_pxml_handle h );
81 char *pnd_pxml_get_osversion_release ( pnd_pxml_handle h );
82 char *pnd_pxml_get_osversion_build ( pnd_pxml_handle h );
83 char *pnd_pxml_get_associationitem1_name ( pnd_pxml_handle h );
84 char *pnd_pxml_get_associationitem1_filetype ( pnd_pxml_handle h );
85 char *pnd_pxml_get_associationitem1_command ( pnd_pxml_handle h );
86 char *pnd_pxml_get_associationitem1_args ( pnd_pxml_handle h );
87 char *pnd_pxml_get_associationitem2_name ( pnd_pxml_handle h );
88 char *pnd_pxml_get_associationitem2_filetype ( pnd_pxml_handle h );
89 char *pnd_pxml_get_associationitem2_command ( pnd_pxml_handle h );
90 char *pnd_pxml_get_associationitem2_args ( pnd_pxml_handle h );
91 char *pnd_pxml_get_associationitem3_name ( pnd_pxml_handle h );
92 char *pnd_pxml_get_associationitem3_filetype ( pnd_pxml_handle h );
93 char *pnd_pxml_get_associationitem3_command ( pnd_pxml_handle h );
94 char *pnd_pxml_get_associationitem3_args ( pnd_pxml_handle h );
95 char *pnd_pxml_get_clockspeed ( pnd_pxml_handle h );
96 char *pnd_pxml_get_background ( pnd_pxml_handle h );
97 char *pnd_pxml_get_startdir ( pnd_pxml_handle h );
98 char *pnd_pxml_get_mkdir ( pnd_pxml_handle h );
99 char *pnd_pxml_get_info_name ( pnd_pxml_handle h );
100 char *pnd_pxml_get_info_type ( pnd_pxml_handle h );
101 char *pnd_pxml_get_info_src ( pnd_pxml_handle h );
102 char *pnd_pxml_get_package_version_major ( pnd_pxml_handle h );
103 char *pnd_pxml_get_package_version_minor ( pnd_pxml_handle h );
104 char *pnd_pxml_get_package_version_release ( pnd_pxml_handle h );
105 char *pnd_pxml_get_package_version_build ( pnd_pxml_handle h );
106
107 // for 'set' functions, pass NULL value to delete existing value without setting new one
108 void pnd_pxml_set_app_name ( pnd_pxml_handle h, char *v );
109
110 /* utilities
111  */
112 typedef enum {
113   pnd_pxml_x11_error = 0,
114   pnd_pxml_x11_required,
115   pnd_pxml_x11_ignored,
116   pnd_pxml_x11_stop
117 } pnd_pxml_x11_req_e;
118 pnd_pxml_x11_req_e pnd_pxml_get_x11 ( char *pxmlvalue ); // returns error, required, ignored, stop hint
119 unsigned char pnd_is_pxml_valid_app ( pnd_pxml_handle h ); // returns 1 when pxml seems like a valid application
120 unsigned char pnd_pxml_is_affirmative ( char *v ); // return 1 for 'Y' or '!'
121
122 typedef struct
123 {
124         char *language;
125         char *string;
126 } pnd_localized_string_t;
127
128 typedef struct
129 {
130         unsigned char subapp_number; // 0+ for <application> # .. first <application> is 0
131         pnd_localized_string_t *titles;
132         int titles_c;
133         int titles_alloc_c;
134         char *unique_id;
135         char *appdata_dirname;       // preferred dir name for appdata; if missing, use unique-id
136         char *standalone;
137         char *icon;
138         pnd_localized_string_t *descriptions;
139         int descriptions_c;
140         int descriptions_alloc_c;
141         char *previewpic1;
142         char *previewpic2;
143         char *author_name;
144         char *author_website;
145         char *version_major;
146         char *version_minor;
147         char *version_release;
148         char *version_build;
149         char *exec;
150         char *execargs;
151         char *main_category;
152         char *subcategory1;
153         char *subcategory2;
154         char *altcategory;
155         char *altsubcategory1;
156         char *altsubcategory2;
157         char *osversion_major;
158         char *osversion_minor;
159         char *osversion_release;
160         char *osversion_build;
161         char *associationitem1_name;
162         char *associationitem1_filetype;
163         char *associationitem1_command;
164         char *associationitem2_name;
165         char *associationitem2_filetype;
166         char *associationitem2_command;
167         char *associationitem3_name;
168         char *associationitem3_filetype;
169         char *associationitem3_command;
170         char *clockspeed;
171         char *background;
172         char *startdir;
173         char *exec_no_x11;
174         char *package_id;
175         char *package_name;
176         char *package_release_date;
177         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.
178
179         char *info_name;      // should be a struct..
180         char *info_filename;
181         char *info_type;
182         char *package_version_major;
183         char *package_version_minor;
184         char *package_version_release;
185         char *package_version_build;
186         char *associationitem1_args; // wish it could be above, but that would break existing ABI
187         char *associationitem2_args; // wish it could be above, but that would break existing ABI
188         char *associationitem3_args; // wish it could be above, but that would break existing ABI
189
190 }  pnd_pxml_t;
191
192 #ifdef __cplusplus
193 } /* "C" */
194 #endif
195
196 #endif