From: Jonathan McDowell Date: Mon, 31 May 2004 23:48:08 +0000 (+0000) Subject: cscvs to tla changeset 112 X-Git-Url: https://git.sommitrealweird.co.uk/onak.git/commitdiff_plain/7f046503b8b8dcec51c1f7752e87ba0ba0af0631?ds=sidebyside cscvs to tla changeset 112 Author: noodles Date: 2003/10/15 21:15:20 Adding the ability to choose a config file at runtime. --- diff --git a/add.c b/add.c index 2c6abb9..2aee761 100644 --- a/add.c +++ b/add.c @@ -5,7 +5,7 @@ * * Copyright 2002 Project Purple * - * $Id: add.c,v 1.10 2003/06/04 20:57:06 noodles Exp $ + * $Id: add.c,v 1.11 2003/10/15 21:15:20 noodles Exp $ */ #include @@ -56,7 +56,7 @@ int main(int argc, char *argv[]) if (ctx.buffer == NULL) { puts("Error: No keytext to add supplied."); } else { - readconfig(); + readconfig(NULL); initlogthing("add", config.logfile); dearmor_openpgp_stream(buffer_fetchchar, &ctx, diff --git a/gpgwww.c b/gpgwww.c index 05cfc00..6f8cbdd 100644 --- a/gpgwww.c +++ b/gpgwww.c @@ -5,7 +5,7 @@ * * Copyright 2001-2002 Project Purple. * - * $Id: gpgwww.c,v 1.11 2003/06/08 19:04:31 noodles Exp $ + * $Id: gpgwww.c,v 1.12 2003/10/15 21:15:20 noodles Exp $ */ #include @@ -62,7 +62,7 @@ int main(int argc, char *argv[]) to, from); - readconfig(); + readconfig(NULL); initlogthing("gpgwww", config.logfile); initdb(); inithash(); diff --git a/lookup.c b/lookup.c index 72798ce..c8582b1 100644 --- a/lookup.c +++ b/lookup.c @@ -5,7 +5,7 @@ * * Copyright 2002 Project Purple * - * $Id: lookup.c,v 1.11 2003/10/04 10:21:41 noodles Exp $ + * $Id: lookup.c,v 1.12 2003/10/15 21:15:21 noodles Exp $ */ #include @@ -146,7 +146,7 @@ int main(int argc, char *argv[]) } else if (search == NULL) { puts("Error: No key to search for supplied."); } else { - readconfig(); + readconfig(NULL); initlogthing("lookup", config.logfile); initdb(); switch (op) { diff --git a/maxpath.c b/maxpath.c index 171d6b1..b0d2e9a 100644 --- a/maxpath.c +++ b/maxpath.c @@ -5,7 +5,7 @@ * * Copyright 2001-2002 Project Purple. * - * $Id: maxpath.c,v 1.9 2003/06/04 20:57:10 noodles Exp $ + * $Id: maxpath.c,v 1.10 2003/10/15 21:15:21 noodles Exp $ */ #include @@ -71,7 +71,7 @@ void findmaxpath(unsigned long max) int main(int argc, char *argv[]) { - readconfig(); + readconfig(NULL); initdb(); inithash(); findmaxpath(30); diff --git a/onak-conf.c b/onak-conf.c index bbe26a1..1ed252c 100644 --- a/onak-conf.c +++ b/onak-conf.c @@ -5,7 +5,7 @@ * * Copyright 2002 Project Purple * - * $Id: onak-conf.c,v 1.7 2003/06/04 20:57:11 noodles Exp $ + * $Id: onak-conf.c,v 1.8 2003/10/15 21:15:21 noodles Exp $ */ #include @@ -45,13 +45,17 @@ struct onak_config config = { NULL, /* pg_dbpass */ }; -void readconfig(void) { +void readconfig(const char *configfile) { FILE *conffile; char curline[1024]; int i; curline[1023] = 0; - conffile = fopen(CONFIGFILE, "r"); + if (configfile == NULL) { + conffile = fopen(CONFIGFILE, "r"); + } else { + conffile = fopen(configfile, "r"); + } if (conffile != NULL) { fgets(curline, 1023, conffile); diff --git a/onak-conf.h b/onak-conf.h index 3f39bac..94ffda9 100644 --- a/onak-conf.h +++ b/onak-conf.h @@ -5,7 +5,7 @@ * * Copyright 2002 Project Purple * - * $Id: onak-conf.h,v 1.11 2003/10/11 22:28:23 noodles Exp $ + * $Id: onak-conf.h,v 1.12 2003/10/15 21:15:21 noodles Exp $ */ #ifndef __ONAK_CONF_H_ @@ -65,8 +65,12 @@ extern struct onak_config config; /* * readconfig - read the onak config. + * @configfile - the config file to read. + * + * Read in our config file. If config file is NULL read in the compile + * time default. */ -void readconfig(void); +void readconfig(const char *configfile); /* * cleanupconfig - clean up the config when we're shutting down. diff --git a/onak.c b/onak.c index 2da86c9..7748ed2 100644 --- a/onak.c +++ b/onak.c @@ -7,7 +7,7 @@ * * Copyright 2002 Project Purple * - * $Id: onak.c,v 1.17 2003/09/30 20:40:11 noodles Exp $ + * $Id: onak.c,v 1.18 2003/10/15 21:15:21 noodles Exp $ */ #include @@ -71,6 +71,7 @@ int main(int argc, char *argv[]) struct openpgp_packet_list *packets = NULL; struct openpgp_packet_list *list_end = NULL; struct openpgp_publickey *keys = NULL; + char *configfile = NULL; int rc = EXIT_SUCCESS; int result = 0; char *search = NULL; @@ -83,11 +84,14 @@ int main(int argc, char *argv[]) bool fingerprint = false; int optchar; - while ((optchar = getopt(argc, argv, "bfuv")) != -1 ) { + while ((optchar = getopt(argc, argv, "bc:fuv")) != -1 ) { switch (optchar) { case 'b': binary = true; break; + case 'c': + configfile = strdup(optarg); + break; case 'f': fingerprint = true; break; @@ -101,7 +105,7 @@ int main(int argc, char *argv[]) } } - readconfig(); + readconfig(configfile); initlogthing("onak", config.logfile); if ((argc - optind) < 1) { diff --git a/sixdegrees.c b/sixdegrees.c index 9b13cfb..a21ed0e 100644 --- a/sixdegrees.c +++ b/sixdegrees.c @@ -5,7 +5,7 @@ * * Copyright 2001-2002 Project Purple. * - * $Id: sixdegrees.c,v 1.4 2003/06/04 20:57:12 noodles Exp $ + * $Id: sixdegrees.c,v 1.5 2003/10/15 21:15:21 noodles Exp $ */ #include @@ -126,7 +126,7 @@ int main(int argc, char *argv[]) keyid = strtoll(argv[1], NULL, 16); } - readconfig(); + readconfig(NULL); initdb(); inithash(); sixdegrees(getfullkeyid(keyid)); diff --git a/splitkeys.c b/splitkeys.c index 4f63655..7fe66fa 100644 --- a/splitkeys.c +++ b/splitkeys.c @@ -5,7 +5,7 @@ * * Copyright 2003 Project Purple * - * $Id: splitkeys.c,v 1.3 2003/10/03 23:34:06 noodles Exp $ + * $Id: splitkeys.c,v 1.4 2003/10/15 21:15:21 noodles Exp $ */ #include @@ -42,7 +42,7 @@ int main(int argc, char *argv[]) } } - readconfig(); + readconfig(NULL); initlogthing("splitkeys", config.logfile); do {