aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/apps/apps.cpp27
-rw-r--r--src/apps/apps.h45
-rw-r--r--src/main.cpp31
3 files changed, 59 insertions, 44 deletions
diff --git a/src/apps/apps.cpp b/src/apps/apps.cpp
new file mode 100644
index 000000000..120457cb1
--- /dev/null
+++ b/src/apps/apps.cpp
@@ -0,0 +1,27 @@
+#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/apps/apps.h b/src/apps/apps.h
index cf77923fe..956a891fd 100644
--- a/src/apps/apps.h
+++ b/src/apps/apps.h
@@ -6,27 +6,28 @@
using namespace Botan;
-#define DEFINE_EXAMPLE(cmd) int cmd ## _main(int argc, char* argv[]);
+int apps_main(const std::string& cmd, int argc, char* argv[]);
-DEFINE_EXAMPLE(asn1);
-DEFINE_EXAMPLE(bcrypt);
-DEFINE_EXAMPLE(bzip);
-DEFINE_EXAMPLE(base64);
-DEFINE_EXAMPLE(ca);
-DEFINE_EXAMPLE(factor);
-DEFINE_EXAMPLE(fpe);
-DEFINE_EXAMPLE(hash);
-DEFINE_EXAMPLE(keygen);
-DEFINE_EXAMPLE(dsa_sign);
-DEFINE_EXAMPLE(dsa_verify);
-DEFINE_EXAMPLE(cert_verify);
-DEFINE_EXAMPLE(ocsp_check);
-DEFINE_EXAMPLE(pkcs10);
-DEFINE_EXAMPLE(read_ssh);
-DEFINE_EXAMPLE(self_sig);
-DEFINE_EXAMPLE(tls_client);
-DEFINE_EXAMPLE(tls_server);
-DEFINE_EXAMPLE(tls_server_asio);
-DEFINE_EXAMPLE(x509);
+#define DEFINE_APP(cmd) int cmd ## _main(int argc, char* argv[]);
-int speed_main(int argc, char* argv[]);
+DEFINE_APP(asn1);
+DEFINE_APP(bcrypt);
+DEFINE_APP(bzip);
+DEFINE_APP(base64);
+DEFINE_APP(ca);
+DEFINE_APP(factor);
+DEFINE_APP(fpe);
+DEFINE_APP(hash);
+DEFINE_APP(keygen);
+DEFINE_APP(dsa_sign);
+DEFINE_APP(dsa_verify);
+DEFINE_APP(cert_verify);
+DEFINE_APP(ocsp_check);
+DEFINE_APP(pkcs10);
+DEFINE_APP(read_ssh);
+DEFINE_APP(self_sig);
+DEFINE_APP(tls_client);
+DEFINE_APP(tls_server);
+DEFINE_APP(tls_server_asio);
+DEFINE_APP(x509);
+DEFINE_APP(speed);
diff --git a/src/main.cpp b/src/main.cpp
index 64715f1d6..f2182fe3f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -121,28 +121,15 @@ int main(int argc, char* argv[])
std::cout << resp << "\n";
}
- //return app_main(cmd, argc - 1, argv + 1);
-
-#define CALL_CMD(cmdsym) \
- do { if(cmd == #cmdsym) { return cmdsym ##_main (argc - 1, argv + 1); } } while(0)
-
- CALL_CMD(asn1);
- CALL_CMD(base64);
- CALL_CMD(bcrypt);
- CALL_CMD(bzip);
- CALL_CMD(ca);
- CALL_CMD(factor);
- CALL_CMD(fpe);
- CALL_CMD(hash);
- CALL_CMD(keygen);
- CALL_CMD(dsa_sign);
- CALL_CMD(dsa_verify);
- CALL_CMD(pkcs10);
- CALL_CMD(read_ssh);
- CALL_CMD(self_sig);
- CALL_CMD(tls_client);
- CALL_CMD(tls_server);
- CALL_CMD(x509);
+ int e = apps_main(cmd, argc - 1, argv + 1);
+
+ if(e == -1)
+ {
+ std::cout << "Unknown command " << cmd << "\n";
+ return help(argc, argv);
+ }
+
+ return e;
}
catch(std::exception& e)
{