]> git.sommitrealweird.co.uk Git - onak.git/blob - gpgwww.c
cscvs to tla changeset 116
[onak.git] / gpgwww.c
1 /*
2  * gpgwww.c - www interface to path finder.
3  * 
4  * Jonathan McDowell <noodles@earth.li>
5  *
6  * Copyright 2001-2002 Project Purple.
7  *
8  * $Id: gpgwww.c,v 1.12 2003/10/15 21:15:20 noodles Exp $
9  */
10
11 #include <inttypes.h>
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <string.h>
15
16 #include "getcgi.h"
17 #include "hash.h"
18 #include "keydb.h"
19 #include "log.h"
20 #include "onak-conf.h"
21 #include "stats.h"
22
23 void parsecgistuff(char **cgiparams, uint64_t *from, uint64_t *to)
24 {
25         int i = 0;
26
27         if (cgiparams != NULL) {
28                 i = 0;
29                 while (cgiparams[i] != NULL) {
30                         if (!strcmp(cgiparams[i], "to")) {
31                                 *to = strtoul(cgiparams[i+1], NULL, 16);
32                         } else if (!strcmp(cgiparams[i], "from")) {
33                                 *from = strtoul(cgiparams[i+1], NULL, 16);
34                         }
35                         i += 2;
36                 }
37         }
38
39         return;
40 }
41
42 int main(int argc, char *argv[])
43 {
44         char **cgiparams = NULL;        /* Our CGI parameter block */
45         uint64_t from = 0, to = 0;
46
47         cgiparams = getcgivars(argc, argv);
48
49         start_html("Experimental PGP key path finder results");
50
51         parsecgistuff(cgiparams, &from, &to);
52
53         if (from == 0 || to == 0) {
54                 printf("Must pass from & to\n");
55                 puts("</HTML>");
56                 exit(1);
57         }
58
59         printf("<P>Looking for path from 0x%llX to 0x%llX.\n", from, to);
60         printf("<A HREF=\"gpgwww?from=0x%08llX&to=0x%08llX\">"
61                         "Find reverse path</A></P>\n",
62                         to,
63                         from);
64
65         readconfig(NULL);
66         initlogthing("gpgwww", config.logfile);
67         initdb();
68         inithash();
69         dofindpath(from, to, true, 3);
70         destroyhash();
71         cleanupdb();
72         cleanuplogthing();
73         cleanupconfig();
74
75         puts("<HR>");
76         puts("Produced by gpgwww " VERSION ", part of onak. "
77                 "<A HREF=\"mailto:noodles-onak@earth.li\">"
78                 "Jonathan McDowell</A>");
79         end_html();
80
81         cleanupcgi(cgiparams);
82         cgiparams = NULL;
83
84         return EXIT_SUCCESS;
85 }