aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstate
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstate')
-rw-r--r--src/libstate/libstate.cpp34
-rw-r--r--src/libstate/libstate.h38
-rw-r--r--src/libstate/policy.cpp20
3 files changed, 25 insertions, 67 deletions
diff --git a/src/libstate/libstate.cpp b/src/libstate/libstate.cpp
index fccedacdf..c2e0ae80d 100644
--- a/src/libstate/libstate.cpp
+++ b/src/libstate/libstate.cpp
@@ -1,6 +1,6 @@
/*
* Library Internal/Global State
-* (C) 1999-2008 Jack Lloyd
+* (C) 1999-2010 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
@@ -99,13 +99,9 @@ Allocator* Library_State::get_allocator(const std::string& type)
if(!cached_default_allocator)
{
- std::string chosen = this->option("base/default_allocator");
-
- if(chosen == "")
- chosen = "malloc";
-
cached_default_allocator =
- search_map<std::string, Allocator*>(alloc_factory, chosen, 0);
+ search_map<std::string, Allocator*>(alloc_factory,
+ default_allocator_name, 0);
}
return cached_default_allocator;
@@ -134,7 +130,7 @@ void Library_State::set_default_allocator(const std::string& type)
std::lock_guard<std::mutex> lock(allocator_lock);
- this->set("conf", "base/default_allocator", type);
+ default_allocator_name = type;
cached_default_allocator = 0;
}
@@ -196,27 +192,10 @@ std::string Library_State::deref_alias(const std::string& key)
return result;
}
-/*
-* Set/Add an option
-*/
-void Library_State::set_option(const std::string& key,
- const std::string& value)
- {
- set("conf", key, value);
- }
-
-/*
-* Get an option value
-*/
-std::string Library_State::option(const std::string& key)
- {
- return get("conf", key);
- }
-
/**
Return a reference to the Algorithm_Factory
*/
-Algorithm_Factory& Library_State::algorithm_factory()
+Algorithm_Factory& Library_State::algorithm_factory() const
{
if(!m_algorithm_factory)
throw Invalid_State("Uninitialized in Library_State::algorithm_factory");
@@ -232,6 +211,7 @@ void Library_State::initialize()
throw Invalid_State("Library_State has already been initialized");
cached_default_allocator = 0;
+ default_allocator_name = "locking";
add_allocator(new Malloc_Allocator);
add_allocator(new Locking_Allocator);
@@ -240,8 +220,6 @@ void Library_State::initialize()
add_allocator(new MemoryMapping_Allocator);
#endif
- set_default_allocator("locking");
-
load_default_config();
std::vector<Engine*> engines = {
diff --git a/src/libstate/libstate.h b/src/libstate/libstate.h
index 5a84f9cb1..36c428ecb 100644
--- a/src/libstate/libstate.h
+++ b/src/libstate/libstate.h
@@ -36,7 +36,7 @@ class BOTAN_DLL Library_State
/**
* @return the global Algorithm_Factory
*/
- Algorithm_Factory& algorithm_factory();
+ Algorithm_Factory& algorithm_factory() const;
/**
* @param name the name of the allocator
@@ -90,21 +90,6 @@ class BOTAN_DLL Library_State
bool overwrite = true);
/**
- * Get a parameters value out of the "conf" section (
- * referred to as option).
- * @param key the desired keys name
- */
- std::string option(const std::string& key);
-
- /**
- * Set an option.
- * @param key the key of the option to set
- * @param value the value to set
- */
- void set_option(const std::string& key,
- const std::string& value);
-
- /**
* Add a parameter value to the "alias" section.
* @param key the name of the parameter which shall have a new alias
* @param value the new alias
@@ -125,6 +110,7 @@ class BOTAN_DLL Library_State
std::map<std::string, std::string> config;
std::mutex allocator_lock;
+ std::string default_allocator_name;
std::map<std::string, Allocator*> alloc_factory;
mutable Allocator* cached_default_allocator;
std::vector<Allocator*> allocators;
@@ -132,12 +118,24 @@ class BOTAN_DLL Library_State
Algorithm_Factory* m_algorithm_factory;
};
-/*
-* Global State
+/**
+* Access the global library state
+* @return reference to the global library state
*/
BOTAN_DLL Library_State& global_state();
-BOTAN_DLL void set_global_state(Library_State*);
-BOTAN_DLL Library_State* swap_global_state(Library_State*);
+
+/**
+* Set the global state object
+* @param state the new global state to use
+*/
+BOTAN_DLL void set_global_state(Library_State* state);
+
+/**
+* Swap the current state for another
+* @param new_state the new state object to use
+* @return the previous state (or NULL if none)
+*/
+BOTAN_DLL Library_State* swap_global_state(Library_State* new_state);
}
diff --git a/src/libstate/policy.cpp b/src/libstate/policy.cpp
index d792443a0..803ca518e 100644
--- a/src/libstate/policy.cpp
+++ b/src/libstate/policy.cpp
@@ -1,6 +1,6 @@
/*
* Default Policy
-* (C) 1999-2008 Jack Lloyd
+* (C) 1999-2010 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
@@ -280,23 +280,6 @@ void set_default_aliases(Library_State& config)
}
/*
-* Set the default configuration toggles
-*/
-void set_default_config(Library_State& config)
- {
- config.set_option("base/default_allocator", "malloc");
-
- config.set_option("x509/exts/basic_constraints", "critical");
- config.set_option("x509/exts/subject_key_id", "yes");
- config.set_option("x509/exts/authority_key_id", "yes");
- config.set_option("x509/exts/subject_alternative_name", "yes");
- config.set_option("x509/exts/issuer_alternative_name", "no");
- config.set_option("x509/exts/key_usage", "critical");
- config.set_option("x509/exts/extended_key_usage", "yes");
- config.set_option("x509/exts/crl_number", "yes");
- }
-
-/*
* Set the built-in discrete log groups
*/
void set_default_dl_groups(Library_State& config)
@@ -812,7 +795,6 @@ void set_default_dl_groups(Library_State& config)
*/
void Library_State::load_default_config()
{
- set_default_config(*this);
set_default_aliases(*this);
set_default_oids(*this);
set_default_dl_groups(*this);