lol
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at master 120 lines 3.1 kB view raw
1From 0e0994c9716700c9484b3dccb25f98a9a59d1744 Mon Sep 17 00:00:00 2001 2From: Jan Tojnar <jtojnar@gmail.com> 3Date: Fri, 23 Aug 2019 18:42:51 +0200 4Subject: [PATCH] Search connectors in OFONO_PLUGIN_PATH 5 6Previously, the connectors would only be looked for in a single 7directory, specified during compilation. This patch allows to 8traverse a list of directories provided by an environment variable. 9--- 10 src/plugin.c | 77 ++++++++++++++++++++++++++++++++++------------------ 11 1 file changed, 50 insertions(+), 27 deletions(-) 12 13diff --git a/src/plugin.c b/src/plugin.c 14index 924a45ec..f05055c3 100644 15--- a/src/plugin.c 16+++ b/src/plugin.c 17@@ -99,35 +99,12 @@ static gboolean check_plugin(struct ofono_plugin_desc *desc, 18 return TRUE; 19 } 20 21-#include "builtin.h" 22- 23-int __ofono_plugin_init(const char *pattern, const char *exclude) 24-{ 25- gchar **patterns = NULL; 26- gchar **excludes = NULL; 27- GSList *list; 28- GDir *dir; 29+static void handle_dir(gchar *plugin_path, gchar **patterns, gchar **excludes) { 30 const gchar *file; 31 gchar *filename; 32- unsigned int i; 33- 34- DBG(""); 35- 36- if (pattern) 37- patterns = g_strsplit_set(pattern, ":, ", -1); 38- 39- if (exclude) 40- excludes = g_strsplit_set(exclude, ":, ", -1); 41- 42- for (i = 0; __ofono_builtin[i]; i++) { 43- if (check_plugin(__ofono_builtin[i], 44- patterns, excludes) == FALSE) 45- continue; 46- 47- add_plugin(NULL, __ofono_builtin[i]); 48- } 49+ GDir *dir; 50 51- dir = g_dir_open(PLUGINDIR, 0, NULL); 52+ dir = g_dir_open(plugin_path, 0, NULL); 53 if (dir != NULL) { 54 while ((file = g_dir_read_name(dir)) != NULL) { 55 void *handle; 56@@ -137,7 +114,7 @@ int __ofono_plugin_init(const char *pattern, const char *exclude) 57 g_str_has_suffix(file, ".so") == FALSE) 58 continue; 59 60- filename = g_build_filename(PLUGINDIR, file, NULL); 61+ filename = g_build_filename(plugin_path, file, NULL); 62 63 handle = dlopen(filename, RTLD_NOW); 64 if (handle == NULL) { 65@@ -168,6 +145,52 @@ int __ofono_plugin_init(const char *pattern, const char *exclude) 66 67 g_dir_close(dir); 68 } 69+} 70+ 71+#include "builtin.h" 72+ 73+int __ofono_plugin_init(const char *pattern, const char *exclude) 74+{ 75+ gchar **patterns = NULL; 76+ gchar **excludes = NULL; 77+ GSList *list; 78+ unsigned int i; 79+ 80+ DBG(""); 81+ 82+ if (pattern) 83+ patterns = g_strsplit_set(pattern, ":, ", -1); 84+ 85+ if (exclude) 86+ excludes = g_strsplit_set(exclude, ":, ", -1); 87+ 88+ for (i = 0; __ofono_builtin[i]; i++) { 89+ if (check_plugin(__ofono_builtin[i], 90+ patterns, excludes) == FALSE) 91+ continue; 92+ 93+ add_plugin(NULL, __ofono_builtin[i]); 94+ } 95+ 96+ 97+ const gchar *plugin_path; 98+ 99+ plugin_path = g_getenv ("OFONO_PLUGIN_PATH"); 100+ 101+ if (plugin_path) { 102+ gchar **plugin_path_list; 103+ gsize i; 104+ 105+ plugin_path_list = g_strsplit (plugin_path, G_SEARCHPATH_SEPARATOR_S, 0); 106+ 107+ for (i = 0; plugin_path_list[i]; i++) { 108+ handle_dir(plugin_path_list[i], patterns, excludes); 109+ } 110+ 111+ g_strfreev(plugin_path_list); 112+ } 113+ 114+ handle_dir(PLUGINDIR, patterns, excludes); 115 116 for (list = plugins; list; list = list->next) { 117 struct ofono_plugin *plugin = list->data; 118-- 1192.22.0 120