VTX_CodeGen, GD_CodeGen, memGD_CodeGen;
#endif
-#ifndef DISABLE_LTDL
-static char *libdir = GVLIBDIR;
-#endif
-
/*
A config for gvrender is a text file containing a
list of plugin librariess and their capabilities using a tcl-like
fputs ("}\n", f);
}
+char * gvconfig_libdir(void)
+{
+ static char line[1024];
+ static char *libdir;
+ char *path, *tmp;
+ FILE *f;
+
+ if (!libdir) {
+
+ /* this only works on linux, other systems will get GVLIBDIR only */
+ libdir = GVLIBDIR;
+ f = fopen ("/proc/self/maps", "r");
+ if (f) {
+ while (!feof (f)) {
+ if (!fgets (line, sizeof (line), f))
+ continue;
+ if (!strstr (line, " r-xp "))
+ continue;
+ path = strchr (line, '/');
+ if (!path)
+ continue;
+ tmp = strstr (path, "/libgvc.");
+ if (tmp) {
+ *tmp = 0;
+ libdir = path;
+ break;
+ }
+ }
+ fclose (f);
+ }
+ }
+ return libdir;
+}
+
#ifdef DISABLE_LTDL
extern gvplugin_library_t *builtins[];
#endif
{
FILE *f = NULL;
glob_t globbuf;
- char *config_glob, *path;
+ char *config_glob, *path, *libdir;
int i, rc;
gvplugin_library_t *library;
char *plugin_glob = "libgvplugin*.so.?";
}
}
+ libdir = gvconfig_libdir();
+
/* load all libraries even if can't save config */
config_glob = malloc(strlen(libdir)
+ 1
struct stat config_st, libdir_st;
FILE *f = NULL;
char *config_path = NULL, *config_text = NULL;
-
+ char *libdir;
char *config_file_name = "config";
#define MAX_SZ_CONFIG 100000
}
#else
/* see if there are any new plugins */
-
+ libdir = gvconfig_libdir();
rc = stat(libdir, &libdir_st);
if (rc == -1) { /* if we fail to stat it then it probably doesn't exist
so just fail silently */
return;
}
- config_path = malloc(strlen(GVLIBDIR) + 1 + strlen(config_file_name) + 1);
- strcpy(config_path, GVLIBDIR);
+ config_path = malloc(strlen(libdir) + 1 + strlen(config_file_name) + 1);
+ strcpy(config_path, libdir);
strcat(config_path, "/");
strcat(config_path, config_file_name);