From df75947ab9f8bdd9eb2b5c05384d49e247c8b41d Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 15 Feb 2016 17:09:58 +0000 Subject: [PATCH] Add method to check if a map looks like a map --- src/libutil/map.c | 23 +++++++++++++++++++++++ src/libutil/map.h | 7 +++++++ 2 files changed, 30 insertions(+) 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 */ -- 2.39.5