@@ -39,7 +39,8 @@ struct rspamadm_command configdump_command = { | |||
.name = "configdump", | |||
.flags = 0, | |||
.help = rspamadm_configdump_help, | |||
.run = rspamadm_configdump | |||
.run = rspamadm_configdump, | |||
.lua_subrs = NULL, | |||
}; | |||
static GOptionEntry entries[] = { | |||
@@ -244,7 +245,7 @@ rspamadm_configdump (gint argc, gchar **argv) | |||
gint i; | |||
context = g_option_context_new ( | |||
"keypair - create encryption keys"); | |||
"configdump - dumps Rspamd configuration"); | |||
g_option_context_set_summary (context, | |||
"Summary:\n Rspamd administration utility version " | |||
RVERSION |
@@ -38,7 +38,8 @@ struct rspamadm_command confighelp_command = { | |||
.name = "confighelp", | |||
.flags = 0, | |||
.help = rspamadm_confighelp_help, | |||
.run = rspamadm_confighelp | |||
.run = rspamadm_confighelp, | |||
.lua_subrs = NULL, | |||
}; | |||
static GOptionEntry entries[] = { |
@@ -35,7 +35,8 @@ struct rspamadm_command configtest_command = { | |||
.name = "configtest", | |||
.flags = 0, | |||
.help = rspamadm_configtest_help, | |||
.run = rspamadm_configtest | |||
.run = rspamadm_configtest, | |||
.lua_subrs = NULL, | |||
}; | |||
static GOptionEntry entries[] = { |
@@ -38,7 +38,8 @@ struct rspamadm_command control_command = { | |||
.name = "control", | |||
.flags = 0, | |||
.help = rspamadm_control_help, | |||
.run = rspamadm_control | |||
.run = rspamadm_control, | |||
.lua_subrs = NULL, | |||
}; | |||
struct rspamadm_control_cbdata { |
@@ -33,7 +33,8 @@ struct rspamadm_command dkim_keygen_command = { | |||
.name = "dkim_keygen", | |||
.flags = 0, | |||
.help = rspamadm_dkim_keygen_help, | |||
.run = rspamadm_dkim_keygen | |||
.run = rspamadm_dkim_keygen, | |||
.lua_subrs = NULL, | |||
}; | |||
static GOptionEntry entries[] = { |
@@ -31,7 +31,8 @@ struct rspamadm_command fuzzyconvert_command = { | |||
.name = "fuzzyconvert", | |||
.flags = 0, | |||
.help = rspamadm_fuzzyconvert_help, | |||
.run = rspamadm_fuzzyconvert | |||
.run = rspamadm_fuzzyconvert, | |||
.lua_subrs = NULL, | |||
}; | |||
static GOptionEntry entries[] = { |
@@ -29,7 +29,8 @@ struct rspamadm_command fuzzy_merge_command = { | |||
.name = "fuzzy_merge", | |||
.flags = 0, | |||
.help = rspamadm_fuzzy_merge_help, | |||
.run = rspamadm_fuzzy_merge | |||
.run = rspamadm_fuzzy_merge, | |||
.lua_subrs = NULL, | |||
}; | |||
static GOptionEntry entries[] = { |
@@ -33,7 +33,8 @@ struct rspamadm_command grep_command = { | |||
.name = "grep", | |||
.flags = 0, | |||
.help = rspamadm_grep_help, | |||
.run = rspamadm_grep | |||
.run = rspamadm_grep, | |||
.lua_subrs = NULL, | |||
}; | |||
static GOptionEntry entries[] = { |
@@ -32,7 +32,8 @@ struct rspamadm_command keypair_command = { | |||
.name = "keypair", | |||
.flags = 0, | |||
.help = rspamadm_keypair_help, | |||
.run = rspamadm_keypair | |||
.run = rspamadm_keypair, | |||
.lua_subrs = NULL, | |||
}; | |||
static GOptionEntry entries[] = { |
@@ -54,7 +54,8 @@ struct rspamadm_command lua_command = { | |||
.name = "lua", | |||
.flags = 0, | |||
.help = rspamadm_lua_help, | |||
.run = rspamadm_lua | |||
.run = rspamadm_lua, | |||
.lua_subrs = NULL, | |||
}; | |||
/* |
@@ -35,7 +35,8 @@ struct rspamadm_command pw_command = { | |||
.name = "pw", | |||
.flags = 0, | |||
.help = rspamadm_pw_help, | |||
.run = rspamadm_pw | |||
.run = rspamadm_pw, | |||
.lua_subrs = NULL, | |||
}; | |||
static GOptionEntry entries[] = { |
@@ -193,11 +193,26 @@ rspamadm_execute_lua_ucl_subr (gpointer pL, gint argc, gchar **argv, | |||
gint err_idx, i, ret; | |||
GString *tb; | |||
gchar str[PATH_MAX]; | |||
const struct rspamadm_command **cmd; | |||
g_assert (script_name != NULL); | |||
g_assert (res != NULL); | |||
g_assert (L != NULL); | |||
/* Init internal rspamadm routines */ | |||
lua_newtable (L); | |||
cmd = commands; | |||
while (*cmd) { | |||
if ((*cmd)->lua_subrs != NULL) { | |||
(*cmd)->lua_subrs (L); | |||
} | |||
cmd ++; | |||
} | |||
lua_setglobal (L, "rspamadm"); | |||
rspamd_snprintf (str, sizeof (str), "return require \"%s.%s\"", "rspamadm", | |||
script_name); | |||
@@ -25,6 +25,7 @@ GQuark rspamadm_error (void); | |||
typedef const gchar* (*rspamadm_help_func) (gboolean full_help); | |||
typedef void (*rspamadm_run_func) (gint argc, gchar **argv); | |||
typedef void (*rspamadm_lua_exports_func) (gpointer lua_state); | |||
#define RSPAMADM_FLAG_NOHELP (1 << 0) | |||
@@ -33,6 +34,7 @@ struct rspamadm_command { | |||
guint flags; | |||
rspamadm_help_func help; | |||
rspamadm_run_func run; | |||
rspamadm_lua_exports_func lua_subrs; | |||
}; | |||
extern const struct rspamadm_command *commands[]; |
@@ -46,7 +46,8 @@ struct rspamadm_command signtool_command = { | |||
.name = "signtool", | |||
.flags = 0, | |||
.help = rspamadm_signtool_help, | |||
.run = rspamadm_signtool | |||
.run = rspamadm_signtool, | |||
.lua_subrs = NULL, | |||
}; | |||
static GOptionEntry entries[] = { |
@@ -32,7 +32,8 @@ struct rspamadm_command statconvert_command = { | |||
.name = "statconvert", | |||
.flags = 0, | |||
.help = rspamadm_statconvert_help, | |||
.run = rspamadm_statconvert | |||
.run = rspamadm_statconvert, | |||
.lua_subrs = NULL, | |||
}; | |||
static GOptionEntry entries[] = { |