From d071dc92a2b0f853309b1c450d739dd4bb69f108 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 18 Sep 2012 18:44:51 +0400 Subject: Remove legacy stuff from librspamdclient. Add support of unix socket for client library and rspamc. --- src/client/rspamc.c | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/client/rspamc.c b/src/client/rspamc.c index 7d88ea65c..1c7eaf318 100644 --- a/src/client/rspamc.c +++ b/src/client/rspamc.c @@ -149,27 +149,36 @@ add_rspamd_server (gboolean is_control) fprintf (stderr, "cannot connect to rspamd server - empty string\n"); exit (EXIT_FAILURE); } - vec = g_strsplit_set (connect_str, ":", 2); - if (vec == NULL || *vec == NULL) { - fprintf (stderr, "cannot connect to rspamd server: %s\n", connect_str); - exit (EXIT_FAILURE); - } + if (*connect_str != '/') { + vec = g_strsplit_set (connect_str, ":", 2); + if (vec == NULL || *vec == NULL) { + fprintf (stderr, "cannot connect to rspamd server: %s\n", connect_str); + exit (EXIT_FAILURE); + } - if (vec[1] == NULL) { - port = is_control ? DEFAULT_CONTROL_PORT : DEFAULT_PORT; + if (vec[1] == NULL) { + port = is_control ? DEFAULT_CONTROL_PORT : DEFAULT_PORT; + } + else { + port = strtoul (vec[1], &err_str, 10); + if (*err_str != '\0') { + fprintf (stderr, "cannot connect to rspamd server: %s, at pos %s\n", connect_str, err_str); + exit (EXIT_FAILURE); + } + } + if (! rspamd_add_server (client, vec[0], port, port, &err)) { + fprintf (stderr, "cannot connect to rspamd server: %s, error: %s\n", connect_str, err->message); + exit (EXIT_FAILURE); + } } else { - port = strtoul (vec[1], &err_str, 10); - if (*err_str != '\0') { - fprintf (stderr, "cannot connect to rspamd server: %s, at pos %s\n", connect_str, err_str); + /* Unix socket version */ + if (! rspamd_add_server (client, connect_str, 0, 0, &err)) { + fprintf (stderr, "cannot connect to rspamd server: %s, error: %s\n", connect_str, err->message); exit (EXIT_FAILURE); } } - if (! rspamd_add_server (client, vec[0], port, port, &err)) { - fprintf (stderr, "cannot connect to rspamd server: %s, error: %s\n", connect_str, err->message); - exit (EXIT_FAILURE); - } } static void -- cgit v1.2.3