GNUnet  0.11.x
Data Structures | Functions
plugin_namecache_flat.c File Reference

flat file-based namecache backend More...

#include "platform.h"
#include "gnunet_namecache_plugin.h"
#include "gnunet_namecache_service.h"
#include "gnunet_gnsrecord_lib.h"
#include "namecache.h"
Include dependency graph for plugin_namecache_flat.c:

Go to the source code of this file.

Data Structures

struct  Plugin
 Handle for a plugin. More...
 
struct  FlatFileEntry
 

Functions

static int database_setup (struct Plugin *plugin)
 Initialize the database connections and associated data structures (create tables and indices as needed as well). More...
 
static int store_and_free_entries (void *cls, const struct GNUNET_HashCode *key, void *value)
 Store values in hashmap in file and free data. More...
 
static void database_shutdown (struct Plugin *plugin)
 Shutdown database connection and associate data structures. More...
 
static int expire_blocks (void *cls, const struct GNUNET_HashCode *key, void *value)
 
static void namecache_expire_blocks (struct Plugin *plugin)
 Removes any expired block. More...
 
static int namecache_cache_block (void *cls, const struct GNUNET_GNSRECORD_Block *block)
 Cache a block in the datastore. More...
 
static int namecache_lookup_block (void *cls, const struct GNUNET_HashCode *query, GNUNET_NAMECACHE_BlockCallback iter, void *iter_cls)
 Get the block for a particular zone and label in the datastore. More...
 
void * libgnunet_plugin_namecache_flat_init (void *cls)
 Entry point for the plugin. More...
 
void * libgnunet_plugin_namecache_flat_done (void *cls)
 Exit point from the plugin. More...
 

Detailed Description

flat file-based namecache backend

Author
Martin Schanzenbach

Definition in file plugin_namecache_flat.c.

Function Documentation

◆ database_setup()

static int database_setup ( struct Plugin plugin)
static

Initialize the database connections and associated data structures (create tables and indices as needed as well).

Parameters
pluginthe plugin context (state for this module)
Returns
GNUNET_OK on success

Definition at line 73 of file plugin_namecache_flat.c.

References _, FlatFileEntry::block, Plugin::cfg, fh, Plugin::fn, GNUNET_assert, GNUNET_break, GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CRYPTO_hash_from_string, GNUNET_DISK_directory_create_for_file(), GNUNET_DISK_file_close(), GNUNET_DISK_file_open(), GNUNET_DISK_file_read(), GNUNET_DISK_file_size(), GNUNET_DISK_file_test(), GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_OPEN_READWRITE, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_log_config_missing(), GNUNET_malloc, GNUNET_NO, GNUNET_OK, GNUNET_STRINGS_base64_decode(), GNUNET_SYSERR, GNUNET_YES, Plugin::hm, line, FlatFileEntry::query, and Plugin::size.

Referenced by libgnunet_plugin_namecache_flat_init().

