rio: 0.0.36 -> 0.0.37
[NixPkgs.git] / pkgs / tools / networking / ofono / 0001-Search-connectors-in-OFONO_PLUGIN_PATH.patch
blobc1174e1093a803ae45c53343cf91dfd51a38752c
1 From 0e0994c9716700c9484b3dccb25f98a9a59d1744 Mon Sep 17 00:00:00 2001
2 From: Jan Tojnar <jtojnar@gmail.com>
3 Date: Fri, 23 Aug 2019 18:42:51 +0200
4 Subject: [PATCH] Search connectors in OFONO_PLUGIN_PATH
6 Previously, the connectors would only be looked for in a single
7 directory, specified during compilation. This patch allows to
8 traverse a list of directories provided by an environment variable.
9 ---
10 src/plugin.c | 77 ++++++++++++++++++++++++++++++++++------------------
11 1 file changed, 50 insertions(+), 27 deletions(-)
13 diff --git a/src/plugin.c b/src/plugin.c
14 index 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;
21 -#include "builtin.h"
23 -int __ofono_plugin_init(const char *pattern, const char *exclude)
25 - gchar **patterns = NULL;
26 - gchar **excludes = NULL;
27 - GSList *list;
28 - GDir *dir;
29 +static handle_dir(const gchar *plugin_path, const gchar **patterns, const gchar **excludes) {
30 const gchar *file;
31 gchar *filename;
32 - unsigned int i;
34 - DBG("");
36 - if (pattern)
37 - patterns = g_strsplit_set(pattern, ":, ", -1);
39 - if (exclude)
40 - excludes = g_strsplit_set(exclude, ":, ", -1);
42 - for (i = 0; __ofono_builtin[i]; i++) {
43 - if (check_plugin(__ofono_builtin[i],
44 - patterns, excludes) == FALSE)
45 - continue;
47 - add_plugin(NULL, __ofono_builtin[i]);
48 - }
49 + GDir *dir;
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;
60 - filename = g_build_filename(PLUGINDIR, file, NULL);
61 + filename = g_build_filename(plugin_path, file, NULL);
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)
67 g_dir_close(dir);
71 +#include "builtin.h"
73 +int __ofono_plugin_init(const char *pattern, const char *exclude)
75 + gchar **patterns = NULL;
76 + gchar **excludes = NULL;
77 + GSList *list;
78 + unsigned int i;
80 + DBG("");
82 + if (pattern)
83 + patterns = g_strsplit_set(pattern, ":, ", -1);
85 + if (exclude)
86 + excludes = g_strsplit_set(exclude, ":, ", -1);
88 + for (i = 0; __ofono_builtin[i]; i++) {
89 + if (check_plugin(__ofono_builtin[i],
90 + patterns, excludes) == FALSE)
91 + continue;
93 + add_plugin(NULL, __ofono_builtin[i]);
94 + }
97 + const gchar *plugin_path;
99 + plugin_path = g_getenv ("OFONO_PLUGIN_PATH");
101 + if (plugin_path) {
102 + gchar **plugin_path_list;
103 + gsize i;
105 + plugin_path_list = g_strsplit (plugin_path, G_SEARCHPATH_SEPARATOR_S, 0);
107 + for (i = 0; plugin_path_list[i]; i++) {
108 + handle_dir(plugin_path_list, patterns, excludes);
111 + g_strfreev(plugin_path_list);
114 + handle_dir(PLUGINDIR, patterns, excludes);
116 for (list = plugins; list; list = list->next) {
117 struct ofono_plugin *plugin = list->data;
119 2.22.0