GNUnet  0.11.x
Data Structures | Macros | Functions | Variables
gnsrecord.c File Reference

API to access GNS record data. More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_constants.h"
#include "gnunet_gnsrecord_lib.h"
#include "gnunet_gnsrecord_plugin.h"
#include "gnunet_tun_lib.h"
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 __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 a 'value' of a record to the binary representation. More...
 
uint32_t GNUNET_GNSRECORD_typename_to_number (const char *dns_typename)
 Convert a type name (i.e. More...
 
const char * GNUNET_GNSRECORD_number_to_typename (uint32_t type)
 Convert a type number (i.e. 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 35 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 79 of file gnsrecord.c.

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

Referenced by init().

82 {
83  struct GNUNET_GNSRECORD_PluginFunctions *api = lib_ret;
84  struct Plugin *plugin;
85 
87  "Loading block plugin `%s'\n",
88  library_name);
89  plugin = GNUNET_new (struct Plugin);
90  plugin->api = api;
93 }
#define GNUNET_array_append(arr, len, element)
Append an element to an array (growing the array by one).
#define GNUNET_new(type)
Allocate a struct or union of the given type.
char * library_name
Name of the shared library.
Definition: block.c:42
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static unsigned int num_plugins
Size of the 'plugins' array.
Definition: gnsrecord.c:63
static char * plugin
Solver plugin name as string.
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:37
#define GNUNET_log(kind,...)
static struct Plugin ** gns_plugins
Array of our plugins.
Definition: gnsrecord.c:58
Here is the caller graph for this function:

◆ init()

static void init ( )
static

Loads all plugins (lazy initialization).

Definition at line 100 of file gnsrecord.c.

References add_plugin(), GNUNET_OS_init(), GNUNET_OS_project_data_default(), GNUNET_OS_project_data_get(), GNUNET_PLUGIN_load_all(), and once.

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

101 {
102  if (1 == once)
103  return;
104  once = 1;
107 
108  if (pd != dpd)
109  GNUNET_OS_init (dpd);
110  GNUNET_PLUGIN_load_all ("libgnunet_plugin_gnsrecord_", NULL,
111  &add_plugin, NULL);
112  if (pd != dpd)
113  GNUNET_OS_init (pd);
114 }
Project-specific data used to help the OS subsystem find installation paths.
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:79
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_default(void)
Return default project data used by 'libgnunetutil' for GNUnet.
static int once
Global to mark if we've run the initialization.
Definition: gnsrecord.c:68
void GNUNET_PLUGIN_load_all(const char *basename, void *arg, GNUNET_PLUGIN_LoaderCallback cb, void *cb_cls)
Load all compatible plugins with the given base name.
Definition: plugin.c:372
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_get(void)
void GNUNET_OS_init(const struct GNUNET_OS_ProjectData *pd)
Setup OS subsystem with project data.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __attribute__()

void __attribute__ ( (destructor)  )

Dual function to init().

Definition at line 120 of file gnsrecord.c.

References Plugin::api, GNUNET_break, GNUNET_free, GNUNET_OS_init(), GNUNET_OS_project_data_default(), GNUNET_OS_project_data_get(), GNUNET_PLUGIN_unload(), Plugin::library_name, num_plugins, once, and plugin.

122 {
123  struct Plugin *plugin;
126 
127  if (pd != dpd)
128  GNUNET_OS_init (dpd);
129 
130  for (unsigned int i = 0; i < num_plugins; i++)
131  {
132  plugin = gns_plugins[i];
133  GNUNET_break (NULL ==
135  plugin->api));
136  GNUNET_free (plugin->library_name);
137  GNUNET_free (plugin);
138  }
140 
141  if (pd != dpd)
142  GNUNET_OS_init (pd);
143 
144  gns_plugins = NULL;
145  once = 0;
146  num_plugins = 0;
147 }
Project-specific data used to help the OS subsystem find installation paths.
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_default(void)
Return default project data used by &#39;libgnunetutil&#39; for GNUnet.
char * library_name
Name of the shared library.
Definition: block.c:42
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
void * GNUNET_PLUGIN_unload(const char *library_name, void *arg)
Unload plugin (runs the "done" callback and returns whatever "done" returned).
Definition: plugin.c:256
static int once
Global to mark if we&#39;ve run the initialization.
Definition: gnsrecord.c:68
static unsigned int num_plugins
Size of the &#39;plugins&#39; array.
Definition: gnsrecord.c:63
static char * plugin
Solver plugin name as string.
Handle for a plugin.
Definition: block.c:37
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_get(void)
static struct Plugin ** gns_plugins
Array of our plugins.
Definition: gnsrecord.c:58
void GNUNET_OS_init(const struct GNUNET_OS_ProjectData *pd)
Setup OS subsystem with project data.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:

Variable Documentation

◆ gns_plugins

struct Plugin** gns_plugins
static

Array of our plugins.

Definition at line 58 of file gnsrecord.c.

◆ num_plugins

unsigned int num_plugins
static

◆ once

int once
static

Global to mark if we've run the initialization.

Definition at line 68 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().