+ "can't create plugin index: %s\n"), index_path);
+ return 1;
+ }
+ fprintf(fp, "%d\n", PLUGIN_FILE_VERSION);
+ fprintf(fp, "%s\n", plugin_path);
+ init_plugin_index(mwindow, preferences, fp, plugin_path);
+ init_ffmpeg_index(mwindow, preferences, fp);
+ fclose(fp);
+ return load_plugin_index(mwindow, index_path, plugin_path);
+}
+
+int MWindow::init_ladspa_plugins(MWindow *mwindow, Preferences *preferences)
+{
+ char *path = getenv("LADSPA_PATH");
+ char ladspa_path[BCTEXTLEN];
+ if( !path ) {
+ get_exe_path(ladspa_path);
+ strcat(ladspa_path, "/ladspa");
+ path = ladspa_path;
+ }
+ for( int len=0; *path; path+=len ) {
+ char *cp = strchr(path,':');
+ len = !cp ? strlen(path) : cp-path;
+ char index_path[BCTEXTLEN], plugin_path[BCTEXTLEN];
+ memcpy(plugin_path, path, len); plugin_path[len] = 0;
+ char *plugin_dir = FileSystem::basepath(plugin_path);
+ strcpy(plugin_path, plugin_dir); delete [] plugin_dir;
+ create_defaults_path(index_path, LADSPA_FILE);
+ cp = index_path + strlen(index_path);
+ for( char *bp=plugin_path; *bp!=0; ++bp )
+ *cp++ = *bp=='/' ? '_' : *bp;
+ *cp = 0;
+ if( !load_plugin_index(mwindow, index_path, plugin_path) ) continue;
+ if( init_ladspa_index(mwindow, preferences, index_path, plugin_path) ) continue;
+ load_plugin_index(mwindow, index_path, plugin_path);
+ }
+ return 1;
+}
+
+void MWindow::init_plugin_index(MWindow *mwindow, Preferences *preferences,
+ FILE *fp, const char *plugin_dir)
+{
+ int idx = PLUGIN_IDS;
+ if( plugindb ) {
+ for( int i=0; i<plugindb->size(); ++i ) {
+ PluginServer *server = plugindb->get(i);
+ if( server->dir_idx >= idx )
+ idx = server->dir_idx+1;
+ }
+ }
+ scan_plugin_index(mwindow, preferences, fp, plugin_dir, ".", idx);
+}
+
+int MWindow::init_ladspa_index(MWindow *mwindow, Preferences *preferences,
+ const char *index_path, const char *plugin_dir)
+{
+ char plugin_path[BCTEXTLEN], *path = FileSystem::basepath(plugin_dir);
+ strcpy(plugin_path, path); delete [] path;
+ printf("init ladspa index: %s\n", plugin_dir);
+ FILE *fp = fopen(index_path,"w");
+ if( !fp ) {
+ fprintf(stderr,_("MWindow::init_ladspa_index: "
+ "can't create plugin index: %s\n"), index_path);