Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "parse_args.hpp"
- void usage() {
- cout << "\n +-++-++-+ +-+ +-++-++-++-++-+"
- "\n |w||3||b| |-| |C||r||4||c||k|"
- "\n +-++-++-+ +-+ +-++-++-++-++-+\n\n"
- "\n -h this screen"
- "\n -v be verbose"
- "\n -s* single hash"
- "\n -f* file of hashes"
- "\n -t* [NUM(1-5)] check NUM amount of sites for each hash"
- "\n\n * requires an argument\n\n";
- exit(-1);
- }
- int set_top(char *x) {
- string t = x;
- if((t.length() == 1) && (isdigit(x[0])) && ((atoi(x) <= 3) && (atoi(x) > 0))) {
- return(atoi(x));
- }
- else {
- cout << "\n\n~! -t value is invalid !~\n\n";
- return(false);
- }
- }
- options parse_args(int arg_count, char **arg_values) {
- if(arg_count > 5) usage();
- int o;
- options ops = { 0, "", "" };
- while((o = getopt(arg_count, arg_values, "hvrt:s:f:")) != -1)
- {
- switch(o)
- {
- case 'h': usage();
- case 'v': VERBOSE = true; break;
- case 'r': RANDOMIZE = true; break;
- case 't': if(!((ops.top = set_top(optarg)))) usage(); else break;
- case 's': ops.single_hash = optarg; break;
- case 'f': ops.file_loc = optarg; break;
- case '?': usage();
- default: usage();
- }
- }
- if(((ops.file_loc.empty()) && (ops.single_hash.empty())) || ((!ops.file_loc.empty()) && (!ops.single_hash.empty()))) usage();
- return(ops);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement