/*
* 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>
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.
*
* it definitely needs updated.
*/
if (update) {
- pg_delete_key(get_keyid(publickey), true);
+ pg_delete_key(keyid, true);
}
next = publickey->next;
snprintf(statement, 1023,
"INSERT INTO onak_keys (keyid, keydata) VALUES "
"('%" PRIX64 "', '%d')",
- get_keyid(publickey),
+ keyid,
key_oid);
result = PQexec(dbconn, statement);
"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);
"INSERT INTO onak_sigs (signer, signee) "
"VALUES ('%" PRIX64 "', '%" PRIX64 "')",
sig_keyid(packets->packet),
- get_keyid(publickey));
+ keyid);
result = PQexec(dbconn, statement);
PQclear(result);
}