aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport_plugins.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/gnunet-service-transport_plugins.c')
-rw-r--r--src/transport/gnunet-service-transport_plugins.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/transport/gnunet-service-transport_plugins.c b/src/transport/gnunet-service-transport_plugins.c
index fc14b6e..1f3727b 100644
--- a/src/transport/gnunet-service-transport_plugins.c
+++ b/src/transport/gnunet-service-transport_plugins.c
@@ -197,6 +197,39 @@ GST_plugins_find (const char *name)
/**
+ * Obtain the plugin API based on a the stripped plugin name after the underscore.
+ *
+ * Example: GST_plugins_printer_find (http_client) will return all plugins
+ * starting with the prefix "http":
+ * http_client or server if loaded
+ *
+ * @param name name of the plugin
+ * @return the plugin's API, NULL if the plugin is not loaded
+ */
+struct GNUNET_TRANSPORT_PluginFunctions *
+GST_plugins_printer_find (const char *name)
+{
+ struct TransportPlugin *head = plugins_head;
+
+ char *stripped = GNUNET_strdup (name);
+ char *sep = strchr (stripped, '_');
+ if (NULL != sep)
+ sep[0] = '\0';
+
+ while (head != NULL)
+ {
+ if (head->short_name == strstr (head->short_name, stripped))
+ break;
+ head = head->next;
+ }
+ GNUNET_free (stripped);
+ if (NULL == head)
+ return NULL;
+ return head->api;
+}
+
+
+/**
* Convert a given address to a human-readable format. Note that the
* return value will be overwritten on the next call to this function.
*
@@ -211,7 +244,7 @@ GST_plugins_a2s (const struct GNUNET_HELLO_Address *address)
if (address == NULL)
return "<inbound>";
- api = GST_plugins_find (address->transport_name);
+ api = GST_plugins_printer_find (address->transport_name);
if (NULL == api)
return "<plugin unknown>";
if (0 == address->address_length)