]> git.sommitrealweird.co.uk Git - onak.git/blob - maxpath.c
cscvs to tla changeset 11
[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 "stats.h"
17
18 void findmaxpath(unsigned long max)
19 {
20         struct stats_key *from, *to, *tmp;
21         struct ll *curkey;
22         unsigned long distance, loop;
23
24         distance = 0;
25         from = to = tmp = NULL;
26         hash_getkeysigs(0xF1BD4BE45B430367);
27
28         for (loop = 0; (loop < HASHSIZE) && (distance < max); loop++) {
29                 curkey = gethashtableentry(loop);
30                 while (curkey != NULL && distance < max) {
31                         hash_getkeysigs(((struct stats_key *)
32                                         curkey->object)->keyid);
33                         initcolour(false);
34                         tmp = furthestkey((struct stats_key *)
35                                                 curkey->object);
36                         if (tmp->colour > distance) {
37                                 from = (struct stats_key *)curkey->object;
38                                 to = tmp;
39                                 distance = to->colour;
40                                 printf("Current max path (#%ld) is from %llX to %llX (%ld steps)\n", 
41                                                 loop,
42                                                 from->keyid,
43                                                 to->keyid,
44                                                 distance);
45                         }
46                         curkey=curkey->next;
47                 }
48         }
49         printf("Max path is from %llX to %llX (%ld steps)\n",
50                         from->keyid,
51                         to->keyid,
52                         distance);
53         dofindpath(to->keyid, from->keyid, false);
54 }
55
56 int main(int argc, char *argv[])
57 {
58         initdb();
59         inithash();
60         findmaxpath(30);
61         printf("--------\n");
62         findmaxpath(30);
63         destroyhash();
64         cleanupdb();
65         
66         return EXIT_SUCCESS;
67 }