]> the.earth.li Git - onak.git/blob - stats.h
Fix compilation with later versions of Nettle
[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, see <https://www.gnu.org/licenses/>.
17  */
18
19 /* MOSTSIGNED
20 SIGNSMOST
21 SIGNS <key>
22 SIGS <key>
23 SIXDEGREES <keyid>
24 MAXPATH
25
26 key_getsigs - get the sigs for a key.
27 key_getsigns - get the keys a key signs. */
28
29 #ifndef __STATS_H__
30 #define __STATS_H__
31
32 #include <inttypes.h>
33 #include <stdbool.h>
34
35 #include "keydb.h"
36 #include "ll.h"
37
38 /**
39  * @brief Holds key details suitable for doing stats on.
40  */
41 struct stats_key {
42         /** The keyid. */
43         uint64_t keyid;
44         /** Used for marking during DFS/BFS. */
45         int colour;
46         /** The key that lead us to this one for DFS/BFS. */
47         uint64_t parent;
48         /** A linked list of the signatures on this key. */
49         struct ll *sigs;
50         /** A linked list of the keys this key signs. */
51         struct ll *signs;
52         /** A bool indicating if we've initialized the sigs element yet. */
53         bool gotsigs;
54         /** If we shouldn't consider the key in calculations. */
55         bool disabled;
56         /** If the key is revoked (and shouldn't be considered). */
57         bool revoked;
58 };
59
60 /**
61  *      initcolour - Clear the key graph ready for use.
62  *      @parent: Do we want to clear the parent pointers too?
63  *
64  *      Clears the parent and colour information on all elements in the key
65  *      graph.
66  */
67 void initcolour(bool parent);
68
69 /**
70  *      findpath - Given 2 keys finds a path between them.
71  *      @have: The key we have.
72  *      @want: The key we want to get to.
73  *
74  *      This does a breadth first search on the key tree, starting with the
75  *      key we have. It returns as soon as a path is found or when we run out
76  *      of keys; whichever comes sooner.
77  */
78 unsigned long findpath(struct onak_dbctx *dbctx,
79                 struct stats_key *have, struct stats_key *want);
80
81 /**
82  *      dofindpath - Given 2 keys displays a path between them.
83  *      @have: The key we have.
84  *      @want: The key we want to get to.
85  *      @html: Should we output in html.
86  *      @count: How many paths we should look for at most.
87  *
88  *      This does a breadth first search on the key tree, starting with the
89  *      key we have. It returns as soon as a path is found or when we run out
90  *      of keys; whichever comes sooner.
91  */
92 void dofindpath(struct onak_dbctx *dbctx,
93                 uint64_t have, uint64_t want, bool html, int count);
94
95 struct stats_key *furthestkey(struct onak_dbctx *dbctx, struct stats_key *have);
96
97 #endif /* __STATS_H__ */