diff options
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c index 78be8cbaf..a420493dc 100644 --- a/src/util.c +++ b/src/util.c @@ -1641,6 +1641,60 @@ rspamd_strlcpy (gchar *dst, const gchar *src, gsize siz) return (s - src - 1); /* count does not include NUL */ } +/* Convert process type to its name */ +const gchar * +process_to_str (enum process_type type) +{ + switch (type) { + case TYPE_MAIN: + return "main"; + case TYPE_WORKER: + return "worker"; + case TYPE_FUZZY: + return "fuzzy"; + case TYPE_GREYLIST: + return "greylist"; + case TYPE_CONTROLLER: + return "controller"; + case TYPE_LMTP: + return "lmtp"; + case TYPE_SMTP: + return "smtp"; + default: + return "unknown"; + } + + return NULL; +} +/* Convert string to process type */ +enum process_type +str_to_process (const gchar *str) +{ + if (g_ascii_strcasecmp (str, "main") == 0) { + return TYPE_MAIN; + } + else if (g_ascii_strcasecmp (str, "worker") == 0) { + return TYPE_WORKER; + } + else if (g_ascii_strcasecmp (str, "fuzzy") == 0) { + return TYPE_FUZZY; + } + else if (g_ascii_strcasecmp (str, "greylist") == 0) { + return TYPE_GREYLIST; + } + else if (g_ascii_strcasecmp (str, "controller") == 0) { + return TYPE_CONTROLLER; + } + else if (g_ascii_strcasecmp (str, "smtp") == 0) { + return TYPE_SMTP; + } + else if (g_ascii_strcasecmp (str, "lmtp") == 0) { + return TYPE_LMTP; + } + + return TYPE_UNKNOWN; +} + /* * vi:ts=4 */ |