From a2df9c48870ee3fb25051c3473476f91e8d467d8 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 23 Nov 2023 15:42:44 -0800 Subject: --hashes option requires an argument to specify the algorithm At the moment only "sha512" or "SHA512" is accepted, but this could extend to more algorithms in the future. --- src/session.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/session.h') diff --git a/src/session.h b/src/session.h index dcb554eb..ce1b69a3 100644 --- a/src/session.h +++ b/src/session.h @@ -112,7 +112,7 @@ public: HANDLER(decimal_comma).report(out); HANDLER(time_colon).report(out); HANDLER(file_).report(out); - HANDLER(hashes).report(out); + HANDLER(hashes_).report(out); HANDLER(input_date_format_).report(out); HANDLER(explicit).report(out); HANDLER(master_account_).report(out); @@ -163,7 +163,22 @@ public: data_files.push_back(str); }); - OPTION(session_t, hashes); + enum hash_type_t { + NO_HASHES = 0, + HASH_SHA512 = 1 + }; + + OPTION__ + (session_t, hashes_, + hash_type_t hash_type = NO_HASHES; + CTOR(session_t, hashes_) {} + DO_(str) { + if (str == "sha512" || str == "SHA512") { + hash_type = HASH_SHA512; + } else { + throw_(std::invalid_argument, _f("Unrecognized hash type")); + } + }); OPTION_(session_t, input_date_format_, DO_(str) { // This changes static variables inside times.h, which affects the -- cgit v1.2.3