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

Go to the source code of this file.

Data Structures

struct  Plugin
 Handle for a plugin. More...
 

Functions

static void add_plugin (void *cls, const char *library_name, void *lib_ret)
 Add a plugin. More...
 
static void init ()
 Load plugins. More...
 
uint32_t GNUNET_RECLAIM_attestation_typename_to_number (const char *typename)
 Convert an attestation type name to the corresponding number. More...
 
const char * GNUNET_RECLAIM_attestation_number_to_typename (uint32_t type)
 Convert an attestation type number to the corresponding attestation type string. More...
 
int GNUNET_RECLAIM_attestation_string_to_value (uint32_t type, const char *s, void **data, size_t *data_size)
 Convert human-readable version of a 'claim' of an attestation to the binary representation. More...
 
char * GNUNET_RECLAIM_attestation_value_to_string (uint32_t type, const void *data, size_t data_size)
 Convert the 'claim' of an attestation to a string. More...
 
struct GNUNET_RECLAIM_AttestationGNUNET_RECLAIM_attestation_new (const char *attr_name, uint32_t type, const void *data, size_t data_size)
 Create a new attestation. More...
 
size_t GNUNET_RECLAIM_attestation_list_serialize_get_size (const struct GNUNET_RECLAIM_AttestationList *attestations)
 Get required size for serialization buffer. More...
 
size_t GNUNET_RECLAIM_attestation_list_serialize (const struct GNUNET_RECLAIM_AttestationList *attestations, char *result)
 Serialize an attribute list. More...
 
struct GNUNET_RECLAIM_AttestationListGNUNET_RECLAIM_attestation_list_deserialize (const char *data, size_t data_size)
 Deserialize an attestation list. More...
 
struct GNUNET_RECLAIM_AttestationListGNUNET_RECLAIM_attestation_list_dup (const struct GNUNET_RECLAIM_AttestationList *al)
 Make a (deep) copy of the attestation list. More...
 
void GNUNET_RECLAIM_attestation_list_destroy (struct GNUNET_RECLAIM_AttestationList *al)
 Destroy attestation list. More...
 
size_t GNUNET_RECLAIM_attestation_serialize_get_size (const struct GNUNET_RECLAIM_Attestation *attestation)
 Get required size for serialization buffer. More...
 
size_t GNUNET_RECLAIM_attestation_serialize (const struct GNUNET_RECLAIM_Attestation *attestation, char *result)
 Serialize an attestation. More...
 
struct GNUNET_RECLAIM_AttestationGNUNET_RECLAIM_attestation_deserialize (const char *data, size_t data_size)
 Deserialize an attestation. More...
 
struct GNUNET_RECLAIM_AttributeListGNUNET_RECLAIM_attestation_get_attributes (const struct GNUNET_RECLAIM_Attestation *attest)
 Convert an attestation type name to the corresponding number. More...
 
char * GNUNET_RECLAIM_attestation_get_issuer (const struct GNUNET_RECLAIM_Attestation *attest)
 
int GNUNET_RECLAIM_attestation_get_expiration (const struct GNUNET_RECLAIM_Attestation *attest, struct GNUNET_TIME_Absolute *exp)
 

Variables

static struct Plugin ** attest_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 
)
static

Add a plugin.

Parameters
clsclosure
library_namename of the API library
lib_retthe plugin API pointer

Definition at line 75 of file reclaim_attestation.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().

76 {
77  struct GNUNET_RECLAIM_AttestationPluginFunctions *api = lib_ret;
78  struct Plugin *plugin;
79 
81  "Loading attestation plugin `%s'\n",
82  library_name);
83  plugin = GNUNET_new (struct Plugin);
84  plugin->api = api;
87 }
static struct Plugin ** attest_plugins
Plugins.
#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
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
static unsigned int num_plugins
Number of plugins.
static char * plugin
Solver plugin name as string.
#define GNUNET_array_append(arr, size, element)
Append an element to a list (growing the list by one).
Handle for a plugin.
Definition: block.c:37
#define GNUNET_log(kind,...)
Here is the caller graph for this function:

