From 47ceb84b5ac99c72bcaef53be93494541e9a68c0 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 6 Sep 2013 12:13:32 +0200 Subject: [PATCH] Deal with resultCountPrecision - SRU 2.0 --- include/yaz/srw.h | 1 + src/seshigh.c | 14 +++++++++++++- src/srw.c | 7 +++++++ src/srwutil.c | 1 + 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/include/yaz/srw.h b/include/yaz/srw.h index 743c1d0..7af2421 100644 --- a/include/yaz/srw.h +++ b/include/yaz/srw.h @@ -102,6 +102,7 @@ typedef struct { typedef struct { Odr_int *numberOfRecords; + char *resultCountPrecision; char * resultSetId; Odr_int *resultSetIdleTime; diff --git a/src/seshigh.c b/src/seshigh.c index 30bf9e2..07ee014 100644 --- a/src/seshigh.c +++ b/src/seshigh.c @@ -1160,7 +1160,19 @@ static void srw_bend_search(association *assoc, res->extraResponseData_buf = rr.extra_response_data; res->extraResponseData_len = strlen(rr.extra_response_data); } - if (rr.estimated_hit_count || rr.partial_resultset) + if (strcmp(res->srw_version, "2.") > 0) + { + if (rr.estimated_hit_count) + srw_res->resultCountPrecision = + odr_strdup(assoc->encode, "estimate"); + else if (rr.partial_resultset) + srw_res->resultCountPrecision = + odr_strdup(assoc->encode, "minimum"); + else + srw_res->resultCountPrecision = + odr_strdup(assoc->encode, "exact"); + } + else if (rr.estimated_hit_count || rr.partial_resultset) { yaz_add_srw_diagnostic( assoc->encode, diff --git a/src/srw.c b/src/srw.c index c88ace0..97cb05d 100644 --- a/src/srw.c +++ b/src/srw.c @@ -852,6 +852,7 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data, odr_malloc(o, sizeof(*res)); res->numberOfRecords = 0; + res->resultCountPrecision = 0; res->resultSetId = 0; res->resultSetIdleTime = 0; res->records = 0; @@ -874,6 +875,9 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data, else if (match_xsd_integer(ptr, "numberOfRecords", o, &res->numberOfRecords)) ; + else if (match_xsd_string(ptr, "resultCountPrecision", o, + &res->resultCountPrecision)) + ; else if (match_xsd_string(ptr, "resultSetId", o, &res->resultSetId)) ; @@ -1142,6 +1146,9 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data, yaz_srw_diagnostics(o, rptr, &res->diagnostics, &res->num_diagnostics, client_data, ns); } + if (res->resultCountPrecision) + add_xsd_string(ptr, "resultCountPrecision", + res->resultCountPrecision); } else if ((*p)->which == Z_SRW_explain_request) { diff --git a/src/srwutil.c b/src/srwutil.c index 4eb9573..4f403a5 100644 --- a/src/srwutil.c +++ b/src/srwutil.c @@ -773,6 +773,7 @@ Z_SRW_PDU *yaz_srw_get_pdu(ODR o, int which, const char *version) sr->u.response = (Z_SRW_searchRetrieveResponse *) odr_malloc(o, sizeof(*sr->u.response)); sr->u.response->numberOfRecords = 0; + sr->u.response->resultCountPrecision = 0; sr->u.response->resultSetId = 0; sr->u.response->resultSetIdleTime = 0; sr->u.response->records = 0; -- 1.7.10.4