Happy new year
[yaz-moved-to-github.git] / src / comstack.c
index 669117d..17c6a41 100644 (file)
@@ -1,5 +1,5 @@
 /* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2011 Index Data
+ * Copyright (C) 1995-2012 Index Data
  * See the file LICENSE for details.
  */
 /** 
@@ -157,13 +157,20 @@ static int cs_parse_host(const char *uri, const char **host,
 
 COMSTACK cs_create_host(const char *vhost, int blocking, void **vp)
 {
+    return cs_create_host_proxy(vhost, blocking, vp, 0);
+}
+
+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;
 
-    cs_parse_host(vhost, &host, &t, &proto, &connect_host);
+    if (!cs_parse_host(vhost, &host, &t, &proto, &connect_host))
+        return 0;
 
     if (t == tcpip_type)
     {
@@ -175,6 +182,8 @@ COMSTACK cs_create_host(const char *vhost, int blocking, void **vp)
     }
     if (cs)
     {
+        if (proxy_host)
+            host = proxy_host;
         if (!(*vp = cs_straddr(cs, connect_host ? connect_host : host)))
         {
             cs_close (cs);