aboutsummaryrefslogtreecommitdiff
path: root/src/namecache/plugin_namecache_flat.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/namecache/plugin_namecache_flat.c')
-rw-r--r--src/namecache/plugin_namecache_flat.c446
1 files changed, 221 insertions, 225 deletions
diff --git a/src/namecache/plugin_namecache_flat.c b/src/namecache/plugin_namecache_flat.c
index c093cb2a9..c48056a29 100644
--- a/src/namecache/plugin_namecache_flat.c
+++ b/src/namecache/plugin_namecache_flat.c
@@ -1,22 +1,22 @@
1 /* 1/*
2 * This file is part of GNUnet 2 * This file is part of GNUnet
3 * Copyright (C) 2009-2015 GNUnet e.V. 3 * Copyright (C) 2009-2015 GNUnet e.V.
4 * 4 *
5 * GNUnet is free software: you can redistribute it and/or modify it 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 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, 7 * by the Free Software Foundation, either version 3 of the License,
8 * or (at your option) any later version. 8 * or (at your option) any later version.
9 * 9 *
10 * GNUnet is distributed in the hope that it will be useful, but 10 * GNUnet is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of 11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Affero General Public License for more details. 13 * Affero General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU Affero General Public License 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/>. 16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19 */ 19 */
20 20
21/** 21/**
22 * @file namecache/plugin_namecache_flat.c 22 * @file namecache/plugin_namecache_flat.c
@@ -33,9 +33,7 @@
33/** 33/**
34 * Context for all functions in this plugin. 34 * Context for all functions in this plugin.
35 */ 35 */
36struct Plugin 36struct Plugin {
37{
38
39 const struct GNUNET_CONFIGURATION_Handle *cfg; 37 const struct GNUNET_CONFIGURATION_Handle *cfg;
40 38
41 /** 39 /**
@@ -47,11 +45,9 @@ struct Plugin
47 * HashMap 45 * HashMap
48 */ 46 */
49 struct GNUNET_CONTAINER_MultiHashMap *hm; 47 struct GNUNET_CONTAINER_MultiHashMap *hm;
50
51}; 48};
52 49
53struct FlatFileEntry 50struct FlatFileEntry {
54{
55 /** 51 /**
56 * Block 52 * Block
57 */ 53 */
@@ -61,7 +57,6 @@ struct FlatFileEntry
61 * query 57 * query
62 */ 58 */
63 struct GNUNET_HashCode query; 59 struct GNUNET_HashCode query;
64
65}; 60};
66 61
67/** 62/**
@@ -73,7 +68,7 @@ struct FlatFileEntry
73 * @return #GNUNET_OK on success 68 * @return #GNUNET_OK on success
74 */ 69 */
75static int 70static int
76database_setup (struct Plugin *plugin) 71database_setup(struct Plugin *plugin)
77{ 72{
78 char *afsdir; 73 char *afsdir;
79 char* block_buffer; 74 char* block_buffer;
@@ -86,107 +81,108 @@ database_setup (struct Plugin *plugin)
86 struct GNUNET_DISK_FileHandle *fh; 81 struct GNUNET_DISK_FileHandle *fh;
87 82
88 if (GNUNET_OK != 83 if (GNUNET_OK !=
89 GNUNET_CONFIGURATION_get_value_filename (plugin->cfg, 84 GNUNET_CONFIGURATION_get_value_filename(plugin->cfg,
90 "namecache-flat", 85 "namecache-flat",
91 "FILENAME", 86 "FILENAME",
92 &afsdir)) 87 &afsdir))
93 {
94 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
95 "namecache-flat", "FILENAME");
96 return GNUNET_SYSERR;
97 }
98 if (GNUNET_OK != GNUNET_DISK_file_test (afsdir))
99 {
100 if (GNUNET_OK != GNUNET_DISK_directory_create_for_file (afsdir))
101 { 88 {
102 GNUNET_break (0); 89 GNUNET_log_config_missing(GNUNET_ERROR_TYPE_ERROR,
103 GNUNET_free (afsdir); 90 "namecache-flat", "FILENAME");
104 return GNUNET_SYSERR; 91 return GNUNET_SYSERR;
105 } 92 }
106 } 93 if (GNUNET_OK != GNUNET_DISK_file_test(afsdir))
94 {
95 if (GNUNET_OK != GNUNET_DISK_directory_create_for_file(afsdir))
96 {
97 GNUNET_break(0);
98 GNUNET_free(afsdir);
99 return GNUNET_SYSERR;
100 }
101 }
107 /* afsdir should be UTF-8-encoded. If it isn't, it's a bug */ 102 /* afsdir should be UTF-8-encoded. If it isn't, it's a bug */
108 plugin->fn = afsdir; 103 plugin->fn = afsdir;
109 104
110 /* Load data from file into hashmap */ 105 /* Load data from file into hashmap */
111 plugin->hm = GNUNET_CONTAINER_multihashmap_create (10, 106 plugin->hm = GNUNET_CONTAINER_multihashmap_create(10,
112 GNUNET_NO); 107 GNUNET_NO);
113 fh = GNUNET_DISK_file_open (afsdir, 108 fh = GNUNET_DISK_file_open(afsdir,
114 GNUNET_DISK_OPEN_CREATE | 109 GNUNET_DISK_OPEN_CREATE |
115 GNUNET_DISK_OPEN_READWRITE, 110 GNUNET_DISK_OPEN_READWRITE,
116 GNUNET_DISK_PERM_USER_WRITE | 111 GNUNET_DISK_PERM_USER_WRITE |
117 GNUNET_DISK_PERM_USER_READ); 112 GNUNET_DISK_PERM_USER_READ);
118 if (NULL == fh) 113 if (NULL == fh)
119 { 114 {
120 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 115 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
121 _("Unable to initialize file: %s.\n"), 116 _("Unable to initialize file: %s.\n"),
122 afsdir); 117 afsdir);
123 return GNUNET_SYSERR; 118 return GNUNET_SYSERR;
124 } 119 }
125 120
126 if (GNUNET_SYSERR == GNUNET_DISK_file_size (afsdir, 121 if (GNUNET_SYSERR == GNUNET_DISK_file_size(afsdir,
127 &size, 122 &size,
128 GNUNET_YES, 123 GNUNET_YES,
129 GNUNET_YES)) 124 GNUNET_YES))
130 { 125 {
131 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 126 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
132 _("Unable to get filesize: %s.\n"), 127 _("Unable to get filesize: %s.\n"),
133 afsdir); 128 afsdir);
134 GNUNET_DISK_file_close (fh); 129 GNUNET_DISK_file_close(fh);
135 return GNUNET_SYSERR; 130 return GNUNET_SYSERR;
136 } 131 }
137 132
138 if (0 == size) 133 if (0 == size)
139 { 134 {
140 GNUNET_DISK_file_close (fh); 135 GNUNET_DISK_file_close(fh);
141 return GNUNET_OK; 136 return GNUNET_OK;
142 } 137 }
143 138
144 buffer = GNUNET_malloc (size + 1); 139 buffer = GNUNET_malloc(size + 1);
145 140
146 if (GNUNET_SYSERR == GNUNET_DISK_file_read (fh, 141 if (GNUNET_SYSERR == GNUNET_DISK_file_read(fh,
147 buffer, 142 buffer,
148 size)) 143 size))
149 { 144 {
150 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 145 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
151 _("Unable to read file: %s.\n"), 146 _("Unable to read file: %s.\n"),
152 afsdir); 147 afsdir);
153 GNUNET_free (buffer); 148 GNUNET_free(buffer);
154 GNUNET_DISK_file_close (fh); 149 GNUNET_DISK_file_close(fh);
155 return GNUNET_SYSERR; 150 return GNUNET_SYSERR;
156 } 151 }
157 buffer[size] = '\0'; 152 buffer[size] = '\0';
158 153
159 GNUNET_DISK_file_close (fh); 154 GNUNET_DISK_file_close(fh);
160 if (0 < size) 155 if (0 < size)
161 { 156 {
162 line = strtok (buffer, "\n"); 157 line = strtok(buffer, "\n");
163 while (line != NULL) { 158 while (line != NULL)
164 query = strtok (line, ","); 159 {
165 if (NULL == query) 160 query = strtok(line, ",");
166 break; 161 if (NULL == query)
167 block = strtok (NULL, ","); 162 break;
168 if (NULL == block) 163 block = strtok(NULL, ",");
169 break; 164 if (NULL == block)
170 line = strtok (NULL, "\n"); 165 break;
171 entry = GNUNET_malloc (sizeof (struct FlatFileEntry)); 166 line = strtok(NULL, "\n");
172 GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_hash_from_string (query, 167 entry = GNUNET_malloc(sizeof(struct FlatFileEntry));
173 &entry->query)); 168 GNUNET_assert(GNUNET_OK == GNUNET_CRYPTO_hash_from_string(query,
174 GNUNET_STRINGS_base64_decode (block, 169 &entry->query));
175 strlen (block), 170 GNUNET_STRINGS_base64_decode(block,
176 (void**)&block_buffer); 171 strlen(block),
177 entry->block = (struct GNUNET_GNSRECORD_Block *) block_buffer; 172 (void**)&block_buffer);
178 if (GNUNET_OK != 173 entry->block = (struct GNUNET_GNSRECORD_Block *)block_buffer;
179 GNUNET_CONTAINER_multihashmap_put (plugin->hm, 174 if (GNUNET_OK !=
180 &entry->query, 175 GNUNET_CONTAINER_multihashmap_put(plugin->hm,
181 entry, 176 &entry->query,
182 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) 177 entry,
183 { 178 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
184 GNUNET_free (entry); 179 {
185 GNUNET_break (0); 180 GNUNET_free(entry);
186 } 181 GNUNET_break(0);
182 }
183 }
187 } 184 }
188 } 185 GNUNET_free(buffer);
189 GNUNET_free (buffer);
190 return GNUNET_OK; 186 return GNUNET_OK;
191} 187}
192 188
@@ -196,9 +192,9 @@ database_setup (struct Plugin *plugin)
196 * @param plugin the plugin context 192 * @param plugin the plugin context
197 */ 193 */
198static int 194static int
199store_and_free_entries (void *cls, 195store_and_free_entries(void *cls,
200 const struct GNUNET_HashCode *key, 196 const struct GNUNET_HashCode *key,
201 void *value) 197 void *value)
202{ 198{
203 struct GNUNET_DISK_FileHandle *fh = cls; 199 struct GNUNET_DISK_FileHandle *fh = cls;
204 struct FlatFileEntry *entry = value; 200 struct FlatFileEntry *entry = value;
@@ -208,29 +204,29 @@ store_and_free_entries (void *cls,
208 struct GNUNET_CRYPTO_HashAsciiEncoded query; 204 struct GNUNET_CRYPTO_HashAsciiEncoded query;
209 size_t block_size; 205 size_t block_size;
210 206
211 block_size = ntohl (entry->block->purpose.size) + 207 block_size = ntohl(entry->block->purpose.size) +
212 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) + 208 sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey) +
213 sizeof (struct GNUNET_CRYPTO_EcdsaSignature); 209 sizeof(struct GNUNET_CRYPTO_EcdsaSignature);
214 210
215 GNUNET_STRINGS_base64_encode ((char*)entry->block, 211 GNUNET_STRINGS_base64_encode((char*)entry->block,
216 block_size, 212 block_size,
217 &block_b64); 213 &block_b64);
218 GNUNET_CRYPTO_hash_to_enc (&entry->query, 214 GNUNET_CRYPTO_hash_to_enc(&entry->query,
219 &query); 215 &query);
220 GNUNET_asprintf (&line, 216 GNUNET_asprintf(&line,
221 "%s,%s\n", 217 "%s,%s\n",
222 (char*)&query, 218 (char*)&query,
223 block_b64); 219 block_b64);
224 220
225 GNUNET_free (block_b64); 221 GNUNET_free(block_b64);
226 222
227 GNUNET_DISK_file_write (fh, 223 GNUNET_DISK_file_write(fh,
228 line, 224 line,
229 strlen (line)); 225 strlen(line));
230 226
231 GNUNET_free (entry->block); 227 GNUNET_free(entry->block);
232 GNUNET_free (entry); 228 GNUNET_free(entry);
233 GNUNET_free (line); 229 GNUNET_free(line);
234 return GNUNET_YES; 230 return GNUNET_YES;
235} 231}
236 232
@@ -240,49 +236,49 @@ store_and_free_entries (void *cls,
240 * @param plugin the plugin context (state for this module) 236 * @param plugin the plugin context (state for this module)
241 */ 237 */
242static void 238static void
243database_shutdown (struct Plugin *plugin) 239database_shutdown(struct Plugin *plugin)
244{ 240{
245 struct GNUNET_DISK_FileHandle *fh; 241 struct GNUNET_DISK_FileHandle *fh;
246 fh = GNUNET_DISK_file_open (plugin->fn, 242
247 GNUNET_DISK_OPEN_CREATE | 243 fh = GNUNET_DISK_file_open(plugin->fn,
248 GNUNET_DISK_OPEN_TRUNCATE | 244 GNUNET_DISK_OPEN_CREATE |
249 GNUNET_DISK_OPEN_READWRITE, 245 GNUNET_DISK_OPEN_TRUNCATE |
250 GNUNET_DISK_PERM_USER_WRITE | 246 GNUNET_DISK_OPEN_READWRITE,
251 GNUNET_DISK_PERM_USER_READ); 247 GNUNET_DISK_PERM_USER_WRITE |
248 GNUNET_DISK_PERM_USER_READ);
252 if (NULL == fh) 249 if (NULL == fh)
253 { 250 {
254 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 251 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
255 _("Unable to initialize file: %s.\n"), 252 _("Unable to initialize file: %s.\n"),
256 plugin->fn); 253 plugin->fn);
257 return; 254 return;
258 } 255 }
259
260 GNUNET_CONTAINER_multihashmap_iterate (plugin->hm,
261 &store_and_free_entries,
262 fh);
263 GNUNET_CONTAINER_multihashmap_destroy (plugin->hm);
264 GNUNET_DISK_file_close (fh);
265 256
257 GNUNET_CONTAINER_multihashmap_iterate(plugin->hm,
258 &store_and_free_entries,
259 fh);
260 GNUNET_CONTAINER_multihashmap_destroy(plugin->hm);
261 GNUNET_DISK_file_close(fh);
266} 262}
267 263
268static int 264static int
269expire_blocks (void *cls, 265expire_blocks(void *cls,
270 const struct GNUNET_HashCode *key, 266 const struct GNUNET_HashCode *key,
271 void *value) 267 void *value)
272{ 268{
273 struct Plugin *plugin = cls; 269 struct Plugin *plugin = cls;
274 struct FlatFileEntry *entry = value; 270 struct FlatFileEntry *entry = value;
275 struct GNUNET_TIME_Absolute now; 271 struct GNUNET_TIME_Absolute now;
276 struct GNUNET_TIME_Absolute expiration; 272 struct GNUNET_TIME_Absolute expiration;
277 273
278 now = GNUNET_TIME_absolute_get (); 274 now = GNUNET_TIME_absolute_get();
279 expiration = GNUNET_TIME_absolute_ntoh (entry->block->expiration_time); 275 expiration = GNUNET_TIME_absolute_ntoh(entry->block->expiration_time);
280 276
281 if (0 == GNUNET_TIME_absolute_get_difference (now, 277 if (0 == GNUNET_TIME_absolute_get_difference(now,
282 expiration).rel_value_us) 278 expiration).rel_value_us)
283 { 279 {
284 GNUNET_CONTAINER_multihashmap_remove_all (plugin->hm, key); 280 GNUNET_CONTAINER_multihashmap_remove_all(plugin->hm, key);
285 } 281 }
286 return GNUNET_YES; 282 return GNUNET_YES;
287} 283}
288 284
@@ -294,11 +290,11 @@ expire_blocks (void *cls,
294 * @param plugin the plugin 290 * @param plugin the plugin
295 */ 291 */
296static void 292static void
297namecache_expire_blocks (struct Plugin *plugin) 293namecache_expire_blocks(struct Plugin *plugin)
298{ 294{
299 GNUNET_CONTAINER_multihashmap_iterate (plugin->hm, 295 GNUNET_CONTAINER_multihashmap_iterate(plugin->hm,
300 &expire_blocks, 296 &expire_blocks,
301 plugin); 297 plugin);
302} 298}
303 299
304 300
@@ -310,43 +306,43 @@ namecache_expire_blocks (struct Plugin *plugin)
310 * @return #GNUNET_OK on success, else #GNUNET_SYSERR 306 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
311 */ 307 */
312static int 308static int
313namecache_cache_block (void *cls, 309namecache_cache_block(void *cls,
314 const struct GNUNET_GNSRECORD_Block *block) 310 const struct GNUNET_GNSRECORD_Block *block)
315{ 311{
316 struct Plugin *plugin = cls; 312 struct Plugin *plugin = cls;
317 struct GNUNET_HashCode query; 313 struct GNUNET_HashCode query;
318 struct FlatFileEntry *entry; 314 struct FlatFileEntry *entry;
319 size_t block_size; 315 size_t block_size;
320 316
321 namecache_expire_blocks (plugin); 317 namecache_expire_blocks(plugin);
322 GNUNET_CRYPTO_hash (&block->derived_key, 318 GNUNET_CRYPTO_hash(&block->derived_key,
323 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey), 319 sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey),
324 &query); 320 &query);
325 block_size = ntohl (block->purpose.size) + 321 block_size = ntohl(block->purpose.size) +
326 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) + 322 sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey) +
327 sizeof (struct GNUNET_CRYPTO_EcdsaSignature); 323 sizeof(struct GNUNET_CRYPTO_EcdsaSignature);
328 if (block_size > 64 * 65536) 324 if (block_size > 64 * 65536)
329 { 325 {
330 GNUNET_break (0); 326 GNUNET_break(0);
331 return GNUNET_SYSERR; 327 return GNUNET_SYSERR;
332 } 328 }
333 entry = GNUNET_malloc (sizeof (struct FlatFileEntry)); 329 entry = GNUNET_malloc(sizeof(struct FlatFileEntry));
334 entry->block = GNUNET_malloc (block_size); 330 entry->block = GNUNET_malloc(block_size);
335 GNUNET_memcpy (entry->block, block, block_size); 331 GNUNET_memcpy(entry->block, block, block_size);
336 GNUNET_CONTAINER_multihashmap_remove_all (plugin->hm, &query); 332 GNUNET_CONTAINER_multihashmap_remove_all(plugin->hm, &query);
337 if (GNUNET_OK != 333 if (GNUNET_OK !=
338 GNUNET_CONTAINER_multihashmap_put (plugin->hm, 334 GNUNET_CONTAINER_multihashmap_put(plugin->hm,
339 &query, 335 &query,
340 entry, 336 entry,
341 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) 337 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
342 { 338 {
343 GNUNET_free (entry); 339 GNUNET_free(entry);
344 GNUNET_break (0); 340 GNUNET_break(0);
345 return GNUNET_SYSERR; 341 return GNUNET_SYSERR;
346 } 342 }
347 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 343 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
348 "Caching block under derived key `%s'\n", 344 "Caching block under derived key `%s'\n",
349 GNUNET_h2s_full (&query)); 345 GNUNET_h2s_full(&query));
350 return GNUNET_OK; 346 return GNUNET_OK;
351} 347}
352 348
@@ -362,20 +358,20 @@ namecache_cache_block (void *cls,
362 * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error 358 * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error
363 */ 359 */
364static int 360static int
365namecache_lookup_block (void *cls, 361namecache_lookup_block(void *cls,
366 const struct GNUNET_HashCode *query, 362 const struct GNUNET_HashCode *query,
367 GNUNET_NAMECACHE_BlockCallback iter, void *iter_cls) 363 GNUNET_NAMECACHE_BlockCallback iter, void *iter_cls)
368{ 364{
369 struct Plugin *plugin = cls; 365 struct Plugin *plugin = cls;
370 const struct GNUNET_GNSRECORD_Block *block; 366 const struct GNUNET_GNSRECORD_Block *block;
371 367
372 block = GNUNET_CONTAINER_multihashmap_get (plugin->hm, query); 368 block = GNUNET_CONTAINER_multihashmap_get(plugin->hm, query);
373 if (NULL == block) 369 if (NULL == block)
374 return GNUNET_NO; 370 return GNUNET_NO;
375 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 371 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
376 "Found block under derived key `%s'\n", 372 "Found block under derived key `%s'\n",
377 GNUNET_h2s_full (query)); 373 GNUNET_h2s_full(query));
378 iter (iter_cls, block); 374 iter(iter_cls, block);
379 return GNUNET_YES; 375 return GNUNET_YES;
380} 376}
381 377
@@ -387,7 +383,7 @@ namecache_lookup_block (void *cls,
387 * @return NULL on error, otherwise the plugin context 383 * @return NULL on error, otherwise the plugin context
388 */ 384 */
389void * 385void *
390libgnunet_plugin_namecache_flat_init (void *cls) 386libgnunet_plugin_namecache_flat_init(void *cls)
391{ 387{
392 static struct Plugin plugin; 388 static struct Plugin plugin;
393 const struct GNUNET_CONFIGURATION_Handle *cfg = cls; 389 const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
@@ -395,19 +391,19 @@ libgnunet_plugin_namecache_flat_init (void *cls)
395 391
396 if (NULL != plugin.cfg) 392 if (NULL != plugin.cfg)
397 return NULL; /* can only initialize once! */ 393 return NULL; /* can only initialize once! */
398 memset (&plugin, 0, sizeof (struct Plugin)); 394 memset(&plugin, 0, sizeof(struct Plugin));
399 plugin.cfg = cfg; 395 plugin.cfg = cfg;
400 if (GNUNET_OK != database_setup (&plugin)) 396 if (GNUNET_OK != database_setup(&plugin))
401 { 397 {
402 database_shutdown (&plugin); 398 database_shutdown(&plugin);
403 return NULL; 399 return NULL;
404 } 400 }
405 api = GNUNET_new (struct GNUNET_NAMECACHE_PluginFunctions); 401 api = GNUNET_new(struct GNUNET_NAMECACHE_PluginFunctions);
406 api->cls = &plugin; 402 api->cls = &plugin;
407 api->cache_block = &namecache_cache_block; 403 api->cache_block = &namecache_cache_block;
408 api->lookup_block = &namecache_lookup_block; 404 api->lookup_block = &namecache_lookup_block;
409 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 405 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
410 _("flat plugin running\n")); 406 _("flat plugin running\n"));
411 return api; 407 return api;
412} 408}
413 409
@@ -419,16 +415,16 @@ libgnunet_plugin_namecache_flat_init (void *cls)
419 * @return always NULL 415 * @return always NULL
420 */ 416 */
421void * 417void *
422libgnunet_plugin_namecache_flat_done (void *cls) 418libgnunet_plugin_namecache_flat_done(void *cls)
423{ 419{
424 struct GNUNET_NAMECACHE_PluginFunctions *api = cls; 420 struct GNUNET_NAMECACHE_PluginFunctions *api = cls;
425 struct Plugin *plugin = api->cls; 421 struct Plugin *plugin = api->cls;
426 422
427 database_shutdown (plugin); 423 database_shutdown(plugin);
428 plugin->cfg = NULL; 424 plugin->cfg = NULL;
429 GNUNET_free (api); 425 GNUNET_free(api);
430 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 426 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
431 "flat plugin is finished\n"); 427 "flat plugin is finished\n");
432 return NULL; 428 return NULL;
433} 429}
434 430