diff options
author | James Booth <boothj5@gmail.com> | 2016-06-29 23:35:57 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2016-06-29 23:35:57 +0100 |
commit | a01eb5d08e1b39d60a6f8fc26e5a87ceb92ec18f (patch) | |
tree | be77126865e0cb26963859ad384a225e9c993c9e /src/plugins/callbacks.c | |
parent | 61a09476c511c33abd9b6be3d5786fee1fa93b94 (diff) | |
download | profani-tty-a01eb5d08e1b39d60a6f8fc26e5a87ceb92ec18f.tar.gz |
WIP - Unload plugin commands
Diffstat (limited to 'src/plugins/callbacks.c')
-rw-r--r-- | src/plugins/callbacks.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/plugins/callbacks.c b/src/plugins/callbacks.c index 2572f7a4..8960738f 100644 --- a/src/plugins/callbacks.c +++ b/src/plugins/callbacks.c @@ -78,6 +78,40 @@ callbacks_add_command(PluginCommand *command) } void +_command_destroy(PluginCommand *command) +{ + free(command->command_name); + free(command->plugin_name); + command_help_free(command->help); + // TODO free callback +} + +void +callbacks_remove_commands(const char *const plugin_name) +{ + GSList *items_to_remove = NULL; + GSList *curr = p_commands; + while (curr) { + PluginCommand *command = curr->data; + if (g_strcmp0(command->plugin_name, plugin_name) == 0) { + cmd_ac_remove(command->command_name); + cmd_ac_remove_help(&command->command_name[1]); + items_to_remove = g_slist_append(items_to_remove, curr); + } + curr = g_slist_next(curr); + } + + curr = items_to_remove; + while (curr) { + GSList *item = curr->data; + PluginCommand *command = item->data; + _command_destroy(command); + p_commands = g_slist_remove_link(p_commands, item); + curr = g_slist_next(curr); + } +} + +void callbacks_add_timed(PluginTimedFunction *timed_function) { p_timed_functions = g_slist_append(p_timed_functions, timed_function); |