+/**
+ * getkeysigs - Gets a linked list of the signatures on a key.
+ * @keyid: The keyid to get the sigs for.
+ *
+ * This function gets the list of signatures on a key. Used for key
+ * indexing and doing stats bits.
+ */
+struct ll *getkeysigs(uint64_t keyid)
+{
+ struct ll *sigs = NULL;
+ PGresult *result = NULL;
+ uint64_t signer;
+ char statement[1024];
+ int i = 0;
+ int numsigs = 0;
+ bool intrans = false;
+
+ if (!intrans) {
+ result = PQexec(dbconn, "BEGIN");
+ PQclear(result);
+ }
+
+ snprintf(statement, 1023,
+ "SELECT signer FROM onak_sigs WHERE signee = '%llX'",
+ keyid);
+ result = PQexec(dbconn, statement);
+
+ if (PQresultStatus(result) == PGRES_TUPLES_OK) {
+ numsigs = PQntuples(result);
+ for (i = 0; i < numsigs; i++) {
+ signer = strtol(PQgetvalue(result, i, 0), NULL, 16);
+ sigs = lladd(sigs, createandaddtohash(signer));
+ }
+ } else if (PQresultStatus(result) != PGRES_TUPLES_OK) {
+ fprintf(stderr, "Problem retrieving key from DB.\n");
+ }
+
+ PQclear(result);
+
+ if (!intrans) {
+ result = PQexec(dbconn, "COMMIT");
+ PQclear(result);
+ }
+ return sigs;
+}
+