+
+char *pnd_pxml_get_best_localized_string(pnd_localized_string_t strings[], int strings_c, char *iso_lang)
+{
+ int i;
+ int similarity_weight = 0xffff; /*Set to something Really Bad in the beginning*/
+ char *best_match = NULL;
+
+ for(i = 0; i < strings_c; i++)
+ {
+ // factor in the length -- if we're given 'en' and have a string 'en_US', thats better than 'de_something'; if we don't
+ // use length, then en_US and de_FO are same to 'en'.
+ int maxcount = strlen ( strings[i].language ) < strlen ( iso_lang ) ? strlen ( strings[i].language ) : strlen ( iso_lang );
+ int new_weight = abs(strncmp(strings[i].language, iso_lang, maxcount));
+ //pnd_log ( PND_LOG_DEFAULT, "looking for lang %s, looking at lang %s (weight %d, old %d): %s\n",
+ // iso_lang, strings [ i ].language, new_weight, similarity_weight, strings [ i ].string );
+ if (new_weight < similarity_weight)
+ {
+ similarity_weight = new_weight;
+ best_match = strings[i].string;
+ }
+ }
+
+ if ( best_match ) {
+ //pnd_log ( PND_LOG_DEFAULT, "best match: %s\n", best_match );
+ return strdup(best_match);
+ }
+
+ //pnd_log ( PND_LOG_DEFAULT, "best match: FAIL\n" );
+
+ return ( NULL );
+}
+
+char *pnd_pxml_get_app_name ( pnd_pxml_handle h, char *iso_lang ) {
+ pnd_pxml_t *p = (pnd_pxml_t *) h;
+ return pnd_pxml_get_best_localized_string(p->titles, p->titles_c, iso_lang);
+}
+
+char *pnd_pxml_get_app_name_en ( pnd_pxml_handle h ) {
+ return pnd_pxml_get_app_name(h, "en");
+}
+
+char *pnd_pxml_get_app_name_de ( pnd_pxml_handle h ) {
+ return pnd_pxml_get_app_name(h, "de");
+}
+
+char *pnd_pxml_get_app_name_it ( pnd_pxml_handle h ) {
+ return pnd_pxml_get_app_name(h, "it");
+}
+
+char *pnd_pxml_get_app_name_fr ( pnd_pxml_handle h ) {
+ return pnd_pxml_get_app_name(h, "fr");
+}
+
+char *pnd_pxml_get_unique_id ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> unique_id );
+}
+
+char *pnd_pxml_get_appdata_dirname ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> appdata_dirname );
+}
+
+char *pnd_pxml_get_standalone ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> standalone );
+}
+
+char *pnd_pxml_get_icon ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> icon );
+}
+
+char *pnd_pxml_get_app_description ( pnd_pxml_handle h, char *iso_lang ) {
+ pnd_pxml_t *p = (pnd_pxml_t *) h;
+ return pnd_pxml_get_best_localized_string(p->descriptions, p->descriptions_c, iso_lang);
+}
+
+char *pnd_pxml_get_description_en ( pnd_pxml_handle h ) {
+ return pnd_pxml_get_app_description(h, "en");
+}
+
+char *pnd_pxml_get_description_de ( pnd_pxml_handle h ) {
+ return pnd_pxml_get_app_description(h, "de");
+}
+
+char *pnd_pxml_get_description_it ( pnd_pxml_handle h ) {
+ return pnd_pxml_get_app_description(h, "it");
+}
+
+char *pnd_pxml_get_description_fr ( pnd_pxml_handle h ) {
+ return pnd_pxml_get_app_description(h, "fr");
+}
+
+char *pnd_pxml_get_previewpic1 ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> previewpic1 );
+}
+
+char *pnd_pxml_get_previewpic2 ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> previewpic2 );
+}
+
+char *pnd_pxml_get_author_name ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> author_name );
+}
+
+char *pnd_pxml_get_author_website ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> author_website );
+}
+
+char *pnd_pxml_get_version_major ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> version_major );
+}
+
+char *pnd_pxml_get_version_minor ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> version_minor );
+}
+
+char *pnd_pxml_get_version_release ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> version_release );
+}
+
+char *pnd_pxml_get_version_build ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> version_build );
+}
+
+char *pnd_pxml_get_exec ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> exec );
+}
+
+char *pnd_pxml_get_execargs ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> execargs );
+}
+
+char *pnd_pxml_get_exec_option_no_x11 ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> exec_no_x11 );
+}
+
+char *pnd_pxml_get_main_category ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> main_category );
+}
+
+char *pnd_pxml_get_subcategory1 ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> subcategory1 );
+}
+
+char *pnd_pxml_get_subcategory2 ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> subcategory2 );
+}
+
+char *pnd_pxml_get_altcategory ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> altcategory );
+}
+
+char *pnd_pxml_get_altsubcategory1 ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> altsubcategory1 );
+}
+
+char *pnd_pxml_get_altsubcategory2 ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> altsubcategory2 );
+}
+
+char *pnd_pxml_get_osversion_major ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> osversion_major );
+}
+
+char *pnd_pxml_get_osversion_minor ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> osversion_minor );
+}
+
+char *pnd_pxml_get_osversion_release ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> osversion_release );
+}
+
+char *pnd_pxml_get_osversion_build ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> osversion_build );
+}
+
+char *pnd_pxml_get_associationitem1_name ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> associationitem1_name );
+}
+
+char *pnd_pxml_get_associationitem1_filetype ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> associationitem1_filetype );
+}
+
+char *pnd_pxml_get_associationitem1_parameter ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> associationitem1_parameter );
+}
+
+char *pnd_pxml_get_associationitem2_name ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> associationitem2_name );
+}
+
+char *pnd_pxml_get_associationitem2_filetype ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> associationitem2_filetype );
+}
+
+char *pnd_pxml_get_associationitem2_parameter ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> associationitem2_parameter );
+}
+
+char *pnd_pxml_get_associationitem3_name ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> associationitem3_name );
+}
+
+char *pnd_pxml_get_associationitem3_filetype ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> associationitem3_filetype );
+}
+
+char *pnd_pxml_get_associationitem3_parameter ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> associationitem3_parameter );
+}
+
+char *pnd_pxml_get_clockspeed ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> clockspeed );
+}
+
+char *pnd_pxml_get_background ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> background );
+}
+
+char *pnd_pxml_get_startdir ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> startdir );
+}
+
+char *pnd_pxml_get_mkdir ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> mkdir_sp );
+}
+
+unsigned char pnd_pxml_is_affirmative ( char *v ) {
+
+ if ( ! v ) {
+ return ( 0 );
+ }
+
+ if ( ( v [ 0 ] == 'Y' ) ||
+ ( v [ 0 ] == 'y' ) ||
+ ( v [ 0 ] == '1' ) )
+ {
+ return ( 0 );
+ }
+
+ return ( 0 );
+}
+
+pnd_pxml_x11_req_e pnd_pxml_get_x11 ( char *pxmlvalue ) {
+
+ if ( ! pxmlvalue ) {
+ return ( pnd_pxml_x11_ignored );
+ } else if ( strcasecmp ( pxmlvalue, "req" ) == 0 ) {
+ return ( pnd_pxml_x11_required );
+ } else if ( strcasecmp ( pxmlvalue, "stop" ) == 0 ) {
+ return ( pnd_pxml_x11_stop );
+ } else if ( strcasecmp ( pxmlvalue, "ignore" ) == 0 ) {
+ return ( pnd_pxml_x11_ignored );
+ }
+
+ return ( pnd_pxml_x11_ignored ); // default
+}
+
+char *pnd_pxml_get_info_name ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> info_name );
+}
+
+char *pnd_pxml_get_info_type ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> info_type );
+}
+
+char *pnd_pxml_get_info_src ( pnd_pxml_handle h ) {
+ pnd_pxml_t *p = (pnd_pxml_t*) h;
+ return ( p -> info_filename );
+}