74 {
75  char *afsdir;
76  char*block_buffer;
77  char*buffer;
78  char*line;
79  char*query;
80  char*block;
81  uint64_t size;
82  struct FlatFileEntry *entry;
83  struct GNUNET_DISK_FileHandle *fh;
84 
85  if (GNUNET_OK !=
87  "namecache-flat",
88  "FILENAME",
89  &afsdir))
90  {
92  "namecache-flat", "FILENAME");
93  return GNUNET_SYSERR;
94  }
95  if (GNUNET_OK != GNUNET_DISK_file_test (afsdir))
96  {
98  {
99  GNUNET_break (0);
100  GNUNET_free (afsdir);
101  return GNUNET_SYSERR;
102  }
103  }
104  /* afsdir should be UTF-8-encoded. If it isn't, it's a bug */
105  plugin->fn = afsdir;
106 
107  /* Load data from file into hashmap */
109  GNUNET_NO);
110  fh = GNUNET_DISK_file_open (afsdir,
115  if (NULL == fh)
116  {
118  _ ("Unable to initialize file: %s.\n"),
119  afsdir);
120  return GNUNET_SYSERR;
121  }
122 
123  if (GNUNET_SYSERR == GNUNET_DISK_file_size (afsdir,
124  &size,
125  GNUNET_YES,
126  GNUNET_YES))
127  {
129  _ ("Unable to get filesize: %s.\n"),
130  afsdir);
132  return GNUNET_SYSERR;
133  }
134 
135  if (0 == size)
136  {
138  return GNUNET_OK;
139  }
140 
141  buffer = GNUNET_malloc (size + 1);
142 
144  buffer,
145  size))
146  {
148  _ ("Unable to read file: %s.\n"),
149  afsdir);
150  GNUNET_free (buffer);
152  return GNUNET_SYSERR;
153  }
154  buffer[size] = '\0';
155 
157  if (0 < size)
158  {
159  line = strtok (buffer, "\n");
160  while (line != NULL)
161  {
162  query = strtok (line, ",");
163  if (NULL == query)
164  break;
165  block = strtok (NULL, ",");
166  if (NULL == block)
167  break;
168  line = strtok (NULL, "\n");
169  entry = GNUNET_malloc (sizeof(struct FlatFileEntry));
171  &entry->query));
173  strlen (block),
174  (void **) &block_buffer);
175  entry->block = (struct GNUNET_GNSRECORD_Block *) block_buffer;
176  if (GNUNET_OK !=
178  &entry->query,
179  entry,
181  {
182  GNUNET_free (entry);
183  GNUNET_break (0);
184  }
185  }
186  }
187  GNUNET_free (buffer);
188  return GNUNET_OK;
189 }
int GNUNET_DISK_file_test(const char *fil)
Check that fil corresponds to a filename (of a file that exists and that is not a directory)...
Definition: disk.c:544
Create file if it doesn&#39;t exist.
int GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1280
struct GNUNET_GNSRECORD_Block * block
Block.
ssize_t GNUNET_DISK_file_read(const struct GNUNET_DISK_FileHandle *h, void *result, size_t len)
Read the contents of a binary file into a buffer.
Definition: disk.c:732
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_HashCode query
query
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
int GNUNET_DISK_directory_create_for_file(const char *filename)
Create the directory structure for storing a file.
Definition: disk.c:684
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define _(String)
GNU gettext support macro.
Definition: platform.h:184
static char * line
Desired phone line (string to be converted to a hash).
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
static int fh
Handle to the unique file.
size_t GNUNET_STRINGS_base64_decode(const char *data, size_t len, void **output)
Decode from Base64.
Definition: strings.c:1978
There must only be one value per key; storing a value should fail if a value under the same key alrea...
static unsigned int size
Size of the "table".
Definition: peer.c:67
struct GNUNET_CONTAINER_MultiHashMap * hm
HashMap.
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
int GNUNET_DISK_file_size(const char *filename, uint64_t *size, int include_symbolic_links, int single_file_mode)
Get the size of the file (or directory) of the given file (in bytes).
Definition: disk.c:257
char * fn
Filename used for the DB.
#define GNUNET_log(kind,...)
Open the file for both reading and writing.
int GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
Definition: disk.c:1203
#define GNUNET_CRYPTO_hash_from_string(enc, result)
Convert ASCII encoding back to struct GNUNET_HashCode
Handle used to access files (and pipes).
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ store_and_free_entries()

static int store_and_free_entries ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Store values in hashmap in file and free data.

Parameters
pluginthe plugin context

Definition at line 198 of file plugin_namecache_flat.c.

References FlatFileEntry::block, fh, GNUNET_asprintf(), GNUNET_CRYPTO_hash_to_enc(), GNUNET_DISK_file_write(), GNUNET_free, GNUNET_GNSRECORD_block_get_size(), GNUNET_STRINGS_base64_encode(), GNUNET_YES, line, FlatFileEntry::query, and value.

Referenced by database_shutdown().

