diff options
author | lloyd <[email protected]> | 2008-11-11 01:01:38 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-11-11 01:01:38 +0000 |
commit | 88f4327ef993dfc15f1483e14df042a83bb459b7 (patch) | |
tree | 98782cb2f6af3a7fb7c864552c93ecae16ddcaf1 /src/libstate | |
parent | 5e340b886319bb21f269520af2d62789df3467d4 (diff) |
Change LibraryInitializer back to accepting a std::string for backwards
compatability.
Diffstat (limited to 'src/libstate')
-rw-r--r-- | src/libstate/init.cpp | 32 | ||||
-rw-r--r-- | src/libstate/init.h | 6 | ||||
-rw-r--r-- | src/libstate/libstate.cpp | 2 |
3 files changed, 35 insertions, 5 deletions
diff --git a/src/libstate/init.cpp b/src/libstate/init.cpp index 0256d70dc..890871411 100644 --- a/src/libstate/init.cpp +++ b/src/libstate/init.cpp @@ -4,6 +4,7 @@ */ #include <botan/init.h> +#include <botan/parsing.h> #include <botan/libstate.h> namespace Botan { @@ -11,8 +12,37 @@ namespace Botan { /************************************************* * Library Initialization * *************************************************/ -void LibraryInitializer::initialize(bool thread_safe) +void LibraryInitializer::initialize(const std::string& arg_string) { + bool thread_safe = true; + + const std::vector<std::string> arg_list = split_on(arg_string, ' '); + for(u32bit j = 0; j != arg_list.size(); ++j) + { + if(arg_list[j].size() == 0) + continue; + + std::string name, value; + + if(arg_list[j].find('=') == std::string::npos) + { + name = arg_list[j]; + value = "true"; + } + else + { + std::vector<std::string> name_and_value = split_on(arg_list[j], '='); + name = name_and_value[0]; + value = name_and_value[1]; + } + + bool is_on = + (value == "1" || value == "true" || value == "yes" || value == "on"); + + if(name == "thread_safe") + thread_safe = is_on; + } + try { /* diff --git a/src/libstate/init.h b/src/libstate/init.h index 794fbd39e..affceb332 100644 --- a/src/libstate/init.h +++ b/src/libstate/init.h @@ -19,7 +19,7 @@ namespace Botan { class BOTAN_DLL LibraryInitializer { public: - static void initialize(bool thread_safe); + static void initialize(const std::string& options); static void deinitialize(); @@ -27,8 +27,8 @@ class BOTAN_DLL LibraryInitializer * Initialize the library * @param thread_safe if the library should use a thread-safe mutex */ - LibraryInitializer(bool thread_safe = false) - { LibraryInitializer::initialize(thread_safe); } + LibraryInitializer(const std::string& options) + { LibraryInitializer::initialize(options); } ~LibraryInitializer() { LibraryInitializer::deinitialize(); } }; diff --git a/src/libstate/libstate.cpp b/src/libstate/libstate.cpp index 7c3105752..14b63293c 100644 --- a/src/libstate/libstate.cpp +++ b/src/libstate/libstate.cpp @@ -58,7 +58,7 @@ Library_State& global_state() on or memory might leak. */ if(!global_lib_state) - LibraryInitializer::initialize(true); + LibraryInitializer::initialize("thread_safe=true"); return (*global_lib_state); } |