]> git.sommitrealweird.co.uk Git - onak.git/blob - gpgwww.c
cscvs to tla changeset 67
[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</P>\n", from, to);
58         readconfig();
59         initlogthing("gpgwww", config.logfile);
60         initdb();
61         inithash();
62         dofindpath(from, to, true);
63         destroyhash();
64         cleanupdb();
65         cleanuplogthing();
66         cleanupconfig();
67
68         puts("<HR>");
69         puts("Produced by gpgwww " VERSION ", part of onak. "
70                 "<A HREF=\"mailto:noodles-onak@earth.li\">"
71                 "Jonathan McDowell</A>");
72         end_html();
73
74         cleanupcgi(cgiparams);
75         cgiparams = NULL;
76
77         return EXIT_SUCCESS;
78 }