]> git.sommitrealweird.co.uk Git - onak.git/blob - gpgwww.c
75022b86e83b5d74d1312c4fc161fc3968e91d92
[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         initdb();
58         inithash();
59         dofindpath(from, to, true);
60         destroyhash();
61         cleanupdb();
62
63         puts("<HR>");
64         puts("Produced by gpgwww " VERSION ", part of onak. <A HREF=\"mailto:noodles-onak@earth.li\">Jonathan McDowell</A>");
65         end_html();
66
67         return EXIT_SUCCESS;
68 }