gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [gnunet] 160/171: -fix makefile


From: gnunet
Subject: [GNUnet-SVN] [gnunet] 160/171: -fix makefile
Date: Thu, 04 Jan 2018 16:11:08 +0100

This is an automated email from the git hooks/post-receive script.

martin-schanzenbach pushed a commit to branch master
in repository gnunet.

commit f485d0399e8ef0c388a321bbad7ae424935752bc
Author: Schanzenbach, Martin <address@hidden>
AuthorDate: Mon Dec 4 16:37:28 2017 +0100

    -fix makefile
---
 po/POTFILES.in                              |   2 +-
 src/identity-attribute/Makefile.am          |   2 +-
 src/identity-attribute/identity_attribute.c | 176 ++++++++++++++++++++++++++++
 src/identity-provider/gnunet-idp.c          |  12 +-
 src/include/gnunet_identity_attribute_lib.h |  45 +++++++
 5 files changed, 231 insertions(+), 6 deletions(-)

diff --git a/po/POTFILES.in b/po/POTFILES.in
index b06eb3a9f..01c197fcd 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -197,7 +197,7 @@ src/hostlist/gnunet-daemon-hostlist.c
 src/hostlist/gnunet-daemon-hostlist_client.c
 src/hostlist/gnunet-daemon-hostlist_server.c
 src/identity-attribute/identity_attribute.c
-src/identity-attribute/plugin_identity_attribute_type_gnuid.c
+src/identity-attribute/plugin_identity_attribute_gnuid.c
 src/identity-provider/gnunet-idp.c
 src/identity-provider/gnunet-service-identity-provider.c
 src/identity-provider/identity_provider_api.c
diff --git a/src/identity-attribute/Makefile.am 
b/src/identity-attribute/Makefile.am
index 770bc2ead..583545344 100644
--- a/src/identity-attribute/Makefile.am
+++ b/src/identity-attribute/Makefile.am
@@ -38,7 +38,7 @@ libgnunet_plugin_identity_attribute_gnuid_la_SOURCES = \
 libgnunet_plugin_identity_attribute_gnuid_la_LIBADD = \
   $(top_builddir)/src/util/libgnunetutil.la \
   $(LTLIBINTL)
-libgnunet_plugin_gnsrecord_dns_la_LDFLAGS = \
+libgnunet_plugin_identity_attribute_gnuid_la_LDFLAGS = \
  $(GN_PLUGIN_LDFLAGS)
 
 
diff --git a/src/identity-attribute/identity_attribute.c 
b/src/identity-attribute/identity_attribute.c
index 377eb3211..05cdcdaf0 100644
--- a/src/identity-attribute/identity_attribute.c
+++ b/src/identity-attribute/identity_attribute.c
@@ -26,6 +26,182 @@
 #include "platform.h"
 #include "gnunet_util_lib.h"
 #include "identity_attribute.h"
