diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-10-29 13:58:33 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-10-29 13:58:33 +0000 |
commit | db0e114862cdac564756485f9d5c9102e73d81ab (patch) | |
tree | 010416fac5f370c5b63b37aa1a4799c9bf1e60c6 /src/libutil/upstream.c | |
parent | 8c9cf87f25a81677b52ed1a309fea505d1c2174f (diff) | |
download | rspamd-db0e114862cdac564756485f9d5c9102e73d81ab.tar.gz rspamd-db0e114862cdac564756485f9d5c9102e73d81ab.zip |
Add parsing of multiple upstreams string.
Diffstat (limited to 'src/libutil/upstream.c')
-rw-r--r-- | src/libutil/upstream.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/libutil/upstream.c b/src/libutil/upstream.c index 43f2bcfcc..5b86628b2 100644 --- a/src/libutil/upstream.c +++ b/src/libutil/upstream.c @@ -329,6 +329,33 @@ rspamd_upstreams_add_upstream (struct upstream_list *ups, return TRUE; } +gboolean +rspamd_upstreams_parse_line (struct upstream_list *ups, + const gchar *str, guint16 def_port, void *data) +{ + const gchar *end = str + strlen (str), *p = str; + const gchar *separators = ";, \n\r\t"; + gchar *tmp; + guint len; + gboolean ret = FALSE; + + while (p < end) { + len = strcspn (p, separators); + if (len > 0) { + tmp = g_malloc (len + 1); + rspamd_strlcpy (tmp, p, len + 1); + if (rspamd_upstreams_add_upstream (ups, tmp, def_port, data)) { + ret = TRUE; + } + } + p += len + 1; + /* Skip separators */ + p += strspn (p, separators) + 1; + } + + return ret; +} + void rspamd_upstreams_destroy (struct upstream_list *ups) { |