From b40d849931a3858b429454bf9b8427529299e3de Mon Sep 17 00:00:00 2001 From: Eric Lombrozo Date: Thu, 18 May 2017 07:04:43 -0700 Subject: [PATCH] Added command line option to choose false positive P. --- cpp/main.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cpp/main.cpp b/cpp/main.cpp index a1cb251..ab5248c 100644 --- a/cpp/main.cpp +++ b/cpp/main.cpp @@ -24,13 +24,14 @@ // For more information, please refer to #include "gcs.h" +#include #include #include static void usage(void) { std::cerr << "Usage:\n"; - std::cerr << " gcs build /path/to/wordlist\n"; + std::cerr << " gcs build /path/to/wordlist [false positive P (default 1024)]\n"; std::cerr << " gcs query word1 [word2...]\n"; } @@ -45,12 +46,14 @@ int main(int argc, char *argv[]) std::string cmd(argv[1]); if (cmd == "build") { - if (argc != 3) + if (argc > 4) { usage(); return 1; } + int p = (argc == 4) ? std::strtol(argv[3], NULL, 0) : 1024; + std::ifstream f(argv[2], std::ios::binary|std::ios::in); if (!f.is_open()) { @@ -67,7 +70,7 @@ int main(int argc, char *argv[]) f.seekg(0); std::cout << "numwords: " << numwords << "\n"; - GCSBuilder gcs(numwords, 1024); + GCSBuilder gcs(numwords, p); while (std::getline(f,line), !f.eof()) gcs.add(line.data(), line.size()); f.close();