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
Function ZOOM_record_get allows type_spec=schema in which case schema
[yaz-moved-to-github.git]
/
src
/
zoom-c.c
diff --git
a/src/zoom-c.c
b/src/zoom-c.c
index
742847b
..
d96d1f5
100644
(file)
--- a/
src/zoom-c.c
+++ b/
src/zoom-c.c
@@
-2,7
+2,7
@@
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: zoom-c.c,v 1.142 2007-08-23 12:24:38 adam Exp $
+ * $Id: zoom-c.c,v 1.146 2007-09-08 06:17:45 adam Exp $
*/
/**
* \file zoom-c.c
*/
/**
* \file zoom-c.c
@@
-395,6
+395,8
@@
ZOOM_API(ZOOM_connection)
c->m_queue_front = 0;
c->m_queue_back = 0;
c->m_queue_front = 0;
c->m_queue_back = 0;
+
+ c->sru_version = xstrdup("1.1");
return c;
}
return c;
}
@@
-541,6
+543,10
@@
ZOOM_API(void)
val = ZOOM_options_get(c->options, "sru");
c->sru_mode = get_sru_mode_from_string(val);
val = ZOOM_options_get(c->options, "sru");
c->sru_mode = get_sru_mode_from_string(val);
+ xfree(c->sru_version);
+ val = ZOOM_options_get(c->options, "sru_version");
+ c->sru_version = xstrdup(val ? val : "1.1");
+
ZOOM_options_set(c->options, "host", c->host_port);
xfree(c->cookie_out);
ZOOM_options_set(c->options, "host", c->host_port);
xfree(c->cookie_out);
@@
-781,6
+787,7
@@
ZOOM_API(void)
xfree(c->user);
xfree(c->group);
xfree(c->password);
xfree(c->user);
xfree(c->group);
xfree(c->password);
+ xfree(c->sru_version);
xfree(c);
}
xfree(c);
}
@@
-1346,7
+1353,7
@@
static zoom_ret ZOOM_connection_send_init(ZOOM_connection c)
odr_prepend(c->odr_out, "ZOOM-C",
ireq->implementationName));
odr_prepend(c->odr_out, "ZOOM-C",
ireq->implementationName));
- version = odr_strdup(c->odr_out, "$Revision: 1.142 $");
+ version = odr_strdup(c->odr_out, "$Revision: 1.146 $");
if (strlen(version) > 10) /* check for unexpanded CVS strings */
version[strlen(version)-2] = '\0';
ireq->implementationVersion =
if (strlen(version) > 10) /* check for unexpanded CVS strings */
version[strlen(version)-2] = '\0';
ireq->implementationVersion =
@@
-1436,6
+1443,15
@@
static zoom_ret send_srw(ZOOM_connection c, Z_SRW_PDU *sr)
}
#endif
}
#endif
+
+static Z_SRW_PDU *ZOOM_srw_get_pdu(ZOOM_connection c, int type) {
+ Z_SRW_PDU *sr = yaz_srw_get_pdu(c->odr_out, type, c->sru_version);
+ sr->username = c->user;
+ sr->password = c->password;
+ return sr;
+}
+
+
#if YAZ_HAVE_XML2
static zoom_ret ZOOM_connection_srw_send_search(ZOOM_connection c)
{
#if YAZ_HAVE_XML2
static zoom_ret ZOOM_connection_srw_send_search(ZOOM_connection c)
{
@@
-1493,8
+1509,7
@@
static zoom_ret ZOOM_connection_srw_send_search(ZOOM_connection c)
}
assert(resultset->query);
}
assert(resultset->query);
- sr = yaz_srw_get(c->odr_out, Z_SRW_searchRetrieve_request);
-
+ sr = ZOOM_srw_get_pdu(c, Z_SRW_searchRetrieve_request);
if (resultset->query->z_query->which == Z_Query_type_104
&& resultset->query->z_query->u.type_104->which == Z_External_CQL)
{
if (resultset->query->z_query->which == Z_Query_type_104
&& resultset->query->z_query->u.type_104->which == Z_External_CQL)
{
@@
-1997,6
+2012,12
@@
ZOOM_API(const char *)
*len = (npr->databaseName ? strlen(npr->databaseName) : 0);
return npr->databaseName;
}
*len = (npr->databaseName ? strlen(npr->databaseName) : 0);
return npr->databaseName;
}
+ else if (!strcmp(type, "schema"))
+ {
+ if (len)
+ *len = rec->schema ? strlen(rec->schema) : 0;
+ return rec->schema;
+ }
else if (!strcmp(type, "syntax"))
{
const char *desc = 0;
else if (!strcmp(type, "syntax"))
{
const char *desc = 0;
@@
-2170,7
+2191,8
@@
static size_t record_hash(int pos)
static void record_cache_add(ZOOM_resultset r, Z_NamePlusRecord *npr,
int pos,
static void record_cache_add(ZOOM_resultset r, Z_NamePlusRecord *npr,
int pos,
- const char *syntax, const char *elementSetName)
+ const char *syntax, const char *elementSetName,
+ const char *schema)
{
ZOOM_record_cache rc;
{
ZOOM_record_cache rc;
@@
-2194,7
+2216,8
@@
static void record_cache_add(ZOOM_resultset r, Z_NamePlusRecord *npr,
}
}
rc = (ZOOM_record_cache) odr_malloc(r->odr, sizeof(*rc));
}
}
rc = (ZOOM_record_cache) odr_malloc(r->odr, sizeof(*rc));
- rc->rec.npr = npr;
+ rc->rec.npr = npr;
+ rc->rec.schema = schema ? odr_strdup(r->odr, schema) : 0;
rc->rec.odr = 0;
rc->rec.wrbuf_marc = 0;
rc->rec.wrbuf_iconv = 0;
rc->rec.odr = 0;
rc->rec.wrbuf_marc = 0;
rc->rec.wrbuf_iconv = 0;
@@
-2293,7
+2316,8
@@
static void handle_records(ZOOM_connection c, Z_Records *sr,
for (i = 0; i<p->num_records; i++)
{
record_cache_add(resultset, p->records[i], i + *start,
for (i = 0; i<p->num_records; i++)
{
record_cache_add(resultset, p->records[i], i + *start,
- syntax, elementSetName);
+ syntax, elementSetName,
+ elementSetName);
}
*count -= i;
if (*count < 0)
}
*count -= i;
if (*count < 0)
@@
-2312,7
+2336,7
@@
static void handle_records(ZOOM_connection c, Z_Records *sr,
Z_NamePlusRecord *myrec =
zget_surrogateDiagRec(resultset->odr, 0, 14, 0);
record_cache_add(resultset, myrec, *start,
Z_NamePlusRecord *myrec =
zget_surrogateDiagRec(resultset->odr, 0, 14, 0);
record_cache_add(resultset, myrec, *start,
- syntax, elementSetName);
+ syntax, elementSetName, 0);
}
}
else if (present_phase)
}
}
else if (present_phase)
@@
-2320,7
+2344,8
@@
static void handle_records(ZOOM_connection c, Z_Records *sr,
/* present response and we didn't get any records! */
Z_NamePlusRecord *myrec =
zget_surrogateDiagRec(resultset->odr, 0, 14, 0);
/* present response and we didn't get any records! */
Z_NamePlusRecord *myrec =
zget_surrogateDiagRec(resultset->odr, 0, 14, 0);
- record_cache_add(resultset, myrec, *start, syntax, elementSetName);
+ record_cache_add(resultset, myrec, *start, syntax, elementSetName,
+ 0);
}
}
}
}
}
}
@@
-2832,7
+2857,7
@@
static zoom_ret ZOOM_connection_srw_send_scan(ZOOM_connection c)
assert (c->tasks->which == ZOOM_TASK_SCAN);
scan = c->tasks->u.scan.scan;
assert (c->tasks->which == ZOOM_TASK_SCAN);
scan = c->tasks->u.scan.scan;
- sr = yaz_srw_get(c->odr_out, Z_SRW_scan_request);
+ sr = ZOOM_srw_get_pdu(c, Z_SRW_scan_request);
/* SRU scan can only carry CQL and PQF */
if (scan->query->z_query->which == Z_Query_type_104)
/* SRU scan can only carry CQL and PQF */
if (scan->query->z_query->which == Z_Query_type_104)
@@
-3858,7
+3883,8
@@
static void handle_srw_response(ZOOM_connection c,
npr->u.databaseRecord->u.octet_aligned->len =
npr->u.databaseRecord->u.octet_aligned->size =
res->records[i].recordData_len;
npr->u.databaseRecord->u.octet_aligned->len =
npr->u.databaseRecord->u.octet_aligned->size =
res->records[i].recordData_len;
- record_cache_add(resultset, npr, pos, syntax, elementSetName);
+ record_cache_add(resultset, npr, pos, syntax, elementSetName,
+ res->records[i].recordSchema);
}
if (res->num_diagnostics > 0)
set_SRU_error(c, &res->diagnostics[0]);
}
if (res->num_diagnostics > 0)
set_SRU_error(c, &res->diagnostics[0]);
@@
-3918,6
+3944,8
@@
static void handle_http(ZOOM_connection c, Z_HTTP_Response *hres)
soap_package->u.generic->no == 0)
{
Z_SRW_PDU *sr = (Z_SRW_PDU*) soap_package->u.generic->p;
soap_package->u.generic->no == 0)
{
Z_SRW_PDU *sr = (Z_SRW_PDU*) soap_package->u.generic->p;
+
+ ZOOM_options_set(c->options, "sru_version", sr->srw_version);
if (sr->which == Z_SRW_searchRetrieve_response)
handle_srw_response(c, sr->u.response);
else if (sr->which == Z_SRW_scan_response)
if (sr->which == Z_SRW_searchRetrieve_response)
handle_srw_response(c, sr->u.response);
else if (sr->which == Z_SRW_scan_response)