From: Vsevolod Stakhov Date: Mon, 15 Feb 2016 17:09:58 +0000 (+0000) Subject: Add method to check if a map looks like a map X-Git-Tag: 1.2.0~230 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=df75947ab9f8bdd9eb2b5c05384d49e247c8b41d;p=rspamd.git Add method to check if a map looks like a map --- diff --git a/src/libutil/map.c b/src/libutil/map.c index 805086633..07558c296 100644 --- a/src/libutil/map.c +++ b/src/libutil/map.c @@ -542,6 +542,29 @@ rspamd_map_check_proto (struct rspamd_config *cfg, return pos; } +gboolean +rspamd_map_is_map (const gchar *map_line) +{ + gboolean ret = FALSE; + + g_assert (map_line != NULL); + + if (map_line[0] == '/') { + ret = TRUE; + } + else if (g_ascii_strncasecmp (map_line, "sign+", sizeof ("sign+") - 1) == 0) { + ret = TRUE; + } + else if (g_ascii_strncasecmp (map_line, "file://", sizeof ("file://") - 1) == 0) { + ret = TRUE; + } + else if (g_ascii_strncasecmp (map_line, "http://", sizeof ("file://") - 1) == 0) { + ret = TRUE; + } + + return ret; +} + gboolean rspamd_map_add (struct rspamd_config *cfg, const gchar *map_line, diff --git a/src/libutil/map.h b/src/libutil/map.h index 13590581e..56933a1cc 100644 --- a/src/libutil/map.h +++ b/src/libutil/map.h @@ -37,6 +37,13 @@ struct map_cb_data { void *cur_data; }; +/** + * Returns TRUE if line looks like a map definition + * @param map_line + * @return + */ +gboolean rspamd_map_is_map (const gchar *map_line); + /** * Add map from line */