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