From: Adam Dickmeiss Date: Mon, 17 Jun 2013 12:48:51 +0000 (+0200) Subject: Add util piggyback_to_RecordComposition X-Git-Tag: v1.3.59~57^2~5^2~1 X-Git-Url: http://lists.indexdata.com/cgi-bin?a=commitdiff_plain;h=b8d5728fc9d3461f5bfd7d79f415512822c38dcc;p=metaproxy-moved-to-github.git Add util piggyback_to_RecordComposition --- diff --git a/include/metaproxy/util.hpp b/include/metaproxy/util.hpp index 0365919..e5d2768 100644 --- a/include/metaproxy/util.hpp +++ b/include/metaproxy/util.hpp @@ -104,6 +104,9 @@ namespace metaproxy_1 { void get_default_diag(Z_DefaultDiagFormat *r, int &error_code, std::string &addinfo); + Z_RecordComposition *piggyback_to_RecordComposition( + ODR odr, Odr_int result_set_size, Z_SearchRequest *sreq); + void piggyback(int smallSetUpperBound, int largeSetLowerBound, int mediumSetPresentNumber, diff --git a/src/util.cpp b/src/util.cpp index 81a27f0..4a3d478 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -163,6 +163,26 @@ std::string mp_util::database_name_normalize(const std::string &s) } +Z_RecordComposition *mp_util::piggyback_to_RecordComposition( + ODR odr, Odr_int result_set_size, Z_SearchRequest *sreq) +{ + Z_RecordComposition *comp = 0; + Odr_int present_dummy; + const char *element_set_name = 0; + mp::util::piggyback_sr(sreq, result_set_size, + present_dummy, &element_set_name); + if (element_set_name) + { + comp = (Z_RecordComposition *) odr_malloc(odr, sizeof(*comp)); + comp->which = Z_RecordComp_simple; + comp->u.simple = (Z_ElementSetNames *) + odr_malloc(odr, sizeof(Z_ElementSetNames)); + comp->u.simple->which = Z_ElementSetNames_generic; + comp->u.simple->u.generic = odr_strdup(odr, element_set_name); + } + return comp; +} + void mp_util::piggyback_sr(Z_SearchRequest *sreq, Odr_int result_set_size, Odr_int &number_to_present,