[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r23932 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r23932 - gnunet/src/transport |
Date: |
Fri, 21 Sep 2012 14:15:48 +0200 |
Author: wachs
Date: 2012-09-21 14:15:48 +0200 (Fri, 21 Sep 2012)
New Revision: 23932
Modified:
gnunet/src/transport/gnunet-service-transport_clients.c
gnunet/src/transport/gnunet-service-transport_plugins.c
gnunet/src/transport/gnunet-service-transport_plugins.h
Log:
prefix based plugin lookup for transport
Modified: gnunet/src/transport/gnunet-service-transport_clients.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_clients.c 2012-09-21
12:15:18 UTC (rev 23931)
+++ gnunet/src/transport/gnunet-service-transport_clients.c 2012-09-21
12:15:48 UTC (rev 23932)
@@ -769,7 +769,7 @@
rtimeout = GNUNET_TIME_relative_ntoh (alum->timeout);
numeric = ntohs (alum->numeric_only);
tc = GNUNET_SERVER_transmit_context_create (client);
- papi = GST_plugins_find (plugin_name);
+ papi = GST_plugins_printer_find (plugin_name);
if (NULL == papi)
{
GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0,
Modified: gnunet/src/transport/gnunet-service-transport_plugins.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_plugins.c 2012-09-21
12:15:18 UTC (rev 23931)
+++ gnunet/src/transport/gnunet-service-transport_plugins.c 2012-09-21
12:15:48 UTC (rev 23932)
@@ -197,6 +197,43 @@
/**
+ * 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;
+ }
+ if (NULL != head)
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Found `%s' in '%s'\n",
+ stripped, head->short_name);
+ 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 +248,7 @@
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)
Modified: gnunet/src/transport/gnunet-service-transport_plugins.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport_plugins.h 2012-09-21
12:15:18 UTC (rev 23931)
+++ gnunet/src/transport/gnunet-service-transport_plugins.h 2012-09-21
12:15:48 UTC (rev 23932)
@@ -66,7 +66,20 @@
struct GNUNET_TRANSPORT_PluginFunctions *
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);
+
/**
* Convert a given address to a human-readable format. Note that the
* return value will be overwritten on the next call to this function.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r23932 - gnunet/src/transport,
gnunet <=