diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-05-24 19:55:37 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-05-24 19:56:05 +0100 |
commit | 25ef6b98215f5518dae638ce0fd6b4710f17b113 (patch) | |
tree | 3bd032e2097a3e65985bb10d1ae926498011086f /src/rspamadm/commands.c | |
parent | bb638f7c7d851f20071f5f9ee77224c0173e73ae (diff) | |
download | rspamd-25ef6b98215f5518dae638ce0fd6b4710f17b113.tar.gz rspamd-25ef6b98215f5518dae638ce0fd6b4710f17b113.zip |
[Project] Rework rspamadm and Lua init path
Diffstat (limited to 'src/rspamadm/commands.c')
-rw-r--r-- | src/rspamadm/commands.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/rspamadm/commands.c b/src/rspamadm/commands.c index 410306fe3..87a3d961e 100644 --- a/src/rspamadm/commands.c +++ b/src/rspamadm/commands.c @@ -14,6 +14,7 @@ * limitations under the License. */ #include "rspamadm.h" +#include "libutil/util.h" extern struct rspamadm_command pw_command; extern struct rspamadm_command keypair_command; @@ -55,23 +56,33 @@ const struct rspamadm_command *commands[] = { const struct rspamadm_command * -rspamadm_search_command (const gchar *name) +rspamadm_search_command (const gchar *name, GPtrArray *all_commands) { - const struct rspamadm_command *ret = NULL; + const struct rspamadm_command *ret = NULL, *cmd; guint i; if (name == NULL) { name = "help"; } - for (i = 0; i < G_N_ELEMENTS (commands); i ++) { - if (commands[i] != NULL) { - if (strcmp (name, commands[i]->name) == 0) { - ret = commands[i]; + PTR_ARRAY_FOREACH (all_commands, i, cmd) { + if (strcmp (name, cmd->name) == 0) { + ret = cmd; break; } - } } return ret; } + +void +rspamadm_fill_internal_commands (GPtrArray *dest) +{ + guint i; + + for (i = 0; i < G_N_ELEMENTS (commands); i ++) { + if (commands[i]) { + g_ptr_array_add (dest, (gpointer)commands[i]); + } + } +} |