diff options
author | Simon Warta <[email protected]> | 2015-12-08 17:25:03 +0100 |
---|---|---|
committer | Simon Warta <[email protected]> | 2015-12-09 15:28:07 +0100 |
commit | 1a0f3438a97b7913ccf444bc48510e0d145af551 (patch) | |
tree | bb4f275f5eba30076d9b48a9164c38b71e2a11e6 /src/cmd/apps.h | |
parent | 0261351f68674105a40d1938a001ba65dda756ed (diff) |
Rename cmd/app -> cli
Diffstat (limited to 'src/cmd/apps.h')
-rw-r--r-- | src/cmd/apps.h | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/src/cmd/apps.h b/src/cmd/apps.h deleted file mode 100644 index 9f1f00ba2..000000000 --- a/src/cmd/apps.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -* (C) 2014,2015 Jack Lloyd -* -* Botan is released under the Simplified BSD License (see license.txt) -*/ - -#include <iostream> -#include <functional> -#include <string> -#include <set> -#include <botan/build.h> -#include <botan/hex.h> -#include <botan/auto_rng.h> -#include "getopt.h" - -using namespace Botan; - -typedef std::function<int (std::vector<std::string>)> app_fn; - -class AppRegistrations - { - public: - void add(const std::string& name, app_fn fn) - { - m_apps[name] = fn; - } - - bool has(const std::string& cmd) const - { - return m_apps.count(cmd) > 0; - } - - std::set<std::string> all_appnames() const - { - std::set<std::string> apps; - for(auto i : m_apps) - apps.insert(i.first); - return apps; - } - - // TODO: Remove redundancy cmd == args[0] - int run(const std::string& cmd, std::vector<std::string> args) const - { - const auto app = m_apps.find(cmd); - if(app != m_apps.end()) - return app->second(args); - return -1; - } - - static AppRegistrations& instance() - { - static AppRegistrations s_apps; - return s_apps; - } - - class AppRegistration - { - public: - AppRegistration(const std::string& name, app_fn fn) - { - AppRegistrations::instance().add(name, fn); - } - }; - - private: - AppRegistrations() {} - - std::map<std::string, app_fn> m_apps; - }; - -#define REGISTER_APP(nm) AppRegistrations::AppRegistration g_ ## nm ## _registration(#nm, nm) - -#if defined(BOTAN_TARGET_OS_IS_WINDOWS) || defined(BOTAN_TARGET_OS_IS_MINGW) - #undef BOTAN_TARGET_OS_HAS_SOCKETS -#else - #define BOTAN_TARGET_OS_HAS_SOCKETS -#endif |