# HG changeset patch # User Sascha Wilde # Date 1395833839 -3600 # Node ID 5d380b6621983eee7df436d72d8523dff161d9af # Parent 642d81594665f0c495da64df04b94b8f2c8d9105 Search for thunderbird profiles, too. diff -r 642d81594665 -r 5d380b662198 cinst/mozilla.c --- a/cinst/mozilla.c Wed Mar 26 12:18:12 2014 +0100 +++ b/cinst/mozilla.c Wed Mar 26 12:37:19 2014 +0100 @@ -61,8 +61,10 @@ #include #ifndef _WIN32 +#define CONFDIRS ".mozilla", ".thunderbird" #define LINUX 1 #else +#define CONFDIRS "Mozilla", "Thunderbird" #define LINUX 0 #endif @@ -198,53 +200,51 @@ char **inis = NULL; char path[LINEBUFLEN]; char *fqpath; - char *mozdirname; DIR *mozdir; struct dirent *mozdirent; char *confbase = get_conf_basedir(); + const char *confdirs[] = { CONFDIRS, NULL }; - if (LINUX) - { - mozdirname = ".mozilla"; - } - else + for (int i=0; confdirs[i] != NULL; i++) { - mozdirname = "Mozilla"; - } - - snprintf(path, LINEBUFLEN, "%s/%s", - confbase, - mozdirname); - if ((mozdir = opendir(path)) != NULL) - { - while ((mozdirent = readdir(mozdir)) != NULL) + snprintf(path, LINEBUFLEN, "%s/%s", + confbase, + confdirs[i]); + if ((mozdir = opendir(path)) != NULL) { - snprintf(path, LINEBUFLEN, "%s/%s/%s", - confbase, - mozdirname, - mozdirent->d_name); - if (port_isdir(path) - && (strcmp(mozdirent->d_name, "..") != 0)) + while ((mozdirent = readdir(mozdir)) != NULL) { - snprintf(path, LINEBUFLEN, "%s/%s/%s/%s", + snprintf(path, LINEBUFLEN, "%s/%s/%s", confbase, - mozdirname, - mozdirent->d_name, - "profiles.ini"); - DEBUGFPRINT("DEBUG: checking for %s...\n", path); - if ((fqpath = port_realpath(path)) != NULL) + confdirs[i], + mozdirent->d_name); + if (port_isdir(path) + && (strcmp(mozdirent->d_name, "..") != 0)) { - strv_append(&inis, fqpath, strlen(fqpath)); - DEBUGFPRINT("DEBUG: Found mozilla ini file: '%s'\n", fqpath); - free(fqpath); + snprintf(path, LINEBUFLEN, "%s/%s/%s/%s", + confbase, + confdirs[i], + mozdirent->d_name, + "profiles.ini"); + DEBUGFPRINT("DEBUG: checking for %s...\n", path); + if ((fqpath = port_realpath(path)) != NULL) + { + strv_append(&inis, fqpath, strlen(fqpath)); + DEBUGFPRINT("DEBUG: Found mozilla ini file: '%s'\n", fqpath); + free(fqpath); + } } } + closedir(mozdir); } - closedir(mozdir); + else + { + DEBUGFPRINT("DEBUG: Could not open %s/%s\n", confbase, confdirs[i]); + } } - else + if (inis == NULL) { - DEBUGFPRINT("DEBUG: Could not open %s/%s\n", confbase, mozdirname); + DEBUGFPRINT("DEBUG: No ini files found - will do nothing!\n"); exit(WARN_MOZ_NO_PROFILES); } return inis; @@ -264,6 +264,7 @@ get_profile_dirs(mozinis[y++]); if (pdirs != NULL) { + x = 0; while (pdirs[x] != NULL) puts(pdirs[x++]); strv_free(pdirs);