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;
27 * Make sure the keys we have and want are in the cache.
29 hash_getkeysigs(have);
30 hash_getkeysigs(want);
32 if ((keyinfoa = findinhash(have)) == NULL) {
33 printf("Couldn't find key 0x%llX.\n", have);
36 if ((keyinfob = findinhash(want)) == NULL) {
37 printf("Couldn't find key 0x%llX.\n", want);
42 * Fill the tree info up.
45 rec = findpath(keyinfoa, keyinfob);
48 printf("%d nodes examined. %ld elements in the hash\n", rec,
50 if (keyinfoa->colour == 0) {
51 printf("Can't find a link from 0x%llX to 0x%llX\n",
55 printf("%d steps from 0x%llX to 0x%llX\n",
56 keyinfoa->colour, have, want);
58 while (curkey != NULL && curkey->keyid != 0) {
59 uid = keyid2uid(curkey->keyid);
60 if (html && uid == NULL) {
61 printf("<a href=\"lookup?op=get&search=%llX\">"
62 "0x%llX</a> ([User id not found])%s)%s\n",
65 (curkey->keyid == want) ? "" :
67 } else if (html && uid != NULL) {
68 printf("<a href=\"lookup?op=get&search=%llX\">"
69 "0x%llX</a> (<a href=\"lookup?op=vindex"
70 "&search=0x%llX\">%s</a>)%s\n",
74 txt2html(keyid2uid(curkey->keyid)),
75 (curkey->keyid == want) ? "" :
78 printf("0x%llX (%s)%s\n",
80 (uid == NULL) ? "[User id not found]" :
82 (curkey->keyid == want) ? "" :
85 curkey = findinhash(curkey->parent);
90 void parsecgistuff(char **cgiparams, uint64_t *from, uint64_t *to)
94 if (cgiparams != NULL) {
96 while (cgiparams[i] != NULL) {
97 if (!strcmp(cgiparams[i], "to")) {
98 *to = strtoul(cgiparams[i+1], NULL, 16);
99 } else if (!strcmp(cgiparams[i], "from")) {
100 *from = strtoul(cgiparams[i+1], NULL, 16);
109 int main(int argc, char *argv[])
111 char **cgiparams = NULL; /* Our CGI parameter block */
112 uint64_t from = 0, to = 0;
114 cgiparams = getcgivars(argc, argv);
116 puts("Content-Type: text/html\n");
119 puts("<TITLE>Experimental PGP key path finder results</TITLE>");
124 parsecgistuff(cgiparams, &from, &to);
126 if (from == 0 || to == 0) {
127 printf("Must pass from & to\n");
132 printf("<P>Looking for path from 0x%llX to 0x%llX</P>\n", from, to);
136 dofindpath(from, to, true);
141 puts("Produced by gpgwww " VERSION ", part of onak. <A HREF=\"mailto:noodles-onak@earth.li\">Jonathan McDowell</A>");