From c62c26d35e1eaf2ab04c4c64a3548e355059ebe3 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 27 Oct 2014 10:35:31 +0100 Subject: [PATCH] Retain cs_create_host_proxy and use blank for optional bind host --- client/client.c | 13 +------------ include/yaz/comstack.h | 4 ---- src/comstack.c | 16 ++++++++-------- src/tcpip.c | 2 ++ 4 files changed, 11 insertions(+), 24 deletions(-) diff --git a/client/client.c b/client/client.c index d64884c..596b76a 100644 --- a/client/client.c +++ b/client/client.c @@ -151,7 +151,6 @@ static Odr_int last_hit_count = 0; static int pretty_xml = 0; static Odr_int sru_maximumRecords = 0; static yaz_cookies_t yaz_cookies = 0; -static char *bind_host = 0; typedef enum { QueryType_Prefix, @@ -704,7 +703,7 @@ static int session_connect_base(const char *arg, const char **basep) strncpy(type_and_host, arg, sizeof(type_and_host)-1); type_and_host[sizeof(type_and_host)-1] = '\0'; - conn = cs_create_host2(arg, 1, &add, yazProxy, bind_host); + conn = cs_create_host_proxy(arg, 1, &add, yazProxy); if (!conn) { printf("Could not resolve address %s\n", arg); @@ -756,15 +755,6 @@ static int session_connect(void) return r; } -static int cmd_bind(const char *arg) -{ - xfree(bind_host); - bind_host = 0; - if (arg && *arg) - bind_host = xstrdup(arg); - return 0; -} - static int cmd_open(const char *arg) { int r; @@ -5061,7 +5051,6 @@ static struct { {"init", cmd_init, "", NULL,0,NULL}, {"sru", cmd_sru, " ", NULL,0,NULL}, {"url", cmd_url, "", NULL,0,NULL}, - {"bind", cmd_bind, "", NULL,0,NULL}, {"exit", cmd_quit, "",NULL,0,NULL}, {0,0,0,0,0,0} }; diff --git a/include/yaz/comstack.h b/include/yaz/comstack.h index e3dada7..2b4b4d5 100644 --- a/include/yaz/comstack.h +++ b/include/yaz/comstack.h @@ -123,10 +123,6 @@ YAZ_EXPORT COMSTACK cs_create_host(const char *type_and_host, YAZ_EXPORT COMSTACK cs_create_host_proxy(const char *vhost, int blocking, void **vp, const char *proxy_host); -YAZ_EXPORT COMSTACK cs_create_host2(const char *vhost, - int blocking, void **vp, - const char *proxy_host, - const char *bind_host); YAZ_EXPORT void cs_get_host_args(const char *type_and_host, const char **args); YAZ_EXPORT int cs_complete_auto_head(const char *buf, int len); YAZ_EXPORT int cs_complete_auto(const char *buf, int len); diff --git a/src/comstack.c b/src/comstack.c index ee64fc8..636cf37 100644 --- a/src/comstack.c +++ b/src/comstack.c @@ -175,14 +175,20 @@ COMSTACK cs_create_host(const char *vhost, int blocking, void **vp) return cs_create_host_proxy(vhost, blocking, vp, 0); } -COMSTACK cs_create_host2(const char *vhost, int blocking, void **vp, - const char *proxy_host, const char *bind_host) +COMSTACK cs_create_host_proxy(const char *vhost, int blocking, void **vp, + const char *proxy_host) { enum oid_proto proto = PROTO_Z3950; const char *host = 0; COMSTACK cs; CS_TYPE t; char *connect_host = 0; + const char *bind_host = strchr(vhost, ' '); + + if (bind_host && bind_host[1]) + bind_host++; + else + bind_host = 0; if (!cs_parse_host(vhost, &host, &t, &proto, &connect_host)) return 0; @@ -217,12 +223,6 @@ COMSTACK cs_create_host2(const char *vhost, int blocking, void **vp, return cs; } -COMSTACK cs_create_host_proxy(const char *vhost, int blocking, void **vp, - const char *proxy_host) -{ - return cs_create_host2(vhost, blocking, vp, proxy_host, 0); -} - int cs_look (COMSTACK cs) { return cs->event; diff --git a/src/tcpip.c b/src/tcpip.c index 47655a9..3ade82b 100644 --- a/src/tcpip.c +++ b/src/tcpip.c @@ -363,6 +363,8 @@ struct addrinfo *tcpip_getaddrinfo(const char *str, const char *port, strncpy(host, str, sizeof(host)-1); host[sizeof(host)-1] = 0; + if ((p = strrchr(host, ' '))) + *p = 0; if ((p = strchr(host, '/'))) *p = 0; if ((p = strrchr(host, ':'))) -- 1.7.10.4