diff options
Diffstat (limited to 'src/cmd')
-rw-r--r-- | src/cmd/apps.cpp | 27 | ||||
-rw-r--r-- | src/cmd/apps.h | 5 | ||||
-rw-r--r-- | src/cmd/bcrypt.cpp | 5 | ||||
-rw-r--r-- | src/cmd/dsa_sign.cpp | 9 | ||||
-rw-r--r-- | src/cmd/fpe.cpp | 5 | ||||
-rw-r--r-- | src/cmd/main.cpp | 82 | ||||
-rw-r--r-- | src/cmd/tls_server_asio.cpp | 11 |
7 files changed, 84 insertions, 60 deletions
diff --git a/src/cmd/apps.cpp b/src/cmd/apps.cpp deleted file mode 100644 index 120457cb1..000000000 --- a/src/cmd/apps.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "apps.h" - -int apps_main(const std::string& cmd, int argc, char* argv[]) - { -#define CALL_APP(cmdsym) \ - do { if(cmd == #cmdsym) { return cmdsym ##_main (argc - 1, argv + 1); } } while(0) - - CALL_APP(asn1); - CALL_APP(base64); - CALL_APP(bcrypt); - CALL_APP(bzip); - CALL_APP(ca); - CALL_APP(factor); - CALL_APP(fpe); - CALL_APP(hash); - CALL_APP(keygen); - CALL_APP(dsa_sign); - CALL_APP(dsa_verify); - CALL_APP(pkcs10); - CALL_APP(read_ssh); - CALL_APP(self_sig); - CALL_APP(tls_client); - CALL_APP(tls_server); - CALL_APP(x509); - - return -1; - } diff --git a/src/cmd/apps.h b/src/cmd/apps.h index 39665a720..280ee46a0 100644 --- a/src/cmd/apps.h +++ b/src/cmd/apps.h @@ -7,7 +7,10 @@ using namespace Botan; -int apps_main(const std::string& cmd, int argc, char* argv[]); +int unimplemented(int argc, char* argv[], const char* what); + +#define UNIMPLEMENTED(main, prob) \ + int main(int argc, char* argv[]) { return unimplemented(argc, argv, prob); } #define DEFINE_APP(cmd) int cmd ## _main(int argc, char* argv[]); diff --git a/src/cmd/bcrypt.cpp b/src/cmd/bcrypt.cpp index 2b0bfa132..2b4b4e61d 100644 --- a/src/cmd/bcrypt.cpp +++ b/src/cmd/bcrypt.cpp @@ -1,4 +1,6 @@ #include "apps.h" + +#if defined(BOTAN_HAS_BCRYPT) #include <botan/bcrypt.h> int bcrypt_main(int argc, char* argv[]) @@ -30,3 +32,6 @@ int bcrypt_main(int argc, char* argv[]) << " " << argv[0] << " password passhash\n"; return 1; } +#else +UNIMPLEMENTED(bcrypt_main, "bcrypt"); +#endif diff --git a/src/cmd/dsa_sign.cpp b/src/cmd/dsa_sign.cpp index 308e68814..365e91a37 100644 --- a/src/cmd/dsa_sign.cpp +++ b/src/cmd/dsa_sign.cpp @@ -5,9 +5,13 @@ #include <string> #include <memory> +#include <botan/base64.h> #include <botan/pubkey.h> + +#if defined(BOTAN_HAS_DSA) + #include <botan/dsa.h> -#include <botan/base64.h> + using namespace Botan; const std::string SUFFIX = ".sig"; @@ -69,3 +73,6 @@ int dsa_sign_main(int argc, char* argv[]) } return 0; } +#else +UNIMPLEMENTED(dsa_sign_main, "DSA"); +#endif diff --git a/src/cmd/fpe.cpp b/src/cmd/fpe.cpp index e40db8a32..d1e748b4c 100644 --- a/src/cmd/fpe.cpp +++ b/src/cmd/fpe.cpp @@ -1,4 +1,6 @@ #include "apps.h" + +#if defined(BOTAN_HAS_FPE_FE1) #include <botan/fpe_fe1.h> #include <botan/sha160.h> @@ -141,3 +143,6 @@ int fpe_main(int argc, char* argv[]) return 0; } +#else +UNIMPLEMENTED(fpe_main, "FPE"); +#endif diff --git a/src/cmd/main.cpp b/src/cmd/main.cpp index 2d675d546..5f6a0042f 100644 --- a/src/cmd/main.cpp +++ b/src/cmd/main.cpp @@ -37,24 +37,21 @@ int help(int , char* argv[]) return 1; } +int config_main(int argc, char* argv[]) + { + return 1; + } + } -int main(int argc, char* argv[]) +int unimplemented(int , char* argv[], const char* what) { - if(BOTAN_VERSION_MAJOR != version_major() || - BOTAN_VERSION_MINOR != version_minor() || - BOTAN_VERSION_PATCH != version_patch()) - { - std::cout << "Warning: linked version (" - << version_major() << '.' - << version_minor() << '.' - << version_patch() - << ") does not match version built against (" - << BOTAN_VERSION_MAJOR << '.' - << BOTAN_VERSION_MINOR << '.' - << BOTAN_VERSION_PATCH << ")\n"; - } + std::cout << argv[0] << " command not implemented - library missing " << what << "\n"; + return 1; + } +int main(int argc, char* argv[]) + { try { Botan::LibraryInitializer init; @@ -67,9 +64,29 @@ int main(int argc, char* argv[]) if(cmd == "help") return help(argc, argv); + if(cmd == "config") + { + return config_main(argc - 1, argv + 1); + } + if(cmd == "version") { std::cout << Botan::version_string() << "\n"; + + if(BOTAN_VERSION_MAJOR != version_major() || + BOTAN_VERSION_MINOR != version_minor() || + BOTAN_VERSION_PATCH != version_patch()) + { + std::cout << "Warning: linked version (" + << version_major() << '.' + << version_minor() << '.' + << version_patch() + << ") does not match version built against (" + << BOTAN_VERSION_MAJOR << '.' + << BOTAN_VERSION_MINOR << '.' + << BOTAN_VERSION_PATCH << ")\n"; + } + return 0; } @@ -79,24 +96,37 @@ int main(int argc, char* argv[]) return 0; } - if(cmd == "speed") - return speed_main(argc - 1, argv + 1); - if(cmd == "http_get") { auto resp = HTTP::GET_sync(argv[2]); std::cout << resp << "\n"; } - int e = apps_main(cmd, argc - 1, argv + 1); - - if(e == -1) - { - std::cout << "Unknown command " << cmd << "\n"; - return help(argc, argv); - } - - return e; +#define CALL_APP(cmdsym) \ + do { if(cmd == #cmdsym) { return cmdsym ##_main (argc - 1, argv + 1); } } while(0) + + CALL_APP(asn1); + CALL_APP(base64); + CALL_APP(bcrypt); + CALL_APP(bzip); + CALL_APP(ca); + CALL_APP(factor); + CALL_APP(fpe); + CALL_APP(hash); + CALL_APP(keygen); + CALL_APP(dsa_sign); + CALL_APP(dsa_verify); + CALL_APP(pkcs10); + CALL_APP(read_ssh); + CALL_APP(self_sig); + CALL_APP(tls_client); + CALL_APP(tls_server); + CALL_APP(tls_server_asio); + CALL_APP(x509); + CALL_APP(speed); + + std::cout << "Unknown command " << cmd << "\n"; + return help(argc, argv); } catch(std::exception& e) { diff --git a/src/cmd/tls_server_asio.cpp b/src/cmd/tls_server_asio.cpp index b49206136..524181510 100644 --- a/src/cmd/tls_server_asio.cpp +++ b/src/cmd/tls_server_asio.cpp @@ -2,10 +2,11 @@ #include <iostream> #include <string> #include <vector> +#include <thread> #define _GLIBCXX_HAVE_GTHR_DEFAULT #include <boost/asio.hpp> #include <boost/bind.hpp> -#include <boost/thread.hpp> +//#include <boost/thread.hpp> #include <boost/shared_ptr.hpp> #include <boost/enable_shared_from_this.hpp> @@ -265,7 +266,7 @@ class asio_tls_server size_t choose_thread_count() { - size_t result = boost::thread::hardware_concurrency(); + size_t result = std::thread::hardware_concurrency(); if(result) return result; @@ -291,12 +292,12 @@ int tls_server_asio_main(int argc, char* argv[]) std::cout << "Using " << num_threads << " threads\n"; - std::vector<boost::shared_ptr<boost::thread> > threads; + std::vector<boost::shared_ptr<std::thread> > threads; for(size_t i = 0; i != num_threads; ++i) { - boost::shared_ptr<boost::thread> thread( - new boost::thread( + boost::shared_ptr<std::thread> thread( + new std::thread( boost::bind(&boost::asio::io_service::run, &io_service))); threads.push_back(thread); } |