GNUnet  0.11.x
Data Structures | Functions | Variables
reclaim_attribute.c File Reference
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_reclaim_plugin.h"
#include "reclaim_attribute.h"
Include dependency graph for reclaim_attribute.c:

Go to the source code of this file.

Data Structures

struct  Plugin
 Handle for a plugin. More...


static void add_plugin (void *cls, const char *library_name, void *lib_ret)
 Add a plugin. More...
static void init ()
 Load plugins. More...
void __attribute__ ((destructor))
 Dual function to init(). More...
uint32_t GNUNET_RECLAIM_attribute_typename_to_number (const char *typename)
 Convert a type name to the corresponding number. More...
const char * GNUNET_RECLAIM_attribute_number_to_typename (uint32_t type)
 Convert a type number to the corresponding type string. More...
int GNUNET_RECLAIM_attribute_string_to_value (uint32_t type, const char *s, void **data, size_t *data_size)
 Convert human-readable version of a 'claim' of an attribute to the binary representation. More...
char * GNUNET_RECLAIM_attribute_value_to_string (uint32_t type, const void *data, size_t data_size)
 Convert the 'claim' of an attribute to a string. More...
struct GNUNET_RECLAIM_AttributeGNUNET_RECLAIM_attribute_new (const char *attr_name, const struct GNUNET_RECLAIM_Identifier *credential, uint32_t type, const void *data, size_t data_size)
 Create a new attribute. More...
void GNUNET_RECLAIM_attribute_list_add (struct GNUNET_RECLAIM_AttributeList *al, const char *attr_name, const struct GNUNET_RECLAIM_Identifier *credential, uint32_t type, const void *data, size_t data_size)
 Add a new attribute to a claim list. More...
size_t GNUNET_RECLAIM_attribute_list_serialize_get_size (const struct GNUNET_RECLAIM_AttributeList *al)
 Get required size for serialization buffer. More...
size_t GNUNET_RECLAIM_attribute_list_serialize (const struct GNUNET_RECLAIM_AttributeList *al, char *result)
 Serialize an attribute list. More...
struct GNUNET_RECLAIM_AttributeListGNUNET_RECLAIM_attribute_list_deserialize (const char *data, size_t data_size)
 Deserialize an attribute list. More...
struct GNUNET_RECLAIM_AttributeListGNUNET_RECLAIM_attribute_list_dup (const struct GNUNET_RECLAIM_AttributeList *al)
 Make a (deep) copy of a claim list. More...
void GNUNET_RECLAIM_attribute_list_destroy (struct GNUNET_RECLAIM_AttributeList *al)
 Destroy claim list. More...
size_t GNUNET_RECLAIM_attribute_serialize_get_size (const struct GNUNET_RECLAIM_Attribute *attr)
 Get required size for serialization buffer. More...
size_t GNUNET_RECLAIM_attribute_serialize (const struct GNUNET_RECLAIM_Attribute *attr, char *result)
 Serialize an attribute. More...
ssize_t GNUNET_RECLAIM_attribute_deserialize (const char *data, size_t data_size, struct GNUNET_RECLAIM_Attribute **attr)
 Deserialize an attribute. More...


static struct Plugin ** attr_plugins
 Plugins. More...
static unsigned int num_plugins
 Number of plugins. More...
static int initialized
 Init canary. More...

Function Documentation

◆ add_plugin()

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

Add a plugin.

library_namename of the API library
lib_retthe plugin API pointer

Definition at line 75 of file reclaim_attribute.c.

76 {
77  struct GNUNET_RECLAIM_AttributePluginFunctions *api = lib_ret;
78  struct Plugin *plugin;
81  "Loading attribute plugin `%s'\n",
82  library_name);
83  plugin = GNUNET_new (struct Plugin);
84  plugin->api = api;
87 }
struct Plugin * plugin
The process handle to the testbed service.
#define GNUNET_log(kind,...)
#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).
static struct Plugin ** attr_plugins
static unsigned int num_plugins
Number of plugins.
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, attr_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 ( )

Load plugins.

Definition at line 94 of file reclaim_attribute.c.

95 {
96  if (GNUNET_YES == initialized)
97  return;
100  "libgnunet_plugin_reclaim_attribute_",
101  NULL,
102  &add_plugin,
103  NULL);
104 }
Definition: gnunet_common.h:97
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_default(void)
Return default project data used by 'libgnunetutil' for GNUnet.
void GNUNET_PLUGIN_load_all_in_context(const struct GNUNET_OS_ProjectData *ctx, const char *basename, void *arg, GNUNET_PLUGIN_LoaderCallback cb, void *cb_cls)
Load all compatible plugins with the given base name while inside the given context (i....
Definition: plugin.c:443
static void add_plugin(void *cls, const char *library_name, void *lib_ret)
Add a plugin.
static int initialized
Init canary.

References add_plugin(), GNUNET_OS_project_data_default(), GNUNET_PLUGIN_load_all_in_context(), GNUNET_YES, and initialized.

Referenced by GNUNET_RECLAIM_attribute_number_to_typename(), GNUNET_RECLAIM_attribute_string_to_value(), GNUNET_RECLAIM_attribute_typename_to_number(), and GNUNET_RECLAIM_attribute_value_to_string().

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 109 of file reclaim_attribute.c.

111 {
112  struct Plugin *plugin;
116  if (pd != dpd)
117  GNUNET_OS_init (dpd);
119  for (unsigned int i = 0; i < num_plugins; i++)
120  {
121  plugin = attr_plugins[i];
122  GNUNET_break (NULL ==
124  plugin->api));
127  }
130  if (pd != dpd)
131  GNUNET_OS_init (pd);
133  attr_plugins = NULL;
134 }
#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.
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.
void * GNUNET_PLUGIN_unload(const char *library_name, void *arg)
Unload plugin (runs the "done" callback and returns whatever "done" returned).
Definition: plugin.c:269
Project-specific data used to help the OS subsystem find installation paths.

References Plugin::api, attr_plugins, 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, and plugin.

Here is the call graph for this function:

Variable Documentation

◆ attr_plugins

struct Plugin** attr_plugins

◆ num_plugins

unsigned int num_plugins

◆ initialized

int initialized

Init canary.

Definition at line 64 of file reclaim_attribute.c.

Referenced by init().