201 {
202  struct GNUNET_DISK_FileHandle *fh = cls;
203  struct FlatFileEntry *entry = value;
204 
205  char *line;
206  char *block_b64;
207  struct GNUNET_CRYPTO_HashAsciiEncoded query;
208  size_t block_size;
209 
210  block_size = GNUNET_GNSRECORD_block_get_size (entry->block);
211  GNUNET_STRINGS_base64_encode ((char *) entry->block,
212  block_size,
213  &block_b64);
215  &query);
216  GNUNET_asprintf (&line,
217  "%s,%s\n",
218  (char *) &query,
219  block_b64);
220 
221  GNUNET_free (block_b64);
222 
224  line,
225  strlen (line));
226 
227  GNUNET_free (entry->block);
228  GNUNET_free (entry);
229  GNUNET_free (line);
230  return GNUNET_YES;
231 }
struct GNUNET_GNSRECORD_Block * block
Block.
struct GNUNET_HashCode query
query
static char * line
Desired phone line (string to be converted to a hash).
static char * value
Value of the record to add/remove.
size_t GNUNET_GNSRECORD_block_get_size(const struct GNUNET_GNSRECORD_Block *block)
Returns the length of this block in bytes.
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
Definition: disk.c:820
static int fh
Handle to the unique file.
size_t GNUNET_STRINGS_base64_encode(const void *in, size_t len, char **output)
Encode into Base64.
Definition: strings.c:1876
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
void GNUNET_CRYPTO_hash_to_enc(const struct GNUNET_HashCode *block, struct GNUNET_CRYPTO_HashAsciiEncoded *result)
Convert hash to ASCII encoding.
Definition: crypto_hash.c:73
0-terminated ASCII encoding of a struct GNUNET_HashCode.
Handle used to access files (and pipes).
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ database_shutdown()

static void database_shutdown ( struct Plugin plugin)
static

Shutdown database connection and associate data structures.

Parameters
pluginthe plugin context (state for this module)

Definition at line 240 of file plugin_namecache_flat.c.

References _, fh, Plugin::fn, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_DISK_file_close(), GNUNET_DISK_file_open(), GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_OPEN_READWRITE, GNUNET_DISK_OPEN_TRUNCATE, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, Plugin::hm, and store_and_free_entries().

Referenced by libgnunet_plugin_namecache_flat_done(), and libgnunet_plugin_namecache_flat_init().

241 {
242  struct GNUNET_DISK_FileHandle *fh;
243 
244  fh = GNUNET_DISK_file_open (plugin->fn,
250  if (NULL == fh)
251  {
253  _ ("Unable to initialize file: %s.\n"),
254  plugin->fn);
255  return;
256  }
257 
260  fh);
263 }
Create file if it doesn&#39;t exist.
int GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1280
#define _(String)
GNU gettext support macro.
Definition: platform.h:184
Truncate file if it exists.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
static int fh
Handle to the unique file.
static int store_and_free_entries(void *cls, const struct GNUNET_HashCode *key, void *value)
Store values in hashmap in file and free data.
struct GNUNET_CONTAINER_MultiHashMap * hm
HashMap.
char * fn
Filename used for the DB.
#define GNUNET_log(kind,...)
Open the file for both reading and writing.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
Definition: disk.c:1203
Handle used to access files (and pipes).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ expire_blocks()

static int expire_blocks ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Definition at line 267 of file plugin_namecache_flat.c.

References FlatFileEntry::block, GNUNET_CONTAINER_multihashmap_remove_all(), GNUNET_GNSRECORD_block_get_expiration(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_difference(), GNUNET_YES, Plugin::hm, plugin, and value.

270 {
271  struct Plugin *plugin = cls;
272  struct FlatFileEntry *entry = value;
273  struct GNUNET_TIME_Absolute now;
275 
276  now = GNUNET_TIME_absolute_get ();
278 
280  expiration).rel_value_us)
281  {
283  }
284  return GNUNET_YES;
285 }
struct GNUNET_GNSRECORD_Block * block
Block.
int GNUNET_CONTAINER_multihashmap_remove_all(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Remove all entries for the given key from the map.
static char * value
Value of the record to add/remove.
static char * expiration
Credential TTL.
Definition: gnunet-abd.c:96
static char * plugin
Solver plugin name as string.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
struct GNUNET_CONTAINER_MultiHashMap * hm
HashMap.
Handle for a plugin.
Definition: block.c:37
Time for absolute times used by GNUnet, in microseconds.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_difference(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Absolute end)
Compute the time difference between the given start and end times.
Definition: time.c:354
struct GNUNET_TIME_Absolute GNUNET_GNSRECORD_block_get_expiration(const struct GNUNET_GNSRECORD_Block *block)
Returns the expiration of a block.
Here is the call graph for this function:

◆ namecache_expire_blocks()

static void namecache_expire_blocks ( struct Plugin plugin)
static

Removes any expired block.

Parameters
pluginthe plugin

Definition at line 294 of file plugin_namecache_flat.c.

References Plugin::expire_blocks, GNUNET_CONTAINER_multihashmap_iterate(), and Plugin::hm.

Referenced by namecache_cache_block().

295 {
297  &expire_blocks,
298  plugin);
299 }
struct GNUNET_CONTAINER_MultiHashMap * hm
HashMap.
static int expire_blocks(void *cls, const struct GNUNET_HashCode *key, void *value)
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ namecache_cache_block()

