aboutsummaryrefslogtreecommitdiffstats
path: root/src/init_def.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2006-09-20 08:20:31 +0000
committerlloyd <[email protected]>2006-09-20 08:20:31 +0000
commit869fa8a3fa7dfedc55ec4c9ece7be00d1118c309 (patch)
tree6b83f57dd0f6b8dc3a5998a1621d958d098aff82 /src/init_def.cpp
parentde37a33633c96366216644a898b8c23fcd0f29a4 (diff)
Make the initialization/deinitialization functions static members of
the LibraryInitializer class, rather than global functions floating around inside the Init namespace. Allow callers to provide an alternative Modules object.
Diffstat (limited to 'src/init_def.cpp')
-rw-r--r--src/init_def.cpp38
1 files changed, 17 insertions, 21 deletions
diff --git a/src/init_def.cpp b/src/init_def.cpp
index 1388445f5..6faa5d86f 100644
--- a/src/init_def.cpp
+++ b/src/init_def.cpp
@@ -17,39 +17,37 @@ namespace Botan {
/*************************************************
* Library Initialization *
*************************************************/
-LibraryInitializer::LibraryInitializer(const std::string& arg_string)
+void LibraryInitializer::initialize(const std::string& arg_string)
{
InitializerOptions args(arg_string);
- Init::initialize(args);
+ initialize(args);
}
/*************************************************
* Library Initialization *
*************************************************/
-LibraryInitializer::LibraryInitializer(const InitializerOptions& args)
+void LibraryInitializer::initialize(const InitializerOptions& args)
{
- Init::initialize(args);
- }
-
-/*************************************************
-* Library Shutdown *
-*************************************************/
-LibraryInitializer::~LibraryInitializer()
- {
- Init::deinitialize();
+ try
+ {
+ Builtin_Modules modules(args);
+ initialize(args, modules);
+ }
+ catch(...)
+ {
+ deinitialize();
+ throw;
+ }
}
-namespace Init {
-
/*************************************************
* Library Initialization *
*************************************************/
-void initialize(const InitializerOptions& args)
+void LibraryInitializer::initialize(const InitializerOptions& args,
+ Modules& modules)
{
try
{
- Builtin_Modules modules(args);
-
set_global_state(
new Library_State(
args.thread_safe() ?
@@ -95,7 +93,7 @@ void initialize(const InitializerOptions& args)
throw Self_Test_Failure("FIPS-140 startup tests");
}
}
- catch(std::exception)
+ catch(...)
{
deinitialize();
throw;
@@ -105,11 +103,9 @@ void initialize(const InitializerOptions& args)
/*************************************************
* Library Shutdown *
*************************************************/
-void deinitialize()
+void LibraryInitializer::deinitialize()
{
set_global_state(0);
}
}
-
-}