From: Adam Dickmeiss Date: Wed, 18 Jan 2006 10:57:27 +0000 (+0000) Subject: Added utility yp2::util::set_vhost_otherinfo to put vhost X-Git-Tag: YP2.0.0.2~21 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=25a823f54ee7b7e0d8000194cd0a6440627b7212;p=metaproxy-moved-to-github.git Added utility yp2::util::set_vhost_otherinfo to put vhost stuff in other-information unit. --- diff --git a/src/filter_multi.cpp b/src/filter_multi.cpp index 7e847d4..6866f3d 100644 --- a/src/filter_multi.cpp +++ b/src/filter_multi.cpp @@ -1,4 +1,4 @@ -/* $Id: filter_multi.cpp,v 1.7 2006-01-18 09:20:30 adam Exp $ +/* $Id: filter_multi.cpp,v 1.8 2006-01-18 10:57:27 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -317,9 +317,11 @@ void yf::Multi::Frontend::init(Package &package, Z_GDU *gdu) BackendPtr b = *bit; Z_APDU *init_apdu = zget_APDU(odr, Z_APDU_initRequest); - yaz_oi_set_string_oidval(&init_apdu->u.initRequest->otherInfo, odr, - VAL_PROXY, 1, b->m_vhost.c_str()); - + std::listvhost_one; + vhost_one.push_back(b->m_vhost); + yp2::util::set_vhost_otherinfo(&init_apdu->u.initRequest->otherInfo, + odr, vhost_one); + Z_InitRequest *req = init_apdu->u.initRequest; ODR_MASK_SET(req->options, Z_Options_search); diff --git a/src/filter_virt_db.cpp b/src/filter_virt_db.cpp index 1fae37a..98ed55a 100644 --- a/src/filter_virt_db.cpp +++ b/src/filter_virt_db.cpp @@ -1,4 +1,4 @@ -/* $Id: filter_virt_db.cpp,v 1.32 2006-01-18 10:30:28 adam Exp $ +/* $Id: filter_virt_db.cpp,v 1.33 2006-01-18 10:57:27 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -174,14 +174,8 @@ yf::Virt_db::BackendPtr yf::Virt_db::Frontend::init_backend( Z_APDU *init_apdu = zget_APDU(odr, Z_APDU_initRequest); - std::list::const_iterator t_it = b->m_targets.begin(); - int cat = 1; - for (; t_it != b->m_targets.end(); t_it++, cat++) - { - yaz_oi_set_string_oidval(&init_apdu->u.initRequest->otherInfo, odr, - VAL_PROXY, cat, t_it->c_str()); - } - + yp2::util::set_vhost_otherinfo(&init_apdu->u.initRequest->otherInfo, odr, + b->m_targets); Z_InitRequest *req = init_apdu->u.initRequest; // copy stuff from Frontend Init Request @@ -606,9 +600,9 @@ void yf::Virt_db::process(Package &package) const { Z_InitRequest *req = gdu->u.z3950->u.initRequest; - const char *vhost = - yaz_oi_get_string_oidval(&req->otherInfo, VAL_PROXY, 1, 0); - if (!vhost) + std::list vhosts; + yp2::util::get_vhost_otherinfo(&req->otherInfo, false, vhosts); + if (vhosts.size() == 0) { f->m_init_gdu = gdu; diff --git a/src/util.cpp b/src/util.cpp index 15aa7ae..dd80df0 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1,4 +1,4 @@ -/* $Id: util.cpp,v 1.9 2006-01-17 17:55:40 adam Exp $ +/* $Id: util.cpp,v 1.10 2006-01-18 10:57:27 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -124,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) { diff --git a/src/util.hpp b/src/util.hpp index 3ee0249..c905304 100644 --- a/src/util.hpp +++ b/src/util.hpp @@ -1,4 +1,4 @@ -/* $Id: util.hpp,v 1.8 2006-01-17 17:55:40 adam Exp $ +/* $Id: util.hpp,v 1.9 2006-01-18 10:57:27 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -26,6 +26,9 @@ namespace yp2 { int get_vhost_otherinfo(Z_OtherInformation **otherInformation, bool remove_flag, std::list &vhosts); + void set_vhost_otherinfo(Z_OtherInformation **otherInformation, + ODR odr, + const std::list &vhosts); void get_init_diagnostics(Z_InitResponse *res, int &error_code, std::string &addinfo); void get_default_diag(Z_DefaultDiagFormat *r,