+#include "gnunet_identity_attribute_plugin.h"
+
+/**
+ * Handle for a plugin
+ */
+struct Plugin
+{
+  /**
+   * Name of the plugin
+   */
+  char *library_name;
+
+  /**
+   * Plugin API
+   */
+  struct GNUNET_IDENTITY_ATTRIBUTE_PluginFunctions *api;
+};
+
+/**
+ * Plugins
+ */
+static struct Plugin **attr_plugins;
+
+/**
+ * Number of plugins
+ */
+static unsigned int num_plugins;
+
+/**
+ * Init canary
+ */
+static int initialized;
+
+/**
+ * Add a plugin
+ */
+static void
+add_plugin (void* cls,
+            const char *library_name,
+            void *lib_ret)
+{
+  struct GNUNET_IDENTITY_ATTRIBUTE_PluginFunctions *api = lib_ret;
+  struct Plugin *plugin;
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Loading attribute plugin `%s'\n",
+              library_name);
+  plugin = GNUNET_new (struct Plugin);
+  plugin->api = api;
+  plugin->library_name = GNUNET_strdup (library_name);
+  GNUNET_array_append (attr_plugins, num_plugins, plugin);
+}
+
+/**
+ * Load plugins
+ */
+static void
+init()
+{
+  if (GNUNET_YES == initialized)
+    return;
+  initialized = GNUNET_YES;
+  GNUNET_PLUGIN_load_all ("libgnunet_plugin_attribute_", NULL,
+                          &add_plugin, NULL);
+}
+
+/**
+ * Convert a type name to the corresponding number
+ *
+ * @param typename name to convert
+ * @return corresponding number, UINT32_MAX on error
+ */
+uint32_t
+GNUNET_IDENTITY_ATTRIBUTE_typename_to_number (const char *typename)
+{
+  unsigned int i;
+  struct Plugin *plugin;
+  uint32_t ret;
+  
+  init ();
+  for (i = 0; i < num_plugins; i++)
+  {
+    plugin = attr_plugins[i];
+    if (UINT32_MAX != (ret = plugin->api->typename_to_number (plugin->api->cls,
+                                                              typename)))
+      return ret;
+  }
+  return UINT32_MAX;
+}
+
+/**
+ * Convert a type number to the corresponding type string
+ *
+ * @param type number of a type
+ * @return corresponding typestring, NULL on error
+ */
+const char*
+GNUNET_IDENTITY_ATTRIBUTE_number_to_typename (uint32_t type)
+{
+  unsigned int i;
+  struct Plugin *plugin;
+  const char *ret;
+
+  init ();
+  for (i = 0; i < num_plugins; i++)
+  {
+    plugin = attr_plugins[i];
+    if (NULL != (ret = plugin->api->number_to_typename (plugin->api->cls,
+                                                        type)))
+      return ret;
+  }
+  return NULL;
+}
+
+/**
+ * Convert human-readable version of a 'claim' of an attribute to the binary
+ * representation
+ *
+ * @param type type of the claim
+ * @param s human-readable string
+ * @param data set to value in binary encoding (will be allocated)
+ * @param data_size set to number of bytes in @a data
+ * @return #GNUNET_OK on success
+ */
+int
+GNUNET_IDENTITY_ATTRIBUTE_string_to_claim (uint32_t type,
+                                           const char *s,
+                                           void **data,
+                                           size_t *data_size)
+{
+  unsigned int i;
+  struct Plugin *plugin;
+
+  init ();
+  for (i = 0; i < num_plugins; i++)
+  {
+    plugin = attr_plugins[i];
+    if (GNUNET_OK == plugin->api->string_to_value (plugin->api->cls,
+                                                   type,
+                                                   s,
+                                                   data,
+                                                   data_size))
+      return GNUNET_OK;
+  }
+  return GNUNET_SYSERR;
+}
+
+/**
+ * Convert the 'claim' of an attribute to a string
+ *
+ * @param type the type of attribute
+ * @param data claim in binary encoding
+ * @param data_size number of bytes in @a data
+ * @return NULL on error, otherwise human-readable representation of the claim
+ */
+char *
+GNUNET_IDENTITY_ATTRIBUTE_claim_to_string (uint32_t type,
+                                           const void* data,
+                                           size_t data_size)
+{
+  unsigned int i;
+  struct Plugin *plugin;
+  char *ret;
+
+  init();
+  for (i = 0; i < num_plugins; i++)
+  {
+    plugin = attr_plugins[i];
+    if (NULL != (ret = plugin->api->value_to_string (plugin->api->cls,
+                                                     type,
+                                                     data,
+                                                     data_size)))
+      return ret;
+  }
+  return NULL;
+}
 
 /**
  * Create a new attribute.
diff --git a/src/identity-provider/gnunet-idp.c 
b/src/identity-provider/gnunet-idp.c
index 18a5676c0..78da1cb4d 100644
--- a/src/identity-provider/gnunet-idp.c
+++ b/src/identity-provider/gnunet-idp.c
@@ -168,6 +168,7 @@ process_attrs (void *cls,
          const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
          const struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr)
 {
+  char *claim;
   if (NULL == identity)
   {
     GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
@@ -178,8 +179,11 @@ process_attrs (void *cls,
     ret = 1;
     return;
   }
+  claim = GNUNET_IDENTITY_ATTRIBUTE_claim_to_string (attr->type,
+                                                     attr->data,
+                                                     attr->data_size);
   GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-              "%s: %s\n", attr->name, (char*)attr->data);
+              "%s: %s\n", attr->name, claim);
 }
 
 
@@ -245,9 +249,9 @@ iter_finished (void *cls)
     return;
   }
   attr = GNUNET_IDENTITY_ATTRIBUTE_claim_new (attr_name,
-                                                 
GNUNET_IDENTITY_ATTRIBUTE_TYPE_STRING,
-                                                 attr_value,
-                                                 strlen (attr_value) + 1);
+                                              
GNUNET_IDENTITY_ATTRIBUTE_TYPE_STRING,
+                                              attr_value,
+                                              strlen (attr_value) + 1);
   idp_op = GNUNET_IDENTITY_PROVIDER_attribute_store (idp_handle,
                                                      pkey,
                                                      attr,
diff --git a/src/include/gnunet_identity_attribute_lib.h 
b/src/include/gnunet_identity_attribute_lib.h
index 039b50351..4e32c2ae1 100644
--- a/src/include/gnunet_identity_attribute_lib.h
+++ b/src/include/gnunet_identity_attribute_lib.h
@@ -213,7 +213,52 @@ GNUNET_IDENTITY_ATTRIBUTE_deserialize (const char* data,
 struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList*
 GNUNET_IDENTITY_ATTRIBUTE_list_dup (const struct 
GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs);
 
+/**
+ * Convert a type name to the corresponding number
+ *
+ * @param typename name to convert
+ * @return corresponding number, UINT32_MAX on error
+ */
+uint32_t
+GNUNET_IDENTITY_ATTRIBUTE_typename_to_number (const char *typename);
+
+/**
+ * Convert human-readable version of a 'claim' of an attribute to the binary
+ * representation
+ *
+ * @param type type of the claim
+ * @param s human-readable string
+ * @param data set to value in binary encoding (will be allocated)
+ * @param data_size set to number of bytes in @a data
+ * @return #GNUNET_OK on success
+ */
+int
+GNUNET_IDENTITY_ATTRIBUTE_string_to_claim (uint32_t type,
+                                           const char *s,
+                                           void **data,
+                                           size_t *data_size);
 
+/**
+ * Convert the 'claim' of an attribute to a string
+ *
+ * @param type the type of attribute
+ * @param data claim in binary encoding
+ * @param data_size number of bytes in @a data
+ * @return NULL on error, otherwise human-readable representation of the claim
+ */
+char *
+GNUNET_IDENTITY_ATTRIBUTE_claim_to_string (uint32_t type,
+                                           const void* data,
+                                           size_t data_size);
+
+/**
+ * Convert a type number to the corresponding type string
+ *
+ * @param type number of a type
+ * @return corresponding typestring, NULL on error
+ */
+const char*
+GNUNET_IDENTITY_ATTRIBUTE_number_to_typename (uint32_t type);
 
 #if 0                           /* keep Emacsens' auto-indent happy */
 {

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]