summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-02-15 17:09:58 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-02-15 17:09:58 +0000
commitdf75947ab9f8bdd9eb2b5c05384d49e247c8b41d (patch)
tree8488569697eecb6e1c207645dd795af9d9b6663a
parenta29d1caf57379e4864ab9680abfbf105f23b0be1 (diff)
downloadrspamd-df75947ab9f8bdd9eb2b5c05384d49e247c8b41d.tar.gz
rspamd-df75947ab9f8bdd9eb2b5c05384d49e247c8b41d.zip
Add method to check if a map looks like a map
-rw-r--r--src/libutil/map.c23
-rw-r--r--src/libutil/map.h7
2 files changed, 30 insertions, 0 deletions
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
@@ -543,6 +543,29 @@ rspamd_map_check_proto (struct rspamd_config *cfg,
}
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,
const gchar *description,
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
@@ -38,6 +38,13 @@ struct map_cb_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
*/
gboolean rspamd_map_add (struct rspamd_config *cfg,