From: Jonathan McDowell Date: Mon, 31 May 2004 23:48:13 +0000 (+0000) Subject: cscvs to tla changeset 117 X-Git-Url: https://git.sommitrealweird.co.uk/onak.git/commitdiff_plain/cd002cef518222c140de94b8817874b072b2d918?ds=sidebyside;hp=7f1c2d9ec737a90d4d216f59ccb8b93f9054c472 cscvs to tla changeset 117 Author: noodles Date: 2004/03/23 12:33:46 Add initial hooks for opening database in read-only mode (eg lookup/gpgwww). --- diff --git a/add.c b/add.c index 2aee761..f90dd88 100644 --- 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 @@ -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) { diff --git a/gpgwww.c b/gpgwww.c index 6f8cbdd..fa8ea4f 100644 --- 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 @@ -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 ea4a789..9088d7d 100644 --- 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__ @@ -18,12 +18,13 @@ /** * 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. diff --git a/keydb_db2.c b/keydb_db2.c index 77a6f8b..b37d480 100644 --- a/keydb_db2.c +++ b/keydb_db2.c @@ -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 @@ -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; diff --git a/keydb_db3.c b/keydb_db3.c index b3441b7..b39c44d 100644 --- a/keydb_db3.c +++ b/keydb_db3.c @@ -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 @@ -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; diff --git a/keydb_file.c b/keydb_file.c index 7426369..f735122 100644 --- a/keydb_file.c +++ b/keydb_file.c @@ -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 @@ -31,7 +31,7 @@ * * This is just a no-op for flat file access. */ -void initdb(void) +void initdb(bool readonly) { } diff --git a/keydb_pg.c b/keydb_pg.c index b424b7f..8b89b71 100644 --- a/keydb_pg.c +++ b/keydb_pg.c @@ -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 @@ -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 dc8c2e8..300f4b8 100644 --- 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 @@ -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. diff --git a/lookup.c b/lookup.c index c8582b1..b824256 100644 --- 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 @@ -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 58e3ca7..f9c7c8e 100644 --- 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(); diff --git a/maxpath.c b/maxpath.c index b0d2e9a..922cc8c 100644 --- 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 @@ -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 7748ed2..0fdb7e4 100644 --- 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 @@ -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); diff --git a/sixdegrees.c b/sixdegrees.c index a21ed0e..f270029 100644 --- a/sixdegrees.c +++ b/sixdegrees.c @@ -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 @@ -127,7 +127,7 @@ int main(int argc, char *argv[]) } readconfig(NULL); - initdb(); + initdb(true); inithash(); sixdegrees(getfullkeyid(keyid)); destroyhash();