Update Debian Vcs-* fields to point to git repository
[onak.git] / keydb_pg.c
index 0771317e747ab1c65a22e5ef71ddb2e7a936a903..1ec0a1a570e16fb0c71397a7055b2207dc213944 100644 (file)
@@ -1,9 +1,20 @@
 /*
  * keydb_pg.c - Routines to store and fetch keys in a PostGres database.
  *
- * Jonathan McDowell <noodles@earth.li>
+ * Copyright 2002-2004 Jonathan McDowell <noodles@earth.li>
  *
- * Copyright 2002-2004 Project Purple
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
 #include <postgresql/libpq-fe.h>
@@ -358,12 +369,15 @@ static int pg_store_key(struct openpgp_publickey *publickey, bool intrans,
        char *primary = NULL;
        char *safeuid = NULL;
        int i;
+       uint64_t keyid;
 
        if (!intrans) {
                result = PQexec(dbconn, "BEGIN");
                PQclear(result);
        }
 
+       get_keyid(publickey, &keyid);
+
        /*
         * Delete the key if we already have it.
         *
@@ -373,7 +387,7 @@ static int pg_store_key(struct openpgp_publickey *publickey, bool intrans,
         * it definitely needs updated.
         */
        if (update) {
-               pg_delete_key(get_keyid(publickey), true);
+               pg_delete_key(keyid, true);
        }
 
        next = publickey->next;
@@ -395,7 +409,7 @@ static int pg_store_key(struct openpgp_publickey *publickey, bool intrans,
        snprintf(statement, 1023, 
                        "INSERT INTO onak_keys (keyid, keydata) VALUES "
                        "('%" PRIX64 "', '%d')", 
-                       get_keyid(publickey),
+                       keyid,
                        key_oid);
        result = PQexec(dbconn, statement);
 
@@ -418,7 +432,7 @@ static int pg_store_key(struct openpgp_publickey *publickey, bool intrans,
                                        "INSERT INTO onak_uids "
                                        "(keyid, uid, pri) "
                                        "VALUES ('%" PRIX64 "', '%s', '%c')",
-                                       get_keyid(publickey),
+                                       keyid,
                                        safeuid,
                                        (uids[i] == primary) ? 't' : 'f');
                                result = PQexec(dbconn, statement);
@@ -453,7 +467,7 @@ static int pg_store_key(struct openpgp_publickey *publickey, bool intrans,
                                "INSERT INTO onak_sigs (signer, signee) "
                                "VALUES ('%" PRIX64 "', '%" PRIX64 "')",
                                sig_keyid(packets->packet),
-                               get_keyid(publickey));
+                               keyid);
                        result = PQexec(dbconn, statement);
                        PQclear(result);
                }