glitch in the license text detected by hyazinthe, thank you!
[oweals/gnunet.git] / src / include / gnunet_peer_lib.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2006, 2009 GNUnet e.V.
4
5      GNUnet is free software: you can redistribute it and/or modify it
6      under the terms of the GNU Affero General Public License as published
7      by the Free Software Foundation, either version 3 of the License,
8      or (at your option) any later version.
9
10      GNUnet is distributed in the hope that it will be useful, but
11      WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13      Affero General Public License for more details.
14 */
15
16 /**
17  * @author Christian Grothoff
18  *
19  * @file
20  * Helper library for interning of peer identifiers
21  *
22  * @defgroup peer  Peer library
23  * Helper library for interning of peer identifiers
24  * @{
25  */
26
27 #ifndef GNUNET_PEER_LIB_H
28 #define GNUNET_PEER_LIB_H
29
30 #include "gnunet_util_lib.h"
31
32 #ifdef __cplusplus
33 extern "C"
34 {
35 #if 0                           /* keep Emacsens' auto-indent happy */
36 }
37 #endif
38 #endif
39
40 /**
41  * A GNUNET_PEER_Id is simply a shorter version of a "struct
42  * GNUNET_PeerIdentifier" that can be used inside of a GNUnet peer to
43  * save memory when the same identifier needs to be used over and over
44  * again.
45  */
46 typedef unsigned int GNUNET_PEER_Id;
47
48
49 /**
50  * Search for a peer identity. The reference counter is not changed.
51  *
52  * @param pid identity to find
53  * @return the interned identity or 0.
54  */
55 GNUNET_PEER_Id
56 GNUNET_PEER_search (const struct GNUNET_PeerIdentity *pid);
57
58
59 /**
60  * Intern an peer identity.  If the identity is already known, its
61  * reference counter will be increased by one.
62  *
63  * @param pid identity to intern
64  * @return the interned identity.
65  */
66 GNUNET_PEER_Id
67 GNUNET_PEER_intern (const struct GNUNET_PeerIdentity *pid);
68
69
70 /**
71  * Change the reference counter of an interned PID.
72  *
73  * @param id identity to change the RC of
74  * @param delta how much to change the RC
75  */
76 void
77 GNUNET_PEER_change_rc (GNUNET_PEER_Id id, int delta);
78
79
80 /**
81  * Decrement multiple RCs of peer identities by one.
82  *
83  * @param ids array of PIDs to decrement the RCs of
84  * @param count size of the @a ids array
85  */
86 void
87 GNUNET_PEER_decrement_rcs (const GNUNET_PEER_Id *ids,
88                            unsigned int count);
89
90
91 /**
92  * Convert an interned PID to a normal peer identity.
93  *
94  * @param id interned PID to convert
95  * @param pid where to write the normal peer identity
96  */
97 void
98 GNUNET_PEER_resolve (GNUNET_PEER_Id id,
99                      struct GNUNET_PeerIdentity *pid);
100
101
102 /**
103  * Convert an interned PID to a normal peer identity.
104  *
105  * @param id interned PID to convert
106  * @return pointer to peer identity, valid as long @a id is valid
107  */
108 const struct GNUNET_PeerIdentity *
109 GNUNET_PEER_resolve2 (GNUNET_PEER_Id id);
110
111
112 #if 0                           /* keep Emacsens' auto-indent happy */
113 {
114 #endif
115 #ifdef __cplusplus
116 }
117 #endif
118
119 /* ifndef GNUNET_PEER_LIB_H */
120 #endif
121
122 /** @} */  /* end of group */
123
124 /* end of gnunet_peer_lib.h */