Mercurial > trustbridge
comparison cinst/mozilla.c @ 231:c342b93c5bd1
Refactoring.
author | Sascha Wilde <wilde@intevation.de> |
---|---|
date | Fri, 28 Mar 2014 10:45:55 +0100 |
parents | 92b1e5ed2d5f |
children | 774e944c395b |
comparison
equal
deleted
inserted
replaced
230:92b1e5ed2d5f | 231:c342b93c5bd1 |
---|---|
263 } | 263 } |
264 return inis; | 264 return inis; |
265 } | 265 } |
266 | 266 |
267 /** | 267 /** |
268 * @brief Collect all mozilla profile directories of current user. | |
269 * @return NULL terminated array of strings containing the absolute | |
270 * path of the profile directories. The array needs to be freed by the | |
271 * caller. | |
272 */ | |
273 static char** | |
274 get_all_profile_dirs() | |
275 { | |
276 char **mozinis, **pdirs; | |
277 char **alldirs = NULL; | |
278 if ((mozinis = get_profile_inis()) != NULL) | |
279 { | |
280 for (int i=0; mozinis[i] != NULL; i++) | |
281 { | |
282 pdirs = | |
283 get_profile_dirs(mozinis[i]); | |
284 if (pdirs != NULL) | |
285 { | |
286 for (int i=0; pdirs[i] != NULL; i++) | |
287 { | |
288 strv_append(&alldirs, pdirs[i], strlen(pdirs[i])); | |
289 } | |
290 strv_free(pdirs); | |
291 } | |
292 } | |
293 strv_free(mozinis); | |
294 } | |
295 return alldirs; | |
296 } | |
297 | |
298 /** | |
268 * @brief list certificates from nss certificate store | 299 * @brief list certificates from nss certificate store |
269 * @param[in] confdir the directory with the certificate store | 300 * @param[in] confdir the directory with the certificate store |
270 */ | 301 */ |
271 static void | 302 static void |
272 nss_list_certs (char *confdir) | 303 nss_list_certs (char *confdir) |
294 | 325 |
295 | 326 |
296 int | 327 int |
297 main () | 328 main () |
298 { | 329 { |
299 int y = 0; | 330 char **pdirs; |
300 char **mozinis, **pdirs; | 331 pdirs = |
301 if ((mozinis = get_profile_inis()) != NULL) | 332 get_all_profile_dirs(); |
302 while (mozinis[y] != NULL) | 333 if (pdirs != NULL) |
303 { | 334 { |
304 pdirs = | 335 for (int i=0; pdirs[i] != NULL; i++) |
305 get_profile_dirs(mozinis[y++]); | 336 { |
306 if (pdirs != NULL) | 337 puts(pdirs[i]); |
307 { | 338 nss_list_certs(pdirs[i]); |
308 for (int x=0; pdirs[x] != NULL; x++) | 339 } |
309 { | 340 strv_free(pdirs); |
310 puts(pdirs[x]); | 341 } |
311 nss_list_certs(pdirs[x]); | |
312 } | |
313 strv_free(pdirs); | |
314 } | |
315 } | |
316 exit(return_code); | 342 exit(return_code); |
317 } | 343 } |