From e0fe7b1a473dd862e41a662d4bb9edab381370cf Mon Sep 17 00:00:00 2001 From: lloyd Date: Sat, 13 Oct 2007 20:11:51 +0000 Subject: Move most of the initializer code directly into the Library_State constructor --- src/init_def.cpp | 71 ++++++++++++++++++-------------------------------------- 1 file changed, 22 insertions(+), 49 deletions(-) (limited to 'src/init_def.cpp') diff --git a/src/init_def.cpp b/src/init_def.cpp index 7f465d3eb..50365b3d6 100644 --- a/src/init_def.cpp +++ b/src/init_def.cpp @@ -6,32 +6,10 @@ #include #include #include -#include -#include #include -#include -#include namespace Botan { -/************************************************* -* Library Initialization * -*************************************************/ -void LibraryInitializer::initialize(const std::string& arg_string) - { - InitializerOptions args(arg_string); - initialize(args); - } - -/************************************************* -* Library Initialization * -*************************************************/ -void LibraryInitializer::initialize(const InitializerOptions& args) - { - Builtin_Modules modules(args); - initialize(args, modules); - } - /************************************************* * Library Initialization * *************************************************/ @@ -40,33 +18,7 @@ void LibraryInitializer::initialize(const InitializerOptions& args, { try { - set_global_state( - new Library_State( - args.thread_safe() ? - modules.mutex_factory() : - new Default_Mutex_Factory - ) - ); - - global_state().config().load_defaults(); - if(args.config_file() != "") - global_config().load_inifile(args.config_file()); - - global_state().load(modules); - global_state().set_prng(new ANSI_X931_RNG); - - if(args.seed_rng()) - { - for(u32bit j = 0; j != 4; ++j) - { - global_state().seed_prng(true, 384); - if(global_state().rng_is_seeded()) - break; - } - - if(!global_state().rng_is_seeded()) - throw PRNG_Unseeded("Unable to collect sufficient entropy"); - } + set_global_state(new Library_State(args, modules)); if(args.fips_mode() || args.self_test()) { @@ -89,4 +41,25 @@ void LibraryInitializer::deinitialize() set_global_state(0); } +/************************************************* +* Library Initialization * +*************************************************/ +void LibraryInitializer::initialize(const std::string& arg_string) + { + InitializerOptions args(arg_string); + Builtin_Modules modules(args); + + initialize(args, modules); + } + +/************************************************* +* Library Initialization * +*************************************************/ +void LibraryInitializer::initialize(const InitializerOptions& args) + { + Builtin_Modules modules(args); + + initialize(args, modules); + } + } -- cgit v1.2.3