new operation queue for limiting overlay connects
[oweals/gnunet.git] / src / transport / gnunet-service-transport_plugins.c
index fc14b6e76ed295fbbd22d0d3b2ca9679174c5ea9..1f3727b8e8be554f9f48342dff6264ec61164158 100644 (file)
@@ -196,6 +196,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)