◆ init()

static void init ( )
static

Load plugins.

Definition at line 94 of file reclaim_attestation.c.

References add_plugin(), GNUNET_PLUGIN_load_all(), GNUNET_YES, and initialized.

Referenced by GNUNET_RECLAIM_attestation_get_attributes(), GNUNET_RECLAIM_attestation_get_expiration(), GNUNET_RECLAIM_attestation_get_issuer(), GNUNET_RECLAIM_attestation_number_to_typename(), GNUNET_RECLAIM_attestation_string_to_value(), GNUNET_RECLAIM_attestation_typename_to_number(), and GNUNET_RECLAIM_attestation_value_to_string().

95 {
96  if (GNUNET_YES == initialized)
97  return;
99  GNUNET_PLUGIN_load_all ("libgnunet_plugin_reclaim_attestation_",
100  NULL,
101  &add_plugin,
102  NULL);
103 }
static void add_plugin(void *cls, const char *library_name, void *lib_ret)
Add a plugin.
static int initialized
Init canary.
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
#define GNUNET_YES
Definition: gnunet_common.h:85
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_attestation_list_dup()

struct GNUNET_RECLAIM_AttestationList* GNUNET_RECLAIM_attestation_list_dup ( const struct GNUNET_RECLAIM_AttestationList al)

Make a (deep) copy of the attestation list.

Parameters
attrsclaim list to copy
Returns
copied claim list

Definition at line 353 of file reclaim_attestation.c.

References GNUNET_RECLAIM_AttestationListEntry::attestation, GNUNET_RECLAIM_Attestation::data, GNUNET_RECLAIM_Attestation::data_size, GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_new, GNUNET_RECLAIM_attestation_new(), GNUNET_RECLAIM_Attestation::id, GNUNET_RECLAIM_AttestationList::list_head, GNUNET_RECLAIM_AttestationList::list_tail, GNUNET_RECLAIM_Attestation::name, GNUNET_RECLAIM_AttestationListEntry::next, result, and GNUNET_RECLAIM_Attestation::type.

355 {
357  struct GNUNET_RECLAIM_AttestationListEntry *result_ale;
359 
360  result = GNUNET_new (struct GNUNET_RECLAIM_AttestationList);
361  for (ale = al->list_head; NULL != ale; ale = ale->next)
362  {
363  result_ale = GNUNET_new (struct GNUNET_RECLAIM_AttestationListEntry);
364  GNUNET_assert (NULL != ale->attestation);
365  result_ale->attestation =
367  ale->attestation->type,
368  ale->attestation->data,
369  ale->attestation->data_size);
370  result_ale->attestation->id = ale->attestation->id;
372  result->list_tail,
373  result_ale);
374  }
375  return result;
376 }
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_RECLAIM_Attestation * attestation
The attestation.
A list of GNUNET_RECLAIM_Attestation structures.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static int result
Global testing status.
size_t data_size
Number of bytes in data.
struct GNUNET_RECLAIM_Attestation * GNUNET_RECLAIM_attestation_new(const char *attr_name, uint32_t type, const void *data, size_t data_size)
Create a new attestation.
const char * name
The name of the attribute.
struct GNUNET_RECLAIM_Identifier id
ID.
uint32_t type
Type/Format of Claim.
struct GNUNET_RECLAIM_AttestationListEntry * list_head
List head.
const void * data
Binary value stored as attribute value.
struct GNUNET_RECLAIM_AttestationListEntry * list_tail
List tail.
struct GNUNET_RECLAIM_AttestationListEntry * next
DLL.
Here is the call graph for this function:

Variable Documentation

◆ attest_plugins

struct Plugin** attest_plugins
static

Plugins.

Definition at line 52 of file reclaim_attestation.c.

◆ num_plugins

unsigned int num_plugins
static

◆ initialized

int initialized
static

Init canary.

Definition at line 64 of file reclaim_attestation.c.

Referenced by init().