Mercurial > trustbridge
comparison cinst/mozilla.c @ 197:5d380b662198
Search for thunderbird profiles, too.
author | Sascha Wilde <wilde@intevation.de> |
---|---|
date | Wed, 26 Mar 2014 12:37:19 +0100 |
parents | 90cf655a4112 |
children | d29997e09177 |
comparison
equal
deleted
inserted
replaced
196:642d81594665 | 197:5d380b662198 |
---|---|
59 #include <errorcodes.h> | 59 #include <errorcodes.h> |
60 #include <portpath.h> | 60 #include <portpath.h> |
61 #include <strhelp.h> | 61 #include <strhelp.h> |
62 | 62 |
63 #ifndef _WIN32 | 63 #ifndef _WIN32 |
64 #define CONFDIRS ".mozilla", ".thunderbird" | |
64 #define LINUX 1 | 65 #define LINUX 1 |
65 #else | 66 #else |
67 #define CONFDIRS "Mozilla", "Thunderbird" | |
66 #define LINUX 0 | 68 #define LINUX 0 |
67 #endif | 69 #endif |
68 | 70 |
69 #define LINEBUFLEN 1000 | 71 #define LINEBUFLEN 1000 |
70 | 72 |
196 get_profile_inis () | 198 get_profile_inis () |
197 { | 199 { |
198 char **inis = NULL; | 200 char **inis = NULL; |
199 char path[LINEBUFLEN]; | 201 char path[LINEBUFLEN]; |
200 char *fqpath; | 202 char *fqpath; |
201 char *mozdirname; | |
202 DIR *mozdir; | 203 DIR *mozdir; |
203 struct dirent *mozdirent; | 204 struct dirent *mozdirent; |
204 char *confbase = get_conf_basedir(); | 205 char *confbase = get_conf_basedir(); |
205 | 206 const char *confdirs[] = { CONFDIRS, NULL }; |
206 if (LINUX) | 207 |
207 { | 208 for (int i=0; confdirs[i] != NULL; i++) |
208 mozdirname = ".mozilla"; | 209 { |
209 } | 210 snprintf(path, LINEBUFLEN, "%s/%s", |
210 else | 211 confbase, |
211 { | 212 confdirs[i]); |
212 mozdirname = "Mozilla"; | 213 if ((mozdir = opendir(path)) != NULL) |
213 } | |
214 | |
215 snprintf(path, LINEBUFLEN, "%s/%s", | |
216 confbase, | |
217 mozdirname); | |
218 if ((mozdir = opendir(path)) != NULL) | |
219 { | |
220 while ((mozdirent = readdir(mozdir)) != NULL) | |
221 { | 214 { |
222 snprintf(path, LINEBUFLEN, "%s/%s/%s", | 215 while ((mozdirent = readdir(mozdir)) != NULL) |
223 confbase, | |
224 mozdirname, | |
225 mozdirent->d_name); | |
226 if (port_isdir(path) | |
227 && (strcmp(mozdirent->d_name, "..") != 0)) | |
228 { | 216 { |
229 snprintf(path, LINEBUFLEN, "%s/%s/%s/%s", | 217 snprintf(path, LINEBUFLEN, "%s/%s/%s", |
230 confbase, | 218 confbase, |
231 mozdirname, | 219 confdirs[i], |
232 mozdirent->d_name, | 220 mozdirent->d_name); |
233 "profiles.ini"); | 221 if (port_isdir(path) |
234 DEBUGFPRINT("DEBUG: checking for %s...\n", path); | 222 && (strcmp(mozdirent->d_name, "..") != 0)) |
235 if ((fqpath = port_realpath(path)) != NULL) | |
236 { | 223 { |
237 strv_append(&inis, fqpath, strlen(fqpath)); | 224 snprintf(path, LINEBUFLEN, "%s/%s/%s/%s", |
238 DEBUGFPRINT("DEBUG: Found mozilla ini file: '%s'\n", fqpath); | 225 confbase, |
239 free(fqpath); | 226 confdirs[i], |
227 mozdirent->d_name, | |
228 "profiles.ini"); | |
229 DEBUGFPRINT("DEBUG: checking for %s...\n", path); | |
230 if ((fqpath = port_realpath(path)) != NULL) | |
231 { | |
232 strv_append(&inis, fqpath, strlen(fqpath)); | |
233 DEBUGFPRINT("DEBUG: Found mozilla ini file: '%s'\n", fqpath); | |
234 free(fqpath); | |
235 } | |
240 } | 236 } |
241 } | 237 } |
238 closedir(mozdir); | |
242 } | 239 } |
243 closedir(mozdir); | 240 else |
244 } | 241 { |
245 else | 242 DEBUGFPRINT("DEBUG: Could not open %s/%s\n", confbase, confdirs[i]); |
246 { | 243 } |
247 DEBUGFPRINT("DEBUG: Could not open %s/%s\n", confbase, mozdirname); | 244 } |
245 if (inis == NULL) | |
246 { | |
247 DEBUGFPRINT("DEBUG: No ini files found - will do nothing!\n"); | |
248 exit(WARN_MOZ_NO_PROFILES); | 248 exit(WARN_MOZ_NO_PROFILES); |
249 } | 249 } |
250 return inis; | 250 return inis; |
251 } | 251 } |
252 | 252 |
262 { | 262 { |
263 pdirs = | 263 pdirs = |
264 get_profile_dirs(mozinis[y++]); | 264 get_profile_dirs(mozinis[y++]); |
265 if (pdirs != NULL) | 265 if (pdirs != NULL) |
266 { | 266 { |
267 x = 0; | |
267 while (pdirs[x] != NULL) | 268 while (pdirs[x] != NULL) |
268 puts(pdirs[x++]); | 269 puts(pdirs[x++]); |
269 strv_free(pdirs); | 270 strv_free(pdirs); |
270 } | 271 } |
271 } | 272 } |