From: Jonathan McDowell Date: Mon, 30 Sep 2013 11:22:59 +0000 (+0100) Subject: Add -c option to maxpath / sixdegrees to specify config file X-Git-Url: https://git.sommitrealweird.co.uk/onak.git/commitdiff_plain/f5be3640e7ca1e6978e199a0a767bda3f40def87?ds=sidebyside;hp=69deababa089b34c7d3dddaac04518fde1b9c2f8 Add -c option to maxpath / sixdegrees to specify config file maxpath + sixdegrees weren't allowing a config file to be specified in the same fashion as onak. Add the -c option so they do so, which helps when using these tools in a non-system install setup. --- diff --git a/maxpath.c b/maxpath.c index 81a2b22..25264ce 100644 --- a/maxpath.c +++ b/maxpath.c @@ -17,6 +17,7 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include #include #include #include @@ -83,7 +84,18 @@ void findmaxpath(unsigned long max) int main(int argc, char *argv[]) { - readconfig(NULL); + int optchar; + char *configfile = NULL; + + while ((optchar = getopt(argc, argv, "c:")) != -1 ) { + switch (optchar) { + case 'c': + configfile = strdup(optarg); + break; + } + } + + readconfig(configfile); initlogthing("maxpath", config.logfile); config.dbbackend->initdb(true); inithash(); diff --git a/sixdegrees.c b/sixdegrees.c index e6a3594..738f626 100644 --- a/sixdegrees.c +++ b/sixdegrees.c @@ -17,8 +17,10 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include #include #include +#include #include "hash.h" #include "keydb.h" @@ -132,13 +134,23 @@ void sixdegrees(uint64_t keyid) int main(int argc, char *argv[]) { + int optchar; + char *configfile = NULL; uint64_t keyid = 0x2DA8B985; - if (argc == 2) { - keyid = strtoll(argv[1], NULL, 16); + while ((optchar = getopt(argc, argv, "c:")) != -1 ) { + switch (optchar) { + case 'c': + configfile = strdup(optarg); + break; + } + } + + if (optind < argc) { + keyid = strtoll(argv[optind], NULL, 16); } - readconfig(NULL); + readconfig(configfile); initlogthing("sixdegrees", config.logfile); config.dbbackend->initdb(true); inithash();