implement VST blacklisting
[ardour.git] / libs / ardour / vst_info_file.cc
index 7d5aaf3795fd7752a7643d4ff4ffa317bbffd1ed..3586d6de28a4c3e9253385e535350b24eded5120 100644 (file)
@@ -42,6 +42,7 @@
 
 #include "pbd/error.h"
 
+#include "ardour/filesystem_paths.h"
 #include "ardour/linux_vst_support.h"
 #include "ardour/vst_info_file.h"
 
 
 using namespace std;
 
+// TODO: make static parts of this file re-usable for standalone app
+// TODO: namespace public API into ARDOUR, ::Session or ::PluginManager
+//       consolidate vstfx_get_info_lx() and vstfx_get_info_fst()
+
+/* prototypes */
+#ifdef WINDOWS_VST_SUPPORT
+#include <fst.h>
+static bool
+vstfx_instantiate_and_get_info_fst (const char* dllpath, vector<VSTInfo*> *infos, int uniqueID);
+#endif
+
+#ifdef LXVST_SUPPORT
+static bool vstfx_instantiate_and_get_info_lx (const char* dllpath, vector<VSTInfo*> *infos, int uniqueID);
+#endif
+
+static int vstfx_current_loading_id = 0;
+
 static char *
 read_string (FILE *fp)
 {
@@ -84,51 +102,105 @@ read_int (FILE* fp, int* n)
        return (sscanf (p, "%d", n) != 1);
 }
 
-static VSTInfo *
-load_vstfx_info_file (FILE* fp)
+static void
+vstfx_free_info (VSTInfo *info)
 {
-       VSTInfo *info;
+       for (int i = 0; i < info->numParams; i++) {
+               free (info->ParamNames[i]);
+               free (info->ParamLabels[i]);
+       }
 
-       if ((info = (VSTInfo*) malloc (sizeof (VSTInfo))) == 0) {
-               return 0;
+       free (info->name);
+       free (info->creator);
+       free (info->Category);
+       free (info->ParamNames);
+       free (info->ParamLabels);
+       free (info);
+}
+
+static void
+vstfx_clear_info_list (vector<VSTInfo *> *infos)
+{
+       for (vector<VSTInfo *>::iterator i = infos->begin(); i != infos->end(); ++i) {
+               vstfx_free_info(*i);
        }
+       infos->clear();
+}
 
-       if ((info->name = read_string(fp)) == 0) goto error;
-       if ((info->creator = read_string(fp)) == 0) goto error;
-       if (read_int (fp, &info->UniqueID)) goto error;
-       if ((info->Category = read_string(fp)) == 0) goto error;
-       if (read_int (fp, &info->numInputs)) goto error;
-       if (read_int (fp, &info->numOutputs)) goto error;
-       if (read_int (fp, &info->numParams)) goto error;
-       if (read_int (fp, &info->wantMidi)) goto error;
-       if (read_int (fp, &info->hasEditor)) goto error;
-       if (read_int (fp, &info->canProcessReplacing)) goto error;
+static bool
+vstfx_load_info_block(FILE* fp, VSTInfo *info)
+{
+       if ((info->name = read_string(fp)) == 0) return false;
+       if ((info->creator = read_string(fp)) == 0) return false;
+       if (read_int (fp, &info->UniqueID)) return false;
+       if ((info->Category = read_string(fp)) == 0) return false;
+       if (read_int (fp, &info->numInputs)) return false;
+       if (read_int (fp, &info->numOutputs)) return false;
+       if (read_int (fp, &info->numParams)) return false;
+       if (read_int (fp, &info->wantMidi)) return false;
+       if (read_int (fp, &info->hasEditor)) return false;
+       if (read_int (fp, &info->canProcessReplacing)) return false;
 
        if ((info->ParamNames = (char **) malloc(sizeof(char*)*info->numParams)) == 0) {
-               goto error;
+               return false;
        }
 
        for (int i = 0; i < info->numParams; ++i) {
-               if ((info->ParamNames[i] = read_string(fp)) == 0) goto error;
+               if ((info->ParamNames[i] = read_string(fp)) == 0) return false;
        }
 
        if ((info->ParamLabels = (char **) malloc(sizeof(char*)*info->numParams)) == 0) {
-               goto error;
+               return false;
        }
 
        for (int i = 0; i < info->numParams; ++i) {
-               if ((info->ParamLabels[i] = read_string(fp)) == 0) goto error;
+               if ((info->ParamLabels[i] = read_string(fp)) == 0) {
+                       return false;
+               }
        }
+       return true;
+}
 
-       return info;
-
-error:
-       free (info);
-       return 0;
+static bool
+vstfx_load_info_file (FILE* fp, vector<VSTInfo*> *infos)
+{
+       VSTInfo *info;
+       if ((info = (VSTInfo*) calloc (1, sizeof (VSTInfo))) == 0) {
+               return false;
+       }
+       if (vstfx_load_info_block(fp, info)) {
+               if (strncmp (info->Category, "Shell", 5)) {
+                       infos->push_back(info);
+               } else {
+                       int plugin_cnt = 0;
+                       vstfx_free_info(info);
+                       if (read_int (fp, &plugin_cnt)) {
+                               for (int i = 0; i < plugin_cnt; i++) {
+                                       if ((info = (VSTInfo*) calloc (1, sizeof (VSTInfo))) == 0) {
+                                               vstfx_clear_info_list(infos);
+                                               return false;
+                                       }
+                                       if (vstfx_load_info_block(fp, info)) {
+                                               infos->push_back(info);
+                                       } else {
+                                               vstfx_free_info(info);
+                                               vstfx_clear_info_list(infos);
+                                               return false;
+                                       }
+                               }
+                       } else {
+                               return false; /* Bad file */
+                       }
+               }
+               return true;
+       }
+       vstfx_free_info(info);
+       vstfx_clear_info_list(infos);
+       return false;
 }
 
-static int
-save_vstfx_info_file (VSTInfo *info, FILE* fp)
+static void
+vstfx_write_info_block (FILE* fp, VSTInfo *info)
 {
        assert (info);
        assert (fp);
@@ -151,24 +223,116 @@ save_vstfx_info_file (VSTInfo *info, FILE* fp)
        for (int i = 0; i < info->numParams; i++) {
                fprintf (fp, "%s\n", info->ParamLabels[i]);
        }
+}
 
-       return 0;
+static void
+vstfx_write_info_file (FILE* fp, vector<VSTInfo *> *infos)
+{
+       assert(infos);
+       assert(fp);
+
+       if (infos->size() > 1) {
+               vector<VSTInfo *>::iterator x = infos->begin();
+               /* write out the shell info first along with count of the number of
+                * plugins contained in this shell
+                */
+               vstfx_write_info_block(fp, *x);
+               fprintf( fp, "%d\n", infos->size() - 1 );
+               ++x;
+               /* Now write out the info for each plugin */
+               for (; x != infos->end(); ++x) {
+                       vstfx_write_info_block(fp, *x);
+               }
+       } else if (infos->size() == 1) {
+               vstfx_write_info_block(fp, infos->front());
+       } else {
+               PBD::error << "Zero plugins in VST." << endmsg; // XXX here? rather make this impossible before if it ain't already.
+       }
 }
 
 static string
-vstfx_infofile_path (char* dllpath, int personal)
+vstfx_blacklist_path (const char* dllpath, int personal)
 {
        string dir;
        if (personal) {
-               dir = Glib::build_filename (Glib::get_home_dir (), ".fst");
+               dir = get_personal_vst_blacklist_dir();
+       } else {
+               dir = Glib::path_get_dirname (std::string(dllpath));
+       }
+
+       stringstream s;
+       s << "." << Glib::path_get_basename (dllpath) << ".fsb";
+       return Glib::build_filename (dir, s.str ());
+}
 
-               /* If the directory doesn't exist, try to create it */
-               if (!Glib::file_test (dir, Glib::FILE_TEST_IS_DIR)) {
-                       if (g_mkdir (dir.c_str (), 0700)) {
-                               return 0;
+/* return true if plugin is blacklisted or has an invalid file extension */
+static bool
+vstfx_blacklist_stat (const char *dllpath, int personal)
+{
+       if (strstr (dllpath, ".so" ) == 0 && strstr(dllpath, ".dll") == 0) {
+               return true;
+       }
+       string const path = vstfx_blacklist_path (dllpath, personal);
+
+       if (Glib::file_test (path, Glib::FileTest (Glib::FILE_TEST_EXISTS | Glib::FILE_TEST_IS_REGULAR))) {
+               struct stat dllstat;
+               struct stat fsbstat;
+
+               if (stat (dllpath, &dllstat) == 0 && stat (path.c_str(), &fsbstat) == 0) {
+                       if (dllstat.st_mtime > fsbstat.st_mtime) {
+                               /* plugin is newer than blacklist file */
+                               return true;
                        }
                }
+               /* stat failed or plugin is older than blacklist file */
+               return true;
+       }
+       /* blacklist file does not exist */
+       return false;
+}
+
+static bool
+vstfx_check_blacklist (const char *dllpath)
+{
+       if (vstfx_blacklist_stat(dllpath, 0)) return true;
+       if (vstfx_blacklist_stat(dllpath, 1)) return true;
+       return false;
+}
+
+static FILE *
+vstfx_blacklist_file (const char *dllpath)
+{
+       FILE *f;
+       if ((f = fopen (vstfx_blacklist_path (dllpath, 0).c_str(), "w"))) {
+               return f;
+       }
+       return fopen (vstfx_blacklist_path (dllpath, 1).c_str(), "w");
+}
+
+static bool
+vstfx_blacklist (const char *dllpath)
+{
+       FILE *f = vstfx_blacklist_file(dllpath);
+       if (f) {
+               fclose(f);
+               return true;
+       }
+       return false;
+}
+
+static bool
+vstfx_un_blacklist (const char *dllpath)
+{
+       ::g_unlink(vstfx_blacklist_path (dllpath, 0).c_str());
+       ::g_unlink(vstfx_blacklist_path (dllpath, 1).c_str());
+}
 
+static string
+vstfx_infofile_path (const char* dllpath, int personal)
+{
+       string dir;
+       if (personal) {
+               dir = get_personal_vst_info_cache_dir();
        } else {
                dir = Glib::path_get_dirname (std::string(dllpath));
        }
@@ -179,7 +343,7 @@ vstfx_infofile_path (char* dllpath, int personal)
 }
 
 static char *
-vstfx_infofile_stat (char *dllpath, struct stat* statbuf, int personal)
+vstfx_infofile_stat (const char *dllpath, struct stat* statbuf, int personal)
 {
        if (strstr (dllpath, ".so" ) == 0 && strstr(dllpath, ".dll") == 0) {
                return 0;
@@ -189,11 +353,6 @@ vstfx_infofile_stat (char *dllpath, struct stat* statbuf, int personal)
 
        if (Glib::file_test (path, Glib::FileTest (Glib::FILE_TEST_EXISTS | Glib::FILE_TEST_IS_REGULAR))) {
 
-               /* info file exists in same location as the shared object, so
-                  check if its current and up to date
-               */
-
-
                struct stat dllstat;
 
                if (stat (dllpath, &dllstat) == 0) {
@@ -211,7 +370,7 @@ vstfx_infofile_stat (char *dllpath, struct stat* statbuf, int personal)
 
 
 static FILE *
-vstfx_infofile_for_read (char* dllpath)
+vstfx_infofile_for_read (const char* dllpath)
 {
        struct stat own_statbuf;
        struct stat sys_statbuf;
@@ -239,7 +398,7 @@ vstfx_infofile_for_read (char* dllpath)
 }
 
 static FILE *
-vstfx_infofile_create (char* dllpath, int personal)
+vstfx_infofile_create (const char* dllpath, int personal)
 {
        if (strstr (dllpath, ".so" ) == 0 && strstr(dllpath, ".dll") == 0) {
                return 0;
@@ -250,7 +409,7 @@ vstfx_infofile_create (char* dllpath, int personal)
 }
 
 static FILE *
-vstfx_infofile_for_write (char* dllpath)
+vstfx_infofile_for_write (const char* dllpath)
 {
        FILE* f;
 
@@ -279,8 +438,8 @@ int vstfx_can_midi (VSTState* vstfx)
        return false;
 }
 
-static VSTInfo *
-vstfx_info_from_plugin (VSTState* vstfx)
+static VSTInfo*
+vstfx_parse_vst_state (VSTState* vstfx)
 {
        assert (vstfx);
 
@@ -313,9 +472,25 @@ vstfx_info_from_plugin (VSTState* vstfx)
                info->creator = strdup (creator);
        }
 
+
+       switch (plugin->dispatcher (plugin, effGetPlugCategory, 0, 0, 0, 0))
+       {
+               case kPlugCategEffect:         info->Category = strdup ("Effect"); break;
+               case kPlugCategSynth:          info->Category = strdup ("Synth"); break;
+               case kPlugCategAnalysis:       info->Category = strdup ("Anaylsis"); break;
+               case kPlugCategMastering:      info->Category = strdup ("Mastering"); break;
+               case kPlugCategSpacializer:    info->Category = strdup ("Spacializer"); break;
+               case kPlugCategRoomFx:         info->Category = strdup ("RoomFx"); break;
+               case kPlugSurroundFx:          info->Category = strdup ("SurroundFx"); break;
+               case kPlugCategRestoration:    info->Category = strdup ("Restoration"); break;
+               case kPlugCategOfflineProcess: info->Category = strdup ("Offline"); break;
+               case kPlugCategShell:          info->Category = strdup ("Shell"); break;
+               case kPlugCategGenerator:      info->Category = strdup ("Generator"); break;
+               default:                       info->Category = strdup ("Unknown"); break;
+       }
+
        info->UniqueID = plugin->uniqueID;
 
-       info->Category = strdup("None"); /* XXX */
        info->numInputs = plugin->numInputs;
        info->numOutputs = plugin->numOutputs;
        info->numParams = plugin->numParams;
@@ -344,149 +519,279 @@ vstfx_info_from_plugin (VSTState* vstfx)
        return info;
 }
 
+static void
+vstfx_info_from_plugin (const char *dllpath, VSTState* vstfx, vector<VSTInfo *> *infos, int type)
+{
+       assert(vstfx);
+       VSTInfo *info;
+
+       if ((info = vstfx_parse_vst_state(vstfx))) {
+               infos->push_back(info);
+#if 1
+               /* If this plugin is a Shell and we are not already inside a shell plugin
+                * read the info for all of the plugins contained in this shell.
+                */
+               if (!strncmp (info->Category, "Shell", 5)
+                   && vstfx->handle->plugincnt == 1) {
+                       int id;
+                       vector< pair<int, string> > ids;
+                       AEffect *plugin = vstfx->plugin;
+                       string path = vstfx->handle->path;
+
+                       do {
+                               char name[65] = "Unknown\0";
+                               id = plugin->dispatcher (plugin, effShellGetNextPlugin, 0, 0, name, 0);
+                               ids.push_back(std::make_pair(id, name));
+                       } while ( id != 0 );
+
+                       switch(type) {
+#ifdef WINDOWS_VST_SUPPORT
+                               case 1: fst_close(vstfx); break;
+#endif
+#ifdef LXVST_SUPPORT
+                               case 2: vstfx_close (vstfx); break;
+#endif
+                               default: assert(0); break;
+                       }
+
+                       for (vector< pair<int, string> >::iterator x = ids.begin(); x != ids.end(); ++x) {
+                               id = (*x).first;
+                               if (id == 0) continue;
+                               /* recurse vstfx_get_info() */
+
+                               bool ok;
+                               switch (type) { // TODO use lib ardour's type
+#ifdef WINDOWS_VST_SUPPORT
+                                       case 1:  ok = vstfx_instantiate_and_get_info_fst(dllpath, infos, id); break;
+#endif
+#ifdef LXVST_SUPPORT
+                                       case 2:  ok = vstfx_instantiate_and_get_info_lx(dllpath, infos, id); break;
+#endif
+                                       default: ok = false;
+                               }
+                               if (ok) {
+                                       // One shell (some?, all?) does not report the actual plugin name
+                                       // even after the shelled plugin has been instantiated.
+                                       // Replace the name of the shell with the real name.
+                                       info = infos->back();
+                                       free (info->name);
+
+                                       if ((*x).second.length() == 0) {
+                                               info->name = strdup("Unknown");
+                                       }
+                                       else {
+                                               info->name = strdup ((*x).second.c_str());
+                                       }
+                               }
+                       }
+               }
+#endif
+       }
+}
+
 /* A simple 'dummy' audiomaster callback which should be ok,
    we will only be instantiating the plugin in order to get its info
 */
 
 static intptr_t
-simple_master_callback (AEffect *, int32_t opcode, int32_t, intptr_t, void *, float)
+simple_master_callback (AEffect *, int32_t opcode, int32_t, intptr_t, void *ptr, float)
 {
+       const char* vstfx_can_do_strings[] = {
+               "supportShell",
+               "shellCategory"
+       };
+       const int vstfx_can_do_string_count = 2;
+
        if (opcode == audioMasterVersion) {
-               return 2;
-       } else {
+               return 2400;
+       }
+       else if (opcode == audioMasterCanDo) {
+               for (int i = 0; i < vstfx_can_do_string_count; i++) {
+                       if (! strcmp(vstfx_can_do_strings[i], (const char*)ptr)) {
+                               return 1;
+                       }
+               }
+               return 0;
+       }
+       else if (opcode == audioMasterCurrentId) {
+               return vstfx_current_loading_id;
+       }
+       else {
                return 0;
        }
 }
 
-static VSTInfo *
-vstfx_get_info_from_file(char* dllpath, bool &found)
+static bool
+vstfx_get_info_from_file(const char* dllpath, vector<VSTInfo*> *infos)
 {
        FILE* infofile;
-       VSTInfo *info = 0;
-       found = false;
+       bool rv = false;
        if ((infofile = vstfx_infofile_for_read (dllpath)) != 0) {
-               found = true;
-               info = load_vstfx_info_file (infofile);
+               rv = vstfx_load_info_file(infofile, infos);
                fclose (infofile);
-               if (info == 0) {
+               if (!rv) {
                        PBD::warning << "Cannot get LinuxVST information form " << dllpath << ": info file load failed." << endmsg;
                }
        }
-       return info;
-}
-
-void
-vstfx_free_info (VSTInfo *info)
-{
-       for (int i = 0; i < info->numParams; i++) {
-               free (info->ParamNames[i]);
-               free (info->ParamLabels[i]);
-       }
-
-       free (info->name);
-       free (info->creator);
-       free (info->Category);
-       free (info->ParamNames);
-       free (info->ParamLabels);
-       free (info);
+       return rv;
 }
 
 #ifdef LXVST_SUPPORT
-/** Try to get plugin info - first by looking for a .fsi cache of the
-    data, and if that doesn't exist, load the plugin, get its data and
-    then cache it for future ref
-*/
-
-VSTInfo *
-vstfx_get_info_lx (char* dllpath)
+static bool
+vstfx_instantiate_and_get_info_lx (
+               const char* dllpath, vector<VSTInfo*> *infos, int uniqueID)
 {
-       FILE* infofile;
        VSTHandle* h;
        VSTState* vstfx;
-
-       bool used_cache;
-       VSTInfo* info = vstfx_get_info_from_file(dllpath, used_cache);
-       if (used_cache) {
-               PBD::info << "using cache for LinuxVST plugin '" << dllpath << "'" << endmsg;
-               return info;
-       }
-
        if (!(h = vstfx_load(dllpath))) {
                PBD::warning << "Cannot get LinuxVST information from " << dllpath << ": load failed." << endmsg;
-               return 0;
+               return false;
        }
 
+       vstfx_current_loading_id = uniqueID;
+
        if (!(vstfx = vstfx_instantiate(h, simple_master_callback, 0))) {
                vstfx_unload(h);
                PBD::warning << "Cannot get LinuxVST information from " << dllpath << ": instantiation failed." << endmsg;
-               return 0;
+               return false;
        }
 
-       infofile = vstfx_infofile_for_write (dllpath);
-
-       if (!infofile) {
-               vstfx_close(vstfx);
-               vstfx_unload(h);
-               PBD::warning << "Cannot get LinuxVST information from " << dllpath << ": cannot create new FST info file." << endmsg;
-               return 0;
-       }
-
-       info = vstfx_info_from_plugin (vstfx);
+       vstfx_current_loading_id = 0;
 
-       save_vstfx_info_file (info, infofile);
-       fclose (infofile);
+       vstfx_info_from_plugin(dllpath, vstfx, infos, 2);
 
        vstfx_close (vstfx);
        vstfx_unload (h);
-
-       return info;
+       return true;
 }
 #endif
 
 #ifdef WINDOWS_VST_SUPPORT
-#include <fst.h>
-
-VSTInfo *
-vstfx_get_info_fst (char* dllpath)
+static bool
+vstfx_instantiate_and_get_info_fst (
+               const char* dllpath, vector<VSTInfo*> *infos, int uniqueID)
 {
-       FILE* infofile;
        VSTHandle* h;
        VSTState* vstfx;
-
-       bool used_cache;
-       VSTInfo* info = vstfx_get_info_from_file(dllpath, used_cache);
-       if (used_cache) {
-               PBD::info << "using cache for VST plugin '" << dllpath << "'" << endmsg;
-               return info;
-       }
-
        if(!(h = fst_load(dllpath))) {
-               PBD::warning << "Cannot get VST information from " << dllpath << ": load failed." << endmsg;
-               return 0;
+               PBD::warning << "Cannot get Windows VST information from " << dllpath << ": load failed." << endmsg;
+               return false;
        }
 
+       vstfx_current_loading_id = uniqueID;
+
        if(!(vstfx = fst_instantiate(h, simple_master_callback, 0))) {
                fst_unload(&h);
-               PBD::warning << "Cannot get VST information from " << dllpath << ": instantiation failed." << endmsg;
-               return 0;
+               vstfx_current_loading_id = 0;
+               PBD::warning << "Cannot get Windows VST information from " << dllpath << ": instantiation failed." << endmsg;
+               return false;
        }
+       vstfx_current_loading_id = 0;
 
-       infofile = vstfx_infofile_for_write (dllpath);
+       vstfx_info_from_plugin(dllpath, vstfx, infos, 1);
+
+       fst_close(vstfx);
+       //fst_unload(&h); // XXX -> fst_close()
+       return true;
+}
+#endif
+
+static vector<VSTInfo *> *
+vstfx_get_info (const char* dllpath, int type)
+{
+       FILE* infofile;
+       vector<VSTInfo*> *infos = new vector<VSTInfo*>;
+
+       if (vstfx_check_blacklist(dllpath)) {
+               return infos;
+       }
+
+       if (vstfx_get_info_from_file(dllpath, infos)) {
+               return infos;
+       }
+
+       bool ok;
+       /* blacklist in case instantiation fails */
+       vstfx_blacklist_file(dllpath);
+
+       switch (type) { // TODO use lib ardour's type
+#ifdef WINDOWS_VST_SUPPORT
+               case 1:  ok = vstfx_instantiate_and_get_info_fst(dllpath, infos, 0); break;
+#endif
+#ifdef LXVST_SUPPORT
+               case 2:  ok = vstfx_instantiate_and_get_info_lx(dllpath, infos, 0); break;
+#endif
+               default: ok = false;
+       }
+
+       if (!ok) {
+               return infos;
+       }
+
+       /* remove from blacklist */
+       vstfx_un_blacklist(dllpath);
 
+       /* crate cache/whitelist */
+       infofile = vstfx_infofile_for_write (dllpath);
        if (!infofile) {
-               fst_close(vstfx);
-               //fst_unload(&h); // XXX -> fst_close()
-               PBD::warning << "Cannot get VST information from " << dllpath << ": cannot create new FST info file." << endmsg;
-               return 0;
+               PBD::warning << "Cannot cache VST information for " << dllpath << ": cannot create new FST info file." << endmsg;
+               return infos;
+       } else {
+               vstfx_write_info_file (infofile, infos);
+               fclose (infofile);
        }
+       return infos;
+}
 
-       info = vstfx_info_from_plugin(vstfx);
-       save_vstfx_info_file (info, infofile);
-       fclose (infofile);
+/* *** public API *** */
 
-       fst_close(vstfx);
-       //fst_unload(&h); // XXX -> fst_close()
+void
+vstfx_free_info_list (vector<VSTInfo *> *infos)
+{
+       for (vector<VSTInfo *>::iterator i = infos->begin(); i != infos->end(); ++i) {
+               vstfx_free_info(*i);
+       }
+       delete infos;
+}
 
-       return info;
+string
+get_personal_vst_blacklist_dir() {
+       string dir = Glib::build_filename (ARDOUR::user_cache_directory(), "fst_blacklist");
+       /* if the directory doesn't exist, try to create it */
+       if (!Glib::file_test (dir, Glib::FILE_TEST_IS_DIR)) {
+               if (g_mkdir (dir.c_str (), 0700)) {
+                       PBD::error << "Cannt create VST cache folder '" << dir << "'" << endmsg;
+                       //exit(1);
+               }
+       }
+       return dir;
+}
+
+string
+get_personal_vst_info_cache_dir() {
+       string dir = Glib::build_filename (ARDOUR::user_cache_directory(), "fst_info");
+       /* if the directory doesn't exist, try to create it */
+       if (!Glib::file_test (dir, Glib::FILE_TEST_IS_DIR)) {
+               if (g_mkdir (dir.c_str (), 0700)) {
+                       PBD::error << "Cannt create VST info folder '" << dir << "'" << endmsg;
+                       //exit(1);
+               }
+       }
+       return dir;
+}
+
+#ifdef LXVST_SUPPORT
+vector<VSTInfo *> *
+vstfx_get_info_lx (char* dllpath)
+{
+       return vstfx_get_info(dllpath, 2);
+}
+#endif
+
+#ifdef WINDOWS_VST_SUPPORT
+vector<VSTInfo *> *
+vstfx_get_info_fst (char* dllpath)
+{
+       return vstfx_get_info(dllpath, 1);
 }
 #endif