/* 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.
*/
/**
}
if (addinfo && addinfo2)
{
- c->addinfo = (char*) xmalloc(strlen(addinfo) + strlen(addinfo2) + 2);
+ c->addinfo = (char*) xmalloc(strlen(addinfo) + strlen(addinfo2) + 3);
strcpy(c->addinfo, addinfo);
+ strcat(c->addinfo, ": ");
strcat(c->addinfo, addinfo2);
}
else if (addinfo)
ZOOM_connection_remove_task(c);
}
+static void odr_wrbuf_write(ODR o, void *handle, int type,
+ const char *buf, int len)
+{
+ WRBUF w = (WRBUF) handle;
+ wrbuf_write(w, buf, len);
+}
ZOOM_API(ZOOM_connection)
ZOOM_connection_create(ZOOM_options options)
c->host_port = 0;
c->proxy = 0;
+ c->tproxy = 0;
c->charset = c->lang = 0;
c->odr_in = odr_createmem(ODR_DECODE);
c->odr_out = odr_createmem(ODR_ENCODE);
c->odr_print = 0;
+ c->odr_save = 0;
c->async = 0;
c->support_named_resultsets = 0;
return c;
}
+ZOOM_API(void) ZOOM_connection_save_apdu_wrbuf(ZOOM_connection c, WRBUF w)
+{
+ if (c->odr_save)
+ {
+ odr_destroy(c->odr_save);
+ c->odr_save = 0;
+ }
+ if (w)
+ {
+ c->odr_save = odr_createmem(ODR_PRINT);
+ odr_set_stream(c->odr_save, w, odr_wrbuf_write, 0);
+ }
+}
/* set database names. Take local databases (if set); otherwise
take databases given in ZURL (if set); otherwise use Default */
if (cp)
cp++;
}
- if (!cp)
+ if (!cp || !*cp)
cp = "Default";
nmem_strsplit(odr_getmem(odr), "+", cp, &databaseNames, num);
return databaseNames;
c->proxy = xstrdup(val);
}
+ xfree(c->tproxy);
+ c->tproxy = 0;
+ val = ZOOM_options_get(c->options, "tproxy");
+ if (val && *val)
+ {
+ yaz_log(c->log_details, "%p ZOOM_connection_connect tproxy=%s", c, val);
+ c->tproxy = xstrdup(val);
+ }
+
+
xfree(c->charset);
c->charset = 0;
val = ZOOM_options_get(c->options, "charset");
xfree(c->diagset);
odr_destroy(c->odr_in);
odr_destroy(c->odr_out);
+ if (c->odr_save)
+ odr_destroy(c->odr_save);
if (c->odr_print)
{
odr_setprint(c->odr_print, 0); /* prevent destroy from fclose'ing */
ZOOM_connection_remove_events(c);
xfree(c->host_port);
xfree(c->proxy);
+ xfree(c->tproxy);
xfree(c->charset);
xfree(c->lang);
xfree(c->cookie_out);
if (c->cs)
cs_close(c->cs);
- c->cs = cs_create_host_proxy(logical_url, 0, &add, c->proxy);
+ c->cs = cs_create_host_proxy(logical_url, 0, &add,
+ c->tproxy ? c->tproxy : c->proxy);
if (c->cs && c->cs->protocol == PROTO_HTTP)
{
return zoom_complete;
if (c->odr_print)
z_GDU(c->odr_print, &gdu, 0, 0);
+ if (c->odr_save)
+ z_GDU(c->odr_save, &gdu, 0, 0);
c->buf_out = odr_getbuf(c->odr_out, &c->len_out, 0);
odr_reset(c->odr_out);
{
if (c->odr_print)
z_GDU(c->odr_print, &gdu, 0, 0);
+ if (c->odr_save)
+ z_GDU(c->odr_save, &gdu, 0, 0);
if (gdu->which == Z_GDU_Z3950)
ZOOM_handle_Z3950_apdu(c, gdu->u.z3950);
else if (gdu->which == Z_GDU_HTTP_Response)