From f58c84b83a73c96d72743f456379193984231bc5 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Mon, 18 Feb 2019 21:25:00 -0800 Subject: Provide compatibility with Sam Bingner's era ldid. --- ldid.cpp | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/ldid.cpp b/ldid.cpp index 6d03d1b..30c8b6d 100644 --- a/ldid.cpp +++ b/ldid.cpp @@ -1035,16 +1035,21 @@ struct AlgorithmSHA256 : } }; +static bool do_sha1(true); +static bool do_sha256(true); + static const std::vector &GetAlgorithms() { static AlgorithmSHA1 sha1; static AlgorithmSHA256 sha256; - static Algorithm *array[] = { - &sha1, - &sha256, - }; + static std::vector algorithms; + if (algorithms.empty()) { + if (do_sha1) + algorithms.push_back(&sha1); + if (do_sha256) + algorithms.push_back(&sha256); + } - static std::vector algorithms(array, array + sizeof(array) / sizeof(array[0])); return algorithms; } @@ -2724,6 +2729,8 @@ int main(int argc, char *argv[]) { bool flag_e(false); bool flag_q(false); + bool flag_H(false); + #ifndef LDID_NOFLAGT bool flag_T(false); #endif @@ -2793,6 +2800,27 @@ int main(int argc, char *argv[]) { case 'q': flag_q = true; break; + case 'H': { + const char *hash = argv[argi] + 2; + + if (!flag_H) { + flag_H = true; + + do_sha1 = false; + do_sha256 = false; + + fprintf(stderr, "WARNING: -H is only present for compatibility with a fork of ldid\n"); + fprintf(stderr, " you should NOT be manually specifying the hash algorithm\n"); + } + + if (false); + else if (strcmp(hash, "sha1") == 0) + do_sha1 = true; + else if (strcmp(hash, "sha256") == 0) + do_sha256 = true; + else _assert(false); + } break; + case 'Q': { const char *xml = argv[argi] + 2; requirements.open(xml, O_RDONLY, PROT_READ, MAP_PRIVATE); -- cgit v1.2.3-56-ge451