aboutsummaryrefslogtreecommitdiff
path: root/plugin/src
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2024-06-15 11:43:10 -0700
committer3gg <3gg@shellblade.net>2024-06-15 11:43:10 -0700
commitbec2d50c843ec4fd98bbbb212848ce4f24b96ebb (patch)
tree59c33bc964e723350886035fe249e41d0f8b397e /plugin/src
parent04e3ded4c28c0b559620609daaae7b939d776b61 (diff)
More convenient list iteration.
Diffstat (limited to 'plugin/src')
-rw-r--r--plugin/src/plugin.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/plugin/src/plugin.c b/plugin/src/plugin.c
index cd05faf..e2aae1f 100644
--- a/plugin/src/plugin.c
+++ b/plugin/src/plugin.c
@@ -34,7 +34,7 @@ typedef struct Plugin {
34 mstring filename; 34 mstring filename;
35} Plugin; 35} Plugin;
36 36
37DEF_LIST(Plugin); 37DEF_LIST(Plugin, Plugin);
38 38
39/// Plugin engine. 39/// Plugin engine.
40typedef struct PluginEngine { 40typedef struct PluginEngine {
@@ -121,7 +121,7 @@ Plugin* load_plugin(PluginEngine* eng, const char* filename) {
121 return 0; 121 return 0;
122 } 122 }
123 123
124 list_push(eng->plugins, plugin); 124 list_add(eng->plugins, plugin);
125 return &eng->plugins.head->val; 125 return &eng->plugins.head->val;
126} 126}
127 127
@@ -180,7 +180,7 @@ void delete_plugin_engine(PluginEngine** pEng) {
180 assert(pEng); 180 assert(pEng);
181 PluginEngine* eng = *pEng; 181 PluginEngine* eng = *pEng;
182 if (eng) { 182 if (eng) {
183 list_foreach_mut(eng->plugins, { destroy_plugin(value); }); 183 list_foreach_mut(eng->plugins, plugin, { destroy_plugin(&plugin); });
184 del_list(eng->plugins); 184 del_list(eng->plugins);
185 if (eng->dir_watch != -1) { 185 if (eng->dir_watch != -1) {
186 inotify_rm_watch(eng->dir_watch, eng->inotify_instance); 186 inotify_rm_watch(eng->dir_watch, eng->inotify_instance);
@@ -226,11 +226,10 @@ void plugin_engine_update(PluginEngine* eng) {
226 if (event->len > 0) { 226 if (event->len > 0) {
227 // Name does not include directory, e.g., libfoo.so 227 // Name does not include directory, e.g., libfoo.so
228 const mstring file = mstring_make(event->name); 228 const mstring file = mstring_make(event->name);
229 list_foreach_mut(eng->plugins, { 229 list_foreach_mut(eng->plugins, plugin, {
230 Plugin* plugin = value; 230 if (mstring_eq(file, plugin_lib_name(&plugin))) {
231 if (mstring_eq(file, plugin_lib_name(plugin))) { 231 if (load_library(&plugin)) {
232 if (load_library(plugin)) { 232 plugin.reloaded = true;
233 plugin->reloaded = true;
234 } 233 }
235 break; 234 break;
236 } 235 }