cscvs to tla changeset 112
authorJonathan McDowell <noodles@earth.li>
Mon, 31 May 2004 23:48:08 +0000 (23:48 +0000)
committerJonathan McDowell <noodles@earth.li>
Mon, 31 May 2004 23:48:08 +0000 (23:48 +0000)
Author: noodles
Date: 2003/10/15 21:15:20
Adding the ability to choose a config file at runtime.

add.c
gpgwww.c
lookup.c
maxpath.c
onak-conf.c
onak-conf.h
onak.c
sixdegrees.c
splitkeys.c

diff --git a/add.c b/add.c
index 2c6abb93af54ba35aa13ecf223e35a54a0a61a38..2aee761884fe6ae786cc2f9f20a76fc91f3fe27f 100644 (file)
--- 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 <errno.h>
@@ -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,
index 05cfc00097833646cc1ac8c54d31b7c9c23bf757..6f8cbdd36df0486cfc8134176c8642511a25a6da 100644 (file)
--- 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 <inttypes.h>
@@ -62,7 +62,7 @@ int main(int argc, char *argv[])
                        to,
                        from);
 
-       readconfig();
+       readconfig(NULL);
        initlogthing("gpgwww", config.logfile);
        initdb();
        inithash();
index 72798ceb103108f2541ec546ea7b87e0ae7cfd65..c8582b1cc3ddb92495792430a6f95470d7882c68 100644 (file)
--- 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 <inttypes.h>
@@ -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) {
index 171d6b1a4793c63065967b9502cc820f67c3242c..b0d2e9a9c6a716a2f4f6368ee4c1e6f1b9179911 100644 (file)
--- 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 <stdio.h>
@@ -71,7 +71,7 @@ void findmaxpath(unsigned long max)
 
 int main(int argc, char *argv[])
 {
-       readconfig();
+       readconfig(NULL);
        initdb();
        inithash();
        findmaxpath(30);
index bbe26a1470f91cde0ce631312225c93f551d86f9..1ed252cd396c0c40d283f28a9f4653f18e7c7492 100644 (file)
@@ -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 <ctype.h>
@@ -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);
 
index 3f39bac94812b54fee712af2749fd3e352c98e43..94ffda906ff8c91074142fad45962a058087a89d 100644 (file)
@@ -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 2da86c915cae8708a192c7f0668cda6bc6eb6076..7748ed2c674657e25b9c4f26e14e9ca2a2664cb4 100644 (file)
--- 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 <stdio.h>
@@ -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) {
index 9b13cfbca08cafa38ac094aeec1ee9897fcb4694..a21ed0ef9c0f1bd84309e49f0c47202eb2d27d56 100644 (file)
@@ -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 <stdio.h>
@@ -126,7 +126,7 @@ int main(int argc, char *argv[])
                keyid = strtoll(argv[1], NULL, 16);
        }
 
-       readconfig();
+       readconfig(NULL);
        initdb();
        inithash();
        sixdegrees(getfullkeyid(keyid));
index 4f6365596a2c3c1a692f3155adf5c61c5261f0da..7fe66fa9e9557f4c856909a2723bb9a5ef48db8e 100644 (file)
@@ -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 <fcntl.h>
@@ -42,7 +42,7 @@ int main(int argc, char *argv[])
                }
        }
 
-       readconfig();
+       readconfig(NULL);
        initlogthing("splitkeys", config.logfile);
 
        do {