work on datastore API implementation
[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 rating the local rating of the pseudonym
46  * @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort
47  */
48 typedef int (*GNUNET_PSEUDONYM_Iterator) (void *cls,
49                                           const GNUNET_HashCode *
50                                           pseudonym,
51                                           const struct
52                                           GNUNET_CONTAINER_MetaData * md,
53                                           int rating);
54
55 /**
56  * Change the ranking of a pseudonym.
57  *
58  * @param pseudonym id of the pseudonym
59  * @param delta by how much should the rating be changed?
60  * @return new rating of the namespace
61  */
62 int GNUNET_PSEUDONYM_rank (struct GNUNET_CONFIGURATION_Handle *cfg,
63                            const GNUNET_HashCode * pseudonym, int delta);
64
65 /**
66  * Add a pseudonym to the set of known pseudonyms.
67  *
68  * @param pseudonym the pseudonym's identifier
69  */
70 void GNUNET_PSEUDONYM_add (struct GNUNET_CONFIGURATION_Handle *cfg,
71                            const GNUNET_HashCode * pseudo,
72                            const struct GNUNET_CONTAINER_MetaData *meta);
73
74
75 /**
76  * List all known pseudonyms.
77  */
78 int GNUNET_PSEUDONYM_list_all (struct GNUNET_CONFIGURATION_Handle *cfg,
79                                GNUNET_PSEUDONYM_Iterator iterator,
80                                void *closure);
81
82 /**
83  * Register callback to be invoked whenever we discover
84  * a new pseudonym.
85  */
86 int GNUNET_PSEUDONYM_discovery_callback_register (struct
87                                                   GNUNET_CONFIGURATION_Handle
88                                                   *cfg,
89                                                   GNUNET_PSEUDONYM_Iterator
90                                                   iterator, void *closure);
91
92 /**
93  * Unregister namespace discovery callback.
94  */
95 int
96 GNUNET_PSEUDONYM_discovery_callback_unregister (GNUNET_PSEUDONYM_Iterator
97                                                 iterator, void *closure);
98
99 /**
100  * Return the unique, human readable name for the given pseudonym.
101  *
102  * @return NULL on failure (should never happen)
103  */
104 char *GNUNET_PSEUDONYM_id_to_name (struct GNUNET_CONFIGURATION_Handle *cfg,
105                                    const GNUNET_HashCode * pseudo);
106
107 /**
108  * Get the pseudonym ID belonging to the given human readable name.
109  *
110  * @return GNUNET_OK on success
111  */
112 int GNUNET_PSEUDONYM_name_to_id (struct GNUNET_CONFIGURATION_Handle *cfg,
113                                  const char *hname, GNUNET_HashCode * psid);
114
115
116 #if 0                           /* keep Emacsens' auto-indent happy */
117 {
118 #endif
119 #ifdef __cplusplus
120 }
121 #endif
122
123 /* ifndef GNUNET_PSEUDONYM_LIB_H */
124 #endif
125 /* end of gnunet_pseudonym_lib.h */