7a9373cc496d3a7870c84a39384d20ceda1ec213
[oweals/gnunet.git] / src / include / gnunet_pseudonym_lib.h
1 /*
2      This file is part of GNUnet.
3      (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 Christian Grothoff (and other contributing authors)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 2, or (at your
8      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      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20
21 /**
22  * @file include/gnunet_pseudonym_lib.h
23  * @brief functions related to pseudonyms
24  * @author Christian Grothoff
25  */
26
27 #ifndef GNUNET_PSEUDONYM_LIB_H
28 #define GNUNET_PSEUDONYM_LIB_H
29
30 #ifdef __cplusplus
31 extern "C"
32 {
33 #if 0                           /* keep Emacsens' auto-indent happy */
34 }
35 #endif
36 #endif
37
38 #include "gnunet_common.h"
39 #include "gnunet_configuration_lib.h"
40 #include "gnunet_container_lib.h"
41
42 /**
43  * Iterator over all known pseudonyms.
44  *
45  * @param cls closure
46  * @param pseudonym hash code of public key of pseudonym
47  * @param md meta data known about the pseudonym
48  * @param rating the local rating of the pseudonym
49  * @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort
50  */
51 typedef int (*GNUNET_PSEUDONYM_Iterator) (void *cls,
52                                           const GNUNET_HashCode * pseudonym,
53                                           const struct GNUNET_CONTAINER_MetaData
54                                           * md, int rating);
55
56 /**
57  * Change the ranking of a pseudonym.
58  *
59  * @param cfg overall configuration
60  * @param nsid id of the pseudonym
61  * @param delta by how much should the rating be changed?
62  * @return new rating of the namespace
63  */
64 int GNUNET_PSEUDONYM_rank (const struct GNUNET_CONFIGURATION_Handle *cfg,
65                            const GNUNET_HashCode * nsid, int delta);
66
67 /**
68  * Add a pseudonym to the set of known pseudonyms.
69  * For all pseudonym advertisements that we discover
70  * FS should automatically call this function.
71  *
72  * @param cfg overall configuration
73  * @param id the pseudonym identifier
74  * @param meta metadata for the pseudonym
75  */
76 void GNUNET_PSEUDONYM_add (const struct GNUNET_CONFIGURATION_Handle *cfg,
77                            const GNUNET_HashCode * id,
78                            const struct GNUNET_CONTAINER_MetaData *meta);
79
80
81 /**
82  * List all known pseudonyms.
83  *
84  * @param cfg overall configuration 
85  * @param iterator function to call for each pseudonym
86  * @param closure closure for iterator
87  * @return number of pseudonyms found
88  */
89 int GNUNET_PSEUDONYM_list_all (const struct GNUNET_CONFIGURATION_Handle *cfg,
90                                GNUNET_PSEUDONYM_Iterator iterator,
91                                void *closure);
92
93 /**
94  * Register callback to be invoked whenever we discover
95  * a new pseudonym.
96  */
97 int GNUNET_PSEUDONYM_discovery_callback_register (const struct
98                                                   GNUNET_CONFIGURATION_Handle
99                                                   *cfg,
100                                                   GNUNET_PSEUDONYM_Iterator
101                                                   iterator, void *closure);
102
103 /**
104  * Unregister namespace discovery callback.
105  */
106 int GNUNET_PSEUDONYM_discovery_callback_unregister (GNUNET_PSEUDONYM_Iterator
107                                                     iterator, void *closure);
108
109 /**
110  * Return the unique, human readable name for the given pseudonym.
111  *
112  * @return NULL on failure (should never happen)
113  */
114 char *GNUNET_PSEUDONYM_id_to_name (const struct GNUNET_CONFIGURATION_Handle
115                                    *cfg, const GNUNET_HashCode * pseudo);
116
117 /**
118  * Get the pseudonym ID belonging to the given human readable name.
119  *
120  * @return GNUNET_OK on success
121  */
122 int GNUNET_PSEUDONYM_name_to_id (const struct GNUNET_CONFIGURATION_Handle *cfg,
123                                  const char *hname, GNUNET_HashCode * psid);
124
125
126 #if 0                           /* keep Emacsens' auto-indent happy */
127 {
128 #endif
129 #ifdef __cplusplus
130 }
131 #endif
132
133 /* ifndef GNUNET_PSEUDONYM_LIB_H */
134 #endif
135 /* end of gnunet_pseudonym_lib.h */