2 * gpgwww.c - www interface to path finder.
4 * Jonathan McDowell <noodles@earth.li>
6 * Copyright 2001-2002 Project Purple.
17 #include "onak-conf.h"
20 void dofindpath(uint64_t have, uint64_t want, bool html)
22 struct stats_key *keyinfoa, *keyinfob, *curkey;
26 have = getfullkeyid(have);
27 want = getfullkeyid(want);
30 * Make sure the keys we have and want are in the cache.
32 hash_getkeysigs(have);
33 hash_getkeysigs(want);
35 if ((keyinfoa = findinhash(have)) == NULL) {
36 printf("Couldn't find key 0x%llX.\n", have);
39 if ((keyinfob = findinhash(want)) == NULL) {
40 printf("Couldn't find key 0x%llX.\n", want);
45 * Fill the tree info up.
48 rec = findpath(keyinfoa, keyinfob);
51 printf("%d nodes examined. %ld elements in the hash\n", rec,
53 if (keyinfoa->colour == 0) {
54 printf("Can't find a link from 0x%llX to 0x%llX\n",
58 printf("%d steps from 0x%llX to 0x%llX\n",
59 keyinfoa->colour, have & 0xFFFFFFFF,
62 while (curkey != NULL && curkey->keyid != 0) {
63 uid = keyid2uid(curkey->keyid);
64 if (html && uid == NULL) {
65 printf("<a href=\"lookup?op=get&search=%llX\">"
66 "0x%llX</a> ([User id not found])%s)%s\n",
67 curkey->keyid & 0xFFFFFFFF,
68 curkey->keyid & 0xFFFFFFFF,
69 (curkey->keyid == want) ? "" :
71 } else if (html && uid != NULL) {
72 printf("<a href=\"lookup?op=get&search=%llX\">"
73 "0x%llX</a> (<a href=\"lookup?op=vindex"
74 "&search=0x%llX\">%s</a>)%s\n",
75 curkey->keyid & 0xFFFFFFFF,
76 curkey->keyid & 0xFFFFFFFF,
77 curkey->keyid & 0xFFFFFFFF,
78 txt2html(keyid2uid(curkey->keyid)),
79 (curkey->keyid == want) ? "" :
82 printf("0x%llX (%s)%s\n",
83 curkey->keyid & 0xFFFFFFFF,
84 (uid == NULL) ? "[User id not found]" :
86 (curkey->keyid == want) ? "" :
89 curkey = findinhash(curkey->parent);
94 void parsecgistuff(char **cgiparams, uint64_t *from, uint64_t *to)
98 if (cgiparams != NULL) {
100 while (cgiparams[i] != NULL) {
101 if (!strcmp(cgiparams[i], "to")) {
102 *to = strtoul(cgiparams[i+1], NULL, 16);
103 } else if (!strcmp(cgiparams[i], "from")) {
104 *from = strtoul(cgiparams[i+1], NULL, 16);
113 int main(int argc, char *argv[])
115 char **cgiparams = NULL; /* Our CGI parameter block */
116 uint64_t from = 0, to = 0;
118 cgiparams = getcgivars(argc, argv);
120 puts("Content-Type: text/html\n");
123 puts("<TITLE>Experimental PGP key path finder results</TITLE>");
128 parsecgistuff(cgiparams, &from, &to);
130 if (from == 0 || to == 0) {
131 printf("Must pass from & to\n");
136 printf("<P>Looking for path from 0x%llX to 0x%llX</P>\n", from, to);
140 dofindpath(from, to, true);
145 puts("Produced by gpgwww " VERSION ", part of onak. <A HREF=\"mailto:noodles-onak@earth.li\">Jonathan McDowell</A>");