diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-04-29 07:49:04 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-04-29 07:49:04 +0000 |
commit | d9dcf9e5754ba3dadb7a6e75b2056863f21b84b4 (patch) | |
tree | 1636005cfec014f61f523ed95fd43beb32153fc7 /src/datacache | |
parent | 5474ff8eae33b31f0d6f9ea0498d5e39432cb28b (diff) | |
download | gnunet-d9dcf9e5754ba3dadb7a6e75b2056863f21b84b4.tar.gz gnunet-d9dcf9e5754ba3dadb7a6e75b2056863f21b84b4.zip |
-doxygen, updating template to reflect extended API
Diffstat (limited to 'src/datacache')
-rw-r--r-- | src/datacache/plugin_datacache_sqlite.c | 97 | ||||
-rw-r--r-- | src/datacache/plugin_datacache_template.c | 62 |
2 files changed, 107 insertions, 52 deletions
diff --git a/src/datacache/plugin_datacache_sqlite.c b/src/datacache/plugin_datacache_sqlite.c index 90b33d877..fe6daf4dd 100644 --- a/src/datacache/plugin_datacache_sqlite.c +++ b/src/datacache/plugin_datacache_sqlite.c | |||
@@ -67,22 +67,37 @@ struct Plugin | |||
67 | 67 | ||
68 | 68 | ||
69 | /** | 69 | /** |
70 | * Log an error message at log-level 'level' that indicates | 70 | * Log an error message at log-level @a level that indicates |
71 | * a failure of the command 'cmd' on file 'filename' | 71 | * a failure of the command @a cmd with the error from the database @a db |
72 | * with the message given by strerror(errno). | 72 | * |
73 | * @param db database handle | ||
74 | * @param level log level | ||
75 | * @param cmd failed command | ||
73 | */ | 76 | */ |
74 | #define LOG_SQLITE(db, level, cmd) do { LOG (level, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, sqlite3_errmsg(db)); } while(0) | 77 | #define LOG_SQLITE(db, level, cmd) do { LOG (level, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, sqlite3_errmsg(db)); } while(0) |
75 | 78 | ||
76 | 79 | ||
80 | /** | ||
81 | * Execute SQL statement. | ||
82 | * | ||
83 | * @param db database handle | ||
84 | * @param cmd SQL command to execute | ||
85 | */ | ||
77 | #define SQLITE3_EXEC(db, cmd) do { emsg = NULL; if (SQLITE_OK != sqlite3_exec(db, cmd, NULL, NULL, &emsg)) { LOG (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, _("`%s' failed at %s:%d with error: %s\n"), "sqlite3_exec", __FILE__, __LINE__, emsg); sqlite3_free(emsg); } } while(0) | 86 | #define SQLITE3_EXEC(db, cmd) do { emsg = NULL; if (SQLITE_OK != sqlite3_exec(db, cmd, NULL, NULL, &emsg)) { LOG (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, _("`%s' failed at %s:%d with error: %s\n"), "sqlite3_exec", __FILE__, __LINE__, emsg); sqlite3_free(emsg); } } while(0) |
78 | 87 | ||
79 | 88 | ||
80 | /** | 89 | /** |
81 | * @brief Prepare a SQL statement | 90 | * @brief Prepare a SQL statement |
91 | * | ||
92 | * @param dbh database handle | ||
93 | * @param zsql SQL statement text | ||
94 | * @param[out] ppStmt set to the prepared statement | ||
95 | * @return 0 on success | ||
82 | */ | 96 | */ |
83 | static int | 97 | static int |
84 | sq_prepare (sqlite3 * dbh, const char *zSql, /* SQL statement, UTF-8 encoded */ | 98 | sq_prepare (sqlite3 *dbh, |
85 | sqlite3_stmt ** ppStmt) | 99 | const char *zSql, /* SQL statement, UTF-8 encoded */ |
100 | sqlite3_stmt **ppStmt) | ||
86 | { /* OUT: Statement handle */ | 101 | { /* OUT: Statement handle */ |
87 | char *dummy; | 102 | char *dummy; |
88 | 103 | ||
@@ -94,9 +109,9 @@ sq_prepare (sqlite3 * dbh, const char *zSql, /* SQL statement, UTF-8 encoded | |||
94 | /** | 109 | /** |
95 | * Store an item in the datastore. | 110 | * Store an item in the datastore. |
96 | * | 111 | * |
97 | * @param cls closure (our "struct Plugin") | 112 | * @param cls closure (our `struct Plugin`) |
98 | * @param key key to store data under | 113 | * @param key key to store data under |
99 | * @param size number of bytes in data | 114 | * @param size number of bytes in @a data |
100 | * @param data data to store | 115 | * @param data data to store |
101 | * @param type type of the value | 116 | * @param type type of the value |
102 | * @param discard_time when to discard the value in any case | 117 | * @param discard_time when to discard the value in any case |
@@ -107,7 +122,8 @@ sq_prepare (sqlite3 * dbh, const char *zSql, /* SQL statement, UTF-8 encoded | |||
107 | static ssize_t | 122 | static ssize_t |
108 | sqlite_plugin_put (void *cls, | 123 | sqlite_plugin_put (void *cls, |
109 | const struct GNUNET_HashCode *key, | 124 | const struct GNUNET_HashCode *key, |
110 | size_t size, const char *data, | 125 | size_t size, |
126 | const char *data, | ||
111 | enum GNUNET_BLOCK_Type type, | 127 | enum GNUNET_BLOCK_Type type, |
112 | struct GNUNET_TIME_Absolute discard_time, | 128 | struct GNUNET_TIME_Absolute discard_time, |
113 | unsigned int path_info_len, | 129 | unsigned int path_info_len, |
@@ -118,8 +134,9 @@ sqlite_plugin_put (void *cls, | |||
118 | int64_t dval; | 134 | int64_t dval; |
119 | 135 | ||
120 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 136 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
121 | "Processing `%s' of %u bytes with key `%4s' and expiration %s\n", | 137 | "Processing PUT of %u bytes with key `%4s' and expiration %s\n", |
122 | "PUT", (unsigned int) size, GNUNET_h2s (key), | 138 | (unsigned int) size, |
139 | GNUNET_h2s (key), | ||
123 | GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (discard_time), GNUNET_YES)); | 140 | GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (discard_time), GNUNET_YES)); |
124 | dval = (int64_t) discard_time.abs_value_us; | 141 | dval = (int64_t) discard_time.abs_value_us; |
125 | if (dval < 0) | 142 | if (dval < 0) |
@@ -129,7 +146,8 @@ sqlite_plugin_put (void *cls, | |||
129 | "INSERT INTO ds090 (type, expire, key, value, path) VALUES (?, ?, ?, ?, ?)", | 146 | "INSERT INTO ds090 (type, expire, key, value, path) VALUES (?, ?, ?, ?, ?)", |
130 | &stmt) != SQLITE_OK) | 147 | &stmt) != SQLITE_OK) |
131 | { | 148 | { |
132 | LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 149 | LOG_SQLITE (plugin->dbh, |
150 | GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
133 | "sq_prepare"); | 151 | "sq_prepare"); |
134 | return -1; | 152 | return -1; |
135 | } | 153 | } |
@@ -147,21 +165,24 @@ sqlite_plugin_put (void *cls, | |||
147 | path_info_len * sizeof (struct GNUNET_PeerIdentity), | 165 | path_info_len * sizeof (struct GNUNET_PeerIdentity), |
148 | SQLITE_TRANSIENT))) | 166 | SQLITE_TRANSIENT))) |
149 | { | 167 | { |
150 | LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 168 | LOG_SQLITE (plugin->dbh, |
169 | GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
151 | "sqlite3_bind_xxx"); | 170 | "sqlite3_bind_xxx"); |
152 | sqlite3_finalize (stmt); | 171 | sqlite3_finalize (stmt); |
153 | return -1; | 172 | return -1; |
154 | } | 173 | } |
155 | if (SQLITE_DONE != sqlite3_step (stmt)) | 174 | if (SQLITE_DONE != sqlite3_step (stmt)) |
156 | { | 175 | { |
157 | LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 176 | LOG_SQLITE (plugin->dbh, |
177 | GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
158 | "sqlite3_step"); | 178 | "sqlite3_step"); |
159 | sqlite3_finalize (stmt); | 179 | sqlite3_finalize (stmt); |
160 | return -1; | 180 | return -1; |
161 | } | 181 | } |
162 | plugin->num_items++; | 182 | plugin->num_items++; |
163 | if (SQLITE_OK != sqlite3_finalize (stmt)) | 183 | if (SQLITE_OK != sqlite3_finalize (stmt)) |
164 | LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 184 | LOG_SQLITE (plugin->dbh, |
185 | GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
165 | "sqlite3_finalize"); | 186 | "sqlite3_finalize"); |
166 | return size + OVERHEAD; | 187 | return size + OVERHEAD; |
167 | } | 188 | } |
@@ -171,16 +192,18 @@ sqlite_plugin_put (void *cls, | |||
171 | * Iterate over the results for a particular key | 192 | * Iterate over the results for a particular key |
172 | * in the datastore. | 193 | * in the datastore. |
173 | * | 194 | * |
174 | * @param cls closure (our "struct Plugin") | 195 | * @param cls closure (our `struct Plugin`) |
175 | * @param key | 196 | * @param key |
176 | * @param type entries of which type are relevant? | 197 | * @param type entries of which type are relevant? |
177 | * @param iter maybe NULL (to just count) | 198 | * @param iter maybe NULL (to just count) |
178 | * @param iter_cls closure for iter | 199 | * @param iter_cls closure for @a iter |
179 | * @return the number of results found | 200 | * @return the number of results found |
180 | */ | 201 | */ |
181 | static unsigned int | 202 | static unsigned int |
182 | sqlite_plugin_get (void *cls, const struct GNUNET_HashCode * key, | 203 | sqlite_plugin_get (void *cls, |
183 | enum GNUNET_BLOCK_Type type, GNUNET_DATACACHE_Iterator iter, | 204 | const struct GNUNET_HashCode *key, |
205 | enum GNUNET_BLOCK_Type type, | ||
206 | GNUNET_DATACACHE_Iterator iter, | ||
184 | void *iter_cls) | 207 | void *iter_cls) |
185 | { | 208 | { |
186 | struct Plugin *plugin = cls; | 209 | struct Plugin *plugin = cls; |
@@ -198,14 +221,16 @@ sqlite_plugin_get (void *cls, const struct GNUNET_HashCode * key, | |||
198 | const struct GNUNET_PeerIdentity *path; | 221 | const struct GNUNET_PeerIdentity *path; |
199 | 222 | ||
200 | now = GNUNET_TIME_absolute_get (); | 223 | now = GNUNET_TIME_absolute_get (); |
201 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' for key `%4s'\n", "GET", | 224 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
225 | "Processing GET for key `%4s'\n", | ||
202 | GNUNET_h2s (key)); | 226 | GNUNET_h2s (key)); |
203 | if (sq_prepare | 227 | if (sq_prepare |
204 | (plugin->dbh, | 228 | (plugin->dbh, |
205 | "SELECT count(*) FROM ds090 WHERE key=? AND type=? AND expire >= ?", | 229 | "SELECT count(*) FROM ds090 WHERE key=? AND type=? AND expire >= ?", |
206 | &stmt) != SQLITE_OK) | 230 | &stmt) != SQLITE_OK) |
207 | { | 231 | { |
208 | LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 232 | LOG_SQLITE (plugin->dbh, |
233 | GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
209 | "sq_prepare"); | 234 | "sq_prepare"); |
210 | return 0; | 235 | return 0; |
211 | } | 236 | } |
@@ -217,7 +242,8 @@ sqlite_plugin_get (void *cls, const struct GNUNET_HashCode * key, | |||
217 | (SQLITE_OK != sqlite3_bind_int (stmt, 2, type)) || | 242 | (SQLITE_OK != sqlite3_bind_int (stmt, 2, type)) || |
218 | (SQLITE_OK != sqlite3_bind_int64 (stmt, 3, now.abs_value_us))) | 243 | (SQLITE_OK != sqlite3_bind_int64 (stmt, 3, now.abs_value_us))) |
219 | { | 244 | { |
220 | LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 245 | LOG_SQLITE (plugin->dbh, |
246 | GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
221 | "sqlite3_bind_xxx"); | 247 | "sqlite3_bind_xxx"); |
222 | sqlite3_finalize (stmt); | 248 | sqlite3_finalize (stmt); |
223 | return 0; | 249 | return 0; |
@@ -229,7 +255,7 @@ sqlite_plugin_get (void *cls, const struct GNUNET_HashCode * key, | |||
229 | "sqlite_step"); | 255 | "sqlite_step"); |
230 | sqlite3_finalize (stmt); | 256 | sqlite3_finalize (stmt); |
231 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 257 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
232 | "No content found when processing `%s' for key `%4s'\n", "GET", | 258 | "No content found when processing GET for key `%4s'\n", |
233 | GNUNET_h2s (key)); | 259 | GNUNET_h2s (key)); |
234 | return 0; | 260 | return 0; |
235 | } | 261 | } |
@@ -239,7 +265,7 @@ sqlite_plugin_get (void *cls, const struct GNUNET_HashCode * key, | |||
239 | { | 265 | { |
240 | if (0 == total) | 266 | if (0 == total) |
241 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 267 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
242 | "No content found when processing `%s' for key `%4s'\n", "GET", | 268 | "No content found when processing GET for key `%4s'\n", |
243 | GNUNET_h2s (key)); | 269 | GNUNET_h2s (key)); |
244 | return total; | 270 | return total; |
245 | } | 271 | } |
@@ -254,17 +280,21 @@ sqlite_plugin_get (void *cls, const struct GNUNET_HashCode * key, | |||
254 | off); | 280 | off); |
255 | if (sq_prepare (plugin->dbh, scratch, &stmt) != SQLITE_OK) | 281 | if (sq_prepare (plugin->dbh, scratch, &stmt) != SQLITE_OK) |
256 | { | 282 | { |
257 | LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 283 | LOG_SQLITE (plugin->dbh, |
284 | GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
258 | "sq_prepare"); | 285 | "sq_prepare"); |
259 | return cnt; | 286 | return cnt; |
260 | } | 287 | } |
261 | if ((SQLITE_OK != | 288 | if ((SQLITE_OK != |
262 | sqlite3_bind_blob (stmt, 1, key, sizeof (struct GNUNET_HashCode), | 289 | sqlite3_bind_blob (stmt, 1, |
290 | key, | ||
291 | sizeof (struct GNUNET_HashCode), | ||
263 | SQLITE_TRANSIENT)) || | 292 | SQLITE_TRANSIENT)) || |
264 | (SQLITE_OK != sqlite3_bind_int (stmt, 2, type)) || | 293 | (SQLITE_OK != sqlite3_bind_int (stmt, 2, type)) || |
265 | (SQLITE_OK != sqlite3_bind_int64 (stmt, 3, now.abs_value_us))) | 294 | (SQLITE_OK != sqlite3_bind_int64 (stmt, 3, now.abs_value_us))) |
266 | { | 295 | { |
267 | LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 296 | LOG_SQLITE (plugin->dbh, |
297 | GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
268 | "sqlite3_bind_xxx"); | 298 | "sqlite3_bind_xxx"); |
269 | sqlite3_finalize (stmt); | 299 | sqlite3_finalize (stmt); |
270 | return cnt; | 300 | return cnt; |
@@ -290,8 +320,9 @@ sqlite_plugin_get (void *cls, const struct GNUNET_HashCode * key, | |||
290 | exp = GNUNET_TIME_UNIT_FOREVER_ABS; | 320 | exp = GNUNET_TIME_UNIT_FOREVER_ABS; |
291 | cnt++; | 321 | cnt++; |
292 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 322 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
293 | "Found %u-byte result when processing `%s' for key `%4s'\n", | 323 | "Found %u-byte result when processing GET for key `%4s'\n", |
294 | (unsigned int) size, "GET", GNUNET_h2s (key)); | 324 | (unsigned int) size, |
325 | GNUNET_h2s (key)); | ||
295 | if (GNUNET_OK != iter (iter_cls, key, size, dat, type, exp, psize, path)) | 326 | if (GNUNET_OK != iter (iter_cls, key, size, dat, type, exp, psize, path)) |
296 | { | 327 | { |
297 | sqlite3_finalize (stmt); | 328 | sqlite3_finalize (stmt); |
@@ -307,8 +338,8 @@ sqlite_plugin_get (void *cls, const struct GNUNET_HashCode * key, | |||
307 | * Delete the entry with the lowest expiration value | 338 | * Delete the entry with the lowest expiration value |
308 | * from the datacache right now. | 339 | * from the datacache right now. |
309 | * | 340 | * |
310 | * @param cls closure (our "struct Plugin") | 341 | * @param cls closure (our `struct Plugin`) |
311 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 342 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
312 | */ | 343 | */ |
313 | static int | 344 | static int |
314 | sqlite_plugin_del (void *cls) | 345 | sqlite_plugin_del (void *cls) |
@@ -383,8 +414,8 @@ sqlite_plugin_del (void *cls) | |||
383 | /** | 414 | /** |
384 | * Entry point for the plugin. | 415 | * Entry point for the plugin. |
385 | * | 416 | * |
386 | * @param cls closure (the "struct GNUNET_DATACACHE_PluginEnvironmnet") | 417 | * @param cls closure (the `struct GNUNET_DATACACHE_PluginEnvironmnet`) |
387 | * @return the plugin's closure (our "struct Plugin") | 418 | * @return the plugin's closure (our `struct Plugin`) |
388 | */ | 419 | */ |
389 | void * | 420 | void * |
390 | libgnunet_plugin_datacache_sqlite_init (void *cls) | 421 | libgnunet_plugin_datacache_sqlite_init (void *cls) |
@@ -461,7 +492,7 @@ libgnunet_plugin_datacache_sqlite_init (void *cls) | |||
461 | /** | 492 | /** |
462 | * Exit point from the plugin. | 493 | * Exit point from the plugin. |
463 | * | 494 | * |
464 | * @param cls closure (our "struct Plugin") | 495 | * @param cls closure (our `struct Plugin`) |
465 | * @return NULL | 496 | * @return NULL |
466 | */ | 497 | */ |
467 | void * | 498 | void * |
diff --git a/src/datacache/plugin_datacache_template.c b/src/datacache/plugin_datacache_template.c index ff0119e69..86e0675c1 100644 --- a/src/datacache/plugin_datacache_template.c +++ b/src/datacache/plugin_datacache_template.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2006, 2009 Christian Grothoff (and other contributing authors) | 3 | Copyright (C) 2006, 2009, 2015 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 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 | 6 | it under the terms of the GNU General Public License as published |
@@ -43,19 +43,22 @@ struct Plugin | |||
43 | /** | 43 | /** |
44 | * Store an item in the datastore. | 44 | * Store an item in the datastore. |
45 | * | 45 | * |
46 | * @param cls closure (our "struct Plugin") | 46 | * @param cls closure (our `struct Plugin`) |
47 | * @param key key to store data under | 47 | * @param key key to store @a data under |
48 | * @param size number of bytes in data | 48 | * @param size number of bytes in @a data |
49 | * @param data data to store | 49 | * @param data data to store |
50 | * @param type type of the value | 50 | * @param type type of the value |
51 | * @param discard_time when to discard the value in any case | 51 | * @param discard_time when to discard the value in any case |
52 | * @param path_info_len number of entries in 'path_info' | 52 | * @param path_info_len number of entries in @a path_info |
53 | * @param path_info a path through the network | 53 | * @param path_info a path through the network |
54 | * @return 0 if duplicate, -1 on error, number of bytes used otherwise | 54 | * @return 0 if duplicate, -1 on error, number of bytes used otherwise |
55 | */ | 55 | */ |
56 | static ssize_t | 56 | static ssize_t |
57 | template_plugin_put (void *cls, const struct GNUNET_HashCode * key, size_t size, | 57 | template_plugin_put (void *cls, |
58 | const char *data, enum GNUNET_BLOCK_Type type, | 58 | const struct GNUNET_HashCode *key, |
59 | size_t size, | ||
60 | const char *data, | ||
61 | enum GNUNET_BLOCK_Type type, | ||
59 | struct GNUNET_TIME_Absolute discard_time, | 62 | struct GNUNET_TIME_Absolute discard_time, |
60 | unsigned int path_info_len, | 63 | unsigned int path_info_len, |
61 | const struct GNUNET_PeerIdentity *path_info) | 64 | const struct GNUNET_PeerIdentity *path_info) |
@@ -69,17 +72,19 @@ template_plugin_put (void *cls, const struct GNUNET_HashCode * key, size_t size, | |||
69 | * Iterate over the results for a particular key | 72 | * Iterate over the results for a particular key |
70 | * in the datastore. | 73 | * in the datastore. |
71 | * | 74 | * |
72 | * @param cls closure (our "struct Plugin") | 75 | * @param cls closure (our `struct Plugin`) |
73 | * @param key | 76 | * @param key |
74 | * @param type entries of which type are relevant? | 77 | * @param type entries of which type are relevant? |
75 | * @param iter maybe NULL (to just count) | 78 | * @param iter maybe NULL (to just count) |
76 | * @param iter_cls closure for iter | 79 | * @param iter_cls closure for @a iter |
77 | * @return the number of results found | 80 | * @return the number of results found |
78 | */ | 81 | */ |
79 | static unsigned int | 82 | static unsigned int |
80 | template_plugin_get (void *cls, const struct GNUNET_HashCode * key, | 83 | template_plugin_get (void *cls, |
84 | const struct GNUNET_HashCode *key, | ||
81 | enum GNUNET_BLOCK_Type type, | 85 | enum GNUNET_BLOCK_Type type, |
82 | GNUNET_DATACACHE_Iterator iter, void *iter_cls) | 86 | GNUNET_DATACACHE_Iterator iter, |
87 | void *iter_cls) | ||
83 | { | 88 | { |
84 | GNUNET_break (0); | 89 | GNUNET_break (0); |
85 | return 0; | 90 | return 0; |
@@ -90,8 +95,8 @@ template_plugin_get (void *cls, const struct GNUNET_HashCode * key, | |||
90 | * Delete the entry with the lowest expiration value | 95 | * Delete the entry with the lowest expiration value |
91 | * from the datacache right now. | 96 | * from the datacache right now. |
92 | * | 97 | * |
93 | * @param cls closure (our "struct Plugin") | 98 | * @param cls closure (our `struct Plugin`) |
94 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 99 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
95 | */ | 100 | */ |
96 | static int | 101 | static int |
97 | template_plugin_del (void *cls) | 102 | template_plugin_del (void *cls) |
@@ -102,10 +107,28 @@ template_plugin_del (void *cls) | |||
102 | 107 | ||
103 | 108 | ||
104 | /** | 109 | /** |
110 | * Return a random value from the datastore. | ||
111 | * | ||
112 | * @param cls closure (internal context for the plugin) | ||
113 | * @param iter maybe NULL (to just count) | ||
114 | * @param iter_cls closure for @a iter | ||
115 | * @return the number of results found (zero or one) | ||
116 | */ | ||
117 | static unsigned int | ||
118 | template_get_random (void *cls, | ||
119 | GNUNET_DATACACHE_Iterator iter, | ||
120 | void *iter_cls) | ||
121 | { | ||
122 | GNUNET_break (0); | ||
123 | return 0; | ||
124 | } | ||
125 | |||
126 | |||
127 | /** | ||
105 | * Entry point for the plugin. | 128 | * Entry point for the plugin. |
106 | * | 129 | * |
107 | * @param cls closure (the "struct GNUNET_DATACACHE_PluginEnvironmnet") | 130 | * @param cls closure (the `struct GNUNET_DATACACHE_PluginEnvironmnet`) |
108 | * @return the plugin's closure (our "struct Plugin") | 131 | * @return the plugin's closure (our `struct Plugin`) |
109 | */ | 132 | */ |
110 | void * | 133 | void * |
111 | libgnunet_plugin_datacache_template_init (void *cls) | 134 | libgnunet_plugin_datacache_template_init (void *cls) |
@@ -121,8 +144,10 @@ libgnunet_plugin_datacache_template_init (void *cls) | |||
121 | api->get = &template_plugin_get; | 144 | api->get = &template_plugin_get; |
122 | api->put = &template_plugin_put; | 145 | api->put = &template_plugin_put; |
123 | api->del = &template_plugin_del; | 146 | api->del = &template_plugin_del; |
124 | GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "template", | 147 | api->get_random = &template_plugin_get_random; |
125 | _("Template datacache running\n")); | 148 | GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, |
149 | "template", | ||
150 | "Template datacache running\n"); | ||
126 | return api; | 151 | return api; |
127 | } | 152 | } |
128 | 153 | ||
@@ -130,7 +155,7 @@ libgnunet_plugin_datacache_template_init (void *cls) | |||
130 | /** | 155 | /** |
131 | * Exit point from the plugin. | 156 | * Exit point from the plugin. |
132 | * | 157 | * |
133 | * @param cls closure (our "struct Plugin") | 158 | * @param cls closure (our `struct Plugin`) |
134 | * @return NULL | 159 | * @return NULL |
135 | */ | 160 | */ |
136 | void * | 161 | void * |
@@ -145,5 +170,4 @@ libgnunet_plugin_datacache_template_done (void *cls) | |||
145 | } | 170 | } |
146 | 171 | ||
147 | 172 | ||
148 | |||
149 | /* end of plugin_datacache_template.c */ | 173 | /* end of plugin_datacache_template.c */ |