]> granicus.if.org Git - graphviz/commitdiff
keep multiple configs for users with NFS mounted home directories
authorellson <devnull@localhost>
Fri, 15 Apr 2005 19:08:15 +0000 (19:08 +0000)
committerellson <devnull@localhost>
Fri, 15 Apr 2005 19:08:15 +0000 (19:08 +0000)
so that it can distinguish between multiple hosts.

FIXME need to use hostname qualification rather than library pathname since
multiple architectures could use same library path

lib/gvc/gvconfig.c

index f8e429d5340b0c66409c08e8c392c1c356dd64c6..69cf58c85f3a326d3b74c00ef1dce524d6cfc219 100644 (file)
@@ -217,9 +217,10 @@ void gvconfig(GVC_t * gvc)
     char *config_glob, *home;
     glob_t globbuf;
 
-    char *dot_graphviz = "/.graphviz";
+    char *config_dir_name = ".graphviz";
     char *libdir = GVLIBDIR;
-    char *plugin_glob = "/libgvplugin*.so.?";
+    char *plugin_glob = "libgvplugin*.so.?";
+    char *s, *config_file_name;
 
 #define MAX_SZ_CONFIG 100000
 #endif
@@ -246,9 +247,25 @@ void gvconfig(GVC_t * gvc)
        rc = -1;
     }
     else {
-        config_path = malloc(strlen(home) + strlen(dot_graphviz) + 1);
+        config_file_name = s = strdup(libdir);
+        while ((s = strchr(s,'/')))
+           *s = '+';
+    
+        config_path = malloc(strlen(home) 
+                               + 1
+                               + strlen(config_dir_name)
+                               + 1
+                               + strlen(config_file_name)
+                               + 1);
         strcpy(config_path, home);
-        strcat(config_path, dot_graphviz);
+        strcat(config_path, "/");
+        strcat(config_path, config_dir_name);
+        rc = mkdir(config_path, 0700);
+
+        strcat(config_path, "/");
+        strcat(config_path, config_file_name);
+
+       free(config_file_name);
 
         rc = stat(config_path, &config_st);
     }
@@ -262,8 +279,12 @@ void gvconfig(GVC_t * gvc)
        }
        /* load all libraries even if can't save config */
 
-       config_glob = malloc(strlen(libdir) + strlen(plugin_glob) + 1);
+       config_glob = malloc(strlen(libdir)
+                               + 1
+                               + strlen(plugin_glob)
+                               + 1);
        strcpy(config_glob, libdir);
+        strcat(config_glob, "/");
        strcat(config_glob, plugin_glob);
 
        rc = glob(config_glob, GLOB_NOSORT, NULL, &globbuf);