+static void free_desc(struct wgt_desc *desc)
+{
+ struct wgt_desc_icon *icon;
+ struct wgt_desc_feature *feature;
+ struct wgt_desc_preference *preference;
+ struct wgt_desc_param *param;
+
+ xmlFree(desc->id);
+ xmlFree(desc->version);
+ xmlFree(desc->viewmodes);
+ xmlFree(desc->defaultlocale);
+ xmlFree(desc->name);
+ xmlFree(desc->name_short);
+ xmlFree(desc->description);
+ xmlFree(desc->author);
+ xmlFree(desc->author_href);
+ xmlFree(desc->author_email);
+ xmlFree(desc->license);
+ xmlFree(desc->license_href);
+ xmlFree(desc->content_src);
+ xmlFree(desc->content_type);
+ xmlFree(desc->content_encoding);
+
+ while(desc->icons) {
+ icon = desc->icons;
+ desc->icons = icon->next;
+ xmlFree(icon->src);
+ free(icon);
+ }
+
+ while(desc->features) {
+ feature = desc->features;
+ desc->features = feature->next;
+ xmlFree(feature->name);
+ while(feature->params) {
+ param = feature->params;
+ feature->params = param->next;
+ xmlFree(param->name);
+ xmlFree(param->value);
+ free(param);
+ }
+ free(feature);
+ }
+
+ while(desc->preferences) {
+ preference = desc->preferences;
+ desc->preferences = preference->next;
+ xmlFree(preference->name);
+ xmlFree(preference->value);
+ free(preference);
+ }
+}
+
+static void dump_desc(struct wgt_desc *desc, FILE *f, const char *prefix)
+{
+ struct wgt_desc_icon *icon;
+ struct wgt_desc_feature *feature;
+ struct wgt_desc_preference *preference;
+ struct wgt_desc_param *param;
+
+ if (desc->id) fprintf(f, "%sid: %s\n", prefix, desc->id);
+ if (desc->width) fprintf(f, "%swidth: %d\n", prefix, desc->width);
+ if (desc->height) fprintf(f, "%sheight: %d\n", prefix, desc->height);
+ if (desc->version) fprintf(f, "%sversion: %s\n", prefix, desc->version);
+ if (desc->viewmodes) fprintf(f, "%sviewmodes: %s\n", prefix, desc->viewmodes);
+ if (desc->defaultlocale) fprintf(f, "%sdefaultlocale: %s\n", prefix, desc->defaultlocale);
+ if (desc->name) fprintf(f, "%sname: %s\n", prefix, desc->name);
+ if (desc->name_short) fprintf(f, "%sname_short: %s\n", prefix, desc->name_short);
+ if (desc->description) fprintf(f, "%sdescription: %s\n", prefix, desc->description);
+ if (desc->author) fprintf(f, "%sauthor: %s\n", prefix, desc->author);
+ if (desc->author_href) fprintf(f, "%sauthor_href: %s\n", prefix, desc->author_href);
+ if (desc->author_email) fprintf(f, "%sauthor_email: %s\n", prefix, desc->author_email);
+ if (desc->license) fprintf(f, "%slicense: %s\n", prefix, desc->license);
+ if (desc->license_href) fprintf(f, "%slicense_href: %s\n", prefix, desc->license_href);
+ if (desc->content_src) fprintf(f, "%scontent_src: %s\n", prefix, desc->content_src);
+ if (desc->content_type) fprintf(f, "%scontent_type: %s\n", prefix, desc->content_type);
+ if (desc->content_encoding) fprintf(f, "%scontent_encoding: %s\n", prefix, desc->content_encoding);
+
+ icon = desc->icons;
+ while(icon) {
+ fprintf(f, "%s+ icon src: %s\n", prefix, icon->src);
+ if (icon->width) fprintf(f, "%s width: %d\n", prefix, icon->width);
+ if (icon->height) fprintf(f, "%s height: %d\n", prefix, icon->height);
+ icon = icon->next;
+ }
+
+ feature = desc->features;
+ while(feature) {
+ fprintf(f, "%s+ feature name: %s\n", prefix, feature->name);
+ fprintf(f, "%s required: %s\n", prefix, feature->required ? "true" : "false");
+ param = feature->params;
+ while(param) {
+ fprintf(f, "%s + param name: %s\n", prefix, param->name);
+ fprintf(f, "%s value: %s\n", prefix, param->value);
+ param = param->next;
+ }
+ feature = feature->next;
+ }
+
+ preference = desc->preferences;
+ while(preference) {
+ fprintf(f, "%s+ preference name: %s\n", prefix, preference->name);
+ if (preference->value) fprintf(f, "%s value: %s\n", prefix, preference->value);
+ fprintf(f, "%s readonly: %s\n", prefix, preference->readonly ? "true" : "false");
+ preference = preference->next;
+ }
+}
+