aboutsummaryrefslogtreecommitdiffstats
path: root/src/init_opt.cpp
blob: cce5f65f617078ed654e5b743f6439427e410150 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*************************************************
* Initialization Options Source File             *
* (C) 1999-2006 The Botan Project                *
*************************************************/

#include <botan/init.h>
#include <botan/parsing.h>

namespace Botan {

/*************************************************
* Check for an arbitrary boolean-valued option   *
*************************************************/
bool InitializerOptions::boolean_arg(const std::string& option_name) const
   {
   return (args.find(option_name) != args.end());
   }

/*************************************************
* Check if thread safety was requested           *
*************************************************/
bool InitializerOptions::thread_safe() const
   {
   return boolean_arg("thread_safe");
   }

/*************************************************
* Check if using engines was requested           *
*************************************************/
bool InitializerOptions::use_engines() const
   {
   return boolean_arg("use_engines");
   }

/*************************************************
* Check if RNG seeding should be disabled        *
*************************************************/
bool InitializerOptions::seed_rng() const
   {
   return !boolean_arg("no_rng_seed");
   }

/*************************************************
* Return the config file to load, if any         *
*************************************************/
std::string InitializerOptions::config_file() const
   {
   std::map<std::string, std::string>::const_iterator i =
      args.find("config");

   return (i != args.end()) ? i->second : "";
   }

/*************************************************
* Setup an InitializerOptions                    *
*************************************************/
InitializerOptions::InitializerOptions(const std::string& arg_string)
   {
   std::vector<std::string> arg_list = split_on(arg_string, ' ');
   for(u32bit j = 0; j != arg_list.size(); ++j)
      {
      if(arg_list[j].find('=') == std::string::npos)
         args[arg_list[j]] = "";
      else
         {
         std::vector<std::string> name_and_value = split_on(arg_list[j], '=');
         args[name_and_value[0]] = name_and_value[1];
         }
      }
   }

}