diff options
author | lloyd <[email protected]> | 2014-01-10 03:41:59 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2014-01-10 03:41:59 +0000 |
commit | 6894dca64c04936d07048c0e8cbf7e25858548c3 (patch) | |
tree | 5d572bfde9fe667dab14e3f04b5285a85d8acd95 /src/lib/libstate/init.cpp | |
parent | 9efa3be92442afb3d0b69890a36c7f122df18eda (diff) |
Move lib into src
Diffstat (limited to 'src/lib/libstate/init.cpp')
-rw-r--r-- | src/lib/libstate/init.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/lib/libstate/init.cpp b/src/lib/libstate/init.cpp new file mode 100644 index 000000000..2d724f366 --- /dev/null +++ b/src/lib/libstate/init.cpp @@ -0,0 +1,47 @@ +/* +* Default Initialization Function +* (C) 1999-2009 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#include <botan/init.h> +#include <botan/libstate.h> +#include <botan/global_state.h> + +namespace Botan { + +/* +* Library Initialization +*/ +void LibraryInitializer::initialize(const std::string&) + { + + try + { + /* + This two stage initialization process is because Library_State's + constructor will implicitly refer to global state through the + allocators and so forth, so global_state() has to be a valid + reference before initialize() can be called. Yeah, gross. + */ + Global_State_Management::set_global_state(new Library_State); + + global_state().initialize(); + } + catch(...) + { + deinitialize(); + throw; + } + } + +/* +* Library Shutdown +*/ +void LibraryInitializer::deinitialize() + { + Global_State_Management::set_global_state(nullptr); + } + +} |