aboutsummaryrefslogtreecommitdiff
path: root/src/peerinfo-tool/gnunet-peerinfo_plugins.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-10-05 15:09:28 +0200
committerChristian Grothoff <christian@grothoff.org>2019-10-05 15:09:28 +0200
commitc4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 (patch)
treecac3ce030d77b4cbe7c7dc62ed58cfe6d24f73e1 /src/peerinfo-tool/gnunet-peerinfo_plugins.c
parentfbb71d527c7d6babf269a8fefce1db291b9f7068 (diff)
downloadgnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz
gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/peerinfo-tool/gnunet-peerinfo_plugins.c')
-rw-r--r--src/peerinfo-tool/gnunet-peerinfo_plugins.c111
1 files changed, 56 insertions, 55 deletions
diff --git a/src/peerinfo-tool/gnunet-peerinfo_plugins.c b/src/peerinfo-tool/gnunet-peerinfo_plugins.c
index 13730629e..9449dd67e 100644
--- a/src/peerinfo-tool/gnunet-peerinfo_plugins.c
+++ b/src/peerinfo-tool/gnunet-peerinfo_plugins.c
@@ -31,7 +31,8 @@
31/** 31/**
32 * Entry in doubly-linked list of all of our plugins. 32 * Entry in doubly-linked list of all of our plugins.
33 */ 33 */
34struct TransportPlugin { 34struct TransportPlugin
35{
35 /** 36 /**
36 * This is a doubly-linked list. 37 * This is a doubly-linked list.
37 */ 38 */
@@ -86,7 +87,7 @@ static struct TransportPlugin *plugins_tail;
86 * @param cfg configuration to use 87 * @param cfg configuration to use
87 */ 88 */
88void 89void
89GPI_plugins_load(const struct GNUNET_CONFIGURATION_Handle *cfg) 90GPI_plugins_load (const struct GNUNET_CONFIGURATION_Handle *cfg)
90{ 91{
91 struct TransportPlugin *plug; 92 struct TransportPlugin *plug;
92 struct TransportPlugin *next; 93 struct TransportPlugin *next;
@@ -97,41 +98,41 @@ GPI_plugins_load(const struct GNUNET_CONFIGURATION_Handle *cfg)
97 if (NULL != plugins_head) 98 if (NULL != plugins_head)
98 return; /* already loaded */ 99 return; /* already loaded */
99 if (GNUNET_OK != 100 if (GNUNET_OK !=
100 GNUNET_CONFIGURATION_get_value_string(cfg, "TRANSPORT", "PLUGINS", 101 GNUNET_CONFIGURATION_get_value_string (cfg, "TRANSPORT", "PLUGINS",
101 &plugs)) 102 &plugs))
102 return; 103 return;
103 GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Starting transport plugins `%s'\n"), 104 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _ ("Starting transport plugins `%s'\n"),
104 plugs); 105 plugs);
105 for (pos = strtok(plugs, " "); pos != NULL; pos = strtok(NULL, " ")) 106 for (pos = strtok (plugs, " "); pos != NULL; pos = strtok (NULL, " "))
106 { 107 {
107 GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Loading `%s' transport plugin\n"), 108 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _ ("Loading `%s' transport plugin\n"),
108 pos); 109 pos);
109 GNUNET_asprintf(&libname, "libgnunet_plugin_transport_%s", pos); 110 GNUNET_asprintf (&libname, "libgnunet_plugin_transport_%s", pos);
110 plug = GNUNET_new(struct TransportPlugin); 111 plug = GNUNET_new (struct TransportPlugin);
111 plug->short_name = GNUNET_strdup(pos); 112 plug->short_name = GNUNET_strdup (pos);
112 plug->lib_name = libname; 113 plug->lib_name = libname;
113 plug->env.cfg = cfg; 114 plug->env.cfg = cfg;
114 plug->env.cls = plug->short_name; 115 plug->env.cls = plug->short_name;
115 GNUNET_CONTAINER_DLL_insert(plugins_head, plugins_tail, plug); 116 GNUNET_CONTAINER_DLL_insert (plugins_head, plugins_tail, plug);
116 } 117 }
117 GNUNET_free(plugs); 118 GNUNET_free (plugs);
118 next = plugins_head; 119 next = plugins_head;
119 while (next != NULL) 120 while (next != NULL)
121 {
122 plug = next;
123 next = plug->next;
124 plug->api = GNUNET_PLUGIN_load (plug->lib_name, &plug->env);
125 if (plug->api == NULL)
120 { 126 {
121 plug = next; 127 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
122 next = plug->next; 128 _ ("Failed to load transport plugin for `%s'\n"),
123 plug->api = GNUNET_PLUGIN_load(plug->lib_name, &plug->env); 129 plug->lib_name);
124 if (plug->api == NULL) 130 GNUNET_CONTAINER_DLL_remove (plugins_head, plugins_tail, plug);
125 { 131 GNUNET_free (plug->short_name);
126 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 132 GNUNET_free (plug->lib_name);
127 _("Failed to load transport plugin for `%s'\n"), 133 GNUNET_free (plug);
128 plug->lib_name);
129 GNUNET_CONTAINER_DLL_remove(plugins_head, plugins_tail, plug);
130 GNUNET_free(plug->short_name);
131 GNUNET_free(plug->lib_name);
132 GNUNET_free(plug);
133 }
134 } 134 }
135 }
135} 136}
136 137
137 138
@@ -139,18 +140,18 @@ GPI_plugins_load(const struct GNUNET_CONFIGURATION_Handle *cfg)
139 * Unload all plugins 140 * Unload all plugins
140 */ 141 */
141void 142void
142GPI_plugins_unload() 143GPI_plugins_unload ()
143{ 144{
144 struct TransportPlugin *plug; 145 struct TransportPlugin *plug;
145 146
146 while (NULL != (plug = plugins_head)) 147 while (NULL != (plug = plugins_head))
147 { 148 {
148 GNUNET_break(NULL == GNUNET_PLUGIN_unload(plug->lib_name, plug->api)); 149 GNUNET_break (NULL == GNUNET_PLUGIN_unload (plug->lib_name, plug->api));
149 GNUNET_free(plug->lib_name); 150 GNUNET_free (plug->lib_name);
150 GNUNET_free(plug->short_name); 151 GNUNET_free (plug->short_name);
151 GNUNET_CONTAINER_DLL_remove(plugins_head, plugins_tail, plug); 152 GNUNET_CONTAINER_DLL_remove (plugins_head, plugins_tail, plug);
152 GNUNET_free(plug); 153 GNUNET_free (plug);
153 } 154 }
154} 155}
155 156
156 157
@@ -161,32 +162,32 @@ GPI_plugins_unload()
161 * @return the plugin's API, NULL if the plugin is not loaded 162 * @return the plugin's API, NULL if the plugin is not loaded
162 */ 163 */
163struct GNUNET_TRANSPORT_PluginFunctions * 164struct GNUNET_TRANSPORT_PluginFunctions *
164GPI_plugins_find(const char *name) 165GPI_plugins_find (const char *name)
165{ 166{
166 struct TransportPlugin *head = plugins_head; 167 struct TransportPlugin *head = plugins_head;
167 168
168 char *stripped = GNUNET_strdup(name); 169 char *stripped = GNUNET_strdup (name);
169 char *head_stripped; 170 char *head_stripped;
170 char *sep = strchr(stripped, '_'); 171 char *sep = strchr (stripped, '_');
171 172
172 if (NULL != sep) 173 if (NULL != sep)
173 sep[0] = '\0'; 174 sep[0] = '\0';
174 175
175 while (head != NULL) 176 while (head != NULL)
177 {
178 head_stripped = GNUNET_strdup (head->short_name);
179 char *head_sep = strchr (head_stripped, '_');
180 if (NULL != head_sep)
181 head_sep[0] = '\0';
182 if (0 == strcmp (head_stripped, stripped))
176 { 183 {
177 head_stripped = GNUNET_strdup(head->short_name); 184 GNUNET_free (head_stripped);
178 char *head_sep = strchr(head_stripped, '_'); 185 break;
179 if (NULL != head_sep)
180 head_sep[0] = '\0';
181 if (0 == strcmp(head_stripped, stripped))
182 {
183 GNUNET_free(head_stripped);
184 break;
185 }
186 GNUNET_free(head_stripped);
187 head = head->next;
188 } 186 }
189 GNUNET_free(stripped); 187 GNUNET_free (head_stripped);
188 head = head->next;
189 }
190 GNUNET_free (stripped);
190 if (NULL == head) 191 if (NULL == head)
191 return NULL; 192 return NULL;
192 return head->api; 193 return head->api;