Mercurial > trustbridge
changeset 198:56ae02b4a0fc
Merged
author | Sascha Wilde <wilde@intevation.de> |
---|---|
date | Wed, 26 Mar 2014 12:38:10 +0100 |
parents | 5d380b662198 (diff) 17eb8ad43984 (current diff) |
children | 45f6b62f91e7 |
files | |
diffstat | 2 files changed, 50 insertions(+), 60 deletions(-) [+] |
line wrap: on
line diff
--- a/cinst/CMakeLists.txt Wed Mar 26 12:22:24 2014 +0100 +++ b/cinst/CMakeLists.txt Wed Mar 26 12:38:10 2014 +0100 @@ -32,4 +32,6 @@ ${POLARSSL_LIBRARIES} ${PROFILING_LIBS}) +set_target_properties(mozilla PROPERTIES COMPILE_FLAGS "-std=c99") + install(TARGETS mozilla DESTINATION bin)
--- a/cinst/mozilla.c Wed Mar 26 12:22:24 2014 +0100 +++ b/cinst/mozilla.c Wed Mar 26 12:38:10 2014 +0100 @@ -61,8 +61,10 @@ #include <strhelp.h> #ifndef _WIN32 +#define CONFDIRS ".mozilla", ".thunderbird" #define LINUX 1 #else +#define CONFDIRS "Mozilla", "Thunderbird" #define LINUX 0 #endif @@ -79,44 +81,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; } /** @@ -214,50 +200,51 @@ char **inis = NULL; char path[LINEBUFLEN]; char *fqpath; - char *mozdirname; DIR *mozdir; struct dirent *mozdirent; - char *home = get_home(); + char *confbase = get_conf_basedir(); + const char *confdirs[] = { CONFDIRS, NULL }; - if (LINUX) + for (int i=0; confdirs[i] != NULL; i++) { - mozdirname = ".mozilla"; - } - else - { - mozdirname = "AppData/Roaming/Mozilla"; - } - - snprintf(path, LINEBUFLEN, "%s/%s", home, 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", - home, - mozdirname, - mozdirent->d_name); - if (port_isdir(path)) + while ((mozdirent = readdir(mozdir)) != NULL) { - snprintf(path, LINEBUFLEN, "%s/%s/%s/%s", - home, - mozdirname, - mozdirent->d_name, - "profiles.ini"); - DEBUGFPRINT("DEBUG: checking for %s...\n", path); - if ((fqpath = port_realpath(path)) != NULL) + snprintf(path, LINEBUFLEN, "%s/%s/%s", + confbase, + 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", home, mozdirname); + DEBUGFPRINT("DEBUG: No ini files found - will do nothing!\n"); exit(WARN_MOZ_NO_PROFILES); } return inis; @@ -277,6 +264,7 @@ get_profile_dirs(mozinis[y++]); if (pdirs != NULL) { + x = 0; while (pdirs[x] != NULL) puts(pdirs[x++]); strv_free(pdirs);