diff cinst/mozilla.c @ 194:d4e97c9b199f

Use %APPDATA% as config bse dir on windows. Much simpler.
author Sascha Wilde <wilde@intevation.de>
date Wed, 26 Mar 2014 11:25:03 +0100
parents bea93c8651b7
children 90cf655a4112
line wrap: on
line diff
--- a/cinst/mozilla.c	Tue Mar 25 17:56:56 2014 +0100
+++ b/cinst/mozilla.c	Wed Mar 26 11:25:03 2014 +0100
@@ -79,44 +79,28 @@
 int return_code = 0;
 
 /**
- * @brief Return users home path, on windows including drive letter
- * @returns a pointer to a string containing the home path, it should
- * be freed by the caller.
+ * @brief Return configuration base directory.
+ * @returns A pointer to a string containing the path to the base
+ * directory holding the configuration directories for e.g. mozilla
+ * and thunderbird.
  */
 static char *
-get_home()
+get_conf_basedir()
 {
-  char *home, *homevar, *fqhome;
-  char *homedrive = NULL;
+  char *cdir, *envvar;
 
-  size_t len;
   if (LINUX)
-    homevar = "HOME";
+    envvar = "HOME" ;
   else
-    homevar = "HOMEPATH";
+    envvar = "APPDATA";
 
-  if ((home = getenv(homevar)) == NULL)
+  if ((cdir = getenv(envvar)) != NULL)
+    return cdir;
+  else
     {
-      DEBUGFPRINT("DEBUG: FATAL!  No HOME in environment.\n");
+      DEBUGFPRINT("DEBUG: FATAL!  No %s in environment.\n", envvar);
       exit(ERR_MOZ_HOMELESS);
     }
-
-  len = strlen(home);
-  if (!LINUX)
-    homedrive = getenv("HOMEDRIVE");
-
-  if (homedrive != NULL)
-    len += strlen(homedrive);
-
-  len++;                        /* Room for \0 */
-  fqhome = xmalloc(len);
-
-  if (homedrive == NULL)
-    snprintf(fqhome, len, "%s", home);
-  else
-    snprintf(fqhome, len, "%s%s", homedrive, home);
-
-  return fqhome;
 }
 
 /**
@@ -217,7 +201,7 @@
   char *mozdirname;
   DIR *mozdir;
   struct dirent *mozdirent;
-  char *home = get_home();
+  char *confbase = get_conf_basedir();
 
   if (LINUX)
     {
@@ -225,22 +209,24 @@
     }
   else
     {
-      mozdirname = "AppData/Roaming/Mozilla";
+      mozdirname = "Mozilla";
     }
 
-  snprintf(path, LINEBUFLEN, "%s/%s", home, mozdirname);
+  snprintf(path, LINEBUFLEN, "%s/%s",
+           confbase,
+           mozdirname);
   if ((mozdir = opendir(path)) != NULL)
     {
       while ((mozdirent = readdir(mozdir)) != NULL)
         {
           snprintf(path, LINEBUFLEN, "%s/%s/%s",
-                   home,
+                   confbase,
                    mozdirname,
                    mozdirent->d_name);
           if (port_isdir(path))
             {
               snprintf(path, LINEBUFLEN, "%s/%s/%s/%s",
-                       home,
+                       confbase,
                        mozdirname,
                        mozdirent->d_name,
                        "profiles.ini");
@@ -257,7 +243,7 @@
     }
   else
     {
-      DEBUGFPRINT("DEBUG: Could not open %s/%s\n", home, mozdirname);
+      DEBUGFPRINT("DEBUG: Could not open %s/%s\n", confbase, mozdirname);
       exit(WARN_MOZ_NO_PROFILES);
     }
   return inis;

http://wald.intevation.org/projects/trustbridge/