From: Jonathan McDowell Date: Wed, 16 Mar 2011 02:50:25 +0000 (+0000) Subject: Add -c option to specify keyd config file on command line X-Git-Url: https://git.sommitrealweird.co.uk/onak.git/commitdiff_plain/f5037a4a370b891e14971228c1d491184c7fe8bd?ds=sidebyside Add -c option to specify keyd config file on command line Matches the parameter the onak binary takes and allows use of something other than the compiled in default config file path. --- diff --git a/keyd.c b/keyd.c index 33af8ea..05f9fe9 100644 --- a/keyd.c +++ b/keyd.c @@ -2,11 +2,12 @@ * keyd.c - key retrieval daemon * * Jonathan McDowell - * + * * Copyright 2004 Project Purple */ #include +#include #include #include #include @@ -341,8 +342,20 @@ int main(int argc, char *argv[]) int fd = -1; fd_set rfds; char sockname[1024]; + char *configfile = NULL; + int optchar; - readconfig(NULL); + while ((optchar = getopt(argc, argv, "c:")) != -1 ) { + switch (optchar) { + case 'c': + configfile = strdup(optarg); + break; + } + } + + readconfig(configfile); + free(configfile); + configfile = NULL; initlogthing("keyd", config.logfile); catchsignals(); @@ -369,6 +382,6 @@ int main(int argc, char *argv[]) cleanuplogthing(); cleanupconfig(); - + return(EXIT_SUCCESS); }