plugins: export a const function pointer interface struct

This commit is contained in:
Daniel Eklöf 2019-01-26 18:32:04 +01:00
parent 37266ae419
commit 452c4b6015
22 changed files with 255 additions and 230 deletions

View file

@ -7,8 +7,9 @@
#define LOG_ENABLE_DBG 0
#include "../log.h"
#include "../bar.h"
#include "../config.h"
#include "../config-verify.h"
#include "../config.h"
#include "../plugin.h"
#include "../tllist.h"
struct private {
@ -284,8 +285,8 @@ alsa_new(const char *card, const char *mixer, struct particle *label)
return mod;
}
struct module *
alsa_from_conf(const struct yml_node *node, struct conf_inherit inherited)
static struct module *
from_conf(const struct yml_node *node, struct conf_inherit inherited)
{
const struct yml_node *card = yml_get_value(node, "card");
const struct yml_node *mixer = yml_get_value(node, "mixer");
@ -297,8 +298,8 @@ alsa_from_conf(const struct yml_node *node, struct conf_inherit inherited)
conf_to_particle(content, inherited));
}
bool
alsa_verify_conf(keychain_t *chain, const struct yml_node *node)
static bool
verify_conf(keychain_t *chain, const struct yml_node *node)
{
static const struct attr_info attrs[] = {
{"card", true, &conf_verify_string},
@ -311,11 +312,11 @@ alsa_verify_conf(keychain_t *chain, const struct yml_node *node)
return conf_verify_dict(chain, node, attrs);
}
const struct module_iface module_alsa_iface = {
.verify_conf = &verify_conf,
.from_conf = &from_conf,
};
#if defined(CORE_PLUGINS_AS_SHARED_LIBRARIES)
bool verify_conf(keychain_t *chain, const struct yml_node *node)
__attribute__((weak, alias("alsa_verify_conf")));
struct deco *from_conf(const struct yml_node *node, struct conf_inherit inherited)
__attribute__((weak, alias("alsa_from_conf")));
extern const struct module_iface iface __attribute__((weak, alias("module_alsa_iface")));
#endif

View file

@ -15,6 +15,7 @@
#include "../bar.h"
#include "../config.h"
#include "../config-verify.h"
#include "../plugin.h"
struct private {
struct particle *label;
@ -219,8 +220,8 @@ backlight_new(const char *device, struct particle *label)
return mod;
}
struct module *
backlight_from_conf(const struct yml_node *node, struct conf_inherit inherited)
static struct module *
from_conf(const struct yml_node *node, struct conf_inherit inherited)
{
const struct yml_node *name = yml_get_value(node, "name");
const struct yml_node *c = yml_get_value(node, "content");
@ -229,8 +230,8 @@ backlight_from_conf(const struct yml_node *node, struct conf_inherit inherited)
yml_value_as_string(name), conf_to_particle(c, inherited));
}
bool
backlight_verify_conf(keychain_t *chain, const struct yml_node *node)
static bool
verify_conf(keychain_t *chain, const struct yml_node *node)
{
static const struct attr_info attrs[] = {
{"name", true, &conf_verify_string},
@ -242,11 +243,11 @@ backlight_verify_conf(keychain_t *chain, const struct yml_node *node)
return conf_verify_dict(chain, node, attrs);
}
const struct module_iface module_backlight_iface = {
.verify_conf = &verify_conf,
.from_conf = &from_conf,
};
#if defined(CORE_PLUGINS_AS_SHARED_LIBRARIES)
bool verify_conf(keychain_t *chain, const struct yml_node *node)
__attribute__((weak, alias("backlight_verify_conf")));
struct deco *from_conf(const struct yml_node *node, struct conf_inherit inherited)
__attribute__((weak, alias("backlight_from_conf")));
extern const struct module_iface iface __attribute__((weak, alias("module_backlight_iface")));
#endif

View file

@ -16,6 +16,7 @@
#include "../bar.h"
#include "../config.h"
#include "../config-verify.h"
#include "../plugin.h"
enum state { STATE_FULL, STATE_CHARGING, STATE_DISCHARGING };
@ -349,8 +350,8 @@ battery_new(const char *battery, struct particle *label, int poll_interval_secs)
return mod;
}
struct module *
battery_from_conf(const struct yml_node *node, struct conf_inherit inherited)
static struct module *
from_conf(const struct yml_node *node, struct conf_inherit inherited)
{
const struct yml_node *c = yml_get_value(node, "content");
const struct yml_node *name = yml_get_value(node, "name");
@ -362,8 +363,8 @@ battery_from_conf(const struct yml_node *node, struct conf_inherit inherited)
poll_interval != NULL ? yml_value_as_int(poll_interval) : 60);
}
bool
battery_verify_conf(keychain_t *chain, const struct yml_node *node)
static bool
verify_conf(keychain_t *chain, const struct yml_node *node)
{
static const struct attr_info attrs[] = {
{"name", true, &conf_verify_string},
@ -376,11 +377,11 @@ battery_verify_conf(keychain_t *chain, const struct yml_node *node)
return conf_verify_dict(chain, node, attrs);
}
const struct module_iface module_battery_iface = {
.verify_conf = &verify_conf,
.from_conf = &from_conf,
};
#if defined(CORE_PLUGINS_AS_SHARED_LIBRARIES)
bool verify_conf(keychain_t *chain, const struct yml_node *node)
__attribute__((weak, alias("battery_verify_conf")));
struct deco *from_conf(const struct yml_node *node, struct conf_inherit inherited)
__attribute__((weak, alias("battery_from_conf")));
extern const struct module_iface iface __attribute__((weak, alias("module_battery_iface")));
#endif

View file

@ -8,6 +8,7 @@
#include "../bar.h"
#include "../config.h"
#include "../config-verify.h"
#include "../plugin.h"
struct private {
struct particle *label;
@ -94,8 +95,8 @@ clock_new(struct particle *label, const char *date_format, const char *time_form
return mod;
}
struct module *
clock_from_conf(const struct yml_node *node, struct conf_inherit inherited)
static struct module *
from_conf(const struct yml_node *node, struct conf_inherit inherited)
{
const struct yml_node *c = yml_get_value(node, "content");
const struct yml_node *date_format = yml_get_value(node, "date-format");
@ -107,8 +108,8 @@ clock_from_conf(const struct yml_node *node, struct conf_inherit inherited)
time_format != NULL ? yml_value_as_string(time_format) : "%H:%M");
}
bool
clock_verify_conf(keychain_t *chain, const struct yml_node *node)
static bool
verify_conf(keychain_t *chain, const struct yml_node *node)
{
static const struct attr_info attrs[] = {
{"date-format", false, &conf_verify_string},
@ -121,11 +122,11 @@ clock_verify_conf(keychain_t *chain, const struct yml_node *node)
return conf_verify_dict(chain, node, attrs);
}
const struct module_iface module_clock_iface = {
.verify_conf = &verify_conf,
.from_conf = &from_conf,
};
#if defined(CORE_PLUGINS_AS_SHARED_LIBRARIES)
bool verify_conf(keychain_t *chain, const struct yml_node *node)
__attribute__((weak, alias("clock_verify_conf")));
struct deco *from_conf(const struct yml_node *node, struct conf_inherit inherited)
__attribute__((weak, alias("clock_from_conf")));
extern const struct module_iface iface __attribute__((weak, alias("module_clock_iface")));
#endif

View file

@ -25,6 +25,7 @@
#include "../config.h"
#include "../config-verify.h"
#include "../particles/dynlist.h"
#include "../plugin.h"
#include "../xcb.h"
struct ws_content {
@ -676,8 +677,8 @@ i3_new(struct i3_workspaces workspaces[], size_t workspace_count,
return mod;
}
struct module *
i3_from_conf(const struct yml_node *node, struct conf_inherit inherited)
static struct module *
from_conf(const struct yml_node *node, struct conf_inherit inherited)
{
const struct yml_node *c = yml_get_value(node, "content");
const struct yml_node *spacing = yml_get_value(node, "spacing");
@ -733,8 +734,8 @@ verify_content(keychain_t *chain, const struct yml_node *node)
return true;
}
bool
i3_verify_conf(keychain_t *chain, const struct yml_node *node)
static bool
verify_conf(keychain_t *chain, const struct yml_node *node)
{
static const struct attr_info attrs[] = {
{"spacing", false, &conf_verify_int},
@ -748,11 +749,11 @@ i3_verify_conf(keychain_t *chain, const struct yml_node *node)
return conf_verify_dict(chain, node, attrs);
}
const struct module_iface module_i3_iface = {
.verify_conf = &verify_conf,
.from_conf = &from_conf,
};
#if defined(CORE_PLUGINS_AS_SHARED_LIBRARIES)
bool verify_conf(keychain_t *chain, const struct yml_node *node)
__attribute__((weak, alias("i3_verify_conf")));
struct deco *from_conf(const struct yml_node *node, struct conf_inherit inherited)
__attribute__((weak, alias("i3_from_conf")));
extern const struct module_iface iface __attribute__((weak, alias("module_i3_iface"))) ;
#endif

View file

@ -6,6 +6,7 @@
#include "../config.h"
#include "../config-verify.h"
#include "../module.h"
#include "../plugin.h"
struct private {
struct particle *label;
@ -47,15 +48,15 @@ label_new(struct particle *label)
return mod;
}
struct module *
label_from_conf(const struct yml_node *node, struct conf_inherit inherited)
static struct module *
from_conf(const struct yml_node *node, struct conf_inherit inherited)
{
const struct yml_node *c = yml_get_value(node, "content");
return label_new(conf_to_particle(c, inherited));
}
bool
label_verify_conf(keychain_t *chain, const struct yml_node *node)
static bool
verify_conf(keychain_t *chain, const struct yml_node *node)
{
static const struct attr_info attrs[] = {
{"content", true, &conf_verify_particle},
@ -66,11 +67,11 @@ label_verify_conf(keychain_t *chain, const struct yml_node *node)
return conf_verify_dict(chain, node, attrs);
}
const struct module_iface module_label_iface = {
.verify_conf = &verify_conf,
.from_conf = &from_conf,
};
#if defined(CORE_PLUGINS_AS_SHARED_LIBRARIES)
bool verify_conf(keychain_t *chain, const struct yml_node *node)
__attribute__((weak, alias("label_verify_conf")));
struct deco *from_conf(const struct yml_node *node, struct conf_inherit inherited)
__attribute__((weak, alias("label_from_conf")));
extern const struct module_iface iface __attribute__((weak, alias("module_label_iface")));
#endif

View file

@ -25,6 +25,7 @@
#include "../bar.h"
#include "../config.h"
#include "../config-verify.h"
#include "../plugin.h"
enum state {
STATE_OFFLINE = 1000,
@ -583,8 +584,8 @@ mpd_new(const char *host, uint16_t port, struct particle *label)
return mod;
}
struct module *
mpd_from_conf(const struct yml_node *node, struct conf_inherit inherited)
static struct module *
from_conf(const struct yml_node *node, struct conf_inherit inherited)
{
const struct yml_node *host = yml_get_value(node, "host");
const struct yml_node *port = yml_get_value(node, "port");
@ -596,8 +597,8 @@ mpd_from_conf(const struct yml_node *node, struct conf_inherit inherited)
conf_to_particle(c, inherited));
}
bool
mpd_verify_conf(keychain_t *chain, const struct yml_node *node)
static bool
verify_conf(keychain_t *chain, const struct yml_node *node)
{
static const struct attr_info attrs[] = {
{"host", true, &conf_verify_string},
@ -610,11 +611,11 @@ mpd_verify_conf(keychain_t *chain, const struct yml_node *node)
return conf_verify_dict(chain, node, attrs);
}
const struct module_iface module_mpd_iface = {
.verify_conf = &verify_conf,
.from_conf = &from_conf,
};
#if defined(CORE_PLUGINS_AS_SHARED_LIBRARIES)
bool verify_conf(keychain_t *chain, const struct yml_node *node)
__attribute__((weak, alias("mpd_verify_conf")));
struct deco *from_conf(const struct yml_node *node, struct conf_inherit inherited)
__attribute__((weak, alias("mpd_from_conf")));
extern const struct module_iface iface __attribute__((weak, alias("module_mpd_iface")));
#endif

View file

@ -20,6 +20,7 @@
#include "../config.h"
#include "../config-verify.h"
#include "../module.h"
#include "../plugin.h"
#include "../tllist.h"
struct af_addr {
@ -530,8 +531,8 @@ network_new(const char *iface, struct particle *label)
return mod;
}
struct module *
network_from_conf(const struct yml_node *node, struct conf_inherit inherited)
static struct module *
from_conf(const struct yml_node *node, struct conf_inherit inherited)
{
const struct yml_node *name = yml_get_value(node, "name");
const struct yml_node *content = yml_get_value(node, "content");
@ -540,8 +541,8 @@ network_from_conf(const struct yml_node *node, struct conf_inherit inherited)
yml_value_as_string(name), conf_to_particle(content, inherited));
}
bool
network_verify_conf(keychain_t *chain, const struct yml_node *node)
static bool
verify_conf(keychain_t *chain, const struct yml_node *node)
{
static const struct attr_info attrs[] = {
{"name", true, &conf_verify_string},
@ -553,11 +554,11 @@ network_verify_conf(keychain_t *chain, const struct yml_node *node)
return conf_verify_dict(chain, node, attrs);
}
const struct module_iface module_network_iface = {
.verify_conf = &verify_conf,
.from_conf = &from_conf,
};
#if defined(CORE_PLUGINS_AS_SHARED_LIBRARIES)
bool verify_conf(keychain_t *chain, const struct yml_node *node)
__attribute__((weak, alias("network_verify_conf")));
struct deco *from_conf(const struct yml_node *node, struct conf_inherit inherited)
__attribute__((weak, alias("network_from_conf")));
extern const struct module_iface iface __attribute__((weak, alias("module_network_iface")));
#endif

View file

@ -19,6 +19,7 @@
#include "../config.h"
#include "../config-verify.h"
#include "../particles/dynlist.h"
#include "../plugin.h"
#include "../tllist.h"
typedef tll(char *) mount_point_list_t;
@ -558,8 +559,8 @@ removables_new(struct particle *label, int left_spacing, int right_spacing)
return mod;
}
struct module *
removables_from_conf(const struct yml_node *node, struct conf_inherit inherited)
static struct module *
from_conf(const struct yml_node *node, struct conf_inherit inherited)
{
const struct yml_node *content = yml_get_value(node, "content");
const struct yml_node *spacing = yml_get_value(node, "spacing");
@ -574,8 +575,8 @@ removables_from_conf(const struct yml_node *node, struct conf_inherit inherited)
return removables_new(conf_to_particle(content, inherited), left, right);
}
bool
removables_verify_conf(keychain_t *chain, const struct yml_node *node)
static bool
verify_conf(keychain_t *chain, const struct yml_node *node)
{
static const struct attr_info attrs[] = {
{"spacing", false, &conf_verify_int},
@ -589,11 +590,11 @@ removables_verify_conf(keychain_t *chain, const struct yml_node *node)
return conf_verify_dict(chain, node, attrs);
}
const struct module_iface module_removables_iface = {
.verify_conf = &verify_conf,
.from_conf = &from_conf,
};
#if defined(CORE_PLUGINS_AS_SHARED_LIBRARIES)
bool verify_conf(keychain_t *chain, const struct yml_node *node)
__attribute__((weak, alias("removables_verify_conf")));
struct deco *from_conf(const struct yml_node *node, struct conf_inherit inherited)
__attribute__((weak, alias("removables_from_conf")));
extern const struct module_iface iface __attribute__((weak, alias("module_removables_iface")));
#endif

View file

@ -14,6 +14,7 @@
#include "../bar.h"
#include "../config.h"
#include "../config-verify.h"
#include "../plugin.h"
#include "../xcb.h"
struct layout {
@ -658,15 +659,15 @@ xkb_new(struct particle *label)
return mod;
}
struct module *
xkb_from_conf(const struct yml_node *node, struct conf_inherit inherited)
static struct module *
from_conf(const struct yml_node *node, struct conf_inherit inherited)
{
const struct yml_node *c = yml_get_value(node, "content");
return xkb_new(conf_to_particle(c, inherited));
}
bool
xkb_verify_conf(keychain_t *chain, const struct yml_node *node)
static bool
verify_conf(keychain_t *chain, const struct yml_node *node)
{
static const struct attr_info attrs[] = {
{"content", true, &conf_verify_particle},
@ -677,11 +678,11 @@ xkb_verify_conf(keychain_t *chain, const struct yml_node *node)
return conf_verify_dict(chain, node, attrs);
}
const struct module_iface module_xkb_iface = {
.verify_conf = &verify_conf,
.from_conf = &from_conf,
};
#if defined(CORE_PLUGINS_AS_SHARED_LIBRARIES)
bool verify_conf(keychain_t *chain, const struct yml_node *node)
__attribute__((weak, alias("xkb_verify_conf")));
struct deco *from_conf(const struct yml_node *node, struct conf_inherit inherited)
__attribute__((weak, alias("xkb_from_conf")));
extern const struct module_iface iface __attribute__((weak, alias("module_xkb_iface")));
#endif

View file

@ -18,6 +18,7 @@
#include "../bar.h"
#include "../config.h"
#include "../config-verify.h"
#include "../plugin.h"
#include "../xcb.h"
struct private {
@ -334,15 +335,15 @@ xwindow_new(struct particle *label)
return mod;
}
struct module *
xwindow_from_conf(const struct yml_node *node, struct conf_inherit inherited)
static struct module *
from_conf(const struct yml_node *node, struct conf_inherit inherited)
{
const struct yml_node *c = yml_get_value(node, "content");
return xwindow_new(conf_to_particle(c, inherited));
}
bool
xwindow_verify_conf(keychain_t *chain, const struct yml_node *node)
static bool
verify_conf(keychain_t *chain, const struct yml_node *node)
{
static const struct attr_info attrs[] = {
{"content", true, &conf_verify_particle},
@ -353,11 +354,11 @@ xwindow_verify_conf(keychain_t *chain, const struct yml_node *node)
return conf_verify_dict(chain, node, attrs);
}
const struct module_iface module_xwindow_iface = {
.verify_conf = &verify_conf,
.from_conf = &from_conf,
};
#if defined(CORE_PLUGINS_AS_SHARED_LIBRARIES)
bool verify_conf(keychain_t *chain, const struct yml_node *node)
__attribute__((weak, alias("xwindow_verify_conf")));
struct deco *from_conf(const struct yml_node *node, struct conf_inherit inherited)
__attribute__((weak, alias("xwindow_from_conf")));
extern const struct module_iface iface __attribute__((weak, alias("module_xwindow_iface")));
#endif