doxygen: group/module definitions (part 2)
[oweals/gnunet.git] / src / include / gnunet_namestore_plugin.h
1 /*
2      This file is part of GNUnet
3      Copyright (C) 2012, 2013 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 3, 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., 51 Franklin Street, Fifth Floor,
18      Boston, MA 02110-1301, USA.
19 */
20
21 /**
22  * @author Christian Grothoff
23  *
24  * @file
25  * Plugin API for the namestore database backend
26  *
27  * @defgroup namestore-plugin  Name Store service plugin API
28  * Plugin API for the namestore database backend
29  * @{
30  */
31 #ifndef GNUNET_NAMESTORE_PLUGIN_H
32 #define GNUNET_NAMESTORE_PLUGIN_H
33
34 #include "gnunet_util_lib.h"
35 #include "gnunet_namestore_service.h"
36
37 #ifdef __cplusplus
38 extern "C"
39 {
40 #if 0                           /* keep Emacsens' auto-indent happy */
41 }
42 #endif
43 #endif
44
45
46 /**
47  * Function called by for each matching record.
48  *
49  * @param cls closure
50  * @param zone_key private key of the zone
51  * @param label name that is being mapped (at most 255 characters long)
52  * @param rd_count number of entries in @a rd array
53  * @param rd array of records with data to store
54  */
55 typedef void (*GNUNET_NAMESTORE_RecordIterator) (void *cls,
56                                                  const struct GNUNET_CRYPTO_EcdsaPrivateKey *private_key,
57                                                  const char *label,
58                                                  unsigned int rd_count,
59                                                  const struct GNUNET_GNSRECORD_Data *rd);
60
61
62 /**
63  * @brief struct returned by the initialization function of the plugin
64  */
65 struct GNUNET_NAMESTORE_PluginFunctions
66 {
67
68   /**
69    * Closure to pass to all plugin functions.
70    */
71   void *cls;
72
73   /**
74    * Store a record in the datastore for which we are the authority.
75    * Removes any existing record in the same zone with the same name.
76    *
77    * @param cls closure (internal context for the plugin)
78    * @param zone private key of the zone
79    * @param label name of the record in the zone
80    * @param rd_count number of entries in @a rd array, 0 to delete all records
81    * @param rd array of records with data to store
82    * @return #GNUNET_OK on success, else #GNUNET_SYSERR
83    */
84   int (*store_records) (void *cls,
85                         const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
86                         const char *label,
87                         unsigned int rd_count,
88                         const struct GNUNET_GNSRECORD_Data *rd);
89
90   /**
91    * Lookup records in the datastore for which we are the authority.
92    *
93    * @param cls closure (internal context for the plugin)
94    * @param zone private key of the zone
95    * @param label name of the record in the zone
96    * @param iter function to call with the result
97    * @param iter_cls closure for @a iter
98    * @return #GNUNET_OK on success, else #GNUNET_SYSERR
99    */
100   int (*lookup_records) (void *cls,
101                         const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
102                         const char *label,
103                         GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls);
104
105
106
107   /**
108    * Iterate over the results for a particular zone in the
109    * datastore.  Will return at most one result to the iterator.
110    *
111    * @param cls closure (internal context for the plugin)
112    * @param zone private key of the zone, NULL for all zones
113    * @param offset offset in the list of all matching records
114    * @param iter function to call with the result
115    * @param iter_cls closure for @a iter
116    * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error
117    */
118   int (*iterate_records) (void *cls,
119                           const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
120                           uint64_t offset,
121                           GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls);
122
123
124   /**
125    * Look for an existing PKEY delegation record for a given public key.
126    * Returns at most one result to the iterator.
127    *
128    * @param cls closure (internal context for the plugin)
129    * @param zone private key of the zone to look up in, never NULL
130    * @param value_zone public key of the target zone (value), never NULL
131    * @param iter function to call with the result
132    * @param iter_cls closure for @a iter
133    * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error
134    */
135   int (*zone_to_name) (void *cls,
136                        const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
137                        const struct GNUNET_CRYPTO_EcdsaPublicKey *value_zone,
138                        GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls);
139
140
141 };
142
143
144 #if 0                           /* keep Emacsens' auto-indent happy */
145 {
146 #endif
147 #ifdef __cplusplus
148 }
149 #endif
150
151 #endif
152
153 /** @} */  /* end of group */