diff options
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) { |