summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2019-02-18 21:25:00 -0800
committerJay Freeman (saurik) <saurik@saurik.com>2019-02-18 21:25:00 -0800
commitf58c84b83a73c96d72743f456379193984231bc5 (patch)
tree996e8d0dee9a075beda8a9beeef0f1601f9d21d5
parent6b3aca98060261601319f503b7c73fdfc6f46913 (diff)
downloadldid-f58c84b83a73c96d72743f456379193984231bc5.tar.gz
ldid-f58c84b83a73c96d72743f456379193984231bc5.tar.zst
ldid-f58c84b83a73c96d72743f456379193984231bc5.zip
Provide compatibility with Sam Bingner's era ldid.
-rw-r--r--ldid.cpp38
1 files 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<Algorithm *> &GetAlgorithms() {
static AlgorithmSHA1 sha1;
static AlgorithmSHA256 sha256;
- static Algorithm *array[] = {
- &sha1,
- &sha256,
- };
+ static std::vector<Algorithm *> algorithms;
+ if (algorithms.empty()) {
+ if (do_sha1)
+ algorithms.push_back(&sha1);
+ if (do_sha256)
+ algorithms.push_back(&sha256);
+ }
- static std::vector<Algorithm *> 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);