changeset 988:2e02fbb8b32b

irccd: load metadata from native plugins
author David Demelier <markand@malikania.fr>
date Wed, 10 Feb 2021 17:45:55 +0100
parents 685b85367c8e
children 73fdae7aa902
files irccd/dl-plugin.c plugins/links/links.c
diffstat 2 files changed, 23 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/irccd/dl-plugin.c	Wed Feb 10 17:21:45 2021 +0100
+++ b/irccd/dl-plugin.c	Wed Feb 10 17:45:55 2021 +0100
@@ -62,7 +62,7 @@
 typedef void            (*set_path_fn)(const char *, const char *);
 typedef void            (*set_template_fn)(const char *, const char *);
 
-static const char *
+static inline const char *
 symbol(const struct self *self, const char *func)
 {
 	static char sym[128];
@@ -72,6 +72,17 @@
 	return sym;
 }
 
+static inline const char *
+metadata(struct self *self, const char *name)
+{
+	char **addr;
+
+	if (!(addr = dlsym(self->handle, symbol(self, name))))
+		return NULL;
+
+	return *addr;
+}
+
 static void
 set_template(struct irc_plugin *plg, const char *key, const char *value)
 {
@@ -245,6 +256,12 @@
 	self->plugin.handle = handle;
 	self->plugin.finish = finish;
 
+	/* Metadata variables. */
+	self->plugin.author = metadata(self, "author");
+	self->plugin.description = metadata(self, "description");
+	self->plugin.version = metadata(self, "version");
+	self->plugin.license = metadata(self, "license");
+
 	return &self->plugin;
 }
 
--- a/plugins/links/links.c	Wed Feb 10 17:21:45 2021 +0100
+++ b/plugins/links/links.c	Wed Feb 10 17:45:55 2021 +0100
@@ -262,3 +262,8 @@
 
 	return keys;
 }
+
+const char *links_description = "Parse links from messages";
+const char *links_version = IRCCD_VERSION;
+const char *links_license = "ISC";
+const char *links_author = "David Demelier <markand@malikania.fr>";