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)
{
* @param ups
*/
void rspamd_upstreams_destroy (struct upstream_list *ups);
+
/**
* Add upstream from the string
* @param ups upstream list
- * @param str string in format "name[:port[:priority]]
+ * @param str string in format "name[:port[:priority]]"
* @param def_port default port number
* @param data optional userdata
* @return TRUE if upstream has been added
gboolean rspamd_upstreams_add_upstream (struct upstream_list *ups,
const gchar *str, guint16 def_port, void *data);
+/**
+ * Add multiple upstreams from comma, semicolon or space separated line
+ * @param ups upstream list
+ * @param str string in format "(<ups>([<sep>+]<ups>)*)+"
+ * @param def_port default port number
+ * @param data optional userdata
+ * @return TRUE if **any** of upstreams has been added
+ */
+gboolean rspamd_upstreams_parse_line (struct upstream_list *ups,
+ const gchar *str, guint16 def_port, void *data);
+
/**
* Returns the current IP address of the upstream
* @param up