aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-09-22 09:54:24 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-09-22 09:54:24 +0100
commitde0d6076198efa2c4bf7d5cf0d11b23f0664d0c5 (patch)
treea007215b2174b092486f0e06aebe72cefb9afc2f
parent884a962a1ef82431b60ce66bc83416898db4ad24 (diff)
downloadrspamd-de0d6076198efa2c4bf7d5cf0d11b23f0664d0c5.tar.gz
rspamd-de0d6076198efa2c4bf7d5cf0d11b23f0664d0c5.zip
[Minor] Add string/enum conversion methods
-rw-r--r--src/libserver/rspamd_control.c48
-rw-r--r--src/libserver/rspamd_control.h7
2 files changed, 54 insertions, 1 deletions
diff --git a/src/libserver/rspamd_control.c b/src/libserver/rspamd_control.c
index 3d1b8ef7c..503825184 100644
--- a/src/libserver/rspamd_control.c
+++ b/src/libserver/rspamd_control.c
@@ -1165,6 +1165,52 @@ rspamd_control_command_from_string (const gchar *str)
else if (g_ascii_strcasecmp (str, "monitored_change") == 0) {
ret = RSPAMD_CONTROL_MONITORED_CHANGE;
}
+ else if (g_ascii_strcasecmp (str, "child_change") == 0) {
+ ret = RSPAMD_CONTROL_CHILD_CHANGE;
+ }
return ret;
-} \ No newline at end of file
+}
+
+const gchar *
+rspamd_control_command_to_string (enum rspamd_control_type cmd)
+{
+ const gchar *reply = "unknown";
+
+ switch (cmd) {
+ case RSPAMD_CONTROL_STAT:
+ reply = "stat";
+ break;
+ case RSPAMD_CONTROL_RELOAD:
+ reply = "reload";
+ break;
+ case RSPAMD_CONTROL_RERESOLVE:
+ reply = "reresolve";
+ break;
+ case RSPAMD_CONTROL_RECOMPILE:
+ reply = "recompile";
+ break;
+ case RSPAMD_CONTROL_HYPERSCAN_LOADED:
+ reply = "hyperscan_loaded";
+ break;
+ case RSPAMD_CONTROL_LOG_PIPE:
+ reply = "log_pipe";
+ break;
+ case RSPAMD_CONTROL_FUZZY_STAT:
+ reply = "fuzzy_stat";
+ break;
+ case RSPAMD_CONTROL_FUZZY_SYNC:
+ reply = "fuzzy_sync";
+ break;
+ case RSPAMD_CONTROL_MONITORED_CHANGE:
+ reply = "monitored_change";
+ break;
+ case RSPAMD_CONTROL_CHILD_CHANGE:
+ reply = "child_change";
+ break;
+ default:
+ break;
+ }
+
+ return reply;
+}
diff --git a/src/libserver/rspamd_control.h b/src/libserver/rspamd_control.h
index 6c092ca74..d1ce88f31 100644
--- a/src/libserver/rspamd_control.h
+++ b/src/libserver/rspamd_control.h
@@ -267,6 +267,13 @@ void rspamd_control_broadcast_srv_cmd (struct rspamd_main *rspamd_main,
*/
enum rspamd_control_type rspamd_control_command_from_string (const gchar *str);
+/**
+ * Returns command name from it's type
+ * @param cmd
+ * @return
+ */
+const gchar *rspamd_control_command_to_string (enum rspamd_control_type cmd);
+
#ifdef __cplusplus
}
#endif