aboutsummaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-04-22 17:12:24 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-04-22 17:12:24 +0100
commite6700d963ccaa536c38176189d54d9bcf808e3f5 (patch)
treefff8f4a57c062b077b1d7ce0f3f3e39441e20d23 /src/client
parent3ce3f00936a96bf8ab88066e298b2677219f09f0 (diff)
downloadrspamd-e6700d963ccaa536c38176189d54d9bcf808e3f5.tar.gz
rspamd-e6700d963ccaa536c38176189d54d9bcf808e3f5.zip
Support no-input commands for rspamc.
Diffstat (limited to 'src/client')
-rw-r--r--src/client/rspamc.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/client/rspamc.c b/src/client/rspamc.c
index 8ef9ebad0..8a0406589 100644
--- a/src/client/rspamc.c
+++ b/src/client/rspamc.c
@@ -103,6 +103,7 @@ struct rspamc_command {
const char *description;
gboolean is_controller;
gboolean is_privileged;
+ gboolean need_input;
void (*command_output_func)(ucl_object_t *obj);
} rspamc_commands[] = {
{
@@ -111,6 +112,7 @@ struct rspamc_command {
.description = "scan message and show symbols (default command)",
.is_controller = FALSE,
.is_privileged = FALSE,
+ .need_input = TRUE,
.command_output_func = rspamc_symbols_output
},
{
@@ -119,6 +121,7 @@ struct rspamc_command {
.description = "learn message as spam",
.is_controller = TRUE,
.is_privileged = TRUE,
+ .need_input = TRUE,
.command_output_func = NULL
},
{
@@ -127,6 +130,7 @@ struct rspamc_command {
.description = "learn message as ham",
.is_controller = TRUE,
.is_privileged = TRUE,
+ .need_input = TRUE,
.command_output_func = NULL
},
{
@@ -135,6 +139,7 @@ struct rspamc_command {
.description = "add message to fuzzy storage (check -f and -w options for this command)",
.is_controller = TRUE,
.is_privileged = TRUE,
+ .need_input = TRUE,
.command_output_func = NULL
},
{
@@ -143,6 +148,7 @@ struct rspamc_command {
.description = "delete message from fuzzy storage (check -f option for this command)",
.is_controller = TRUE,
.is_privileged = TRUE,
+ .need_input = TRUE,
.command_output_func = NULL
},
{
@@ -151,6 +157,7 @@ struct rspamc_command {
.description = "show rspamd statistics",
.is_controller = TRUE,
.is_privileged = FALSE,
+ .need_input = FALSE,
.command_output_func = NULL
},
{
@@ -159,6 +166,7 @@ struct rspamc_command {
.description = "show and reset rspamd statistics (useful for graphs)",
.is_controller = TRUE,
.is_privileged = TRUE,
+ .need_input = FALSE,
.command_output_func = NULL
},
{
@@ -167,6 +175,7 @@ struct rspamc_command {
.description = "display rspamd symbols statistics",
.is_controller = TRUE,
.is_privileged = FALSE,
+ .need_input = FALSE,
.command_output_func = NULL
},
{
@@ -175,6 +184,7 @@ struct rspamc_command {
.description = "show rspamd uptime",
.is_controller = TRUE,
.is_privileged = FALSE,
+ .need_input = FALSE,
.command_output_func = NULL
},
{
@@ -183,6 +193,7 @@ struct rspamc_command {
.description = "add or modify symbol settings in rspamd",
.is_controller = TRUE,
.is_privileged = TRUE,
+ .need_input = FALSE,
.command_output_func = NULL
},
{
@@ -191,6 +202,7 @@ struct rspamc_command {
.description = "add or modify action settings",
.is_controller = TRUE,
.is_privileged = TRUE,
+ .need_input = FALSE,
.command_output_func = NULL
}
};
@@ -560,7 +572,14 @@ rspamc_process_input (struct event_base *ev_base, struct rspamc_command *cmd,
cbdata = g_slice_alloc (sizeof (struct rspamc_callback_data));
cbdata->cmd = cmd;
cbdata->filename = name;
- rspamd_client_command (conn, cmd->name, attrs, in, rspamc_client_cb, cbdata, &err);
+ if (cmd->need_input) {
+ rspamd_client_command (conn, cmd->name, attrs, in, rspamc_client_cb,
+ cbdata, &err);
+ }
+ else {
+ rspamd_client_command (conn, cmd->name, attrs, NULL, rspamc_client_cb,
+ cbdata, &err);
+ }
}
}