]> the.earth.li Git - onak.git/blob - stats.h
Run autoreconf -i to produce configure script for Travis CI builds
[onak.git] / stats.h
1 /*
2  * stats.c - various routines to do stats on the key graph
3  *
4  * Copyright 2000-2004,2007-2009 Jonathan McDowell <noodles@earth.li>
5  *
6  * This program is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the Free
8  * Software Foundation; version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along with
16  * this program; if not, write to the Free Software Foundation, Inc., 51
17  * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19
20 /* MOSTSIGNED
21 SIGNSMOST
22 SIGNS <key>
23 SIGS <key>
24 SIXDEGREES <keyid>
25 MAXPATH
26
27 key_getsigs - get the sigs for a key.
28 key_getsigns - get the keys a key signs. */
29
30 #ifndef __STATS_H__
31 #define __STATS_H__
32
33 #include <inttypes.h>
34 #include <stdbool.h>
35
36 #include "keydb.h"
37 #include "ll.h"
38
39 /**
40  * @brief Holds key details suitable for doing stats on.
41  */
42 struct stats_key {
43         /** The keyid. */
44         uint64_t keyid;
45         /** Used for marking during DFS/BFS. */
46         int colour;
47         /** The key that lead us to this one for DFS/BFS. */
48         uint64_t parent;
49         /** A linked list of the signatures on this key. */
50         struct ll *sigs;
51         /** A linked list of the keys this key signs. */
52         struct ll *signs;
53         /** A bool indicating if we've initialized the sigs element yet. */
54         bool gotsigs;
55         /** If we shouldn't consider the key in calculations. */
56         bool disabled;
57         /** If the key is revoked (and shouldn't be considered). */
58         bool revoked;
59 };
60
61 /**
62  *      initcolour - Clear the key graph ready for use.
63  *      @parent: Do we want to clear the parent pointers too?
64  *
65  *      Clears the parent and colour information on all elements in the key
66  *      graph.
67  */
68 void initcolour(bool parent);
69
70 /**
71  *      findpath - Given 2 keys finds a path between them.
72  *      @have: The key we have.
73  *      @want: The key we want to get to.
74  *
75  *      This does a breadth first search on the key tree, starting with the
76  *      key we have. It returns as soon as a path is found or when we run out
77  *      of keys; whichever comes sooner.
78  */
79 unsigned long findpath(struct onak_dbctx *dbctx,
80                 struct stats_key *have, struct stats_key *want);
81
82 /**
83  *      dofindpath - Given 2 keys displays a path between them.
84  *      @have: The key we have.
85  *      @want: The key we want to get to.
86  *      @html: Should we output in html.
87  *      @count: How many paths we should look for at most.
88  *
89  *      This does a breadth first search on the key tree, starting with the
90  *      key we have. It returns as soon as a path is found or when we run out
91  *      of keys; whichever comes sooner.
92  */
93 void dofindpath(struct onak_dbctx *dbctx,
94                 uint64_t have, uint64_t want, bool html, int count);
95
96 struct stats_key *furthestkey(struct onak_dbctx *dbctx, struct stats_key *have);
97
98 #endif /* __STATS_H__ */