cscvs to tla changeset 1
[onak.git] / stats.h
1 /*
2  * stats.c - various routines to do stats on the key graph
3  *
4  * Jonathan McDowell <noodles@earth.li>
5  *
6  * Copyright 2002 Project Purple
7  */
8
9 /* MOSTSIGNED
10 SIGNSMOST
11 SIGNS <key>
12 SIGS <key>
13 SIXDEGREES <keyid>
14 MAXPATH
15
16 key_getsigs - get the sigs for a key.
17 key_getsigns - get the keys a key signs. */
18
19 #ifndef __STATS_H__
20 #define __STATS_H__
21
22 #include <stdbool.h>
23 // #include <stdint.h>
24 #include <inttypes.h>
25
26 #include "ll.h"
27
28 /**
29  *      struct stats_key - holds key details suitable for doing stats on.
30  *      @keyid: The keyid.
31  *      @colour: Used for marking during DFS/BFS.
32  *      @parent: The key that lead us to this one for DFS/BFS.
33  *      @sigs: A linked list of the signatures on this key.
34  *      @gotsigs: A bool indicating if we've initialized the sigs element yet.
35  */
36 struct stats_key {
37         uint64_t keyid;
38         int colour;
39         uint64_t parent;
40         struct ll *sigs;
41         bool gotsigs;
42 };
43
44 /**
45  *      initcolour - Clear the key graph ready for use.
46  *      @parent: Do we want to clear the parent pointers too?
47  *
48  *      Clears the parent and colour information on all elements in the key
49  *      graph.
50  */
51 void initcolour(bool parent);
52
53 /**
54  *      findpath - Given 2 keys finds a path between them.
55  *      @have: The key we have.
56  *      @want: The key we want to get to.
57  *
58  *      This does a breadth first search on the key tree, starting with the
59  *      key we have. It returns as soon as a path is found or when we run out
60  *      of keys; whichever comes sooner.
61  */
62 unsigned long findpath(struct stats_key *have, struct stats_key *want);
63
64
65 struct stats_key *furthestkey(struct stats_key *have);
66
67 #endif /* __STATS_H__ */