diff options
Diffstat (limited to 'src/include/gnunet_namestore_plugin.h')
-rw-r--r-- | src/include/gnunet_namestore_plugin.h | 125 |
1 files changed, 99 insertions, 26 deletions
diff --git a/src/include/gnunet_namestore_plugin.h b/src/include/gnunet_namestore_plugin.h index 9cc8abc6e..b7bcc4eb6 100644 --- a/src/include/gnunet_namestore_plugin.h +++ b/src/include/gnunet_namestore_plugin.h | |||
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup GNS | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
@@ -31,6 +34,7 @@ | |||
31 | #ifndef GNUNET_NAMESTORE_PLUGIN_H | 34 | #ifndef GNUNET_NAMESTORE_PLUGIN_H |
32 | #define GNUNET_NAMESTORE_PLUGIN_H | 35 | #define GNUNET_NAMESTORE_PLUGIN_H |
33 | 36 | ||
37 | |||
34 | #include "gnunet_util_lib.h" | 38 | #include "gnunet_util_lib.h" |
35 | #include "gnunet_namestore_service.h" | 39 | #include "gnunet_namestore_service.h" |
36 | 40 | ||
@@ -49,6 +53,7 @@ extern "C" | |||
49 | * @param cls closure | 53 | * @param cls closure |
50 | * @param serial unique serial number of the record, MUST NOT BE ZERO, | 54 | * @param serial unique serial number of the record, MUST NOT BE ZERO, |
51 | * and must be monotonically increasing while iterating | 55 | * and must be monotonically increasing while iterating |
56 | * @param editor_hint content of the editor field when record was read (may be NULL) | ||
52 | * @param zone_key private key of the zone | 57 | * @param zone_key private key of the zone |
53 | * @param label name that is being mapped (at most 255 characters long) | 58 | * @param label name that is being mapped (at most 255 characters long) |
54 | * @param rd_count number of entries in @a rd array | 59 | * @param rd_count number of entries in @a rd array |
@@ -57,8 +62,9 @@ extern "C" | |||
57 | typedef void | 62 | typedef void |
58 | (*GNUNET_NAMESTORE_RecordIterator) (void *cls, | 63 | (*GNUNET_NAMESTORE_RecordIterator) (void *cls, |
59 | uint64_t serial, | 64 | uint64_t serial, |
65 | const char *editor_hint, | ||
60 | const struct | 66 | const struct |
61 | GNUNET_IDENTITY_PrivateKey *private_key, | 67 | GNUNET_CRYPTO_PrivateKey *private_key, |
62 | const char *label, | 68 | const char *label, |
63 | unsigned int rd_count, | 69 | unsigned int rd_count, |
64 | const struct GNUNET_GNSRECORD_Data *rd); | 70 | const struct GNUNET_GNSRECORD_Data *rd); |
@@ -85,12 +91,12 @@ struct GNUNET_NAMESTORE_PluginFunctions | |||
85 | * @param rd array of records with data to store | 91 | * @param rd array of records with data to store |
86 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR | 92 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR |
87 | */ | 93 | */ |
88 | int | 94 | enum GNUNET_GenericReturnValue |
89 | (*store_records) (void *cls, | 95 | (*store_records)(void *cls, |
90 | const struct GNUNET_IDENTITY_PrivateKey *zone, | 96 | const struct GNUNET_CRYPTO_PrivateKey *zone, |
91 | const char *label, | 97 | const char *label, |
92 | unsigned int rd_count, | 98 | unsigned int rd_count, |
93 | const struct GNUNET_GNSRECORD_Data *rd); | 99 | const struct GNUNET_GNSRECORD_Data *rd); |
94 | 100 | ||
95 | /** | 101 | /** |
96 | * Lookup records in the datastore for which we are the authority. | 102 | * Lookup records in the datastore for which we are the authority. |
@@ -102,12 +108,12 @@ struct GNUNET_NAMESTORE_PluginFunctions | |||
102 | * @param iter_cls closure for @a iter | 108 | * @param iter_cls closure for @a iter |
103 | * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR | 109 | * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR |
104 | */ | 110 | */ |
105 | int | 111 | enum GNUNET_GenericReturnValue |
106 | (*lookup_records) (void *cls, | 112 | (*lookup_records)(void *cls, |
107 | const struct GNUNET_IDENTITY_PrivateKey *zone, | 113 | const struct GNUNET_CRYPTO_PrivateKey *zone, |
108 | const char *label, | 114 | const char *label, |
109 | GNUNET_NAMESTORE_RecordIterator iter, | 115 | GNUNET_NAMESTORE_RecordIterator iter, |
110 | void *iter_cls); | 116 | void *iter_cls); |
111 | 117 | ||
112 | 118 | ||
113 | /** | 119 | /** |
@@ -124,13 +130,13 @@ struct GNUNET_NAMESTORE_PluginFunctions | |||
124 | * @param iter_cls closure for @a iter | 130 | * @param iter_cls closure for @a iter |
125 | * @return #GNUNET_OK on success, #GNUNET_NO if there were no more results, #GNUNET_SYSERR on error | 131 | * @return #GNUNET_OK on success, #GNUNET_NO if there were no more results, #GNUNET_SYSERR on error |
126 | */ | 132 | */ |
127 | int | 133 | enum GNUNET_GenericReturnValue |
128 | (*iterate_records) (void *cls, | 134 | (*iterate_records)(void *cls, |
129 | const struct GNUNET_IDENTITY_PrivateKey *zone, | 135 | const struct GNUNET_CRYPTO_PrivateKey *zone, |
130 | uint64_t serial, | 136 | uint64_t serial, |
131 | uint64_t limit, | 137 | uint64_t limit, |
132 | GNUNET_NAMESTORE_RecordIterator iter, | 138 | GNUNET_NAMESTORE_RecordIterator iter, |
133 | void *iter_cls); | 139 | void *iter_cls); |
134 | 140 | ||
135 | 141 | ||
136 | /** | 142 | /** |
@@ -144,12 +150,77 @@ struct GNUNET_NAMESTORE_PluginFunctions | |||
144 | * @param iter_cls closure for @a iter | 150 | * @param iter_cls closure for @a iter |
145 | * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error | 151 | * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error |
146 | */ | 152 | */ |
147 | int | 153 | enum GNUNET_GenericReturnValue |
148 | (*zone_to_name) (void *cls, | 154 | (*zone_to_name)(void *cls, |
149 | const struct GNUNET_IDENTITY_PrivateKey *zone, | 155 | const struct GNUNET_CRYPTO_PrivateKey *zone, |
150 | const struct GNUNET_IDENTITY_PublicKey *value_zone, | 156 | const struct GNUNET_CRYPTO_PublicKey *value_zone, |
151 | GNUNET_NAMESTORE_RecordIterator iter, | 157 | GNUNET_NAMESTORE_RecordIterator iter, |
152 | void *iter_cls); | 158 | void *iter_cls); |
159 | |||
160 | /** Transaction-based API draft **/ | ||
161 | |||
162 | /** | ||
163 | * Edit records in the namestore. | ||
164 | * This modifies the editor hint, an advisory lock entry. | ||
165 | * The record iterator will be called with the old editor hint (if any). | ||
166 | * | ||
167 | * @param cls closure (internal context for the plugin) | ||
168 | * @param zone private key of the zone | ||
169 | * @param editor_hint the new value for the advisory lock field | ||
170 | * @param label name of the record in the zone | ||
171 | * @param iter function to call with the result | ||
172 | * @param iter_cls closure for @a iter | ||
173 | * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR | ||
174 | */ | ||
175 | enum GNUNET_GenericReturnValue | ||
176 | (*edit_records)(void *cls, | ||
177 | const char *editor_hint, | ||
178 | const struct GNUNET_CRYPTO_PrivateKey *zone, | ||
179 | const char *label, | ||
180 | GNUNET_NAMESTORE_RecordIterator iter, | ||
181 | void *iter_cls); | ||
182 | |||
183 | /** | ||
184 | * This clears the editor hint, unless it does not match the | ||
185 | * given editor hint, in which case this is a NOP. | ||
186 | * If a replacement hint is given, it hint is not cleared, but | ||
187 | * set to the replacement. | ||
188 | * | ||
189 | * @param cls closure (internal context for the plugin) | ||
190 | * @param zone private key of the zone | ||
191 | * @param editor_hint the new value for the advisory lock field | ||
192 | * @param editor_hint_replacement an optional value to use instead of a clear | ||
193 | * @param label name of the record in the zone | ||
194 | * @param iter function to call with the result | ||
195 | * @param iter_cls closure for @a iter | ||
196 | * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR | ||
197 | */ | ||
198 | enum GNUNET_GenericReturnValue | ||
199 | (*clear_editor_hint)(void *cls, | ||
200 | const char *editor_hint, | ||
201 | const char *editor_hint_replacement, | ||
202 | const struct GNUNET_CRYPTO_PrivateKey *zone, | ||
203 | const char *label); | ||
204 | |||
205 | /** | ||
206 | * Setup the database. | ||
207 | * | ||
208 | * @param cls closure (internal context for the plugin) | ||
209 | * @return #GNUNET_OK on success, else fails with #GNUNET_SYSERR | ||
210 | */ | ||
211 | enum GNUNET_GenericReturnValue | ||
212 | (*create_tables)(void *cls); | ||
213 | |||
214 | |||
215 | /** | ||
216 | * Drop existing tables. | ||
217 | * DANGEROUS: All existing data in the dabase will be lost! | ||
218 | * | ||
219 | * @param cls closure (internal context for the plugin) | ||
220 | * @return #GNUNET_OK on success, else fails with #GNUNET_SYSERR | ||
221 | */ | ||
222 | enum GNUNET_GenericReturnValue | ||
223 | (*drop_tables)(void *cls); | ||
153 | }; | 224 | }; |
154 | 225 | ||
155 | 226 | ||
@@ -163,3 +234,5 @@ struct GNUNET_NAMESTORE_PluginFunctions | |||
163 | #endif | 234 | #endif |
164 | 235 | ||
165 | /** @} */ /* end of group */ | 236 | /** @} */ /* end of group */ |
237 | |||
238 | /** @} */ /* end of group addition */ | ||