mirror of
https://github.com/eosswedenorg/antelope-keygen
synced 2026-06-17 03:50:03 +02:00
src/main.cpp: refactor cmd_search to take strlist_t and int parameters and do all parsing outside.
This commit is contained in:
parent
d636cf7756
commit
67df405309
1 changed files with 18 additions and 19 deletions
37
src/main.cpp
37
src/main.cpp
|
|
@ -39,40 +39,30 @@ bool option_l33t = false;
|
|||
int option_num_threads = std::thread::hardware_concurrency();
|
||||
#endif /* HAVE_THREADS */
|
||||
|
||||
void cmd_search(int argc, char **argv) {
|
||||
void cmd_search(const strlist_t& words, int count) {
|
||||
|
||||
int n = 10;
|
||||
std::string input(argv[0]);
|
||||
KeySearch ks;
|
||||
|
||||
if (option_l33t) {
|
||||
strlist_t tmp = strsplitwords(input);
|
||||
for(std::size_t i = 0; i < tmp.size(); i++) {
|
||||
ks.addList(l33twords(tmp[i]));
|
||||
for(std::size_t i = 0; i < words.size(); i++) {
|
||||
ks.addList(l33twords(words[i]));
|
||||
}
|
||||
} else {
|
||||
ks.addList(strsplitwords(input));
|
||||
}
|
||||
|
||||
if (argc > 1) {
|
||||
n = atoi(argv[1]);
|
||||
if (n < 1) {
|
||||
n = 1;
|
||||
}
|
||||
ks.addList(words);
|
||||
}
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
ks.setThreadCount(option_num_threads);
|
||||
#endif /* HAVE_THREADS */
|
||||
|
||||
std::cout << "Searching for " << n
|
||||
std::cout << "Searching for " << count
|
||||
<< " keys containing: " << strjoin(ks.getList(), ",")
|
||||
#ifdef HAVE_THREADS
|
||||
<< ", Using: " << option_num_threads << " threads"
|
||||
#endif /* HAVE_THREADS */
|
||||
<< std::endl;
|
||||
|
||||
ks.find(n);
|
||||
ks.find(count);
|
||||
}
|
||||
|
||||
void usage(const char *name) {
|
||||
|
|
@ -182,10 +172,19 @@ int main(int argc, char **argv) {
|
|||
std::cerr << "You must specify a word list." << std::endl;
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
int count = 10;
|
||||
strlist_t words = strsplitwords(std::string(argv[p]));
|
||||
|
||||
// Pass the rest of argv, argc
|
||||
cmd_search(argc - p, &argv[p]);
|
||||
if (p + 1 < argc) {
|
||||
count = atoi(argv[p+1]);
|
||||
if (count < 1) {
|
||||
count = 1;
|
||||
}
|
||||
}
|
||||
|
||||
cmd_search(words, count);
|
||||
}
|
||||
}
|
||||
// Benchmark
|
||||
else if (!strcmp(argv[p], "benchmark")) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue