diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2015-08-04 04:37:12 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2015-08-04 04:37:12 +0300 |
commit | 0c593583dccd88e90450972e6a1b9e6bc67e0911 (patch) | |
tree | d38de5fb6255fec9424bf9694c1cf3fcfd8b9c39 /utils/encrypt_block.cpp | |
parent | test/toolkit.py: fix utility names (diff) | |
download | aes-tools-0c593583dccd88e90450972e6a1b9e6bc67e0911.tar.gz aes-tools-0c593583dccd88e90450972e6a1b9e6bc67e0911.zip |
utils: bugfix & refactoring
Diffstat (limited to 'utils/encrypt_block.cpp')
-rw-r--r-- | utils/encrypt_block.cpp | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/utils/encrypt_block.cpp b/utils/encrypt_block.cpp index a40cc67..c8313a6 100644 --- a/utils/encrypt_block.cpp +++ b/utils/encrypt_block.cpp @@ -6,15 +6,19 @@ * See LICENSE.txt for details. */ -#include "block_common.hpp" +#include "block_cmd_parser.hpp" +#include "block_dumper.hpp" #include <aesni/all.h> #include <aesnixx/all.hpp> +#include <boost/program_options.hpp> + #include <deque> #include <exception> #include <iostream> +#include <iterator> #include <string> namespace @@ -211,14 +215,16 @@ int main(int argc, char** argv) try { CommandLineParser cmd_parser("encrypt_block.exe"); + cmd_parser.parse(argc, argv); - if (!cmd_parser.parse_options(argc, argv)) + if (cmd_parser.requested_help()) + { + std::cout << cmd_parser; return 0; + } - const auto algorithm = cmd_parser.get_algorithm(); - const auto mode = cmd_parser.get_mode(); - - auto args = cmd_parser.get_args(); + std::deque<std::string> args{ std::make_move_iterator(cmd_parser.args.begin()), + std::make_move_iterator(cmd_parser.args.end()) }; while (!args.empty()) { @@ -239,13 +245,13 @@ int main(int argc, char** argv) args.pop_front(); } - const auto success = cmd_parser.use_boxes() - ? encrypt_using_boxes(algorithm, mode, key, plaintexts) - : encrypt_using_cxx_api(algorithm, mode, key, plaintexts, cmd_parser.verbose()); + const auto success = cmd_parser.use_boxes + ? encrypt_using_boxes(cmd_parser.algorithm, cmd_parser.mode, key, plaintexts) + : encrypt_using_cxx_api(cmd_parser.algorithm, cmd_parser.mode, key, plaintexts, cmd_parser.verbose); if (!success) { - cmd_parser.print_usage(); + std::cout << cmd_parser; return 1; } } |