2 * sixdegrees.c - List the size of the six degrees of trust away from a key.
4 * Jonathan McDowell <noodles@earth.li>
6 * Copyright 2001-2002 Project Purple.
14 #include "keystructs.h"
16 #include "onak-conf.h"
19 unsigned long countdegree(struct stats_key *have, int maxdegree)
21 unsigned long count = 0, curdegree = 0;
22 struct ll *curll, *nextll, *sigll, *tmp;
27 curll = lladd(NULL, have);
29 while (curll != NULL && curdegree <= maxdegree) {
30 sigll = cached_getkeysigs(((struct stats_key *)
31 curll->object)->keyid);
32 while (sigll != NULL) {
33 if (((struct stats_key *) sigll->object)->colour==0) {
34 /* We've never seen it. Count it, mark it and
35 explore its subtree */
37 ((struct stats_key *)sigll->object)->colour =
39 ((struct stats_key *)sigll->object)->parent =
41 curll->object)->keyid;
42 nextll=lladd(nextll, sigll->object);
67 void sixdegrees(uint64_t keyid)
69 struct stats_key *keyinfo;
74 cached_getkeysigs(keyid);
76 if ((keyinfo = findinhash(keyid)) == NULL) {
77 printf("Couldn't find key 0x%llX.\n", keyid);
81 uid = keyid2uid(keyinfo->keyid);
82 printf("Six degrees for 0x%llX (%s):\n", keyinfo->keyid, uid);
86 puts("\t\tSigned by");
87 for (loop = 1; loop < 7; loop++) {
89 degree = countdegree(keyinfo, loop);
90 printf("Degree %d:\t%8ld\n", loop, degree);
92 * TODO: Used to have keys we signed as well but this takes a
93 * lot of resource and isn't quite appropriate for something
94 * intended to be run on the fly. Given this isn't a CGI at
95 * present perhaps should be readded.
100 int main(int argc, char *argv[])
102 uint64_t keyid = 0x5B430367;
105 keyid = strtoll(argv[1], NULL, 16);