@@ -0,0 +1,95 @@
1+From bf549a028a5da122b7a4206529711b969c2ecd48 Mon Sep 17 00:00:00 2001
2+From: Jan Tojnar <jtojnar@gmail.com>
3+Date: Fri, 1 Sep 2017 13:49:06 +0200
4+Subject: [PATCH] Search connectors in DLEYNA_CONNECTOR_PATH
5+
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+ libdleyna/core/connector-mgr.c | 63 ++++++++++++++++++++++++++++--------------
11+ 1 file changed, 42 insertions(+), 21 deletions(-)
12+
13+diff --git a/libdleyna/core/connector-mgr.c b/libdleyna/core/connector-mgr.c
14+index eafb16c..8041c67 100644
15+--- a/libdleyna/core/connector-mgr.c
16++++ b/libdleyna/core/connector-mgr.c
17+@@ -34,33 +34,54 @@ const dleyna_connector_t *dleyna_connector_mgr_load(const gchar *name)
18+ const dleyna_connector_t *connector;
19+ dleyna_connector_get_interface_t get_interface;
20+ gchar *path;
21++ const gchar *connector_path;
22++ gchar **connector_path_list;
23++ gsize i;
24+
25+ DLEYNA_LOG_DEBUG("Enter");
26+
27+- path = g_strdup_printf("%s/%s%s.so", CONNECTOR_DIR,
28+- DLEYNA_CONNECTOR_LIB_PATTERN, name);
29+- module = g_module_open(path, G_MODULE_BIND_LAZY);
30+- g_free(path);
31++ connector_path = g_getenv ("DLEYNA_CONNECTOR_PATH");
32++ if (!connector_path) {
33++ DLEYNA_LOG_DEBUG ("DLEYNA_CONNECTOR_PATH not set");
34++ connector_path = CONNECTOR_DIR;
35++ } else {
36++ DLEYNA_LOG_DEBUG ("DLEYNA_CONNECTOR_PATH set to %s", connector_path);
37++ }
38++
39++ connector_path_list = g_strsplit (connector_path, G_SEARCHPATH_SEPARATOR_S, 0);
40++
41++ for (i = 0; connector_path_list[i]; i++) {
42++ path = g_strdup_printf("%s/%s%s.so", connector_path_list[i],
43++ DLEYNA_CONNECTOR_LIB_PATTERN, name);
44++ module = g_module_open(path, G_MODULE_BIND_LAZY);
45++ g_free(path);
46++
47++ if (module) {
48++ if (!g_connectors)
49++ g_connectors = g_hash_table_new(g_direct_hash,
50++ g_direct_equal);
51++
52++ if (g_module_symbol(module, "dleyna_connector_get_interface",
53++ (gpointer *)&get_interface)) {
54++ connector = get_interface();
55++ g_hash_table_insert(g_connectors, (gpointer)connector,
56++ module);
57++
58++ break;
59++ } else {
60++ connector = NULL;
61++ g_module_close(module);
62++ DLEYNA_LOG_CRITICAL(
63++ "Connector '%s' entry point not found",
64++ name);
65++ }
66+
67+- if (module) {
68+- if (!g_connectors)
69+- g_connectors = g_hash_table_new(g_direct_hash,
70+- g_direct_equal);
71+-
72+- if (g_module_symbol(module, "dleyna_connector_get_interface",
73+- (gpointer *)&get_interface)) {
74+- connector = get_interface();
75+- g_hash_table_insert(g_connectors, (gpointer)connector,
76+- module);
77+- } else {
78+- connector = NULL;
79+- g_module_close(module);
80+- DLEYNA_LOG_CRITICAL(
81+- "Connector '%s' entry point not found",
82+- name);
83+ }
84++ }
85+
86+- } else {
87++ g_strfreev (connector_path_list);
88++
89++ if (!module) {
90+ connector = NULL;
91+ DLEYNA_LOG_CRITICAL("Connector '%s' not found", name);
92+ }
93+--
94+2.14.1
95+