From 533abeb00f0777da365e3609d4335394680ffeaf Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Fri, 27 Apr 2001 00:16:41 +0000 Subject: Automagically call camel_shutdown() atexit() ;-) (camel_init): Also 2001-04-26 Jeffrey Stedfast * camel.c (camel_init): Automagically call camel_shutdown() atexit() ;-) (camel_init): Also initialize NSS databases as read/write for S/MIME and if NSS fails to init, try initializing with volatile databases. * camel-file-utils.h: #include for off_t. svn path=/trunk/; revision=9609 --- camel/ChangeLog | 6 ++++++ camel/camel.c | 33 +++++++++++++++++++-------------- camel/camel.h | 2 -- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/camel/ChangeLog b/camel/ChangeLog index 0d3f7288fe..e0e98844b8 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,5 +1,11 @@ 2001-04-26 Jeffrey Stedfast + * camel.c (camel_init): Automagically call camel_shutdown() + atexit() ;-) + (camel_init): Also initialize NSS databases as read/write for + S/MIME and if NSS fails to init, try initializing with volatile + databases. + * camel-file-utils.h: #include for off_t. 2001-04-26 Dan Winship diff --git a/camel/camel.c b/camel/camel.c index f2d8b8d369..6ae93081d6 100644 --- a/camel/camel.c +++ b/camel/camel.c @@ -38,8 +38,18 @@ gboolean camel_verbose_debug = FALSE; +static void +camel_shutdown (void) +{ +#ifdef HAVE_NSS + NSS_Shutdown (); + + PR_Cleanup (); +#endif /* HAVE_NSS */ +} + gint -camel_init (const char *certdb_dir, gboolean nss_init) +camel_init (const char *configdir, gboolean nss_init) { #ifdef ENABLE_THREADS #ifdef G_THREADS_ENABLED @@ -56,12 +66,17 @@ camel_init (const char *certdb_dir, gboolean nss_init) if (nss_init) { PR_Init (PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 10); - if (NSS_Init (certdb_dir) == SECFailure) { - g_warning ("Failed to initialize NSS"); - return -1; + if (NSS_InitReadWrite (configdir) == SECFailure) { + /* fall back on using volatile dbs? */ + if (NSS_NoDB_Init (configdir) == SECFailure) { + g_warning ("Failed to initialize NSS"); + return -1; + } } NSS_SetDomesticPolicy (); + + g_atexit (camel_shutdown); } SSL_OptionSetDefault (SSL_ENABLE_SSL2, PR_TRUE); @@ -72,13 +87,3 @@ camel_init (const char *certdb_dir, gboolean nss_init) return 0; } - -void -camel_shutdown (void) -{ -#ifdef HAVE_NSS - NSS_Shutdown (); - - PR_Cleanup (); -#endif /* HAVE_NSS */ -} diff --git a/camel/camel.h b/camel/camel.h index 34740e92ab..e775f67812 100644 --- a/camel/camel.h +++ b/camel/camel.h @@ -77,8 +77,6 @@ extern "C" { gint camel_init (const char *certdb_dir, gboolean nss_init); -void camel_shutdown (void); - #ifdef __cplusplus } #endif /* __cplusplus */ -- cgit v1.2.3