cscvs to tla changeset 39
[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
9 // #include <stdint.h>
10 #include <inttypes.h>
11 #include <stdio.h>
12 #include <stdlib.h>
13
14 #include "getcgi.h"
15 #include "hash.h"
16 #include "keydb.h"
17 #include "onak-conf.h"
18 #include "stats.h"
19
20 void parsecgistuff(char **cgiparams, uint64_t *from, uint64_t *to)
21 {
22         int i = 0;
23
24         if (cgiparams != NULL) {
25                 i = 0;
26                 while (cgiparams[i] != NULL) {
27                         if (!strcmp(cgiparams[i], "to")) {
28                                 *to = strtoul(cgiparams[i+1], NULL, 16);
29                         } else if (!strcmp(cgiparams[i], "from")) {
30                                 *from = strtoul(cgiparams[i+1], NULL, 16);
31                         }
32                         i += 2;
33                 }
34         }
35
36         return;
37 }
38
39 int main(int argc, char *argv[])
40 {
41         char **cgiparams = NULL;        /* Our CGI parameter block */
42         uint64_t from = 0, to = 0;
43
44         cgiparams = getcgivars(argc, argv);
45
46         start_html("Experimental PGP key path finder results");
47
48         parsecgistuff(cgiparams, &from, &to);
49
50         if (from == 0 || to == 0) {
51                 printf("Must pass from & to\n");
52                 puts("</HTML>");
53                 exit(1);
54         }
55
56         printf("<P>Looking for path from 0x%llX to 0x%llX</P>\n", from, to);
57         readconfig();
58         initdb();
59         inithash();
60         dofindpath(from, to, true);
61         destroyhash();
62         cleanupdb();
63         cleanupconfig();
64
65         puts("<HR>");
66         puts("Produced by gpgwww " VERSION ", part of onak. "
67                 "<A HREF=\"mailto:noodles-onak@earth.li\">"
68                 "Jonathan McDowell</A>");
69         end_html();
70
71         cleanupcgi(cgiparams);
72         cgiparams = NULL;
73
74         return EXIT_SUCCESS;
75 }