]> git.sommitrealweird.co.uk Git - onak.git/blob - maxpath.c
37142811797279165c67bdf9efe3a68991716609
[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         printf("In findmaxpath\n");
25         distance = 0;
26         from = to = tmp = NULL;
27         hash_getkeysigs(0x5B430367);
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 }
55
56 int main(int argc, char *argv[])
57 {
58         initdb();
59         inithash();
60         findmaxpath(30);
61         printf("--------\n");
62         findmaxpath(30);
63         cleanupdb();
64         
65         return EXIT_SUCCESS;
66 }