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