+ // base paths
+ p -> object_path = strdup ( fpath );
+
+ if ( ( fixpxml = strcasestr ( p -> object_path, PXML_FILENAME ) ) ) {
+ *fixpxml = '\0'; // if this is not a .pnd, lop off the PXML.xml at the end
+ } else if ( ( fixpxml = strrchr ( p -> object_path, '/' ) ) ) {
+ *(fixpxml+1) = '\0'; // for pnd, lop off to last /
+ }
+
+ if ( ( fixpxml = strrchr ( fpath, '/' ) ) ) {
+ p -> object_filename = strdup ( fixpxml + 1 );
+ }
+
+ // subapp-number
+ p -> subapp_number = ((pnd_pxml_t*) pxmlh) -> subapp_number;
+
+ // png icon path
+ p -> pnd_icon_pos = pxml_close_pos;
+
+ // type
+ p -> object_type = valid;
+
+ // PXML fields
+ if ( pnd_pxml_get_package_id ( pxmlh ) ) {
+ p -> package_id = strdup ( pnd_pxml_get_package_id ( pxmlh ) );
+ }
+ char *name_en = pnd_pxml_get_app_name_en ( pxmlh );
+ if (name_en) {
+ p -> title_en = name_en; /* already strdupped */
+ }
+ char *desc_en = pnd_pxml_get_description_en ( pxmlh );
+ if ( desc_en ) {
+ p -> desc_en = desc_en; /* already strdupped */
+ }
+ if ( pnd_pxml_get_icon ( pxmlh ) ) {
+ p -> icon = strdup ( pnd_pxml_get_icon ( pxmlh ) );
+ }
+ if ( pnd_pxml_get_exec ( pxmlh ) ) {
+ p -> exec = strdup ( pnd_pxml_get_exec ( pxmlh ) );
+ }
+ if ( pnd_pxml_get_execargs ( pxmlh ) ) {
+ p -> execargs = strdup ( pnd_pxml_get_execargs ( pxmlh ) );
+ }
+ if ( pnd_pxml_get_exec_option_no_x11 ( pxmlh ) ) {
+ p -> option_no_x11 = strdup ( pnd_pxml_get_exec_option_no_x11 ( pxmlh ) );
+ }
+ if ( pnd_pxml_get_unique_id ( pxmlh ) ) {
+ p -> unique_id = strdup ( pnd_pxml_get_unique_id ( pxmlh ) );
+ }
+ if ( pnd_pxml_get_appdata_dirname ( pxmlh ) ) {
+ p -> appdata_dirname = strdup ( pnd_pxml_get_appdata_dirname ( pxmlh ) );
+ }
+ if ( pnd_pxml_get_clockspeed ( pxmlh ) ) {
+ p -> clockspeed = strdup ( pnd_pxml_get_clockspeed ( pxmlh ) );
+ }
+ if ( pnd_pxml_get_startdir ( pxmlh ) ) {
+ p -> startdir = strdup ( pnd_pxml_get_startdir ( pxmlh ) );
+ }
+ // category kruft
+ if ( pnd_pxml_get_main_category ( pxmlh ) ) {
+ p -> main_category = strdup ( pnd_pxml_get_main_category ( pxmlh ) );
+ }
+ if ( pnd_pxml_get_subcategory1 ( pxmlh ) ) {
+ p -> main_category1 = strdup ( pnd_pxml_get_subcategory1 ( pxmlh ) );
+ }
+ if ( pnd_pxml_get_subcategory2 ( pxmlh ) ) {
+ p -> main_category2 = strdup ( pnd_pxml_get_subcategory2 ( pxmlh ) );
+ }
+ if ( pnd_pxml_get_altcategory ( pxmlh ) ) {
+ p -> alt_category = strdup ( pnd_pxml_get_altcategory ( pxmlh ) );
+ }
+ if ( pnd_pxml_get_altsubcategory1 ( pxmlh ) ) {
+ p -> alt_category1 = strdup ( pnd_pxml_get_altsubcategory1 ( pxmlh ) );
+ }
+ if ( pnd_pxml_get_altsubcategory2 ( pxmlh ) ) {
+ p -> alt_category2 = strdup ( pnd_pxml_get_altsubcategory2 ( pxmlh ) );
+ }
+ // preview pics
+ if ( ( z = pnd_pxml_get_previewpic1 ( pxmlh ) ) ) {
+ p -> preview_pic1 = strdup ( z );
+ }
+ if ( ( z = pnd_pxml_get_previewpic2 ( pxmlh ) ) ) {
+ p -> preview_pic2 = strdup ( z );
+ }
+ // mkdirs
+ if ( pnd_pxml_get_mkdir ( pxmlh ) ) {
+ p -> mkdir_sp = strdup ( pnd_pxml_get_mkdir ( pxmlh ) );
+ }
+ // info
+ if ( pnd_pxml_get_info_src ( pxmlh ) ) {
+ p -> info_filename = strdup ( pnd_pxml_get_info_src ( pxmlh ) );
+ }
+ if ( pnd_pxml_get_info_name ( pxmlh ) ) {
+ p -> info_name = strdup ( pnd_pxml_get_info_name ( pxmlh ) );
+ }
+ if ( pnd_pxml_get_info_type ( pxmlh ) ) {
+ p -> info_type = strdup ( pnd_pxml_get_info_type ( pxmlh ) );
+ }
+ if ( pnd_pxml_get_version_major ( pxmlh ) ) {
+ p -> version_major = strdup ( pnd_pxml_get_version_major ( pxmlh ) );
+ }
+ if ( pnd_pxml_get_version_minor ( pxmlh ) ) {
+ p -> version_minor = strdup ( pnd_pxml_get_version_minor ( pxmlh ) );
+ }
+ if ( pnd_pxml_get_version_release ( pxmlh ) ) {
+ p -> version_release = strdup ( pnd_pxml_get_version_release ( pxmlh ) );
+ }
+ if ( pnd_pxml_get_version_build ( pxmlh ) ) {
+ p -> version_build = strdup ( pnd_pxml_get_version_build ( pxmlh ) );
+ }
+ if ( pnd_pxml_get_package_version_major ( pxmlh ) ) {
+ p -> package_version_major = strdup ( pnd_pxml_get_package_version_major ( pxmlh ) );
+ }
+ if ( pnd_pxml_get_package_version_minor ( pxmlh ) ) {
+ p -> package_version_minor = strdup ( pnd_pxml_get_package_version_minor ( pxmlh ) );
+ }
+ if ( pnd_pxml_get_package_version_release ( pxmlh ) ) {
+ p -> package_version_release = strdup ( pnd_pxml_get_package_version_release ( pxmlh ) );
+ }
+ if ( pnd_pxml_get_package_version_build ( pxmlh ) ) {
+ p -> package_version_build = strdup ( pnd_pxml_get_package_version_build ( pxmlh ) );
+ }
+#if 1
+ // file associations
+ if ( pnd_pxml_get_associationitem1_name ( pxmlh ) ) {
+ p -> associationitem1_name = strdup ( pnd_pxml_get_associationitem1_name ( pxmlh ) );
+ p -> associationitem1_filetype = strdup ( pnd_pxml_get_associationitem1_filetype ( pxmlh ) );
+ p -> associationitem1_command = strdup ( pnd_pxml_get_associationitem1_command ( pxmlh ) );
+ p -> associationitem1_args = strdup ( pnd_pxml_get_associationitem1_args ( pxmlh ) );
+ //pnd_log ( PND_LOG_DEFAULT, " Disco: Found file association request in PXML (%s)\n", p -> title_en );
+ }
+ if ( pnd_pxml_get_associationitem2_name ( pxmlh ) ) {
+ p -> associationitem2_name = strdup ( pnd_pxml_get_associationitem2_name ( pxmlh ) );
+ p -> associationitem2_filetype = strdup ( pnd_pxml_get_associationitem2_filetype ( pxmlh ) );
+ p -> associationitem2_command = strdup ( pnd_pxml_get_associationitem2_command ( pxmlh ) );
+ p -> associationitem2_args = strdup ( pnd_pxml_get_associationitem2_args ( pxmlh ) );
+ }
+ if ( pnd_pxml_get_associationitem3_name ( pxmlh ) ) {
+ p -> associationitem3_name = strdup ( pnd_pxml_get_associationitem3_name ( pxmlh ) );
+ p -> associationitem3_filetype = strdup ( pnd_pxml_get_associationitem3_filetype ( pxmlh ) );
+ p -> associationitem3_command = strdup ( pnd_pxml_get_associationitem3_command ( pxmlh ) );
+ p -> associationitem3_args = strdup ( pnd_pxml_get_associationitem3_args ( pxmlh ) );
+ }
+#endif
+
+ // look for any PXML overrides, if requested
+ if ( disco_overrides ) {
+ pnd_pxml_merge_override ( pxmlh, disco_overrides );
+ }
+
+ // handle ovr overrides
+ // try to load a same-path-as-pnd override file
+ if ( ovrh == 0 ) {
+ sprintf ( ovrfile, "%s/%s", p -> object_path, p -> object_filename );
+ fixpxml = strcasestr ( ovrfile, PND_PACKAGE_FILEEXT );
+ if ( fixpxml ) {
+ strcpy ( fixpxml, PXML_SAMEPATH_OVERRIDE_FILEEXT );
+ struct stat statbuf;
+ if ( stat ( ovrfile, &statbuf ) == 0 ) {
+ ovrh = pnd_conf_fetch_by_path ( ovrfile );
+
+ if ( ! ovrh ) {
+ // couldn't pull conf out of file, so don't try again
+ ovrh = (void*)(-1);
+ }
+
+ } else {
+ ovrh = (void*)(-1); // not found, don't try again
+ } // stat
+ } // can find .pnd
+ } // tried ovr yet?
+
+ // is ovr file open?
+ if ( ovrh != 0 && ovrh != (void*)(-1) ) {
+ // pull in appropriate values
+ char key [ 100 ];
+ char *v;
+
+ // set the flag regardless, so its for all subapps
+ p -> object_flags |= PND_DISCO_FLAG_OVR;
+
+ // title
+ snprintf ( key, 100, "Application-%u.title", p -> subapp_number );
+ if ( ( v = pnd_conf_get_as_char ( ovrh, key ) ) ) {
+ if ( p -> title_en ) {
+ free ( p -> title_en );
+ }
+ p -> title_en = strdup ( v );
+ }
+
+ // clockspeed
+ snprintf ( key, 100, "Application-%u.clockspeed", p -> subapp_number );
+ if ( ( v = pnd_conf_get_as_char ( ovrh, key ) ) ) {
+ if ( p -> clockspeed ) {
+ free ( p -> clockspeed );
+ }
+ p -> clockspeed = strdup ( v );
+ }
+
+ // appdata dirname
+ snprintf ( key, 100, "Application-%u.appdata", p -> subapp_number );
+ if ( ( v = pnd_conf_get_as_char ( ovrh, key ) ) ) {
+ if ( p -> appdata_dirname ) {
+ free ( p -> appdata_dirname );
+ }
+ p -> appdata_dirname = strdup ( v );
+ }
+
+ // categories
+ snprintf ( key, 100, "Application-%u.maincategory", p -> subapp_number );
+ if ( ( v = pnd_conf_get_as_char ( ovrh, key ) ) ) {
+ if ( p -> main_category ) {
+ free ( p -> main_category );
+ }
+ p -> main_category = strdup ( v );
+ }
+ snprintf ( key, 100, "Application-%u.maincategorysub1", p -> subapp_number );
+ if ( ( v = pnd_conf_get_as_char ( ovrh, key ) ) ) {
+ if ( p -> main_category1 ) {
+ free ( p -> main_category1 );
+ p -> main_category1 = NULL;
+ }
+ if ( strcasecmp ( v, "NoSubcategory" ) != 0 ) {
+ p -> main_category1 = strdup ( v );
+ }
+ }
+
+ } // got ovr conf loaded?
+
+ } else {
+ //printf ( "Invalid PXML; skipping.\n" );