projects
/
yaz-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Version 4.2.34
[yaz-moved-to-github.git]
/
src
/
zoom-c.c
diff --git
a/src/zoom-c.c
b/src/zoom-c.c
index
3615ed9
..
e597e24
100644
(file)
--- a/
src/zoom-c.c
+++ b/
src/zoom-c.c
@@
-1,5
+1,5
@@
/* This file is part of the YAZ toolkit.
/* 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.
*/
/**
* See the file LICENSE for details.
*/
/**
@@
-236,6
+236,12
@@
void ZOOM_connection_remove_tasks(ZOOM_connection c)
ZOOM_connection_remove_task(c);
}
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)
ZOOM_API(ZOOM_connection)
ZOOM_connection_create(ZOOM_options options)
@@
-286,6
+292,7
@@
ZOOM_API(ZOOM_connection)
c->odr_in = odr_createmem(ODR_DECODE);
c->odr_out = odr_createmem(ODR_ENCODE);
c->odr_print = 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;
c->async = 0;
c->support_named_resultsets = 0;
@@
-299,6
+306,19
@@
ZOOM_API(ZOOM_connection)
return c;
}
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 */
/* set database names. Take local databases (if set); otherwise
take databases given in ZURL (if set); otherwise use Default */
@@
-317,7
+337,7
@@
char **ZOOM_connection_get_databases(ZOOM_connection con, ZOOM_options options,
if (cp)
cp++;
}
if (cp)
cp++;
}
- if (!cp)
+ if (!cp || !*cp)
cp = "Default";
nmem_strsplit(odr_getmem(odr), "+", cp, &databaseNames, num);
return databaseNames;
cp = "Default";
nmem_strsplit(odr_getmem(odr), "+", cp, &databaseNames, num);
return databaseNames;
@@
-399,7
+419,6
@@
ZOOM_API(void)
c->tproxy = xstrdup(val);
}
c->tproxy = xstrdup(val);
}
-
xfree(c->charset);
c->charset = 0;
val = ZOOM_options_get(c->options, "charset");
xfree(c->charset);
c->charset = 0;
val = ZOOM_options_get(c->options, "charset");
@@
-446,20
+465,22
@@
ZOOM_API(void)
char *pcomma;
char *pequals;
while ((pcomma = strchr(remainder, ',')) != 0 &&
char *pcomma;
char *pequals;
while ((pcomma = strchr(remainder, ',')) != 0 &&
- (pcolon == 0 || pcomma < pcolon)) {
+ (pcolon == 0 || pcomma < pcolon))
+ {
*pcomma = '\0';
*pcomma = '\0';
- if ((pequals = strchr(remainder, '=')) != 0) {
+ if ((pequals = strchr(remainder, '=')) != 0)
+ {
*pequals = '\0';
*pequals = '\0';
- /*printf("# setting '%s'='%s'\n", remainder, pequals+1);*/
ZOOM_connection_option_set(c, remainder, pequals+1);
}
remainder = pcomma+1;
}
ZOOM_connection_option_set(c, remainder, pequals+1);
}
remainder = pcomma+1;
}
- if (remainder != c->host_port) {
+ if (remainder != c->host_port)
+ {
+ remainder = xstrdup(remainder);
xfree(c->host_port);
xfree(c->host_port);
- c->host_port = xstrdup(remainder);
- /*printf("# reset hp='%s'\n", remainder);*/
+ c->host_port = remainder;
}
}
}
}
@@
-592,6
+613,8
@@
ZOOM_API(void)
xfree(c->diagset);
odr_destroy(c->odr_in);
odr_destroy(c->odr_out);
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 */
if (c->odr_print)
{
odr_setprint(c->odr_print, 0); /* prevent destroy from fclose'ing */
@@
-998,6
+1021,15
@@
ZOOM_API(ZOOM_facet_field)
return 0;
}
return 0;
}
+ZOOM_API(ZOOM_facet_field)
+ ZOOM_resultset_get_facet_field_by_index(ZOOM_resultset r, int index) {
+ int num = r->num_facets;
+ ZOOM_facet_field *facets = r->facets;
+ if (index >= 0 && index < num) {
+ return facets[index];
+ }
+ return 0;
+}
ZOOM_API(ZOOM_facet_field *)
ZOOM_resultset_facets(ZOOM_resultset r)
ZOOM_API(ZOOM_facet_field *)
ZOOM_resultset_facets(ZOOM_resultset r)
@@
-1006,7
+1038,7
@@
ZOOM_API(ZOOM_facet_field *)
}
ZOOM_API(const char**)
}
ZOOM_API(const char**)
- ZOOM_resultset_facet_names(ZOOM_resultset r)
+ ZOOM_resultset_facets_names(ZOOM_resultset r)
{
return (const char **) r->facets_names;
}
{
return (const char **) r->facets_names;
}
@@
-1528,6
+1560,8
@@
static zoom_ret send_HTTP_redirect(ZOOM_connection c, const char *uri,
return zoom_complete;
if (c->odr_print)
z_GDU(c->odr_print, &gdu, 0, 0);
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);
c->buf_out = odr_getbuf(c->odr_out, &c->len_out, 0);
odr_reset(c->odr_out);
@@
-1686,6
+1720,8
@@
static int do_read(ZOOM_connection c)
{
if (c->odr_print)
z_GDU(c->odr_print, &gdu, 0, 0);
{
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)
if (gdu->which == Z_GDU_Z3950)
ZOOM_handle_Z3950_apdu(c, gdu->u.z3950);
else if (gdu->which == Z_GDU_HTTP_Response)