X-Git-Url: http://lists.indexdata.com/cgi-bin?a=blobdiff_plain;f=src%2Futil.cpp;h=dd80df01770c2dc89f6f98a938731da2e82ff5bd;hb=25a823f54ee7b7e0d8000194cd0a6440627b7212;hp=26f1edb149575fd45e987fc3f816f0d18161f8aa;hpb=574ad8ce17a312c7396603e3ba3604ce52e75fb2;p=metaproxy-moved-to-github.git diff --git a/src/util.cpp b/src/util.cpp index 26f1edb..dd80df0 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1,4 +1,4 @@ -/* $Id: util.cpp,v 1.7 2006-01-17 16:43:22 adam Exp $ +/* $Id: util.cpp,v 1.10 2006-01-18 10:57:27 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -11,6 +11,32 @@ #include #include "util.hpp" +void yp2::util::piggyback(int smallSetUpperBound, + int largeSetLowerBound, + int mediumSetPresentNumber, + int result_set_size, + int &number_to_present) +{ + // deal with piggyback + + if (result_set_size < smallSetUpperBound) + { + // small set . Return all records in set + number_to_present = result_set_size; + } + else if (result_set_size > largeSetLowerBound) + { + // large set . Return no records + number_to_present = 0; + } + else + { + // medium set . Return mediumSetPresentNumber records + number_to_present = mediumSetPresentNumber; + if (number_to_present > result_set_size) + number_to_present = result_set_size; + } +} bool yp2::util::pqf(ODR odr, Z_APDU *apdu, const std::string &q) { YAZ_PQF_Parser pqf_parser = yaz_pqf_create(); @@ -98,6 +124,19 @@ int yp2::util::get_vhost_otherinfo(Z_OtherInformation **otherInformation, return cat; } +void yp2::util::set_vhost_otherinfo(Z_OtherInformation **otherInformation, + ODR odr, + const std::list &vhosts) +{ + int cat; + std::list::const_iterator it = vhosts.begin(); + for (cat = 1; it != vhosts.end() ; cat++, it++) + { + yaz_oi_set_string_oidval(otherInformation, odr, + VAL_PROXY, cat, it->c_str()); + } +} + void yp2::util::split_zurl(std::string zurl, std::string &host, std::list &db) { @@ -246,6 +285,7 @@ Z_APDU *yp2::odr::create_presentResponse(Z_APDU *in_apdu, rec->which = Z_Records_NSD; rec->u.nonSurrogateDiagnostic = zget_DefaultDiagFormat(m_odr, error, addinfo); + *apdu->u.presentResponse->presentStatus = Z_PresentStatus_failure; } return apdu; }