]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Add string/enum conversion methods
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 22 Sep 2019 08:54:24 +0000 (09:54 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 22 Sep 2019 08:54:24 +0000 (09:54 +0100)
src/libserver/rspamd_control.c
src/libserver/rspamd_control.h

index 3d1b8ef7ca31c7a042758170d5fca88e04a4d757..503825184e7523eaca562925fb6e5ed4c0d7d424 100644 (file)
@@ -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;
+}
index 6c092ca74ec2ef750bb1d9988050e6ad344376f6..d1ce88f3166097e8e460fbbc03608ed43dbba24c 100644 (file)
@@ -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