]> git.sommitrealweird.co.uk Git - onak.git/blob - maxpath.c
cscvs to tla changeset 43
[onak.git] / maxpath.c
1 /*
2         gpgstats.c - Program to produce stats on a GPG keyring.
3         Written by Jonathan McDowell <noodles@earth.li>.
4
5         19/02/2000 - Started writing (sort of).
6 */
7
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11
12 #include "stats.h"
13 #include "hash.h"
14 #include "keydb.h"
15 #include "ll.h"
16 #include "onak-conf.h"
17 #include "stats.h"
18
19 void findmaxpath(unsigned long max)
20 {
21         struct stats_key *from, *to, *tmp;
22         struct ll *curkey;
23         unsigned long distance, loop;
24
25         distance = 0;
26         from = to = tmp = NULL;
27         hash_getkeysigs(0xF1BD4BE45B430367);
28
29         for (loop = 0; (loop < HASHSIZE) && (distance < max); loop++) {
30                 curkey = gethashtableentry(loop);
31                 while (curkey != NULL && distance < max) {
32                         hash_getkeysigs(((struct stats_key *)
33                                         curkey->object)->keyid);
34                         initcolour(false);
35                         tmp = furthestkey((struct stats_key *)
36                                                 curkey->object);
37                         if (tmp->colour > distance) {
38                                 from = (struct stats_key *)curkey->object;
39                                 to = tmp;
40                                 distance = to->colour;
41                                 printf("Current max path (#%ld) is from %llX to %llX (%ld steps)\n", 
42                                                 loop,
43                                                 from->keyid,
44                                                 to->keyid,
45                                                 distance);
46                         }
47                         curkey=curkey->next;
48                 }
49         }
50         printf("Max path is from %llX to %llX (%ld steps)\n",
51                         from->keyid,
52                         to->keyid,
53                         distance);
54         dofindpath(to->keyid, from->keyid, false);
55 }
56
57 int main(int argc, char *argv[])
58 {
59         readconfig();
60         initdb();
61         inithash();
62         findmaxpath(30);
63         printf("--------\n");
64         findmaxpath(30);
65         destroyhash();
66         cleanupdb();
67         cleanupconfig();
68         
69         return EXIT_SUCCESS;
70 }