2 * gpgwww.c - www interface to path finder.
4 * Jonathan McDowell <noodles@earth.li>
6 * Copyright 2001-2002 Project Purple.
19 void dofindpath(uint64_t have, uint64_t want, bool html)
21 struct stats_key *keyinfoa, *keyinfob, *curkey;
26 * Make sure the keys we have and want are in the cache.
28 hash_getkeysigs(have);
29 hash_getkeysigs(want);
31 if ((keyinfoa = findinhash(have)) == NULL) {
32 printf("Couldn't find key 0x%llX.\n", have);
35 if ((keyinfob = findinhash(want)) == NULL) {
36 printf("Couldn't find key 0x%llX.\n", want);
41 * Fill the tree info up.
44 rec = findpath(keyinfoa, keyinfob);
47 printf("%d nodes examined. %ld elements in the hash\n", rec,
49 if (keyinfoa->colour == 0) {
50 printf("Can't find a link from 0x%llX to 0x%llX\n",
54 printf("%d steps from 0x%llX to 0x%llX\n",
55 keyinfoa->colour, have, want);
57 while (curkey != NULL && curkey->keyid != 0) {
58 uid = keyid2uid(curkey->keyid);
59 if (html && uid == NULL) {
60 printf("<a href=\"lookup?op=get&search=%llX\">"
61 "0x%llX</a> ([User id not found])%s)%s\n",
64 (curkey->keyid == want) ? "" :
66 } else if (html && uid != NULL) {
67 printf("<a href=\"lookup?op=get&search=%llX\">"
68 "0x%llX</a> (<a href=\"lookup?op=vindex"
69 "&search=0x%llX\">%s</a>)%s\n",
73 txt2html(keyid2uid(curkey->keyid)),
74 (curkey->keyid == want) ? "" :
77 printf("0x%llX (%s)%s\n",
79 (uid == NULL) ? "[User id not found]" :
81 (curkey->keyid == want) ? "" :
84 curkey = findinhash(curkey->parent);
89 void parsecgistuff(char **cgiparams, uint64_t *from, uint64_t *to)
93 if (cgiparams != NULL) {
95 while (cgiparams[i] != NULL) {
96 if (!strcmp(cgiparams[i], "to")) {
97 *to = strtoul(cgiparams[i+1], NULL, 16);
98 } else if (!strcmp(cgiparams[i], "from")) {
99 *from = strtoul(cgiparams[i+1], NULL, 16);
108 int main(int argc, char *argv[])
110 char **cgiparams = NULL; /* Our CGI parameter block */
111 uint64_t from = 0, to = 0;
113 cgiparams = getcgivars(argc, argv);
115 puts("Content-Type: text/html\n");
118 puts("<TITLE>Experimental PGP key path finder results</TITLE>");
123 parsecgistuff(cgiparams, &from, &to);
125 if (from == 0 || to == 0) {
126 printf("Must pass from & to\n");
131 printf("<P>Looking for path from 0x%llX to 0x%llX</P>\n", from, to);
135 dofindpath(from, to, true);
140 puts("Produced by gpgwww 0.0.1, part of onak. <A HREF=\"mailto:noodles-onak@earth.li\">Jonathan McDowell</A>");