GNUnet 0.22.2
gnsrecord.c File Reference

API to access GNS record data. More...

Include dependency graph for gnsrecord.c:

Go to the source code of this file.

Data Structures

struct  Plugin
 Handle for a plugin. More...
 

Macros

#define LOG(kind, ...)   GNUNET_log_from (kind, "gnsrecord", __VA_ARGS__)
 

Functions

static void add_plugin (void *cls, const char *library_name, void *lib_ret)
 Add a plugin to the list managed by the block library. More...
 
static void init ()
 Loads all plugins (lazy initialization). More...
 
void GNSRECORD_fini (void)
 
void __attribute__ ((destructor))
 Dual function to init(). More...
 
char * GNUNET_GNSRECORD_value_to_string (uint32_t type, const void *data, size_t data_size)
 Convert the 'value' of a record to a string. More...
 
int GNUNET_GNSRECORD_string_to_value (uint32_t type, const char *s, void **data, size_t *data_size)
 Convert human-readable version of the value s of a record of type type to the respective binary representation. More...
 
uint32_t GNUNET_GNSRECORD_typename_to_number (const char *dns_typename)
 Convert a type name (e.g. More...
 
const char * GNUNET_GNSRECORD_number_to_typename (uint32_t type)
 Convert a type number to the corresponding type string (e.g. More...
 
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_is_critical (uint32_t type)
 Check if this type is a critical record. More...
 

Variables

static struct Plugin ** gns_plugins
 Array of our plugins. More...
 
static unsigned int num_plugins
 Size of the 'plugins' array. More...
 
static int once
 Global to mark if we've run the initialization. More...
 

Detailed Description

API to access GNS record data.

Author
Martin Schanzenbach
Matthias Wachs
Christian Grothoff

Definition in file gnsrecord.c.

Macro Definition Documentation

◆ LOG

#define LOG (   kind,
  ... 
)    GNUNET_log_from (kind, "gnsrecord", __VA_ARGS__)

Definition at line 32 of file gnsrecord.c.

Function Documentation

◆ add_plugin()

static void add_plugin ( void *  cls,
const char *  library_name,
void *  lib_ret 
)
static

Add a plugin to the list managed by the block library.

Parameters
clsNULL
library_namename of the plugin
lib_retthe plugin API

Definition at line 76 of file gnsrecord.c.

79{
80 struct GNUNET_GNSRECORD_PluginFunctions *api = lib_ret;
81 struct Plugin *plugin;
82
84 "Loading block plugin `%s'\n",
86 plugin = GNUNET_new (struct Plugin);
87 plugin->api = api;
88 plugin->library_name = GNUNET_strdup (library_name);
90}
static unsigned int num_plugins
Size of the 'plugins' array.
Definition: gnsrecord.c:60
static struct Plugin ** gns_plugins
Array of our plugins.
Definition: gnsrecord.c:55
static struct GNUNET_TESTING_PluginFunctions * plugin
Plugin to dynamically load a test case.
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_array_append(arr, len, element)
Append an element to an array (growing the array by one).
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
Handle for a plugin.
Definition: block.c:38
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
char * library_name
Name of the shared library.
Definition: block.c:42

References Plugin::api, gns_plugins, GNUNET_array_append, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_strdup, Plugin::library_name, num_plugins, and plugin.

Referenced by init().

Here is the caller graph for this function:

◆ init()

static void init ( )
static

Loads all plugins (lazy initialization).

Definition at line 97 of file gnsrecord.c.

98{
99 if (1 == once)
100 return;
101 once = 1;
103 "libgnunet_plugin_gnsrecord_",
104 NULL,
105 &add_plugin,
106 NULL);
107}
static void add_plugin(void *cls, const char *library_name, void *lib_ret)
Add a plugin to the list managed by the block library.
Definition: gnsrecord.c:76
static int once
Global to mark if we've run the initialization.
Definition: gnsrecord.c:65
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
void GNUNET_PLUGIN_load_all(const struct GNUNET_OS_ProjectData *pd, const char *basename, void *arg, GNUNET_PLUGIN_LoaderCallback cb, void *cb_cls)
Load all compatible plugins with the given base name.
Definition: plugin.c:401

References add_plugin(), GNUNET_OS_project_data_gnunet(), GNUNET_PLUGIN_load_all(), and once.

Referenced by GNUNET_GNSRECORD_is_critical(), GNUNET_GNSRECORD_number_to_typename(), GNUNET_GNSRECORD_string_to_value(), GNUNET_GNSRECORD_typename_to_number(), and GNUNET_GNSRECORD_value_to_string().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNSRECORD_fini()

void GNSRECORD_fini ( void  )

◆ __attribute__()

void __attribute__ ( (destructor)  )

Dual function to init().

Definition at line 117 of file gnsrecord.c.

119{
120 struct Plugin *plugin;
121
122 for (unsigned int i = 0; i < num_plugins; i++)
123 {
124 plugin = gns_plugins[i];
125 GNUNET_break (NULL ==
126 GNUNET_PLUGIN_unload (plugin->library_name,
127 plugin->api));
128 GNUNET_free (plugin->library_name);
130 }
132 gns_plugins = NULL;
133 once = 0;
134 num_plugins = 0;
135}
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_PLUGIN_unload(const char *library_name, void *arg)
Unload plugin (runs the "done" callback and returns whatever "done" returned).
Definition: plugin.c:277

References gns_plugins, GNUNET_break, GNUNET_free, GNUNET_PLUGIN_unload(), num_plugins, once, and plugin.

Here is the call graph for this function:

Variable Documentation

◆ gns_plugins

◆ num_plugins

◆ once

int once
static

Global to mark if we've run the initialization.

Definition at line 65 of file gnsrecord.c.

Referenced by __attribute__(), conn_status(), crc_init(), GNUNET_CRYPTO_ecdsa_key_get_anonymous(), GNUNET_CRYPTO_hmac_raw(), init(), and task_check().