static int namecache_cache_block ( void *  cls,
const struct GNUNET_GNSRECORD_Block block 
)
static

Cache a block in the datastore.

Parameters
clsclosure (internal context for the plugin)
blockblock to cache
Returns
GNUNET_OK on success, else GNUNET_SYSERR

Definition at line 310 of file plugin_namecache_flat.c.

References FlatFileEntry::block, GNUNET_break, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_multihashmap_remove_all(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_GNSRECORD_block_get_size(), GNUNET_GNSRECORD_query_from_block(), GNUNET_h2s_full(), GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_OK, GNUNET_SYSERR, Plugin::hm, namecache_expire_blocks(), and plugin.

Referenced by libgnunet_plugin_namecache_flat_init().

312 {
313  struct Plugin *plugin = cls;
314  struct GNUNET_HashCode query;
315  struct FlatFileEntry *entry;
316  size_t block_size;
317 
318  namecache_expire_blocks (plugin);
320  &query);
321  block_size = GNUNET_GNSRECORD_block_get_size (block);
322  if (block_size > 64 * 65536)
323  {
324  GNUNET_break (0);
325  return GNUNET_SYSERR;
326  }
327  entry = GNUNET_malloc (sizeof(struct FlatFileEntry));
328  entry->block = GNUNET_malloc (block_size);
329  GNUNET_memcpy (entry->block, block, block_size);
331  if (GNUNET_OK !=
333  &query,
334  entry,
336  {
337  GNUNET_free (entry);
338  GNUNET_break (0);
339  return GNUNET_SYSERR;
340  }
342  "Caching block under derived key `%s'\n",
344  return GNUNET_OK;
345 }
struct GNUNET_GNSRECORD_Block * block
Block.
struct GNUNET_HashCode query
query
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
int GNUNET_CONTAINER_multihashmap_remove_all(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Remove all entries for the given key from the map.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
size_t GNUNET_GNSRECORD_block_get_size(const struct GNUNET_GNSRECORD_Block *block)
Returns the length of this block in bytes.
static void namecache_expire_blocks(struct Plugin *plugin)
Removes any expired block.
A 512-bit hashcode.
static char * plugin
Solver plugin name as string.
There must only be one value per key; storing a value should fail if a value under the same key alrea...
struct GNUNET_CONTAINER_MultiHashMap * hm
HashMap.
const char * GNUNET_h2s_full(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
Handle for a plugin.
Definition: block.c:37
#define GNUNET_log(kind,...)
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_query_from_block(const struct GNUNET_GNSRECORD_Block *block, struct GNUNET_HashCode *query)
Builds the query hash from a block.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ namecache_lookup_block()

static int namecache_lookup_block ( void *  cls,
const struct GNUNET_HashCode query,
GNUNET_NAMECACHE_BlockCallback  iter,
void *  iter_cls 
)
static

Get the block for a particular zone and label in the datastore.

Will return at most one result to the iterator.

Parameters
clsclosure (internal context for the plugin)
queryhash of public key derived from the zone and the label
iterfunction to call with the result
iter_clsclosure for iter
Returns
GNUNET_OK on success, GNUNET_NO if there were no results, GNUNET_SYSERR on error

Definition at line 359 of file plugin_namecache_flat.c.

References GNUNET_CONTAINER_multihashmap_get(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s_full(), GNUNET_log, GNUNET_NO, GNUNET_YES, Plugin::hm, Plugin::iter, and plugin.

Referenced by libgnunet_plugin_namecache_flat_init().

362 {
363  struct Plugin *plugin = cls;
364  const struct GNUNET_GNSRECORD_Block *block;
365 
366  block = GNUNET_CONTAINER_multihashmap_get (plugin->hm, query);
367  if (NULL == block)
368  return GNUNET_NO;
370  "Found block under derived key `%s'\n",
371  GNUNET_h2s_full (query));
372  iter (iter_cls, block);
373  return GNUNET_YES;
374 }
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
static char * plugin
Solver plugin name as string.
struct GNUNET_CONTAINER_MultiHashMap * hm
HashMap.
const char * GNUNET_h2s_full(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
Handle for a plugin.
Definition: block.c:37
#define GNUNET_log(kind,...)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ libgnunet_plugin_namecache_flat_init()

void* libgnunet_plugin_namecache_flat_init ( void *  cls)

Entry point for the plugin.

Parameters
clsthe "struct GNUNET_NAMECACHE_PluginEnvironment*"
Returns
NULL on error, otherwise the plugin context

Definition at line 384 of file plugin_namecache_flat.c.

References _, Plugin::api, GNUNET_NAMECACHE_PluginFunctions::cache_block, Plugin::cfg, GNUNET_NAMECACHE_PluginFunctions::cls, database_setup(), database_shutdown(), GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_new, GNUNET_OK, GNUNET_NAMECACHE_PluginFunctions::lookup_block, namecache_cache_block(), namecache_lookup_block(), and plugin.

385 {
386  static struct Plugin plugin;
387  const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
389 
390  if (NULL != plugin.cfg)
391  return NULL; /* can only initialize once! */
392  memset (&plugin, 0, sizeof(struct Plugin));
393  plugin.cfg = cfg;
394  if (GNUNET_OK != database_setup (&plugin))
395  {
397  return NULL;
398  }
400  api->cls = &plugin;
404  _ ("flat plugin running\n"));
405  return api;
406 }
void * cls
Closure to pass to all plugin functions.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static int namecache_cache_block(void *cls, const struct GNUNET_GNSRECORD_Block *block)
Cache a block in the datastore.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define _(String)
GNU gettext support macro.
Definition: platform.h:184
int(* cache_block)(void *cls, const struct GNUNET_GNSRECORD_Block *block)
Cache a block in the datastore.
int(* lookup_block)(void *cls, const struct GNUNET_HashCode *query, GNUNET_NAMECACHE_BlockCallback iter, void *iter_cls)
Get the block for a particular zone and label in the datastore.
static char * plugin
Solver plugin name as string.
struct returned by the initialization function of the plugin
static void database_shutdown(struct Plugin *plugin)
Shutdown database connection and associate data structures.
configuration data
Definition: configuration.c:84
Handle for a plugin.
Definition: block.c:37
#define GNUNET_log(kind,...)
static int namecache_lookup_block(void *cls, const struct GNUNET_HashCode *query, GNUNET_NAMECACHE_BlockCallback iter, void *iter_cls)
Get the block for a particular zone and label in the datastore.
static int database_setup(struct Plugin *plugin)
Initialize the database connections and associated data structures (create tables and indices as need...
Here is the call graph for this function:

◆ libgnunet_plugin_namecache_flat_done()

void* libgnunet_plugin_namecache_flat_done ( void *  cls)

Exit point from the plugin.

Parameters
clsthe plugin context (as returned by "init")
Returns
always NULL

Definition at line 416 of file plugin_namecache_flat.c.

References Plugin::api, Plugin::cfg, GNUNET_NAMECACHE_PluginFunctions::cls, database_shutdown(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, and plugin.

417 {
419  struct Plugin *plugin = api->cls;
420 
421  database_shutdown (plugin);
422  plugin->cfg = NULL;
423  GNUNET_free (api);
425  "flat plugin is finished\n");
426  return NULL;
427 }
void * cls
Closure to pass to all plugin functions.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static char * plugin
Solver plugin name as string.
struct returned by the initialization function of the plugin
static void database_shutdown(struct Plugin *plugin)
Shutdown database connection and associate data structures.
Handle for a plugin.
Definition: block.c:37
#define GNUNET_log(kind,...)
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function: