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