cscvs to tla changeset 117
authorJonathan McDowell <noodles@earth.li>
Mon, 31 May 2004 23:48:13 +0000 (23:48 +0000)
committerJonathan McDowell <noodles@earth.li>
Mon, 31 May 2004 23:48:13 +0000 (23:48 +0000)
Author: noodles
Date: 2004/03/23 12:33:46
Add initial hooks for opening database in read-only mode (eg lookup/gpgwww).

13 files changed:
add.c
gpgwww.c
keydb.h
keydb_db2.c
keydb_db3.c
keydb_file.c
keydb_pg.c
log.c
lookup.c
main.c
maxpath.c
onak.c
sixdegrees.c

diff --git a/add.c b/add.c
index 2aee761884fe6ae786cc2f9f20a76fc91f3fe27f..f90dd88be53a10d7e809ea7e2ecb30fe71f4a298 100644 (file)
--- a/add.c
+++ b/add.c
@@ -5,7 +5,7 @@
  *
  * Copyright 2002 Project Purple
  *
- * $Id: add.c,v 1.11 2003/10/15 21:15:20 noodles Exp $
+ * $Id: add.c,v 1.12 2004/03/23 12:33:46 noodles Exp $
  */
 
 #include <errno.h>
@@ -63,7 +63,7 @@ int main(int argc, char *argv[])
                                        &packets);
                if (packets != NULL) {
                        parse_keys(packets, &keys);
-                       initdb();
+                       initdb(false);
                        printf("Got %d new keys.\n",
                                        update_keys(&keys));
                        if (keys != NULL) {
index 6f8cbdd36df0486cfc8134176c8642511a25a6da..fa8ea4f952eb8024003a547c9d6aa0a896f2f391 100644 (file)
--- a/gpgwww.c
+++ b/gpgwww.c
@@ -5,7 +5,7 @@
  *
  * Copyright 2001-2002 Project Purple.
  *
- * $Id: gpgwww.c,v 1.12 2003/10/15 21:15:20 noodles Exp $
+ * $Id: gpgwww.c,v 1.13 2004/03/23 12:33:46 noodles Exp $
  */
 
 #include <inttypes.h>
@@ -64,7 +64,7 @@ int main(int argc, char *argv[])
 
        readconfig(NULL);
        initlogthing("gpgwww", config.logfile);
-       initdb();
+       initdb(true);
        inithash();
        dofindpath(from, to, true, 3);
        destroyhash();
diff --git a/keydb.h b/keydb.h
index ea4a78999ce4b217f150ad22288f7c17ef27d29f..9088d7d9df5fdb674ff1c0773ef550d8d01ec824 100644 (file)
--- a/keydb.h
+++ b/keydb.h
@@ -5,7 +5,7 @@
  *
  * Copyright 2002 Project Purple
  *
- * $Id: keydb.h,v 1.9 2003/06/08 21:11:00 noodles Exp $
+ * $Id: keydb.h,v 1.10 2004/03/23 12:33:46 noodles Exp $
  */
 
 #ifndef __KEYDB_H__
 
 /**
  *     initdb - Initialize the key database.
+ *     @readonly: If we'll only be reading the DB, not writing to it.
  *
  *     This function should be called before any of the other functions in
  *     this file are called in order to allow the DB to be initialized ready
  *     for access.
  */
-void initdb(void);
+void initdb(bool readonly);
 
 /**
  *     cleanupdb - De-initialize the key database.
index 77a6f8b4b7c5471e2b63b4ca1da00fb22434e5fe..b37d4807e73a31dc8f6111c0ca02278101c1f236 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Copyright 2002 Project Purple
  *
- * $Id: keydb_db2.c,v 1.10 2003/09/30 20:40:10 noodles Exp $
+ * $Id: keydb_db2.c,v 1.11 2004/03/23 12:33:46 noodles Exp $
  */
 
 #include <sys/types.h>
@@ -65,7 +65,7 @@ DB *keydb(DBT *key)
  *     this file are called in order to allow the DB to be initialized ready
  *     for access.
  */
-void initdb(void)
+void initdb(bool readonly)
 {
        DB_INFO keydbinfo;
        int i;
index b3441b7edaa21db571f594f9a010de58b50ffca9..b39c44dfb63c17928e76c75ae62d3bff717238a5 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Copyright 2002 Project Purple
  *
- * $Id: keydb_db3.c,v 1.22 2003/10/10 16:57:27 noodles Exp $
+ * $Id: keydb_db3.c,v 1.23 2004/03/23 12:33:46 noodles Exp $
  */
 
 #include <assert.h>
@@ -122,7 +122,7 @@ struct ll *makewordlist(struct ll *wordlist, char *word)
  *     this file are called in order to allow the DB to be initialized ready
  *     for access.
  */
-void initdb(void)
+void initdb(bool readonly)
 {
        char  buf[1024];
        FILE *numdb = NULL;
index 742636992c5945d68c20769402d7eca5aa899cc1..f7351225622e65074f434a77527b2cd890ac27c3 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Copyright 2002 Project Purple
  *
- * $Id: keydb_file.c,v 1.10 2003/09/30 20:40:10 noodles Exp $
+ * $Id: keydb_file.c,v 1.11 2004/03/23 12:33:46 noodles Exp $
  */
 
 #include <sys/types.h>
@@ -31,7 +31,7 @@
  *
  *     This is just a no-op for flat file access.
  */
-void initdb(void)
+void initdb(bool readonly)
 {
 }
 
index b424b7f9814fd4b170c7ccf0ec95f2ec50303506..8b89b7182115f296af3c37ca1bec7482c5a4d1a7 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Copyright 2002 Project Purple
  *
- * $Id: keydb_pg.c,v 1.13 2003/09/30 20:40:11 noodles Exp $
+ * $Id: keydb_pg.c,v 1.14 2004/03/23 12:33:47 noodles Exp $
  */
 
 #include <postgresql/libpq-fe.h>
@@ -60,7 +60,7 @@ static int keydb_putchar(void *fd, size_t count, unsigned char *c)
  *     this file are called in order to allow the DB to be initialized ready
  *     for access.
  */
-void initdb(void)
+void initdb(bool readonly)
 {
        dbconn = PQsetdbLogin(config.pg_dbhost, // host
                        NULL, // port
diff --git a/log.c b/log.c
index dc8c2e8d6198c418f92fab0d75d182044ec06b30..300f4b8e066cd1269f89466509d171116c0f5841 100644 (file)
--- a/log.c
+++ b/log.c
@@ -5,7 +5,7 @@
  *
  * Copyright 2003 Project Purple
  *
- * $Id: log.c,v 1.4 2003/06/04 20:57:10 noodles Exp $
+ * $Id: log.c,v 1.5 2004/03/23 12:33:47 noodles Exp $
  */
 
 #include <stdarg.h>
@@ -24,7 +24,7 @@
  *     logs - if we're asked to log something below this level we won't output
  *     it.
  */
-static loglevels logthres = LOGTHING_DEBUG;
+static loglevels logthres = LOGTHING_NOTICE;
 
 /*
  *     logappname - the name of the application using us.
index c8582b1cc3ddb92495792430a6f95470d7882c68..b8242563d8b62d9b28b50631bd13cb27c785c5dc 100644 (file)
--- a/lookup.c
+++ b/lookup.c
@@ -5,7 +5,7 @@
  *
  * Copyright 2002 Project Purple
  *
- * $Id: lookup.c,v 1.12 2003/10/15 21:15:21 noodles Exp $
+ * $Id: lookup.c,v 1.13 2004/03/23 12:33:47 noodles Exp $
  */
 
 #include <inttypes.h>
@@ -148,7 +148,7 @@ int main(int argc, char *argv[])
        } else {
                readconfig(NULL);
                initlogthing("lookup", config.logfile);
-               initdb();
+               initdb(true);
                switch (op) {
                case OP_GET:
                        if (fetch_key(keyid, &publickey, false)) {
diff --git a/main.c b/main.c
index 58e3ca743a44fec7e3362eefffdbaac50b0281e8..f9c7c8ec87967152fa44d9af5214d31028b9c145 100644 (file)
--- a/main.c
+++ b/main.c
@@ -37,7 +37,7 @@ int main(int argc, char *argv[])
 
        key_index(keys, true, false, false);
 
-       initdb();
+       initdb(true);
        fetch_key(get_keyid(keys), &newkeys);
        cleanupdb();
 
index b0d2e9a9c6a716a2f4f6368ee4c1e6f1b9179911..922cc8cf65ab94753471b7118ec021dca12b237f 100644 (file)
--- a/maxpath.c
+++ b/maxpath.c
@@ -5,7 +5,7 @@
  *
  * Copyright 2001-2002 Project Purple.
  *
- * $Id: maxpath.c,v 1.10 2003/10/15 21:15:21 noodles Exp $
+ * $Id: maxpath.c,v 1.11 2004/03/23 12:33:47 noodles Exp $
  */
 
 #include <stdio.h>
@@ -72,7 +72,7 @@ void findmaxpath(unsigned long max)
 int main(int argc, char *argv[])
 {
        readconfig(NULL);
-       initdb();
+       initdb(true);
        inithash();
        findmaxpath(30);
        printf("--------\n");
diff --git a/onak.c b/onak.c
index 7748ed2c674657e25b9c4f26e14e9ca2a2664cb4..0fdb7e4bf7510456cd9498422b808cc4e773201b 100644 (file)
--- a/onak.c
+++ b/onak.c
@@ -7,7 +7,7 @@
  * 
  * Copyright 2002 Project Purple
  *
- * $Id: onak.c,v 1.18 2003/10/15 21:15:21 noodles Exp $
+ * $Id: onak.c,v 1.19 2004/03/23 12:33:47 noodles Exp $
  */
 
 #include <stdio.h>
@@ -111,7 +111,7 @@ int main(int argc, char *argv[])
        if ((argc - optind) < 1) {
                usage();
        } else if (!strcmp("dump", argv[optind])) {
-               initdb();
+               initdb(true);
                dumpdb("keydump");
                cleanupdb();
        } else if (!strcmp("add", argv[optind])) {
@@ -130,7 +130,7 @@ int main(int argc, char *argv[])
                        logthing(LOGTHING_INFO, "Finished reading %d keys.",
                                        result);
 
-                       initdb();
+                       initdb(false);
                        logthing(LOGTHING_NOTICE, "Got %d new keys.",
                                        update_keys(&keys));
                        if (keys != NULL && update) {
@@ -166,7 +166,7 @@ int main(int argc, char *argv[])
                                ishex = true;
                        }
                }
-               initdb();
+               initdb(false);
                if (!strcmp("index", argv[optind])) {
                        find_keys(search, keyid, ishex, fingerprint,
                                        false, false);
index a21ed0ef9c0f1bd84309e49f0c47202eb2d27d56..f2700290bdedc1b3bc64fa5f7d5732cb65790546 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Copyright 2001-2002 Project Purple.
  *
- * $Id: sixdegrees.c,v 1.5 2003/10/15 21:15:21 noodles Exp $
+ * $Id: sixdegrees.c,v 1.6 2004/03/23 12:33:47 noodles Exp $
  */
 
 #include <stdio.h>
@@ -127,7 +127,7 @@ int main(int argc, char *argv[])
        }
 
        readconfig(NULL);
-       initdb();
+       initdb(true);
        inithash();
        sixdegrees(getfullkeyid(keyid));
        destroyhash();