Skip to content

Instantly share code, notes, and snippets.

@Vudentz
Created January 26, 2024 18:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Vudentz/0b8bcb78a8898614fc4848cbf44a0a9f to your computer and use it in GitHub Desktop.
Save Vudentz/0b8bcb78a8898614fc4848cbf44a0a9f to your computer and use it in GitHub Desktop.
diff --git a/obexd/src/plugin.c b/obexd/src/plugin.c
index 212299fa5b32..74b5c79780f6 100644
--- a/obexd/src/plugin.c
+++ b/obexd/src/plugin.c
@@ -34,17 +34,17 @@
#define PLUGINFLAG (RTLD_NOW)
#endif
+#define IS_ENABLED(x) (x)
+
static GSList *plugins = NULL;
struct obex_plugin {
-#if EXTERNAL_PLUGINS
void *handle;
-#endif
const struct obex_plugin_desc *desc;
};
-#if EXTERNAL_PLUGINS
-static gboolean add_external_plugin(void *handle, const struct obex_plugin_desc *desc)
+static gboolean add_external_plugin(void *handle,
+ const struct obex_plugin_desc *desc)
{
struct obex_plugin *plugin;
@@ -68,7 +68,6 @@ static gboolean add_external_plugin(void *handle, const struct obex_plugin_desc
return TRUE;
}
-#endif
static void add_plugin(const struct obex_plugin_desc *desc)
{
@@ -118,12 +117,11 @@ static gboolean check_plugin(const struct obex_plugin_desc *desc,
static void external_plugin_init(char **patterns, char **excludes)
{
-#if EXTERNAL_PLUGINS
GDir *dir;
const char *file;
- warn("Using external plugins is not officially supported.\n");
- warn("Consider upstreaming your plugins into the BlueZ project.");
+ info("Using external plugins is not officially supported.\n");
+ info("Consider upstreaming your plugins into the BlueZ project.");
if (strlen(PLUGINDIR) == 0)
return;
@@ -173,7 +171,6 @@ static void external_plugin_init(char **patterns, char **excludes)
}
g_dir_close(dir);
-#endif
}
#include "builtin.h"
diff --git a/obexd/src/plugin.c b/obexd/src/plugin.c
index 212299fa5b32..74b5c79780f6 100644
--- a/obexd/src/plugin.c
+++ b/obexd/src/plugin.c
@@ -34,17 +34,17 @@
#define PLUGINFLAG (RTLD_NOW)
#endif
+#define IS_ENABLED(x) (x)
+
static GSList *plugins = NULL;
struct obex_plugin {
-#if EXTERNAL_PLUGINS
void *handle;
-#endif
const struct obex_plugin_desc *desc;
};
-#if EXTERNAL_PLUGINS
-static gboolean add_external_plugin(void *handle, const struct obex_plugin_desc *desc)
+static gboolean add_external_plugin(void *handle,
+ const struct obex_plugin_desc *desc)
{
struct obex_plugin *plugin;
@@ -68,7 +68,6 @@ static gboolean add_external_plugin(void *handle, const struct obex_plugin_desc
return TRUE;
}
-#endif
static void add_plugin(const struct obex_plugin_desc *desc)
{
@@ -118,12 +117,11 @@ static gboolean check_plugin(const struct obex_plugin_desc *desc,
static void external_plugin_init(char **patterns, char **excludes)
{
-#if EXTERNAL_PLUGINS
GDir *dir;
const char *file;
- warn("Using external plugins is not officially supported.\n");
- warn("Consider upstreaming your plugins into the BlueZ project.");
+ info("Using external plugins is not officially supported.\n");
+ info("Consider upstreaming your plugins into the BlueZ project.");
if (strlen(PLUGINDIR) == 0)
return;
@@ -173,7 +171,6 @@ static void external_plugin_init(char **patterns, char **excludes)
}
g_dir_close(dir);
-#endif
}
#include "builtin.h"
@@ -200,7 +197,8 @@ void plugin_init(const char *pattern, const char *exclude)
add_plugin(__obex_builtin[i]);
}
- external_plugin_init(patterns, excludes);
+ if (IS_ENABLED(EXTERNAL_PLUGINS))
+ external_plugin_init(patterns, excludes);
g_strfreev(patterns);
g_strfreev(excludes);
@@ -218,10 +216,8 @@ void plugin_cleanup(void)
if (plugin->desc->exit)
plugin->desc->exit();
-#if EXTERNAL_PLUGINS
if (plugin->handle != NULL)
dlclose(plugin->handle);
-#endif
g_free(plugin);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment