From 79100c2ae2dac4bdde4f4d46b69e147562b4ec6c Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 16 Mar 2006 10:40:58 +0000 Subject: [PATCH] Rename from yp2 to metaproxy. The namespace for all definitions is using metaproxy_1, but we use namespace alias 'mp' in .cpp files to keep things easier to read (or using namespace). --- configure.ac | 2 +- src/Makefile.am | 23 +++---- src/ex_filter_frontend_net.cpp | 32 ++++----- src/ex_router_flexml.cpp | 12 ++-- src/factory_filter.cpp | 36 +++++----- src/factory_filter.hpp | 10 +-- src/factory_static.cpp | 32 ++++----- src/factory_static.hpp | 6 +- src/filter.cpp | 10 +-- src/filter.hpp | 10 +-- src/filter_auth_simple.cpp | 55 ++++++++-------- src/filter_auth_simple.hpp | 18 ++--- src/filter_backend_test.cpp | 21 +++--- src/filter_backend_test.hpp | 10 +-- src/filter_dl.cpp | 20 +++--- src/filter_frontend_net.cpp | 132 +++++++++++++++++++------------------ src/filter_frontend_net.hpp | 10 +-- src/filter_http_file.cpp | 57 ++++++++-------- src/filter_http_file.hpp | 10 +-- src/filter_log.cpp | 25 +++---- src/filter_log.hpp | 10 +-- src/filter_multi.cpp | 83 +++++++++++------------ src/filter_multi.hpp | 10 +-- src/filter_query_rewrite.cpp | 35 +++++----- src/filter_query_rewrite.hpp | 10 +-- src/filter_session_shared.cpp | 22 +++---- src/filter_session_shared.hpp | 10 +-- src/filter_template.cpp | 17 ++--- src/filter_template.hpp | 10 +-- src/filter_virt_db.cpp | 69 +++++++++---------- src/filter_virt_db.hpp | 10 +-- src/filter_z3950_client.cpp | 43 ++++++------ src/filter_z3950_client.hpp | 10 +-- src/metaproxy_prog.cpp | 99 ++++++++++++++++++++++++++++ src/package.cpp | 40 +++++------ src/package.hpp | 10 +-- src/pipe.cpp | 10 +-- src/pipe.hpp | 6 +- src/plainfile.cpp | 20 +++--- src/router.hpp | 6 +- src/router_chain.cpp | 30 +++++---- src/router_chain.hpp | 6 +- src/router_flexml.cpp | 121 +++++++++++++++++----------------- src/router_flexml.hpp | 12 ++-- src/session.cpp | 10 +-- src/session.hpp | 20 +++--- src/test_boost_threads.cpp | 4 +- src/test_boost_time.cpp | 4 +- src/test_filter1.cpp | 9 +-- src/test_filter2.cpp | 31 ++++----- src/test_filter_auth_simple.cpp | 21 +++--- src/test_filter_backend_test.cpp | 34 +++++----- src/test_filter_factory.cpp | 35 +++++----- src/test_filter_frontend_net.cpp | 25 +++---- src/test_filter_log.cpp | 21 +++--- src/test_filter_multi.cpp | 21 +++--- src/test_filter_query_rewrite.cpp | 64 ++++++------------ src/test_filter_virt_db.cpp | 51 +++++++------- src/test_filter_z3950_client.cpp | 33 +++++----- src/test_package1.cpp | 13 ++-- src/test_pipe.cpp | 7 +- src/test_router_flexml.cpp | 34 +++++----- src/test_ses_map.cpp | 13 ++-- src/test_session1.cpp | 17 ++--- src/test_session2.cpp | 9 +-- src/test_thread_pool_observer.cpp | 25 +++---- src/thread_pool_observer.cpp | 10 +-- src/thread_pool_observer.hpp | 6 +- src/tstdl.cpp | 4 +- src/util.cpp | 58 ++++++++-------- src/util.hpp | 8 +-- src/xmlutil.cpp | 32 ++++----- src/xmlutil.hpp | 6 +- src/yp2_prog.cpp | 97 --------------------------- 74 files changed, 994 insertions(+), 958 deletions(-) create mode 100644 src/metaproxy_prog.cpp delete mode 100644 src/yp2_prog.cpp diff --git a/configure.ac b/configure.ac index 9d5223d..babf624 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ # Autoconf and automake setup AC_PREREQ(2.57) -AC_INIT(yp2, 0.0.3, adam@indexdata.dk) +AC_INIT(metaproxy, 0.9, adam@indexdata.dk) AC_CONFIG_HEADERS(src/config.hpp) diff --git a/src/Makefile.am b/src/Makefile.am index 8644b6a..9b6cbab 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,4 @@ -## $Id: Makefile.am,v 1.49 2006-02-02 13:08:22 adam Exp $ +## $Id: Makefile.am,v 1.50 2006-03-16 10:40:59 adam Exp $ MAINTAINERCLEANFILES = Makefile.in config.in config.hpp @@ -8,10 +8,10 @@ EXTRA_DIST=Jamfile.in # Rules for the library.. -lib_LTLIBRARIES = libyp2.la -libyp2_la_LDFLAGS = -version-info 0:0:0 -export-dynamic +lib_LTLIBRARIES = libmetaproxy.la +libmetaproxy_la_LDFLAGS = -version-info 1:0:0 -export-dynamic -libyp2_la_SOURCES = \ +libmetaproxy_la_SOURCES = \ factory_filter.cpp factory_filter.hpp \ factory_static.cpp factory_static.hpp \ filter.hpp filter.cpp \ @@ -38,22 +38,22 @@ libyp2_la_SOURCES = \ # Rules for programs.. -LDADD= libyp2.la $(YAZPPLALIB) $(XSLT_LIBS) +LDADD= libmetaproxy.la $(YAZPPLALIB) $(XSLT_LIBS) -bin_PROGRAMS = yp2 +bin_PROGRAMS = metaproxy noinst_PROGRAMS = ex_filter_frontend_net ex_router_flexml tstdl ex_filter_frontend_net_SOURCES = ex_filter_frontend_net.cpp ex_router_flexml_SOURCES = ex_router_flexml.cpp tstdl_SOURCES = tstdl.cpp -yp2_SOURCES = yp2_prog.cpp +metaproxy_SOURCES = metaproxy_prog.cpp # Rules for dl programs -pkglib_LTLIBRARIES = yp2_filter_dl.la +pkglib_LTLIBRARIES = metaproxy_filter_dl.la -yp2_filter_dl_la_SOURCES = filter_dl.cpp -yp2_filter_dl_la_LDFLAGS = -rpath $(pkglibdir) -module -avoid-version -yp2_filter_dl_la_LIBADD = libyp2.la +metaproxy_filter_dl_la_SOURCES = filter_dl.cpp +metaproxy_filter_dl_la_LDFLAGS = -rpath $(pkglibdir) -module -avoid-version +metaproxy_filter_dl_la_LIBADD = libmetaproxy.la # Rules for test programs.. @@ -69,6 +69,7 @@ check_PROGRAMS = \ test_filter_frontend_net \ test_filter_log \ test_filter_multi \ + test_filter_query_rewrite \ test_filter_z3950_client \ test_filter_backend_test \ test_filter_virt_db \ diff --git a/src/ex_filter_frontend_net.cpp b/src/ex_filter_frontend_net.cpp index 15e6b55..038178d 100644 --- a/src/ex_filter_frontend_net.cpp +++ b/src/ex_filter_frontend_net.cpp @@ -1,5 +1,5 @@ -/* $Id: ex_filter_frontend_net.cpp,v 1.25 2006-01-16 15:51:56 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: ex_filter_frontend_net.cpp,v 1.26 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -25,9 +25,11 @@ namespace po = boost::program_options; #include "session.hpp" #include "package.hpp" -class HTTPFilter: public yp2::filter::Base { +namespace mp = metaproxy_1; + +class HTTPFilter: public mp::filter::Base { public: - void process(yp2::Package & package) const { + void process(mp::Package & package) const { if (package.session().is_closed()) { // std::cout << "Got Close.\n"; @@ -36,7 +38,7 @@ public: Z_GDU *gdu = package.request().get(); if (gdu && gdu->which == Z_GDU_HTTP_Request) { - yp2::odr odr; + mp::odr odr; Z_GDU *gdu = z_get_HTTP_Response(odr, 200); Z_HTTP_Response *http_res = gdu->u.HTTP_Response; @@ -86,10 +88,10 @@ int main(int argc, char **argv) for (size_t i = 0; i0 timeout in seconds @@ -99,11 +101,11 @@ int main(int argc, char **argv) router.append(filter_front); // put log filter in router - yp2::filter::Log filter_log_front("FRONT"); + mp::filter::Log filter_log_front("FRONT"); router.append(filter_log_front); // put Virt db filter in router - yp2::filter::Virt_db filter_virt_db; + mp::filter::Virt_db filter_virt_db; filter_virt_db.add_map_db2target("gils", "indexdata.dk/gils", ""); filter_virt_db.add_map_db2target("Default", "localhost:9999/Default", @@ -111,10 +113,10 @@ int main(int argc, char **argv) filter_virt_db.add_map_db2target("2", "localhost:9999/Slow", ""); router.append(filter_virt_db); - yp2::filter::SessionShared filter_session_shared; + mp::filter::SessionShared filter_session_shared; //router.append(filter_session_shared); - yp2::filter::Log filter_log_back("BACK"); + mp::filter::Log filter_log_back("BACK"); router.append(filter_log_back); // put HTTP backend filter in router @@ -122,12 +124,12 @@ int main(int argc, char **argv) router.append(filter_init); // put Z39.50 backend filter in router - yp2::filter::Z3950Client z3950_client; + mp::filter::Z3950Client z3950_client; router.append(z3950_client); - yp2::Session session; - yp2::Origin origin; - yp2::Package pack(session, origin); + mp::Session session; + mp::Origin origin; + mp::Package pack(session, origin); pack.router(router).move(); } diff --git a/src/ex_router_flexml.cpp b/src/ex_router_flexml.cpp index 3d77c98..2e0605d 100644 --- a/src/ex_router_flexml.cpp +++ b/src/ex_router_flexml.cpp @@ -1,5 +1,5 @@ -/* $Id: ex_router_flexml.cpp,v 1.7 2006-01-16 11:22:56 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: ex_router_flexml.cpp,v 1.8 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -17,6 +17,8 @@ namespace po = boost::program_options; #include "router_flexml.hpp" #include "factory_static.hpp" +namespace mp = metaproxy_1; + int main(int argc, char **argv) { try @@ -66,10 +68,10 @@ int main(int argc, char **argv) } if (doc) { - yp2::FactoryStatic factory; - yp2::RouterFleXML router(doc, factory); + mp::FactoryStatic factory; + mp::RouterFleXML router(doc, factory); - yp2::Package pack; + mp::Package pack; pack.router(router).move(); diff --git a/src/factory_filter.cpp b/src/factory_filter.cpp index 8b69ae1..5ba05bc 100644 --- a/src/factory_filter.cpp +++ b/src/factory_filter.cpp @@ -1,5 +1,5 @@ -/* $Id: factory_filter.cpp,v 1.3 2006-01-19 09:41:01 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: factory_filter.cpp,v 1.4 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -16,7 +16,9 @@ #include #include -namespace yp2 { +namespace mp = metaproxy_1; + +namespace metaproxy_1 { class FactoryFilter::Rep { typedef std::map CallbackMap; typedef std::map::iterator @@ -29,42 +31,42 @@ namespace yp2 { }; } -yp2::FactoryFilter::NotFound::NotFound(const std::string message) +mp::FactoryFilter::NotFound::NotFound(const std::string message) : std::runtime_error(message) { } -yp2::FactoryFilter::Rep::Rep() +mp::FactoryFilter::Rep::Rep() { } -yp2::FactoryFilter::Rep::~Rep() +mp::FactoryFilter::Rep::~Rep() { } -yp2::FactoryFilter::FactoryFilter() : m_p(new yp2::FactoryFilter::Rep) +mp::FactoryFilter::FactoryFilter() : m_p(new mp::FactoryFilter::Rep) { } -yp2::FactoryFilter::~FactoryFilter() +mp::FactoryFilter::~FactoryFilter() { } -bool yp2::FactoryFilter::add_creator(std::string fi, +bool mp::FactoryFilter::add_creator(std::string fi, CreateFilterCallback cfc) { return m_p->m_fcm.insert(Rep::CallbackMap::value_type(fi, cfc)).second; } -bool yp2::FactoryFilter::drop_creator(std::string fi) +bool mp::FactoryFilter::drop_creator(std::string fi) { return m_p->m_fcm.erase(fi) == 1; } -bool yp2::FactoryFilter::exist(std::string fi) +bool mp::FactoryFilter::exist(std::string fi) { Rep::CallbackMap::const_iterator it = m_p->m_fcm.find(fi); @@ -75,7 +77,7 @@ bool yp2::FactoryFilter::exist(std::string fi) return true; } -yp2::filter::Base* yp2::FactoryFilter::create(std::string fi) +mp::filter::Base* mp::FactoryFilter::create(std::string fi) { Rep::CallbackMap::const_iterator it = m_p->m_fcm.find(fi); @@ -87,7 +89,7 @@ yp2::filter::Base* yp2::FactoryFilter::create(std::string fi) return (it->second()); } -bool yp2::FactoryFilter::have_dl_support() +bool mp::FactoryFilter::have_dl_support() { #if HAVE_DLFCN_H return true; @@ -96,7 +98,7 @@ bool yp2::FactoryFilter::have_dl_support() #endif } -bool yp2::FactoryFilter::add_creator_dl(const std::string &fi, +bool mp::FactoryFilter::add_creator_dl(const std::string &fi, const std::string &path) { #if HAVE_DLFCN_H @@ -105,7 +107,7 @@ bool yp2::FactoryFilter::add_creator_dl(const std::string &fi, return true; } - std::string full_path = path + "/yp2_filter_" + fi + ".so"; + std::string full_path = path + "/metaproxy_1_filter_" + fi + ".so"; void *dl_handle = dlopen(full_path.c_str(), RTLD_GLOBAL|RTLD_NOW); if (!dl_handle) { @@ -115,7 +117,7 @@ bool yp2::FactoryFilter::add_creator_dl(const std::string &fi, return false; } - std::string full_name = "yp2_filter_" + fi; + std::string full_name = "metaproxy_1_filter_" + fi; void *dlsym_ptr = dlsym(dl_handle, full_name.c_str()); if (!dlsym_ptr) @@ -123,7 +125,7 @@ bool yp2::FactoryFilter::add_creator_dl(const std::string &fi, std::cout << "dlsym " << full_name << " failed\n"; return false; } - struct yp2_filter_struct *s = (struct yp2_filter_struct *) dlsym_ptr; + struct metaproxy_1_filter_struct *s = (struct metaproxy_1_filter_struct *) dlsym_ptr; return add_creator(fi, s->creator); #else return false; diff --git a/src/factory_filter.hpp b/src/factory_filter.hpp index 006ac1d..b0b88a4 100644 --- a/src/factory_filter.hpp +++ b/src/factory_filter.hpp @@ -1,5 +1,5 @@ -/* $Id: factory_filter.hpp,v 1.3 2006-01-19 09:41:01 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: factory_filter.hpp,v 1.4 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -17,10 +17,10 @@ #include "filter.hpp" -namespace yp2 { +namespace metaproxy_1 { class FactoryFilter : public boost::noncopyable { - typedef yp2::filter::Base* (*CreateFilterCallback)(); + typedef metaproxy_1::filter::Base* (*CreateFilterCallback)(); class Rep; public: @@ -33,7 +33,7 @@ namespace yp2 { bool drop_creator(std::string fi); - yp2::filter::Base* create(std::string fi); + metaproxy_1::filter::Base* create(std::string fi); bool exist(std::string fi); bool add_creator_dl(const std::string &fi, const std::string &path); diff --git a/src/factory_static.cpp b/src/factory_static.cpp index b4e0aed..b49bf7f 100644 --- a/src/factory_static.cpp +++ b/src/factory_static.cpp @@ -1,5 +1,5 @@ -/* $Id: factory_static.cpp,v 1.8 2006-03-15 14:55:17 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: factory_static.cpp,v 1.9 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -27,20 +27,22 @@ #include "filter_virt_db.hpp" #include "filter_z3950_client.hpp" -yp2::FactoryStatic::FactoryStatic() +namespace mp = metaproxy_1; + +mp::FactoryStatic::FactoryStatic() { - struct yp2_filter_struct *buildins[] = { - &yp2_filter_auth_simple, - &yp2_filter_backend_test, - &yp2_filter_frontend_net, - &yp2_filter_http_file, - &yp2_filter_log, - &yp2_filter_multi, - &yp2_filter_query_rewrite, - &yp2_filter_session_shared, - &yp2_filter_template, - &yp2_filter_virt_db, - &yp2_filter_z3950_client, + struct metaproxy_1_filter_struct *buildins[] = { + &metaproxy_1_filter_auth_simple, + &metaproxy_1_filter_backend_test, + &metaproxy_1_filter_frontend_net, + &metaproxy_1_filter_http_file, + &metaproxy_1_filter_log, + &metaproxy_1_filter_multi, + &metaproxy_1_filter_query_rewrite, + &metaproxy_1_filter_session_shared, + &metaproxy_1_filter_template, + &metaproxy_1_filter_virt_db, + &metaproxy_1_filter_z3950_client, 0 }; int i; diff --git a/src/factory_static.hpp b/src/factory_static.hpp index 29b77e8..40aac5c 100644 --- a/src/factory_static.hpp +++ b/src/factory_static.hpp @@ -1,5 +1,5 @@ -/* $Id: factory_static.hpp,v 1.3 2006-01-04 14:30:51 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: factory_static.hpp,v 1.4 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -9,7 +9,7 @@ #include "factory_filter.hpp" -namespace yp2 { +namespace metaproxy_1 { class FactoryStatic : public FactoryFilter { public: FactoryStatic(); diff --git a/src/filter.cpp b/src/filter.cpp index ecbec46..91977c6 100644 --- a/src/filter.cpp +++ b/src/filter.cpp @@ -1,5 +1,5 @@ -/* $Id: filter.cpp,v 1.6 2006-01-11 14:58:28 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: filter.cpp,v 1.7 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -9,9 +9,11 @@ #include "config.hpp" #include "filter.hpp" -void yp2::filter::Base::configure(const xmlNode * ptr) +namespace mp = metaproxy_1; + +void mp::filter::Base::configure(const xmlNode * ptr) { - yp2::xml::check_empty(ptr); + mp::xml::check_empty(ptr); } /* diff --git a/src/filter.hpp b/src/filter.hpp index d61fa45..b441284 100644 --- a/src/filter.hpp +++ b/src/filter.hpp @@ -1,5 +1,5 @@ -/* $Id: filter.hpp,v 1.15 2006-01-11 11:51:49 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: filter.hpp,v 1.16 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -12,7 +12,7 @@ #include #include "xmlutil.hpp" -namespace yp2 { +namespace metaproxy_1 { class Package; @@ -36,10 +36,10 @@ namespace yp2 { } } -struct yp2_filter_struct { +struct metaproxy_1_filter_struct { int ver; const char *type; - yp2::filter::Base* (*creator)(); + metaproxy_1::filter::Base* (*creator)(); }; #endif diff --git a/src/filter_auth_simple.cpp b/src/filter_auth_simple.cpp index 33a94fa..7b0cba8 100644 --- a/src/filter_auth_simple.cpp +++ b/src/filter_auth_simple.cpp @@ -1,5 +1,5 @@ -/* $Id: filter_auth_simple.cpp,v 1.17 2006-01-18 15:07:09 mike Exp $ - Copyright (c) 2005, Index Data. +/* $Id: filter_auth_simple.cpp,v 1.18 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -20,9 +20,10 @@ #include #include -namespace yf = yp2::filter; +namespace mp = metaproxy_1; +namespace yf = mp::filter; -namespace yp2 { +namespace metaproxy_1 { namespace filter { class AuthSimple::Rep { friend class AuthSimple; @@ -37,7 +38,7 @@ namespace yp2 { bool got_userRegister, got_targetRegister; std::map userRegister; std::map > targetsByUser; - std::map userBySession; + std::map userBySession; bool discardUnauthorisedTargets; Rep() { got_userRegister = false; got_targetRegister = false; @@ -56,11 +57,11 @@ yf::AuthSimple::~AuthSimple() } -static void die(std::string s) { throw yp2::filter::FilterException(s); } +static void die(std::string s) { throw mp::filter::FilterException(s); } // Read XML config.. Put config info in m_p. -void yp2::filter::AuthSimple::configure(const xmlNode * ptr) +void mp::filter::AuthSimple::configure(const xmlNode * ptr) { std::string userRegisterName; std::string targetRegisterName; @@ -69,10 +70,10 @@ void yp2::filter::AuthSimple::configure(const xmlNode * ptr) if (ptr->type != XML_ELEMENT_NODE) continue; if (!strcmp((const char *) ptr->name, "userRegister")) { - userRegisterName = yp2::xml::get_text(ptr); + userRegisterName = mp::xml::get_text(ptr); m_p->got_userRegister = true; } else if (!strcmp((const char *) ptr->name, "targetRegister")) { - targetRegisterName = yp2::xml::get_text(ptr); + targetRegisterName = mp::xml::get_text(ptr); m_p->got_targetRegister = true; } else if (!strcmp((const char *) ptr->name, "discardUnauthorisedTargets")) { @@ -94,7 +95,7 @@ void yp2::filter::AuthSimple::configure(const xmlNode * ptr) } -void yp2::filter::AuthSimple::config_userRegister(std::string filename) +void mp::filter::AuthSimple::config_userRegister(std::string filename) { FILE *fp = fopen(filename.c_str(), "r"); if (fp == 0) @@ -134,7 +135,7 @@ void yp2::filter::AuthSimple::config_userRegister(std::string filename) // I feel a little bad about the duplication of code between this and // config_userRegister(). But not bad enough to refactor. // -void yp2::filter::AuthSimple::config_targetRegister(std::string filename) +void mp::filter::AuthSimple::config_targetRegister(std::string filename) { FILE *fp = fopen(filename.c_str(), "r"); if (fp == 0) @@ -166,7 +167,7 @@ void yp2::filter::AuthSimple::config_targetRegister(std::string filename) } -void yf::AuthSimple::process(yp2::Package &package) const +void yf::AuthSimple::process(mp::Package &package) const { Z_GDU *gdu = package.request().get(); @@ -203,10 +204,10 @@ void yf::AuthSimple::process(yp2::Package &package) const } -static void reject_init(yp2::Package &package, int err, const char *addinfo); +static void reject_init(mp::Package &package, int err, const char *addinfo); -void yf::AuthSimple::process_init(yp2::Package &package) const +void yf::AuthSimple::process_init(mp::Package &package) const { Z_IdAuthentication *auth = package.request().get()->u.z3950->u.initRequest->idAuthentication; @@ -248,7 +249,7 @@ static bool contains(std::list list, std::string thing) { } -void yf::AuthSimple::process_search(yp2::Package &package) const +void yf::AuthSimple::process_search(mp::Package &package) const { Z_SearchRequest *req = package.request().get()->u.z3950->u.searchRequest; @@ -264,7 +265,7 @@ void yf::AuthSimple::process_search(yp2::Package &package) const if (!contains(pdb.dbs, req->databaseNames[i]) && !contains(pdb.dbs, "*")) { // Make an Search rejection APDU - yp2::odr odr; + mp::odr odr; Z_APDU *apdu = odr.create_searchResponse( package.request().get()->u.z3950, YAZ_BIB1_ACCESS_TO_SPECIFIED_DATABASE_DENIED, @@ -280,7 +281,7 @@ void yf::AuthSimple::process_search(yp2::Package &package) const } -void yf::AuthSimple::process_scan(yp2::Package &package) const +void yf::AuthSimple::process_scan(mp::Package &package) const { Z_ScanRequest *req = package.request().get()->u.z3950->u.scanRequest; @@ -296,7 +297,7 @@ void yf::AuthSimple::process_scan(yp2::Package &package) const if (!contains(pdb.dbs, req->databaseNames[i]) && !contains(pdb.dbs, "*")) { // Make an Scan rejection APDU - yp2::odr odr; + mp::odr odr; Z_APDU *apdu = odr.create_scanResponse( package.request().get()->u.z3950, YAZ_BIB1_ACCESS_TO_SPECIFIED_DATABASE_DENIED, @@ -312,12 +313,12 @@ void yf::AuthSimple::process_scan(yp2::Package &package) const } -static void reject_init(yp2::Package &package, int err, const char *addinfo) { +static void reject_init(mp::Package &package, int err, const char *addinfo) { if (err == 0) err = YAZ_BIB1_INIT_AC_AUTHENTICATION_SYSTEM_ERROR; // Make an Init rejection APDU Z_GDU *gdu = package.request().get(); - yp2::odr odr; + mp::odr odr; Z_APDU *apdu = odr.create_initResponse(gdu->u.z3950, err, addinfo); apdu->u.initResponse->implementationName = "YP2/YAZ"; *apdu->u.initResponse->result = 0; // reject @@ -326,7 +327,7 @@ static void reject_init(yp2::Package &package, int err, const char *addinfo) { } -void yf::AuthSimple::check_targets(yp2::Package & package) const +void yf::AuthSimple::check_targets(mp::Package & package) const { Z_InitRequest *initReq = package.request().get()->u.z3950->u.initRequest; @@ -341,7 +342,7 @@ void yf::AuthSimple::check_targets(yp2::Package & package) const std::list targets; Z_OtherInformation *otherInfo = initReq->otherInfo; - yp2::util::get_vhost_otherinfo(&otherInfo, 1, targets); + mp::util::get_vhost_otherinfo(&otherInfo, 1, targets); // Check each of the targets specified in the otherInfo package std::list::iterator i; @@ -365,19 +366,19 @@ void yf::AuthSimple::check_targets(yp2::Package & package) const // ### It would be better to use the Z-db name "all databases"); - yp2::odr odr; - yp2::util::set_vhost_otherinfo(&otherInfo, odr, targets); + mp::odr odr; + mp::util::set_vhost_otherinfo(&otherInfo, odr, targets); package.move(); } -static yp2::filter::Base* filter_creator() +static mp::filter::Base* filter_creator() { - return new yp2::filter::AuthSimple; + return new mp::filter::AuthSimple; } extern "C" { - struct yp2_filter_struct yp2_filter_auth_simple = { + struct metaproxy_1_filter_struct metaproxy_1_filter_auth_simple = { 0, "auth_simple", filter_creator diff --git a/src/filter_auth_simple.hpp b/src/filter_auth_simple.hpp index 7c4ab74..f7b1a6e 100644 --- a/src/filter_auth_simple.hpp +++ b/src/filter_auth_simple.hpp @@ -1,5 +1,5 @@ -/* $Id: filter_auth_simple.hpp,v 1.5 2006-01-18 13:32:46 mike Exp $ - Copyright (c) 2005, Index Data. +/* $Id: filter_auth_simple.hpp,v 1.6 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -11,7 +11,7 @@ #include "filter.hpp" -namespace yp2 { +namespace metaproxy_1 { namespace filter { class AuthSimple : public Base { class Rep; @@ -20,20 +20,20 @@ namespace yp2 { AuthSimple(); ~AuthSimple(); void configure(const xmlNode * ptr); - void process(yp2::Package & package) const; + void process(metaproxy_1::Package & package) const; private: void config_userRegister(std::string filename); void config_targetRegister(std::string filename); - void process_init(yp2::Package & package) const; - void process_search(yp2::Package & package) const; - void process_scan(yp2::Package & package) const; - void check_targets(yp2::Package & package) const; + void process_init(metaproxy_1::Package & package) const; + void process_search(metaproxy_1::Package & package) const; + void process_scan(metaproxy_1::Package & package) const; + void check_targets(metaproxy_1::Package & package) const; }; } } extern "C" { - extern struct yp2_filter_struct yp2_filter_auth_simple; + extern struct metaproxy_1_filter_struct metaproxy_1_filter_auth_simple; } #endif diff --git a/src/filter_backend_test.cpp b/src/filter_backend_test.cpp index 0bac12a..5fe5338 100644 --- a/src/filter_backend_test.cpp +++ b/src/filter_backend_test.cpp @@ -1,5 +1,5 @@ -/* $Id: filter_backend_test.cpp,v 1.17 2006-01-17 17:55:40 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: filter_backend_test.cpp,v 1.18 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -23,9 +23,11 @@ #include #include -namespace yf = yp2::filter; +namespace mp = metaproxy_1; +namespace yf = mp::filter; +using namespace mp; -namespace yp2 { +namespace metaproxy_1 { namespace filter { class Session_info { int dummy; @@ -45,7 +47,6 @@ namespace yp2 { } } -using namespace yp2; static const int result_set_size = 42; @@ -153,7 +154,7 @@ void yf::Backend_test::process(Package &package) const { Z_APDU *apdu_req = gdu->u.z3950; Z_APDU *apdu_res = 0; - yp2::odr odr; + mp::odr odr; if (apdu_req->which != Z_APDU_initRequest && !m_p->m_sessions.exist(package.session())) @@ -216,7 +217,7 @@ void yf::Backend_test::process(Package &package) const std::string addinfo; int number = 0; - yp2::util::piggyback(*req->smallSetUpperBound, + mp::util::piggyback(*req->smallSetUpperBound, *req->largeSetLowerBound, *req->mediumSetPresentNumber, result_set_size, @@ -295,13 +296,13 @@ void yf::Backend_test::process(Package &package) const m_p->m_sessions.release(package.session()); } -static yp2::filter::Base* filter_creator() +static mp::filter::Base* filter_creator() { - return new yp2::filter::Backend_test; + return new mp::filter::Backend_test; } extern "C" { - struct yp2_filter_struct yp2_filter_backend_test = { + struct metaproxy_1_filter_struct metaproxy_1_filter_backend_test = { 0, "backend_test", filter_creator diff --git a/src/filter_backend_test.hpp b/src/filter_backend_test.hpp index 7c2b71e..b4909ad 100644 --- a/src/filter_backend_test.hpp +++ b/src/filter_backend_test.hpp @@ -1,5 +1,5 @@ -/* $Id: filter_backend_test.hpp,v 1.7 2006-01-04 11:55:31 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: filter_backend_test.hpp,v 1.8 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -11,14 +11,14 @@ #include "filter.hpp" -namespace yp2 { +namespace metaproxy_1 { namespace filter { class Backend_test : public Base { class Rep; public: ~Backend_test(); Backend_test(); - void process(yp2::Package & package) const; + void process(metaproxy_1::Package & package) const; private: boost::scoped_ptr m_p; }; @@ -26,7 +26,7 @@ namespace yp2 { } extern "C" { - extern struct yp2_filter_struct yp2_filter_backend_test; + extern struct metaproxy_1_filter_struct metaproxy_1_filter_backend_test; } #endif diff --git a/src/filter_dl.cpp b/src/filter_dl.cpp index 6b4802a..d0d500a 100644 --- a/src/filter_dl.cpp +++ b/src/filter_dl.cpp @@ -1,5 +1,5 @@ -/* $Id: filter_dl.cpp,v 1.4 2006-01-09 21:20:15 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: filter_dl.cpp,v 1.5 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -9,27 +9,29 @@ #include "filter.hpp" #include "package.hpp" -namespace yp2 { +namespace mp = metaproxy_1; + +namespace metaproxy_1 { namespace filter { - class Filter_dl: public yp2::filter::Base { + class Filter_dl: public mp::filter::Base { public: - void process(yp2::Package & package) const; + void process(mp::Package & package) const; }; } } -void yp2::filter::Filter_dl::process(yp2::Package & package) const +void mp::filter::Filter_dl::process(mp::Package & package) const { package.data() = 42; // magic checked in test_filter_factory } -static yp2::filter::Base* filter_creator() +static mp::filter::Base* filter_creator() { - return new yp2::filter::Filter_dl; + return new mp::filter::Filter_dl; } extern "C" { - struct yp2_filter_struct yp2_filter_dl = { + struct metaproxy_1_filter_struct metaproxy_1_filter_dl = { 0, "dl", filter_creator diff --git a/src/filter_frontend_net.cpp b/src/filter_frontend_net.cpp index 3554d63..c6340a5 100644 --- a/src/filter_frontend_net.cpp +++ b/src/filter_frontend_net.cpp @@ -1,5 +1,5 @@ -/* $Id: filter_frontend_net.cpp,v 1.15 2006-01-11 11:51:49 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: filter_frontend_net.cpp,v 1.16 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -18,7 +18,9 @@ #include -namespace yp2 { +namespace mp = metaproxy_1; + +namespace metaproxy_1 { namespace filter { class FrontendNet::Rep { friend class FrontendNet; @@ -41,8 +43,8 @@ namespace yp2 { public: ~ZAssocChild(); ZAssocChild(yazpp_1::IPDU_Observable *the_PDU_Observable, - yp2::ThreadPoolSocketObserver *m_thread_pool_observer, - const yp2::Package *package); + mp::ThreadPoolSocketObserver *m_thread_pool_observer, + const mp::Package *package); int m_no_requests; private: yazpp_1::IPDU_Observer* sessionNotify( @@ -54,31 +56,31 @@ namespace yp2 { void timeoutNotify(); void connectNotify(); private: - yp2::ThreadPoolSocketObserver *m_thread_pool_observer; - yp2::Session m_session; - yp2::Origin m_origin; + mp::ThreadPoolSocketObserver *m_thread_pool_observer; + mp::Session m_session; + mp::Origin m_origin; bool m_delete_flag; - const yp2::Package *m_package; + const mp::Package *m_package; }; - class ThreadPoolPackage : public yp2::IThreadPoolMsg { + class ThreadPoolPackage : public mp::IThreadPoolMsg { public: - ThreadPoolPackage(yp2::Package *package, yp2::ZAssocChild *ses) : + ThreadPoolPackage(mp::Package *package, mp::ZAssocChild *ses) : m_session(ses), m_package(package) { }; ~ThreadPoolPackage(); IThreadPoolMsg *handle(); void result(); private: - yp2::ZAssocChild *m_session; - yp2::Package *m_package; + mp::ZAssocChild *m_session; + mp::Package *m_package; }; class ZAssocServer : public yazpp_1::Z_Assoc { public: ~ZAssocServer(); ZAssocServer(yazpp_1::IPDU_Observable *PDU_Observable, - yp2::ThreadPoolSocketObserver *m_thread_pool_observer, - const yp2::Package *package); + mp::ThreadPoolSocketObserver *m_thread_pool_observer, + const mp::Package *package); private: yazpp_1::IPDU_Observer* sessionNotify( yazpp_1::IPDU_Observable *the_PDU_Observable, @@ -89,17 +91,17 @@ namespace yp2 { void timeoutNotify(); void connectNotify(); private: - yp2::ThreadPoolSocketObserver *m_thread_pool_observer; - const yp2::Package *m_package; + mp::ThreadPoolSocketObserver *m_thread_pool_observer; + const mp::Package *m_package; }; } -yp2::ThreadPoolPackage::~ThreadPoolPackage() +mp::ThreadPoolPackage::~ThreadPoolPackage() { delete m_package; } -void yp2::ThreadPoolPackage::result() +void mp::ThreadPoolPackage::result() { m_session->m_no_requests--; @@ -114,16 +116,16 @@ void yp2::ThreadPoolPackage::result() delete this; } -yp2::IThreadPoolMsg *yp2::ThreadPoolPackage::handle() +mp::IThreadPoolMsg *mp::ThreadPoolPackage::handle() { m_package->move(); return this; } -yp2::ZAssocChild::ZAssocChild(yazpp_1::IPDU_Observable *PDU_Observable, - yp2::ThreadPoolSocketObserver *my_thread_pool, - const yp2::Package *package) +mp::ZAssocChild::ZAssocChild(yazpp_1::IPDU_Observable *PDU_Observable, + mp::ThreadPoolSocketObserver *my_thread_pool, + const mp::Package *package) : Z_Assoc(PDU_Observable) { m_thread_pool_observer = my_thread_pool; @@ -133,29 +135,29 @@ yp2::ZAssocChild::ZAssocChild(yazpp_1::IPDU_Observable *PDU_Observable, } -yazpp_1::IPDU_Observer *yp2::ZAssocChild::sessionNotify(yazpp_1::IPDU_Observable +yazpp_1::IPDU_Observer *mp::ZAssocChild::sessionNotify(yazpp_1::IPDU_Observable *the_PDU_Observable, int fd) { return 0; } -yp2::ZAssocChild::~ZAssocChild() +mp::ZAssocChild::~ZAssocChild() { } -void yp2::ZAssocChild::recv_GDU(Z_GDU *z_pdu, int len) +void mp::ZAssocChild::recv_GDU(Z_GDU *z_pdu, int len) { m_no_requests++; - yp2::Package *p = new yp2::Package(m_session, m_origin); + mp::Package *p = new mp::Package(m_session, m_origin); - yp2::ThreadPoolPackage *tp = new yp2::ThreadPoolPackage(p, this); + mp::ThreadPoolPackage *tp = new mp::ThreadPoolPackage(p, this); p->copy_filter(*m_package); p->request() = yazpp_1::GDU(z_pdu); m_thread_pool_observer->put(tp); } -void yp2::ZAssocChild::failNotify() +void mp::ZAssocChild::failNotify() { // TODO: send Package to signal "close" if (m_session.is_closed()) @@ -164,26 +166,26 @@ void yp2::ZAssocChild::failNotify() m_session.close(); - yp2::Package *p = new yp2::Package(m_session, m_origin); + mp::Package *p = new mp::Package(m_session, m_origin); - yp2::ThreadPoolPackage *tp = new yp2::ThreadPoolPackage(p, this); + mp::ThreadPoolPackage *tp = new mp::ThreadPoolPackage(p, this); p->copy_filter(*m_package); m_thread_pool_observer->put(tp); } -void yp2::ZAssocChild::timeoutNotify() +void mp::ZAssocChild::timeoutNotify() { failNotify(); } -void yp2::ZAssocChild::connectNotify() +void mp::ZAssocChild::connectNotify() { } -yp2::ZAssocServer::ZAssocServer(yazpp_1::IPDU_Observable *PDU_Observable, - yp2::ThreadPoolSocketObserver *thread_pool_observer, - const yp2::Package *package) +mp::ZAssocServer::ZAssocServer(yazpp_1::IPDU_Observable *PDU_Observable, + mp::ThreadPoolSocketObserver *thread_pool_observer, + const mp::Package *package) : Z_Assoc(PDU_Observable) { m_thread_pool_observer = thread_pool_observer; @@ -191,51 +193,51 @@ yp2::ZAssocServer::ZAssocServer(yazpp_1::IPDU_Observable *PDU_Observable, } -yazpp_1::IPDU_Observer *yp2::ZAssocServer::sessionNotify(yazpp_1::IPDU_Observable +yazpp_1::IPDU_Observer *mp::ZAssocServer::sessionNotify(yazpp_1::IPDU_Observable *the_PDU_Observable, int fd) { - yp2::ZAssocChild *my = - new yp2::ZAssocChild(the_PDU_Observable, m_thread_pool_observer, + mp::ZAssocChild *my = + new mp::ZAssocChild(the_PDU_Observable, m_thread_pool_observer, m_package); return my; } -yp2::ZAssocServer::~ZAssocServer() +mp::ZAssocServer::~ZAssocServer() { } -void yp2::ZAssocServer::recv_GDU(Z_GDU *apdu, int len) +void mp::ZAssocServer::recv_GDU(Z_GDU *apdu, int len) { } -void yp2::ZAssocServer::failNotify() +void mp::ZAssocServer::failNotify() { } -void yp2::ZAssocServer::timeoutNotify() +void mp::ZAssocServer::timeoutNotify() { } -void yp2::ZAssocServer::connectNotify() +void mp::ZAssocServer::connectNotify() { } -yp2::filter::FrontendNet::FrontendNet() : m_p(new Rep) +mp::filter::FrontendNet::FrontendNet() : m_p(new Rep) { m_p->m_no_threads = 5; m_p->m_listen_duration = 0; } -yp2::filter::FrontendNet::~FrontendNet() +mp::filter::FrontendNet::~FrontendNet() { } -bool yp2::My_Timer_Thread::timeout() +bool mp::My_Timer_Thread::timeout() { return m_timeout; } -yp2::My_Timer_Thread::My_Timer_Thread(yazpp_1::ISocketObservable *obs, +mp::My_Timer_Thread::My_Timer_Thread(yazpp_1::ISocketObservable *obs, int duration) : m_obs(obs), m_pipe(9123), m_timeout(false) { @@ -244,13 +246,13 @@ yp2::My_Timer_Thread::My_Timer_Thread(yazpp_1::ISocketObservable *obs, obs->timeoutObserver(this, duration); } -void yp2::My_Timer_Thread::socketNotify(int event) +void mp::My_Timer_Thread::socketNotify(int event) { m_timeout = true; m_obs->deleteObserver(this); } -void yp2::filter::FrontendNet::process(Package &package) const +void mp::filter::FrontendNet::process(Package &package) const { if (m_p->m_ports.size() == 0) return; @@ -263,17 +265,17 @@ void yp2::filter::FrontendNet::process(Package &package) const ThreadPoolSocketObserver threadPool(&mySocketManager, m_p->m_no_threads); - yp2::ZAssocServer **az = new yp2::ZAssocServer *[m_p->m_ports.size()]; + mp::ZAssocServer **az = new mp::ZAssocServer *[m_p->m_ports.size()]; - // Create yp2::ZAssocServer for each port + // Create mp::ZAssocServer for each port size_t i; for (i = 0; im_ports.size(); i++) { - // create a PDU assoc object (one per yp2::ZAssocServer) + // create a PDU assoc object (one per mp::ZAssocServer) yazpp_1::PDU_Assoc *as = new yazpp_1::PDU_Assoc(&mySocketManager); // create ZAssoc with PDU Assoc - az[i] = new yp2::ZAssocServer(as, &threadPool, &package); + az[i] = new mp::ZAssocServer(as, &threadPool, &package); az[i]->server(m_p->m_ports[i].c_str()); } while (mySocketManager.processEvent() > 0) @@ -288,11 +290,11 @@ void yp2::filter::FrontendNet::process(Package &package) const delete tt; } -void yp2::filter::FrontendNet::configure(const xmlNode * ptr) +void mp::filter::FrontendNet::configure(const xmlNode * ptr) { if (!ptr || !ptr->children) { - throw yp2::filter::FilterException("No ports for Frontend"); + throw mp::filter::FilterException("No ports for Frontend"); } std::vector ports; for (ptr = ptr->children; ptr; ptr = ptr->next) @@ -301,22 +303,22 @@ void yp2::filter::FrontendNet::configure(const xmlNode * ptr) continue; if (!strcmp((const char *) ptr->name, "port")) { - std::string port = yp2::xml::get_text(ptr); + std::string port = mp::xml::get_text(ptr); ports.push_back(port); } else if (!strcmp((const char *) ptr->name, "threads")) { - std::string threads_str = yp2::xml::get_text(ptr); + std::string threads_str = mp::xml::get_text(ptr); int threads = atoi(threads_str.c_str()); if (threads < 1) - throw yp2::filter::FilterException("Bad value for threads: " + throw mp::filter::FilterException("Bad value for threads: " + threads_str); m_p->m_no_threads = threads; } else { - throw yp2::filter::FilterException("Bad element " + throw mp::filter::FilterException("Bad element " + std::string((const char *) ptr->name)); } @@ -324,23 +326,23 @@ void yp2::filter::FrontendNet::configure(const xmlNode * ptr) m_p->m_ports = ports; } -std::vector &yp2::filter::FrontendNet::ports() +std::vector &mp::filter::FrontendNet::ports() { return m_p->m_ports; } -int &yp2::filter::FrontendNet::listen_duration() +int &mp::filter::FrontendNet::listen_duration() { return m_p->m_listen_duration; } -static yp2::filter::Base* filter_creator() +static mp::filter::Base* filter_creator() { - return new yp2::filter::FrontendNet; + return new mp::filter::FrontendNet; } extern "C" { - struct yp2_filter_struct yp2_filter_frontend_net = { + struct metaproxy_1_filter_struct metaproxy_1_filter_frontend_net = { 0, "frontend_net", filter_creator diff --git a/src/filter_frontend_net.hpp b/src/filter_frontend_net.hpp index 546b5b1..2b55ec5 100644 --- a/src/filter_frontend_net.hpp +++ b/src/filter_frontend_net.hpp @@ -1,5 +1,5 @@ -/* $Id: filter_frontend_net.hpp,v 1.12 2006-01-09 21:19:11 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: filter_frontend_net.hpp,v 1.13 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -14,7 +14,7 @@ #include "filter.hpp" -namespace yp2 { +namespace metaproxy_1 { namespace filter { class FrontendNet : public Base { class Rep; @@ -22,7 +22,7 @@ namespace yp2 { public: FrontendNet(); ~FrontendNet(); - void process(yp2::Package & package) const; + void process(metaproxy_1::Package & package) const; void configure(const xmlNode * ptr); public: /// set ports @@ -34,7 +34,7 @@ namespace yp2 { } extern "C" { - extern struct yp2_filter_struct yp2_filter_frontend_net; + extern struct metaproxy_1_filter_struct metaproxy_1_filter_frontend_net; } #endif diff --git a/src/filter_http_file.cpp b/src/filter_http_file.cpp index 7ca4062..1b9f0a4 100644 --- a/src/filter_http_file.cpp +++ b/src/filter_http_file.cpp @@ -1,5 +1,5 @@ -/* $Id: filter_http_file.cpp,v 1.3 2006-02-02 11:33:46 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: filter_http_file.cpp,v 1.4 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -27,9 +27,10 @@ #include #endif -namespace yf = yp2::filter; +namespace mp = metaproxy_1; +namespace yf = mp::filter; -namespace yp2 { +namespace metaproxy_1 { namespace filter { struct HttpFile::Area { std::string m_url_path_prefix; @@ -50,11 +51,11 @@ namespace yp2 { MimeMap m_ext_to_map; AreaList m_area_list; - void fetch_uri(yp2::Session &session, - Z_HTTP_Request *req, yp2::Package &package); - void fetch_file(yp2::Session &session, + void fetch_uri(mp::Session &session, + Z_HTTP_Request *req, mp::Package &package); + void fetch_file(mp::Session &session, Z_HTTP_Request *req, - std::string &fname, yp2::Package &package); + std::string &fname, mp::Package &package); std::string get_mime_type(std::string &fname); }; } @@ -111,11 +112,11 @@ std::string yf::HttpFile::Rep::get_mime_type(std::string &fname) return content_type; } -void yf::HttpFile::Rep::fetch_file(yp2::Session &session, +void yf::HttpFile::Rep::fetch_file(mp::Session &session, Z_HTTP_Request *req, - std::string &fname, yp2::Package &package) + std::string &fname, mp::Package &package) { - yp2::odr o; + mp::odr o; FILE *f = fopen(fname.c_str(), "rb"); if (!f) @@ -157,8 +158,8 @@ void yf::HttpFile::Rep::fetch_file(yp2::Session &session, package.response() = gdu; } -void yf::HttpFile::Rep::fetch_uri(yp2::Session &session, - Z_HTTP_Request *req, yp2::Package &package) +void yf::HttpFile::Rep::fetch_uri(mp::Session &session, + Z_HTTP_Request *req, mp::Package &package) { bool sane = true; std::string path = req->path; @@ -186,12 +187,12 @@ void yf::HttpFile::Rep::fetch_uri(yp2::Session &session, } } } - yp2::odr o; + mp::odr o; Z_GDU *gdu = o.create_HTTP_Response(session, req, 404); package.response() = gdu; } -void yf::HttpFile::process(yp2::Package &package) const +void yf::HttpFile::process(mp::Package &package) const { Z_GDU *gdu = package.request().get(); if (gdu && gdu->which == Z_GDU_HTTP_Request) @@ -200,7 +201,7 @@ void yf::HttpFile::process(yp2::Package &package) const package.move(); } -void yp2::filter::HttpFile::configure(const xmlNode * ptr) +void mp::filter::HttpFile::configure(const xmlNode * ptr) { for (ptr = ptr->children; ptr; ptr = ptr->next) { @@ -208,13 +209,13 @@ void yp2::filter::HttpFile::configure(const xmlNode * ptr) continue; if (!strcmp((const char *) ptr->name, "mimetypes")) { - std::string fname = yp2::xml::get_text(ptr); + std::string fname = mp::xml::get_text(ptr); - yp2::PlainFile f; + mp::PlainFile f; if (!f.open(fname)) { - throw yp2::filter::FilterException + throw mp::filter::FilterException ("Can not open mime types file " + fname); } @@ -235,12 +236,12 @@ void yp2::filter::HttpFile::configure(const xmlNode * ptr) if (a_node->type != XML_ELEMENT_NODE) continue; - if (yp2::xml::is_element_yp2(a_node, "documentroot")) - a.m_file_root = yp2::xml::get_text(a_node); - else if (yp2::xml::is_element_yp2(a_node, "prefix")) - a.m_url_path_prefix = yp2::xml::get_text(a_node); + if (mp::xml::is_element_yp2(a_node, "documentroot")) + a.m_file_root = mp::xml::get_text(a_node); + else if (mp::xml::is_element_yp2(a_node, "prefix")) + a.m_url_path_prefix = mp::xml::get_text(a_node); else - throw yp2::filter::FilterException + throw mp::filter::FilterException ("Bad element " + std::string((const char *) a_node->name) + " in area section" @@ -253,7 +254,7 @@ void yp2::filter::HttpFile::configure(const xmlNode * ptr) } else { - throw yp2::filter::FilterException + throw mp::filter::FilterException ("Bad element " + std::string((const char *) ptr->name) + " in virt_db filter"); @@ -261,13 +262,13 @@ void yp2::filter::HttpFile::configure(const xmlNode * ptr) } } -static yp2::filter::Base* filter_creator() +static mp::filter::Base* filter_creator() { - return new yp2::filter::HttpFile; + return new mp::filter::HttpFile; } extern "C" { - struct yp2_filter_struct yp2_filter_http_file = { + struct metaproxy_1_filter_struct metaproxy_1_filter_http_file = { 0, "http_file", filter_creator diff --git a/src/filter_http_file.hpp b/src/filter_http_file.hpp index 43dc9b9..6868d3e 100644 --- a/src/filter_http_file.hpp +++ b/src/filter_http_file.hpp @@ -1,5 +1,5 @@ -/* $Id: filter_http_file.hpp,v 1.3 2006-02-02 11:33:46 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: filter_http_file.hpp,v 1.4 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -11,7 +11,7 @@ #include "filter.hpp" -namespace yp2 { +namespace metaproxy_1 { namespace filter { class HttpFile : public Base { class Rep; @@ -21,14 +21,14 @@ namespace yp2 { public: HttpFile(); ~HttpFile(); - void process(yp2::Package & package) const; + void process(metaproxy_1::Package & package) const; void configure(const xmlNode * ptr); }; } } extern "C" { - extern struct yp2_filter_struct yp2_filter_http_file; + extern struct metaproxy_1_filter_struct metaproxy_1_filter_http_file; } #endif diff --git a/src/filter_log.cpp b/src/filter_log.cpp index 34a335c..bd5f862 100644 --- a/src/filter_log.cpp +++ b/src/filter_log.cpp @@ -1,5 +1,5 @@ -/* $Id: filter_log.cpp,v 1.16 2006-01-17 15:08:02 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: filter_log.cpp,v 1.17 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -17,9 +17,10 @@ #include -namespace yf = yp2::filter; +namespace mp = metaproxy_1; +namespace yf = mp::filter; -namespace yp2 { +namespace metaproxy_1 { namespace filter { class Log::Rep { friend class Log; @@ -40,7 +41,7 @@ yf::Log::Log() : m_p(new Rep) yf::Log::~Log() {} -void yf::Log::process(yp2::Package &package) const +void yf::Log::process(mp::Package &package) const { Z_GDU *gdu; @@ -59,7 +60,7 @@ void yf::Log::process(yp2::Package &package) const gdu = package.request().get(); if (gdu) { - yp2::odr odr(ODR_PRINT); + mp::odr odr(ODR_PRINT); z_GDU(odr, &gdu, 0, 0); } } @@ -88,7 +89,7 @@ void yf::Log::process(yp2::Package &package) const gdu = package.response().get(); if (gdu) { - yp2::odr odr(ODR_PRINT); + mp::odr odr(ODR_PRINT); z_GDU(odr, &gdu, 0, 0); } } @@ -101,23 +102,23 @@ void yf::Log::configure(const xmlNode *ptr) if (ptr->type != XML_ELEMENT_NODE) continue; if (!strcmp((const char *) ptr->name, "message")) - m_p->m_msg = yp2::xml::get_text(ptr); + m_p->m_msg = mp::xml::get_text(ptr); else { - throw yp2::filter::FilterException("Bad element " + throw mp::filter::FilterException("Bad element " + std::string((const char *) ptr->name)); } } } -static yp2::filter::Base* filter_creator() +static mp::filter::Base* filter_creator() { - return new yp2::filter::Log; + return new mp::filter::Log; } extern "C" { - struct yp2_filter_struct yp2_filter_log = { + struct metaproxy_1_filter_struct metaproxy_1_filter_log = { 0, "log", filter_creator diff --git a/src/filter_log.hpp b/src/filter_log.hpp index b6238b5..ad47803 100644 --- a/src/filter_log.hpp +++ b/src/filter_log.hpp @@ -1,5 +1,5 @@ -/* $Id: filter_log.hpp,v 1.13 2006-01-11 08:53:52 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: filter_log.hpp,v 1.14 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -11,7 +11,7 @@ #include "filter.hpp" -namespace yp2 { +namespace metaproxy_1 { namespace filter { class Log : public Base { class Rep; @@ -20,14 +20,14 @@ namespace yp2 { Log(); Log(const std::string &x); ~Log(); - void process(yp2::Package & package) const; + void process(metaproxy_1::Package & package) const; void configure(const xmlNode * ptr); }; } } extern "C" { - extern struct yp2_filter_struct yp2_filter_log; + extern struct metaproxy_1_filter_struct metaproxy_1_filter_log; } #endif diff --git a/src/filter_multi.cpp b/src/filter_multi.cpp index b412bb4..a03319a 100644 --- a/src/filter_multi.cpp +++ b/src/filter_multi.cpp @@ -1,5 +1,5 @@ -/* $Id: filter_multi.cpp,v 1.14 2006-02-02 11:33:46 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: filter_multi.cpp,v 1.15 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -26,9 +26,10 @@ #include #include -namespace yf = yp2::filter; +namespace mp = metaproxy_1; +namespace yf = mp::filter; -namespace yp2 { +namespace metaproxy_1 { namespace filter { struct Multi::BackendSet { @@ -102,12 +103,12 @@ namespace yp2 { std::map m_target_route; boost::mutex m_mutex; boost::condition m_cond_session_ready; - std::map m_clients; + std::map m_clients; }; } } -using namespace yp2; +using namespace mp; bool yf::Multi::BackendSet::operator < (const BackendSet &k) const { @@ -128,7 +129,7 @@ yf::Multi::FrontendPtr yf::Multi::Rep::get_frontend(Package &package) { boost::mutex::scoped_lock lock(m_mutex); - std::map::iterator it; + std::map::iterator it; while(true) { @@ -152,7 +153,7 @@ yf::Multi::FrontendPtr yf::Multi::Rep::get_frontend(Package &package) void yf::Multi::Rep::release_frontend(Package &package) { boost::mutex::scoped_lock lock(m_mutex); - std::map::iterator it; + std::map::iterator it; it = m_clients.find(package.session()); if (it != m_clients.end()) @@ -339,7 +340,7 @@ void yf::Multi::Frontend::init(Package &package, Z_GDU *gdu) std::list targets; - yp2::util::get_vhost_otherinfo(&req->otherInfo, false, targets); + mp::util::get_vhost_otherinfo(&req->otherInfo, false, targets); if (targets.size() < 1) { @@ -366,13 +367,13 @@ void yf::Multi::Frontend::init(Package &package, Z_GDU *gdu) std::list::const_iterator bit; for (bit = m_backend_list.begin(); bit != m_backend_list.end(); bit++) { - yp2::odr odr; + mp::odr odr; BackendPtr b = *bit; Z_APDU *init_apdu = zget_APDU(odr, Z_APDU_initRequest); std::listvhost_one; vhost_one.push_back(b->m_vhost); - yp2::util::set_vhost_otherinfo(&init_apdu->u.initRequest->otherInfo, + mp::util::set_vhost_otherinfo(&init_apdu->u.initRequest->otherInfo, odr, vhost_one); Z_InitRequest *req = init_apdu->u.initRequest; @@ -393,7 +394,7 @@ void yf::Multi::Frontend::init(Package &package, Z_GDU *gdu) multi_move(m_backend_list); // create the frontend init response based on each backend init response - yp2::odr odr; + mp::odr odr; Z_APDU *f_apdu = odr.create_initResponse(gdu->u.z3950, 0, 0); Z_InitResponse *f_resp = f_apdu->u.initResponse; @@ -467,9 +468,9 @@ void yf::Multi::Frontend::search(Package &package, Z_APDU *apdu_req) for (bit = m_backend_list.begin(); bit != m_backend_list.end(); bit++) { PackagePtr p = (*bit)->m_package; - yp2::odr odr; + mp::odr odr; - if (!yp2::util::set_databases_from_zurl(odr, (*bit)->m_vhost, + if (!mp::util::set_databases_from_zurl(odr, (*bit)->m_vhost, &req->num_databaseNames, &req->databaseNames)) { @@ -522,7 +523,7 @@ void yf::Multi::Frontend::search(Package &package, Z_APDU *apdu_req) } } - yp2::odr odr; + mp::odr odr; Z_APDU *f_apdu = odr.create_searchResponse(apdu_req, 0, 0); Z_SearchResponse *f_resp = f_apdu->u.searchResponse; @@ -538,7 +539,7 @@ void yf::Multi::Frontend::search(Package &package, Z_APDU *apdu_req) m_sets[resultSet.m_setname] = resultSet; int number; - yp2::util::piggyback(smallSetUpperBound, + mp::util::piggyback(smallSetUpperBound, largeSetLowerBound, mediumSetPresentNumber, result_set_size, @@ -588,7 +589,7 @@ void yf::Multi::Frontend::present(Package &package, Z_APDU *apdu_req) it = m_sets.find(std::string(req->resultSetId)); if (it == m_sets.end()) { - yp2::odr odr; + mp::odr odr; Z_APDU *apdu = odr.create_presentResponse( apdu_req, @@ -671,7 +672,7 @@ void yf::Multi::Frontend::present(Package &package, Z_APDU *apdu_req) } } - yp2::odr odr; + mp::odr odr; Z_APDU *f_apdu = odr.create_presentResponse(apdu_req, 0, 0); Z_PresentResponse *f_resp = f_apdu->u.presentResponse; @@ -716,7 +717,7 @@ void yf::Multi::Frontend::scan1(Package &package, Z_APDU *apdu_req) { if (m_backend_list.size() > 1) { - yp2::odr odr; + mp::odr odr; Z_APDU *f_apdu = odr.create_scanResponse( apdu_req, YAZ_BIB1_COMBI_OF_SPECIFIED_DATABASES_UNSUPP, 0); @@ -732,9 +733,9 @@ void yf::Multi::Frontend::scan1(Package &package, Z_APDU *apdu_req) for (bit = m_backend_list.begin(); bit != m_backend_list.end(); bit++) { PackagePtr p = (*bit)->m_package; - yp2::odr odr; + mp::odr odr; - if (!yp2::util::set_databases_from_zurl(odr, (*bit)->m_vhost, + if (!mp::util::set_databases_from_zurl(odr, (*bit)->m_vhost, &req->num_databaseNames, &req->databaseNames)) { @@ -814,9 +815,9 @@ void yf::Multi::Frontend::scan2(Package &package, Z_APDU *apdu_req) for (bit = m_backend_list.begin(); bit != m_backend_list.end(); bit++) { PackagePtr p = (*bit)->m_package; - yp2::odr odr; + mp::odr odr; - if (!yp2::util::set_databases_from_zurl(odr, (*bit)->m_vhost, + if (!mp::util::set_databases_from_zurl(odr, (*bit)->m_vhost, &req->num_databaseNames, &req->databaseNames)) { @@ -849,7 +850,7 @@ void yf::Multi::Frontend::scan2(Package &package, Z_APDU *apdu_req) if (res->entries && res->entries->nonsurrogateDiagnostics) { // failure - yp2::odr odr; + mp::odr odr; Z_APDU *f_apdu = odr.create_scanResponse(apdu_req, 1, 0); Z_ScanResponse *f_res = f_apdu->u.scanResponse; @@ -981,13 +982,13 @@ void yf::Multi::Frontend::scan2(Package &package, Z_APDU *apdu_req) if (false) { - yp2::odr odr; + mp::odr odr; Z_APDU *f_apdu = odr.create_scanResponse(apdu_req, 1, "not implemented"); package.response() = f_apdu; } else { - yp2::odr odr; + mp::odr odr; Z_APDU *f_apdu = odr.create_scanResponse(apdu_req, 0, 0); Z_ScanResponse *resp = f_apdu->u.scanResponse; @@ -1049,7 +1050,7 @@ void yf::Multi::process(Package &package) const Z_APDU *apdu = gdu->u.z3950; if (apdu->which == Z_APDU_initRequest) { - yp2::odr odr; + mp::odr odr; package.response() = odr.create_close( apdu, @@ -1072,7 +1073,7 @@ void yf::Multi::process(Package &package) const } else { - yp2::odr odr; + mp::odr odr; package.response() = odr.create_close( apdu, Z_Close_protocolError, @@ -1084,7 +1085,7 @@ void yf::Multi::process(Package &package) const m_p->release_frontend(package); } -void yp2::filter::Multi::configure(const xmlNode * ptr) +void mp::filter::Multi::configure(const xmlNode * ptr) { for (ptr = ptr->children; ptr; ptr = ptr->next) { @@ -1092,8 +1093,8 @@ void yp2::filter::Multi::configure(const xmlNode * ptr) continue; if (!strcmp((const char *) ptr->name, "target")) { - std::string route = yp2::xml::get_route(ptr); - std::string target = yp2::xml::get_text(ptr); + std::string route = mp::xml::get_route(ptr); + std::string target = mp::xml::get_text(ptr); std::cout << "route=" << route << " target=" << target << "\n"; m_p->m_target_route[target] = route; } @@ -1107,18 +1108,18 @@ void yp2::filter::Multi::configure(const xmlNode * ptr) if (v_node->type != XML_ELEMENT_NODE) continue; - if (yp2::xml::is_element_yp2(v_node, "vhost")) - vhost = yp2::xml::get_text(v_node); - else if (yp2::xml::is_element_yp2(v_node, "target")) - targets.push_back(yp2::xml::get_text(v_node)); + if (mp::xml::is_element_yp2(v_node, "vhost")) + vhost = mp::xml::get_text(v_node); + else if (mp::xml::is_element_yp2(v_node, "target")) + targets.push_back(mp::xml::get_text(v_node)); else - throw yp2::filter::FilterException + throw mp::filter::FilterException ("Bad element " + std::string((const char *) v_node->name) + " in virtual section" ); } - std::string route = yp2::xml::get_route(ptr); + std::string route = mp::xml::get_route(ptr); add_map_host2hosts(vhost, targets, route); std::list::const_iterator it; for (it = targets.begin(); it != targets.end(); it++) @@ -1129,7 +1130,7 @@ void yp2::filter::Multi::configure(const xmlNode * ptr) } else { - throw yp2::filter::FilterException + throw mp::filter::FilterException ("Bad element " + std::string((const char *) ptr->name) + " in virt_db filter"); @@ -1137,13 +1138,13 @@ void yp2::filter::Multi::configure(const xmlNode * ptr) } } -static yp2::filter::Base* filter_creator() +static mp::filter::Base* filter_creator() { - return new yp2::filter::Multi; + return new mp::filter::Multi; } extern "C" { - struct yp2_filter_struct yp2_filter_multi = { + struct metaproxy_1_filter_struct metaproxy_1_filter_multi = { 0, "multi", filter_creator diff --git a/src/filter_multi.hpp b/src/filter_multi.hpp index db54055..86ab144 100644 --- a/src/filter_multi.hpp +++ b/src/filter_multi.hpp @@ -1,5 +1,5 @@ -/* $Id: filter_multi.hpp,v 1.4 2006-02-02 11:33:46 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: filter_multi.hpp,v 1.5 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -15,7 +15,7 @@ #include "filter.hpp" -namespace yp2 { +namespace metaproxy_1 { namespace filter { class Multi : public Base { class Rep; @@ -33,7 +33,7 @@ namespace yp2 { public: ~Multi(); Multi(); - void process(yp2::Package & package) const; + void process(metaproxy_1::Package & package) const; void configure(const xmlNode * ptr); void add_map_host2hosts(std::string host, std::list hosts, @@ -45,7 +45,7 @@ namespace yp2 { } extern "C" { - extern struct yp2_filter_struct yp2_filter_multi; + extern struct metaproxy_1_filter_struct metaproxy_1_filter_multi; } #endif diff --git a/src/filter_query_rewrite.cpp b/src/filter_query_rewrite.cpp index e63cc62..e431b27 100644 --- a/src/filter_query_rewrite.cpp +++ b/src/filter_query_rewrite.cpp @@ -1,5 +1,5 @@ -/* $Id: filter_query_rewrite.cpp,v 1.5 2006-03-16 09:38:33 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: filter_query_rewrite.cpp,v 1.6 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -19,15 +19,16 @@ #include #include -namespace yf = yp2::filter; +namespace mp = metaproxy_1; +namespace yf = mp::filter; -namespace yp2 { +namespace metaproxy_1 { namespace filter { class QueryRewrite::Rep { public: Rep(); ~Rep(); - void process(yp2::Package &package) const; + void process(mp::Package &package) const; void configure(const xmlNode * ptr); private: xsltStylesheetPtr m_stylesheet; @@ -54,17 +55,17 @@ yf::QueryRewrite::~QueryRewrite() { // must have a destructor because of boost::scoped_ptr } -void yf::QueryRewrite::process(yp2::Package &package) const +void yf::QueryRewrite::process(mp::Package &package) const { m_p->process(package); } -void yp2::filter::QueryRewrite::configure(const xmlNode *ptr) +void mp::filter::QueryRewrite::configure(const xmlNode *ptr) { m_p->configure(ptr); } -void yf::QueryRewrite::Rep::process(yp2::Package &package) const +void yf::QueryRewrite::Rep::process(mp::Package &package) const { Z_GDU *gdu = package.request().get(); @@ -75,7 +76,7 @@ void yf::QueryRewrite::Rep::process(yp2::Package &package) const { int error_code = 0; const char *addinfo = 0; - yp2::odr odr; + mp::odr odr; Z_SearchRequest *req = apdu_req->u.searchRequest; xmlDocPtr doc_input = 0; @@ -120,7 +121,7 @@ void yf::QueryRewrite::Rep::process(yp2::Package &package) const package.move(); } -void yp2::filter::QueryRewrite::Rep::configure(const xmlNode *ptr) +void mp::filter::QueryRewrite::Rep::configure(const xmlNode *ptr) { for (ptr = ptr->children; ptr; ptr = ptr->next) { @@ -130,15 +131,15 @@ void yp2::filter::QueryRewrite::Rep::configure(const xmlNode *ptr) { if (m_stylesheet) { - throw yp2::filter::FilterException + throw mp::filter::FilterException ("Only one xslt element allowed in query_rewrite filter"); } - std::string fname = yp2::xml::get_text(ptr); + std::string fname = mp::xml::get_text(ptr); m_stylesheet = xsltParseStylesheetFile(BAD_CAST fname.c_str()); if (!m_stylesheet) { - throw yp2::filter::FilterException + throw mp::filter::FilterException ("Failed to read stylesheet " + fname + " in query_rewrite filter"); @@ -146,7 +147,7 @@ void yp2::filter::QueryRewrite::Rep::configure(const xmlNode *ptr) } else { - throw yp2::filter::FilterException + throw mp::filter::FilterException ("Bad element " + std::string((const char *) ptr->name) + " in query_rewrite filter"); @@ -154,13 +155,13 @@ void yp2::filter::QueryRewrite::Rep::configure(const xmlNode *ptr) } } -static yp2::filter::Base* filter_creator() +static mp::filter::Base* filter_creator() { - return new yp2::filter::QueryRewrite; + return new mp::filter::QueryRewrite; } extern "C" { - struct yp2_filter_struct yp2_filter_query_rewrite = { + struct metaproxy_1_filter_struct metaproxy_1_filter_query_rewrite = { 0, "query-rewrite", filter_creator diff --git a/src/filter_query_rewrite.hpp b/src/filter_query_rewrite.hpp index 7fea8f7..daefd2a 100644 --- a/src/filter_query_rewrite.hpp +++ b/src/filter_query_rewrite.hpp @@ -1,5 +1,5 @@ -/* $Id: filter_query_rewrite.hpp,v 1.3 2006-03-15 14:55:17 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: filter_query_rewrite.hpp,v 1.4 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -12,7 +12,7 @@ #include "filter.hpp" -namespace yp2 { +namespace metaproxy_1 { namespace filter { class QueryRewrite : public Base { class Rep; @@ -20,14 +20,14 @@ namespace yp2 { public: QueryRewrite(); ~QueryRewrite(); - void process(yp2::Package & package) const; + void process(metaproxy_1::Package & package) const; void configure(const xmlNode * ptr); }; } } extern "C" { - extern struct yp2_filter_struct yp2_filter_query_rewrite; + extern struct metaproxy_1_filter_struct metaproxy_1_filter_query_rewrite; } #endif diff --git a/src/filter_session_shared.cpp b/src/filter_session_shared.cpp index 996bfe9..91ed879 100644 --- a/src/filter_session_shared.cpp +++ b/src/filter_session_shared.cpp @@ -1,5 +1,5 @@ -/* $Id: filter_session_shared.cpp,v 1.6 2006-01-13 15:09:35 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: filter_session_shared.cpp,v 1.7 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -23,9 +23,10 @@ #include #include -namespace yf = yp2::filter; +namespace mp = metaproxy_1; +namespace yf = mp::filter; -namespace yp2 { +namespace metaproxy_1 { namespace filter { class SessionShared::Rep { friend class SessionShared; @@ -61,8 +62,7 @@ namespace yp2 { } - -using namespace yp2; +using namespace mp; bool yf::SessionShared::InitKey::operator < (const SessionShared::InitKey &k) const @@ -112,7 +112,7 @@ void yf::SessionShared::Rep::handle_search(Z_APDU *apdu_req, SessionListMap::iterator it = m_session_list_map.find(package.session()); if (it == m_session_list_map.end()) { - yp2::odr odr; + mp::odr odr; package.response() = odr.create_close(apdu_req, Z_Close_protocolError, @@ -237,7 +237,7 @@ void yf::SessionShared::process(Package &package) const m_p->handle_search(apdu, package); break; default: - yp2::odr odr; + mp::odr odr; package.response() = odr.create_close(apdu, Z_Close_protocolError, "cannot handle a package of this type"); @@ -253,13 +253,13 @@ void yf::SessionShared::process(Package &package) const package.move(); // Not Z39.50 or not Init } -static yp2::filter::Base* filter_creator() +static mp::filter::Base* filter_creator() { - return new yp2::filter::SessionShared; + return new mp::filter::SessionShared; } extern "C" { - struct yp2_filter_struct yp2_filter_session_shared = { + struct metaproxy_1_filter_struct metaproxy_1_filter_session_shared = { 0, "session_shared", filter_creator diff --git a/src/filter_session_shared.hpp b/src/filter_session_shared.hpp index ff8898d..81579ce 100644 --- a/src/filter_session_shared.hpp +++ b/src/filter_session_shared.hpp @@ -1,5 +1,5 @@ -/* $Id: filter_session_shared.hpp,v 1.3 2006-01-04 11:55:31 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: filter_session_shared.hpp,v 1.4 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -11,7 +11,7 @@ #include "filter.hpp" -namespace yp2 { +namespace metaproxy_1 { namespace filter { class SessionShared : public Base { class Rep; @@ -20,7 +20,7 @@ namespace yp2 { public: ~SessionShared(); SessionShared(); - void process(yp2::Package & package) const; + void process(metaproxy_1::Package & package) const; private: boost::scoped_ptr m_p; }; @@ -28,7 +28,7 @@ namespace yp2 { } extern "C" { - extern struct yp2_filter_struct yp2_filter_session_shared; + extern struct metaproxy_1_filter_struct metaproxy_1_filter_session_shared; } #endif diff --git a/src/filter_template.cpp b/src/filter_template.cpp index e367020..59c9b1a 100644 --- a/src/filter_template.cpp +++ b/src/filter_template.cpp @@ -1,5 +1,5 @@ -/* $Id: filter_template.cpp,v 1.6 2006-01-09 21:20:15 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: filter_template.cpp,v 1.7 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -16,9 +16,10 @@ #include -namespace yf = yp2::filter; +namespace mp = metaproxy_1; +namespace yf = mp::filter; -namespace yp2 { +namespace metaproxy_1 { namespace filter { class Template::Rep { friend class Template; @@ -36,19 +37,19 @@ yf::Template::~Template() { // must have a destructor because of boost::scoped_ptr } -void yf::Template::process(yp2::Package &package) const +void yf::Template::process(mp::Package &package) const { // Z_GDU *gdu = package.request().get(); package.move(); } -static yp2::filter::Base* filter_creator() +static mp::filter::Base* filter_creator() { - return new yp2::filter::Template; + return new mp::filter::Template; } extern "C" { - struct yp2_filter_struct yp2_filter_template = { + struct metaproxy_1_filter_struct metaproxy_1_filter_template = { 0, "template", filter_creator diff --git a/src/filter_template.hpp b/src/filter_template.hpp index 0b437cb..e2941bb 100644 --- a/src/filter_template.hpp +++ b/src/filter_template.hpp @@ -1,5 +1,5 @@ -/* $Id: filter_template.hpp,v 1.4 2006-01-04 11:55:31 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: filter_template.hpp,v 1.5 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -12,7 +12,7 @@ #include "filter.hpp" -namespace yp2 { +namespace metaproxy_1 { namespace filter { class Template : public Base { class Rep; @@ -20,13 +20,13 @@ namespace yp2 { public: Template(); ~Template(); - void process(yp2::Package & package) const; + void process(metaproxy_1::Package & package) const; }; } } extern "C" { - extern struct yp2_filter_struct yp2_filter_template; + extern struct metaproxy_1_filter_struct metaproxy_1_filter_template; } #endif diff --git a/src/filter_virt_db.cpp b/src/filter_virt_db.cpp index 7947c6b..fdbe827 100644 --- a/src/filter_virt_db.cpp +++ b/src/filter_virt_db.cpp @@ -1,5 +1,5 @@ -/* $Id: filter_virt_db.cpp,v 1.35 2006-02-02 11:33:46 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: filter_virt_db.cpp,v 1.36 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -23,9 +23,10 @@ #include #include -namespace yf = yp2::filter; +namespace mp = metaproxy_1; +namespace yf = mp::filter; -namespace yp2 { +namespace metaproxy_1 { namespace filter { struct Virt_db::Set { @@ -43,7 +44,7 @@ namespace yp2 { std::string m_route; }; struct Virt_db::Backend { - yp2::Session m_backend_session; + mp::Session m_backend_session; std::list m_frontend_databases; std::list m_targets; std::string m_route; @@ -53,7 +54,7 @@ namespace yp2 { struct Virt_db::Frontend { Frontend(Rep *rep); ~Frontend(); - yp2::Session m_session; + mp::Session m_session; bool m_is_virtual; bool m_in_use; yazpp_1::GDU m_init_gdu; @@ -93,12 +94,12 @@ namespace yp2 { boost::mutex m_mutex; boost::condition m_cond_session_ready; - std::map m_clients; + std::map m_clients; }; } } -using namespace yp2; +using namespace mp; yf::Virt_db::BackendPtr yf::Virt_db::Frontend::lookup_backend_from_databases( std::list databases) @@ -170,11 +171,11 @@ yf::Virt_db::BackendPtr yf::Virt_db::Frontend::init_backend( Package init_package(b->m_backend_session, package.origin()); init_package.copy_filter(package); - yp2::odr odr; + mp::odr odr; Z_APDU *init_apdu = zget_APDU(odr, Z_APDU_initRequest); - yp2::util::set_vhost_otherinfo(&init_apdu->u.initRequest->otherInfo, odr, + mp::util::set_vhost_otherinfo(&init_apdu->u.initRequest->otherInfo, odr, b->m_targets); Z_InitRequest *req = init_apdu->u.initRequest; @@ -212,7 +213,7 @@ yf::Virt_db::BackendPtr yf::Virt_db::Frontend::init_backend( } if (!*res->result) { - yp2::util::get_init_diagnostics(res, error_code, addinfo); + mp::util::get_init_diagnostics(res, error_code, addinfo); BackendPtr null; return null; } @@ -241,7 +242,7 @@ void yf::Virt_db::Frontend::search(Package &package, Z_APDU *apdu_req) Z_SearchRequest *req = apdu_req->u.searchRequest; std::string vhost; std::string resultSetId = req->resultSetName; - yp2::odr odr; + mp::odr odr; std::list databases; int i; @@ -336,7 +337,7 @@ void yf::Virt_db::Frontend::search(Package &package, Z_APDU *apdu_req) std::list::const_iterator t_it = b->m_targets.begin(); if (t_it != b->m_targets.end()) { - yp2::util::set_databases_from_zurl(odr, *t_it, + mp::util::set_databases_from_zurl(odr, *t_it, &req->num_databaseNames, &req->databaseNames); } @@ -388,7 +389,7 @@ yf::Virt_db::FrontendPtr yf::Virt_db::Rep::get_frontend(Package &package) { boost::mutex::scoped_lock lock(m_mutex); - std::map::iterator it; + std::map::iterator it; while(true) { @@ -412,7 +413,7 @@ yf::Virt_db::FrontendPtr yf::Virt_db::Rep::get_frontend(Package &package) void yf::Virt_db::Rep::release_frontend(Package &package) { boost::mutex::scoped_lock lock(m_mutex); - std::map::iterator it; + std::map::iterator it; it = m_clients.find(package.session()); if (it != m_clients.end()) @@ -465,7 +466,7 @@ void yf::Virt_db::Frontend::present(Package &package, Z_APDU *apdu_req) { Z_PresentRequest *req = apdu_req->u.presentRequest; std::string resultSetId = req->resultSetId; - yp2::odr odr; + mp::odr odr; Sets_it sets_it = m_sets.find(resultSetId); if (sets_it == m_sets.end()) @@ -479,7 +480,7 @@ void yf::Virt_db::Frontend::present(Package &package, Z_APDU *apdu_req) return; } Session *id = - new yp2::Session(sets_it->second.m_backend->m_backend_session); + new mp::Session(sets_it->second.m_backend->m_backend_session); // sending present to backend Package present_package(*id, package.origin()); @@ -508,7 +509,7 @@ void yf::Virt_db::Frontend::scan(Package &package, Z_APDU *apdu_req) { Z_ScanRequest *req = apdu_req->u.scanRequest; std::string vhost; - yp2::odr odr; + mp::odr odr; std::list databases; int i; @@ -552,7 +553,7 @@ void yf::Virt_db::Frontend::scan(Package &package, Z_APDU *apdu_req) std::list::const_iterator t_it = b->m_targets.begin(); if (t_it != b->m_targets.end()) { - yp2::util::set_databases_from_zurl(odr, *t_it, + mp::util::set_databases_from_zurl(odr, *t_it, &req->num_databaseNames, &req->databaseNames); } @@ -600,12 +601,12 @@ void yf::Virt_db::process(Package &package) const Z_InitRequest *req = gdu->u.z3950->u.initRequest; std::list vhosts; - yp2::util::get_vhost_otherinfo(&req->otherInfo, false, vhosts); + mp::util::get_vhost_otherinfo(&req->otherInfo, false, vhosts); if (vhosts.size() == 0) { f->m_init_gdu = gdu; - yp2::odr odr; + mp::odr odr; Z_APDU *apdu = odr.create_initResponse(gdu->u.z3950, 0, 0); Z_InitResponse *resp = apdu->u.initResponse; @@ -646,7 +647,7 @@ void yf::Virt_db::process(Package &package) const Z_APDU *apdu = gdu->u.z3950; if (apdu->which == Z_APDU_initRequest) { - yp2::odr odr; + mp::odr odr; package.response() = odr.create_close( apdu, @@ -669,7 +670,7 @@ void yf::Virt_db::process(Package &package) const } else { - yp2::odr odr; + mp::odr odr; package.response() = odr.create_close( apdu, Z_Close_protocolError, @@ -682,7 +683,7 @@ void yf::Virt_db::process(Package &package) const } -void yp2::filter::Virt_db::configure(const xmlNode * ptr) +void mp::filter::Virt_db::configure(const xmlNode * ptr) { for (ptr = ptr->children; ptr; ptr = ptr->next) { @@ -698,23 +699,23 @@ void yp2::filter::Virt_db::configure(const xmlNode * ptr) if (v_node->type != XML_ELEMENT_NODE) continue; - if (yp2::xml::is_element_yp2(v_node, "database")) - database = yp2::xml::get_text(v_node); - else if (yp2::xml::is_element_yp2(v_node, "target")) - targets.push_back(yp2::xml::get_text(v_node)); + if (mp::xml::is_element_yp2(v_node, "database")) + database = mp::xml::get_text(v_node); + else if (mp::xml::is_element_yp2(v_node, "target")) + targets.push_back(mp::xml::get_text(v_node)); else - throw yp2::filter::FilterException + throw mp::filter::FilterException ("Bad element " + std::string((const char *) v_node->name) + " in virtual section" ); } - std::string route = yp2::xml::get_route(ptr); + std::string route = mp::xml::get_route(ptr); add_map_db2targets(database, targets, route); } else { - throw yp2::filter::FilterException + throw mp::filter::FilterException ("Bad element " + std::string((const char *) ptr->name) + " in virt_db filter"); @@ -722,13 +723,13 @@ void yp2::filter::Virt_db::configure(const xmlNode * ptr) } } -static yp2::filter::Base* filter_creator() +static mp::filter::Base* filter_creator() { - return new yp2::filter::Virt_db; + return new mp::filter::Virt_db; } extern "C" { - struct yp2_filter_struct yp2_filter_virt_db = { + struct metaproxy_1_filter_struct metaproxy_1_filter_virt_db = { 0, "virt_db", filter_creator diff --git a/src/filter_virt_db.hpp b/src/filter_virt_db.hpp index 0ae5b26..447b2eb 100644 --- a/src/filter_virt_db.hpp +++ b/src/filter_virt_db.hpp @@ -1,5 +1,5 @@ -/* $Id: filter_virt_db.hpp,v 1.14 2006-02-02 11:33:46 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: filter_virt_db.hpp,v 1.15 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -14,7 +14,7 @@ #include "filter.hpp" -namespace yp2 { +namespace metaproxy_1 { namespace filter { class Virt_db : public Base { class Rep; @@ -27,7 +27,7 @@ namespace yp2 { public: ~Virt_db(); Virt_db(); - void process(yp2::Package & package) const; + void process(metaproxy_1::Package & package) const; void configure(const xmlNode * ptr); void add_map_db2targets(std::string db, std::list targets, @@ -42,7 +42,7 @@ namespace yp2 { } extern "C" { - extern struct yp2_filter_struct yp2_filter_virt_db; + extern struct metaproxy_1_filter_struct metaproxy_1_filter_virt_db; } #endif diff --git a/src/filter_z3950_client.cpp b/src/filter_z3950_client.cpp index 13e25d7..0c775e7 100644 --- a/src/filter_z3950_client.cpp +++ b/src/filter_z3950_client.cpp @@ -1,5 +1,5 @@ -/* $Id: filter_z3950_client.cpp,v 1.23 2006-01-17 17:55:18 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: filter_z3950_client.cpp,v 1.24 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -28,9 +28,10 @@ #include #include -namespace yf = yp2::filter; +namespace mp = metaproxy_1; +namespace yf = mp::filter; -namespace yp2 { +namespace metaproxy_1 { namespace filter { class Z3950Client::Assoc : public yazpp_1::Z_Assoc{ friend class Rep; @@ -64,7 +65,7 @@ namespace yp2 { int m_timeout_sec; boost::mutex m_mutex; boost::condition m_cond_session_ready; - std::map m_clients; + std::map m_clients; Z3950Client::Assoc *get_assoc(Package &package); void send_and_receive(Package &package, yf::Z3950Client::Assoc *c); @@ -73,7 +74,7 @@ namespace yp2 { } } -using namespace yp2; +using namespace mp; yf::Z3950Client::Assoc::Assoc(yazpp_1::SocketManager *socket_manager, yazpp_1::IPDU_Observable *PDU_Observable, @@ -104,7 +105,7 @@ void yf::Z3950Client::Assoc::failNotify() { m_waiting = false; - yp2::odr odr; + mp::odr odr; if (m_package) { @@ -125,7 +126,7 @@ void yf::Z3950Client::Assoc::timeoutNotify() { m_waiting = false; - yp2::odr odr; + mp::odr odr; if (m_package) { @@ -175,7 +176,7 @@ yf::Z3950Client::Assoc *yf::Z3950Client::Rep::get_assoc(Package &package) // only one thread messes with the clients list at a time boost::mutex::scoped_lock lock(m_mutex); - std::map::iterator it; + std::map::iterator it; Z_GDU *gdu = package.request().get(); // only deal with Z39.50 @@ -214,7 +215,7 @@ yf::Z3950Client::Assoc *yf::Z3950Client::Rep::get_assoc(Package &package) // check that it is init. If not, close if (apdu->which != Z_APDU_initRequest) { - yp2::odr odr; + mp::odr odr; package.response() = odr.create_close(apdu, Z_Close_protocolError, @@ -224,12 +225,12 @@ yf::Z3950Client::Assoc *yf::Z3950Client::Rep::get_assoc(Package &package) return 0; } std::list vhosts; - yp2::util::get_vhost_otherinfo(&apdu->u.initRequest->otherInfo, + mp::util::get_vhost_otherinfo(&apdu->u.initRequest->otherInfo, true, vhosts); size_t no_vhosts = vhosts.size(); if (no_vhosts == 0) { - yp2::odr odr; + mp::odr odr; package.response() = odr.create_initResponse( apdu, YAZ_BIB1_INIT_NEGOTIATION_OPTION_REQUIRED, @@ -240,7 +241,7 @@ yf::Z3950Client::Assoc *yf::Z3950Client::Rep::get_assoc(Package &package) } if (no_vhosts > 1) { - yp2::odr odr; + mp::odr odr; package.response() = odr.create_initResponse( apdu, YAZ_BIB1_COMBI_OF_SPECIFIED_DATABASES_UNSUPP, @@ -251,7 +252,7 @@ yf::Z3950Client::Assoc *yf::Z3950Client::Rep::get_assoc(Package &package) std::list::const_iterator v_it = vhosts.begin(); std::list dblist; std::string host; - yp2::util::split_zurl(*v_it, host, dblist); + mp::util::split_zurl(*v_it, host, dblist); if (dblist.size()) { @@ -320,7 +321,7 @@ void yf::Z3950Client::Rep::send_and_receive(Package &package, void yf::Z3950Client::Rep::release_assoc(Package &package) { boost::mutex::scoped_lock lock(m_mutex); - std::map::iterator it; + std::map::iterator it; it = m_clients.find(package.session()); if (it != m_clients.end()) @@ -370,29 +371,29 @@ void yf::Z3950Client::configure(const xmlNode *ptr) continue; if (!strcmp((const char *) ptr->name, "timeout")) { - std::string timeout_str = yp2::xml::get_text(ptr); + std::string timeout_str = mp::xml::get_text(ptr); int timeout_sec = atoi(timeout_str.c_str()); if (timeout_sec < 2) - throw yp2::filter::FilterException("Bad timeout value " + throw mp::filter::FilterException("Bad timeout value " + timeout_str); m_p->m_timeout_sec = timeout_sec; } else { - throw yp2::filter::FilterException("Bad element " + throw mp::filter::FilterException("Bad element " + std::string((const char *) ptr->name)); } } } -static yp2::filter::Base* filter_creator() +static mp::filter::Base* filter_creator() { - return new yp2::filter::Z3950Client; + return new mp::filter::Z3950Client; } extern "C" { - struct yp2_filter_struct yp2_filter_z3950_client = { + struct metaproxy_1_filter_struct metaproxy_1_filter_z3950_client = { 0, "z3950_client", filter_creator diff --git a/src/filter_z3950_client.hpp b/src/filter_z3950_client.hpp index 077805e..8c94349 100644 --- a/src/filter_z3950_client.hpp +++ b/src/filter_z3950_client.hpp @@ -1,5 +1,5 @@ -/* $Id: filter_z3950_client.hpp,v 1.8 2006-01-09 18:19:09 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: filter_z3950_client.hpp,v 1.9 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -11,7 +11,7 @@ #include "filter.hpp" -namespace yp2 { +namespace metaproxy_1 { namespace filter { class Z3950Client : public Base { class Rep; @@ -19,7 +19,7 @@ namespace yp2 { public: ~Z3950Client(); Z3950Client(); - void process(yp2::Package & package) const; + void process(metaproxy_1::Package & package) const; void configure(const xmlNode * ptr); private: boost::scoped_ptr m_p; @@ -28,7 +28,7 @@ namespace yp2 { } extern "C" { - extern struct yp2_filter_struct yp2_filter_z3950_client; + extern struct metaproxy_1_filter_struct metaproxy_1_filter_z3950_client; } #endif diff --git a/src/metaproxy_prog.cpp b/src/metaproxy_prog.cpp new file mode 100644 index 0000000..9151d0b --- /dev/null +++ b/src/metaproxy_prog.cpp @@ -0,0 +1,99 @@ +/* $Id: metaproxy_prog.cpp,v 1.1 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. + +%LICENSE% + */ + +#include "config.hpp" + +#include +namespace po = boost::program_options; + +#include +#include + +#include "filter.hpp" +#include "package.hpp" +#include "router_flexml.hpp" +#include "factory_static.hpp" + +namespace mp = metaproxy_1; + +int main(int argc, char **argv) +{ + try + { + po::options_description desc("Allowed options"); + desc.add_options() + ("help", "produce help message") + ("config", po::value< std::vector >(), "xml config") + ; + + po::positional_options_description p; + p.add("config", -1); + + po::variables_map vm; + po::store(po::command_line_parser(argc, argv). + options(desc).positional(p).run(), vm); + po::notify(vm); + + if (vm.count("help")) { + std::cout << desc << "\n"; + return 1; + } + + xmlDocPtr doc = 0; + if (vm.count("config")) + { + std::vector config_fnames = + vm["config"].as< std::vector >(); + + if (config_fnames.size() != 1) + { + std::cerr << "Only one configuration must be given\n"; + std::exit(1); + } + + doc = xmlParseFile(config_fnames[0].c_str()); + if (!doc) + { + std::cerr << "xmlParseFile failed\n"; + std::exit(1); + } + } + else + { + std::cerr << "No configuration given\n"; + std::exit(1); + } + if (doc) + { + try { + mp::FactoryStatic factory; + mp::RouterFleXML router(doc, factory); + mp::Package pack; + pack.router(router).move(); + } + catch (std::runtime_error &e) { + std::cout << "std::runtime error: " << e.what() << "\n"; + exit(1); + } + xmlFreeDoc(doc); + } + } + catch ( ... ) { + std::cerr << "Unknown Exception" << std::endl; + std::exit(1); + } + std::exit(0); +} + + +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * c-file-style: "stroustrup" + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ diff --git a/src/package.cpp b/src/package.cpp index 2e3276b..1277b39 100644 --- a/src/package.cpp +++ b/src/package.cpp @@ -1,5 +1,5 @@ -/* $Id: package.cpp,v 1.6 2006-01-11 11:51:50 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: package.cpp,v 1.7 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -8,30 +8,32 @@ #include "package.hpp" -yp2::Package::Package() +namespace mp = metaproxy_1; + +mp::Package::Package() : m_route_pos(0), m_data(0) { } -yp2::Package::~Package() +mp::Package::~Package() { delete m_route_pos; } -yp2::Package::Package(yp2::Session &session, yp2::Origin &origin) +mp::Package::Package(mp::Session &session, mp::Origin &origin) : m_session(session), m_origin(origin), m_route_pos(0), m_data(0) { } -yp2::Package & yp2::Package::copy_filter(const Package &p) +mp::Package & mp::Package::copy_filter(const Package &p) { m_route_pos = p.m_route_pos->clone(); return *this; } -void yp2::Package::move() +void mp::Package::move() { if (m_route_pos) { @@ -41,7 +43,7 @@ void yp2::Package::move() } } -void yp2::Package::move(std::string route) +void mp::Package::move(std::string route) { if (m_route_pos) { @@ -53,62 +55,62 @@ void yp2::Package::move(std::string route) } -yp2::Session & yp2::Package::session() +mp::Session & mp::Package::session() { return m_session; } -int yp2::Package::data() const +int mp::Package::data() const { return m_data; } -int & yp2::Package::data() +int & mp::Package::data() { return m_data; } -yp2::Package & yp2::Package::data(const int & data) +mp::Package & mp::Package::data(const int & data) { m_data = data; return *this; } -yp2::Origin yp2::Package::origin() const +mp::Origin mp::Package::origin() const { return m_origin; } -yp2::Origin & yp2::Package::origin() +mp::Origin & mp::Package::origin() { return m_origin; } -yp2::Package & yp2::Package::origin(const Origin & origin) +mp::Package & mp::Package::origin(const Origin & origin) { m_origin = origin; return *this; } -yp2::Package & yp2::Package::router(const yp2::Router &router) +mp::Package & mp::Package::router(const mp::Router &router) { m_route_pos = router.createpos(); return *this; } -yazpp_1::GDU &yp2::Package::request() +yazpp_1::GDU &mp::Package::request() { return m_request_gdu; } -yazpp_1::GDU &yp2::Package::response() +yazpp_1::GDU &mp::Package::response() { return m_response_gdu; } -yp2::Session yp2::Package::session() const +mp::Session mp::Package::session() const { return m_session; } diff --git a/src/package.hpp b/src/package.hpp index ee9516b..60855db 100644 --- a/src/package.hpp +++ b/src/package.hpp @@ -1,5 +1,5 @@ -/* $Id: package.hpp,v 1.14 2006-01-11 11:51:50 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: package.hpp,v 1.15 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -15,7 +15,7 @@ #include "filter.hpp" #include "session.hpp" -namespace yp2 { +namespace metaproxy_1 { class Origin { enum origin_t { @@ -35,7 +35,7 @@ namespace yp2 { ~Package(); - Package(yp2::Session &session, yp2::Origin &origin); + Package(metaproxy_1::Session &session, metaproxy_1::Origin &origin); Package & copy_filter(const Package &p); @@ -46,7 +46,7 @@ namespace yp2 { void move(std::string route); /// access session - left val in assignment - yp2::Session & session(); + metaproxy_1::Session & session(); /// get function - right val in assignment int data() const; diff --git a/src/pipe.cpp b/src/pipe.cpp index 42f009b..d43e466 100644 --- a/src/pipe.cpp +++ b/src/pipe.cpp @@ -1,5 +1,5 @@ -/* $Id: pipe.cpp,v 1.5 2005-11-10 23:10:42 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: pipe.cpp,v 1.6 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -41,7 +41,9 @@ #include "pipe.hpp" -namespace yp2 { +namespace mp = metaproxy_1; + +namespace metaproxy_1 { class Pipe::Rep : public boost::noncopyable { friend class Pipe; Rep(); @@ -52,7 +54,7 @@ namespace yp2 { }; } -using namespace yp2; +using namespace mp; void Pipe::Rep::close(int &fd) { diff --git a/src/pipe.hpp b/src/pipe.hpp index 8068438..38f85fe 100644 --- a/src/pipe.hpp +++ b/src/pipe.hpp @@ -1,5 +1,5 @@ -/* $Id: pipe.hpp,v 1.3 2005-11-07 22:04:15 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: pipe.hpp,v 1.4 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -13,7 +13,7 @@ #include -namespace yp2 { +namespace metaproxy_1 { class Pipe { class Error : public std::runtime_error { public: diff --git a/src/plainfile.cpp b/src/plainfile.cpp index 07361aa..38e2148 100644 --- a/src/plainfile.cpp +++ b/src/plainfile.cpp @@ -1,5 +1,5 @@ -/* $Id: plainfile.cpp,v 1.1 2006-01-25 11:27:19 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: plainfile.cpp,v 1.2 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -15,7 +15,9 @@ #define PLAINFILE_MAX_LINE 256 -namespace yp2 { +namespace mp = metaproxy_1; + +namespace metaproxy_1 { class PlainFile::Rep { friend class PlainFile; Rep(); @@ -25,28 +27,28 @@ namespace yp2 { }; } -yp2::PlainFile::Rep::Rep() : lineno(1) +mp::PlainFile::Rep::Rep() : lineno(1) { fh = 0; } -yp2::PlainFile::PlainFile() : m_p(new Rep) +mp::PlainFile::PlainFile() : m_p(new Rep) { } -void yp2::PlainFile::Rep::close() +void mp::PlainFile::Rep::close() { delete fh; fh = 0; lineno = 0; } -yp2::PlainFile::~PlainFile() +mp::PlainFile::~PlainFile() { m_p->close(); } -bool yp2::PlainFile::open(const std::string &fname) +bool mp::PlainFile::open(const std::string &fname) { m_p->close(); @@ -60,7 +62,7 @@ bool yp2::PlainFile::open(const std::string &fname) return true; } -bool yp2::PlainFile::getline(std::vector &args) +bool mp::PlainFile::getline(std::vector &args) { args.clear(); diff --git a/src/router.hpp b/src/router.hpp index 5c5ce07..d59b741 100644 --- a/src/router.hpp +++ b/src/router.hpp @@ -1,5 +1,5 @@ -/* $Id: router.hpp,v 1.10 2006-01-11 11:51:50 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: router.hpp,v 1.11 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -11,7 +11,7 @@ #include #include -namespace yp2 +namespace metaproxy_1 { namespace filter { class Base; diff --git a/src/router_chain.cpp b/src/router_chain.cpp index 0114fd2..b58b481 100644 --- a/src/router_chain.cpp +++ b/src/router_chain.cpp @@ -1,5 +1,5 @@ -/* $Id: router_chain.cpp,v 1.5 2006-01-11 11:51:50 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: router_chain.cpp,v 1.6 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -8,7 +8,9 @@ #include -namespace yp2 +namespace mp = metaproxy_1; + +namespace metaproxy_1 { class ChainPos; @@ -23,49 +25,49 @@ namespace yp2 virtual RoutePos *clone(); virtual ~Pos(); std::list::const_iterator it; - yp2::RouterChain::Rep *m_p; + mp::RouterChain::Rep *m_p; }; } -yp2::RouterChain::RouterChain() : m_p(new yp2::RouterChain::Rep) +mp::RouterChain::RouterChain() : m_p(new mp::RouterChain::Rep) { } -yp2::RouterChain::~RouterChain() +mp::RouterChain::~RouterChain() { } -const yp2::filter::Base *yp2::RouterChain::Pos::move(const char *route) +const mp::filter::Base *mp::RouterChain::Pos::move(const char *route) { if (it == m_p->m_filter_list.end()) return 0; - const yp2::filter::Base *f = *it; + const mp::filter::Base *f = *it; it++; return f; } -yp2::RoutePos *yp2::RouterChain::createpos() const +mp::RoutePos *mp::RouterChain::createpos() const { - yp2::RouterChain::Pos *p = new yp2::RouterChain::Pos; + mp::RouterChain::Pos *p = new mp::RouterChain::Pos; p->it = m_p->m_filter_list.begin(); p->m_p = m_p.get(); return p; } -yp2::RoutePos *yp2::RouterChain::Pos::clone() +mp::RoutePos *mp::RouterChain::Pos::clone() { - yp2::RouterChain::Pos *p = new yp2::RouterChain::Pos; + mp::RouterChain::Pos *p = new mp::RouterChain::Pos; p->it = it; p->m_p = m_p; return p; } -yp2::RouterChain::Pos::~Pos() +mp::RouterChain::Pos::~Pos() { } -yp2::RouterChain & yp2::RouterChain::append(const filter::Base &filter) +mp::RouterChain & mp::RouterChain::append(const filter::Base &filter) { m_p->m_filter_list.push_back(&filter); return *this; diff --git a/src/router_chain.hpp b/src/router_chain.hpp index a05eb37..21a423c 100644 --- a/src/router_chain.hpp +++ b/src/router_chain.hpp @@ -1,5 +1,5 @@ -/* $Id: router_chain.hpp,v 1.5 2006-01-09 13:53:13 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: router_chain.hpp,v 1.6 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -13,7 +13,7 @@ #include #include -namespace yp2 { +namespace metaproxy_1 { class RouterChain : public Router { class Rep; class Pos; diff --git a/src/router_flexml.cpp b/src/router_flexml.cpp index 69953e0..c029fa2 100644 --- a/src/router_flexml.cpp +++ b/src/router_flexml.cpp @@ -1,5 +1,5 @@ -/* $Id: router_flexml.cpp,v 1.16 2006-01-19 09:41:01 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: router_flexml.cpp,v 1.17 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -20,23 +20,24 @@ #include #include +namespace mp = metaproxy_1; -namespace yp2 { +namespace metaproxy_1 { class RouterFleXML::Route { friend class RouterFleXML::Rep; friend class RouterFleXML::Pos; friend class RouterFleXML; - std::list > m_list; + std::list > m_list; }; class RouterFleXML::Rep { friend class RouterFleXML; friend class RouterFleXML::Pos; Rep(); - void base(xmlDocPtr doc, yp2::FactoryFilter &factory); + void base(xmlDocPtr doc, mp::FactoryFilter &factory); typedef std::map > + boost::shared_ptr > IdFilterMap ; IdFilterMap m_id_filter_map; @@ -62,19 +63,19 @@ namespace yp2 { virtual const filter::Base *move(const char *route); virtual RoutePos *clone(); virtual ~Pos(); - yp2::RouterFleXML::Rep *m_p; + mp::RouterFleXML::Rep *m_p; std::map::iterator m_route_it; - std::list >::iterator m_filter_it; + std::list >::iterator m_filter_it; }; } -void yp2::RouterFleXML::Rep::parse_xml_filters(xmlDocPtr doc, +void mp::RouterFleXML::Rep::parse_xml_filters(xmlDocPtr doc, const xmlNode *node) { unsigned int filter_nr = 0; - while(node && yp2::xml::check_element_yp2(node, "filter")) + while(node && mp::xml::check_element_yp2(node, "filter")) { filter_nr++; @@ -94,7 +95,7 @@ void yp2::RouterFleXML::Rep::parse_xml_filters(xmlDocPtr doc, else if (name == "type") type_value = value; else - throw yp2::XMLError("Only attribute id or type allowed" + throw mp::XMLError("Only attribute id or type allowed" " in filter element. Got " + name); } @@ -104,27 +105,27 @@ void yp2::RouterFleXML::Rep::parse_xml_filters(xmlDocPtr doc, m_dl_path << "\n"; m_factory->add_creator_dl(type_value, m_dl_path); } - yp2::filter::Base* filter_base = m_factory->create(type_value); + mp::filter::Base* filter_base = m_factory->create(type_value); filter_base->configure(node); if (m_id_filter_map.find(id_value) != m_id_filter_map.end()) - throw yp2::XMLError("Filter " + id_value + " already defined"); + throw mp::XMLError("Filter " + id_value + " already defined"); m_id_filter_map[id_value] = - boost::shared_ptr(filter_base); + boost::shared_ptr(filter_base); - node = yp2::xml::jump_to_next(node, XML_ELEMENT_NODE); + node = mp::xml::jump_to_next(node, XML_ELEMENT_NODE); } } -void yp2::RouterFleXML::Rep::parse_xml_routes(xmlDocPtr doc, +void mp::RouterFleXML::Rep::parse_xml_routes(xmlDocPtr doc, const xmlNode *node) { - yp2::xml::check_element_yp2(node, "route"); + mp::xml::check_element_yp2(node, "route"); unsigned int route_nr = 0; - while(yp2::xml::is_element_yp2(node, "route")) + while(mp::xml::is_element_yp2(node, "route")) { route_nr++; @@ -141,7 +142,7 @@ void yp2::RouterFleXML::Rep::parse_xml_routes(xmlDocPtr doc, if (name == "id") id_value = value; else - throw yp2::XMLError("Only attribute 'id' allowed for" + throw mp::XMLError("Only attribute 'id' allowed for" " element 'route'." " Got " + name); } @@ -149,10 +150,10 @@ void yp2::RouterFleXML::Rep::parse_xml_routes(xmlDocPtr doc, Route route; // process nodes in third level - const xmlNode* node3 = yp2::xml::jump_to_children(node, XML_ELEMENT_NODE); + const xmlNode* node3 = mp::xml::jump_to_children(node, XML_ELEMENT_NODE); unsigned int filter3_nr = 0; - while(node3 && yp2::xml::check_element_yp2(node3, "filter")) + while(node3 && mp::xml::check_element_yp2(node3, "filter")) { filter3_nr++; @@ -172,17 +173,17 @@ void yp2::RouterFleXML::Rep::parse_xml_routes(xmlDocPtr doc, else if (name == "type") type_value = value; else - throw yp2::XMLError("Only attribute 'refid' or 'type'" + throw mp::XMLError("Only attribute 'refid' or 'type'" " allowed for element 'filter'." " Got " + name); } if (refid_value.length()) { std::map >::iterator it; + boost::shared_ptr >::iterator it; it = m_id_filter_map.find(refid_value); if (it == m_id_filter_map.end()) - throw yp2::XMLError("Unknown filter refid " + throw mp::XMLError("Unknown filter refid " + refid_value); else route.m_list.push_back(it->second); @@ -195,45 +196,45 @@ void yp2::RouterFleXML::Rep::parse_xml_routes(xmlDocPtr doc, m_dl_path << "\n"; m_factory->add_creator_dl(type_value, m_dl_path); } - yp2::filter::Base* filter_base = m_factory->create(type_value); + mp::filter::Base* filter_base = m_factory->create(type_value); filter_base->configure(node3); route.m_list.push_back( - boost::shared_ptr(filter_base)); + boost::shared_ptr(filter_base)); } - node3 = yp2::xml::jump_to_next(node3, XML_ELEMENT_NODE); + node3 = mp::xml::jump_to_next(node3, XML_ELEMENT_NODE); } std::map::iterator it; it = m_routes.find(id_value); if (it != m_routes.end()) - throw yp2::XMLError("Route id='" + id_value + throw mp::XMLError("Route id='" + id_value + "' already exist"); else m_routes[id_value] = route; - node = yp2::xml::jump_to_next(node, XML_ELEMENT_NODE); + node = mp::xml::jump_to_next(node, XML_ELEMENT_NODE); } } -void yp2::RouterFleXML::Rep::parse_xml_config_dom(xmlDocPtr doc) +void mp::RouterFleXML::Rep::parse_xml_config_dom(xmlDocPtr doc) { if (!doc) - throw yp2::XMLError("Empty XML Document"); + throw mp::XMLError("Empty XML Document"); const xmlNode* root = xmlDocGetRootElement(doc); - yp2::xml::check_element_yp2(root, "yp2"); + mp::xml::check_element_yp2(root, "yp2"); - const xmlNode* node = yp2::xml::jump_to_children(root, XML_ELEMENT_NODE); + const xmlNode* node = mp::xml::jump_to_children(root, XML_ELEMENT_NODE); - if (yp2::xml::is_element_yp2(node, "dlpath")) + if (mp::xml::is_element_yp2(node, "dlpath")) { - m_dl_path = yp2::xml::get_text(node); - node = yp2::xml::jump_to_next(node, XML_ELEMENT_NODE); + m_dl_path = mp::xml::get_text(node); + node = mp::xml::jump_to_next(node, XML_ELEMENT_NODE); } // process node which is expected first element node - if (yp2::xml::check_element_yp2(node, "start")) + if (mp::xml::check_element_yp2(node, "start")) { const struct _xmlAttr *attr; std::string id_value; @@ -248,50 +249,50 @@ void yp2::RouterFleXML::Rep::parse_xml_config_dom(xmlDocPtr doc) if (name == "route") m_start_route = value; else - throw yp2::XMLError("Only attribute start allowed" + throw mp::XMLError("Only attribute start allowed" " in element 'start'. Got " + name); } - node = yp2::xml::jump_to_next(node, XML_ELEMENT_NODE); + node = mp::xml::jump_to_next(node, XML_ELEMENT_NODE); } // process node if given - if (yp2::xml::is_element_yp2(node, "filters")) + if (mp::xml::is_element_yp2(node, "filters")) { - parse_xml_filters(doc, yp2::xml::jump_to_children(node, + parse_xml_filters(doc, mp::xml::jump_to_children(node, XML_ELEMENT_NODE)); - node = yp2::xml::jump_to_next(node, XML_ELEMENT_NODE); + node = mp::xml::jump_to_next(node, XML_ELEMENT_NODE); } // process node which is expected third element node - yp2::xml::check_element_yp2(node, "routes"); + mp::xml::check_element_yp2(node, "routes"); - parse_xml_routes(doc, yp2::xml::jump_to_children(node, XML_ELEMENT_NODE)); + parse_xml_routes(doc, mp::xml::jump_to_children(node, XML_ELEMENT_NODE)); - node = yp2::xml::jump_to_next(node, XML_ELEMENT_NODE); + node = mp::xml::jump_to_next(node, XML_ELEMENT_NODE); if (node) { - throw yp2::XMLError("Unexpected element " + throw mp::XMLError("Unexpected element " + std::string((const char *)node->name)); } } -yp2::RouterFleXML::Rep::Rep() : m_xinclude(false) +mp::RouterFleXML::Rep::Rep() : m_xinclude(false) { } -void yp2::RouterFleXML::Rep::base(xmlDocPtr doc, yp2::FactoryFilter &factory) +void mp::RouterFleXML::Rep::base(xmlDocPtr doc, mp::FactoryFilter &factory) { m_factory = &factory; parse_xml_config_dom(doc); m_start_route = "start"; } -yp2::RouterFleXML::RouterFleXML(xmlDocPtr doc, yp2::FactoryFilter &factory) +mp::RouterFleXML::RouterFleXML(xmlDocPtr doc, mp::FactoryFilter &factory) : m_p(new Rep) { m_p->base(doc, factory); } -yp2::RouterFleXML::RouterFleXML(std::string xmlconf, yp2::FactoryFilter &factory) +mp::RouterFleXML::RouterFleXML(std::string xmlconf, mp::FactoryFilter &factory) : m_p(new Rep) { LIBXML_TEST_VERSION; @@ -299,7 +300,7 @@ yp2::RouterFleXML::RouterFleXML(std::string xmlconf, yp2::FactoryFilter &factory xmlDocPtr doc = xmlParseMemory(xmlconf.c_str(), xmlconf.size()); if (!doc) - throw yp2::XMLError("xmlParseMemory failed"); + throw mp::XMLError("xmlParseMemory failed"); else { m_p->base(doc, factory); @@ -307,11 +308,11 @@ yp2::RouterFleXML::RouterFleXML(std::string xmlconf, yp2::FactoryFilter &factory } } -yp2::RouterFleXML::~RouterFleXML() +mp::RouterFleXML::~RouterFleXML() { } -const yp2::filter::Base *yp2::RouterFleXML::Pos::move(const char *route) +const mp::filter::Base *mp::RouterFleXML::Pos::move(const char *route) { if (route && *route) { @@ -320,20 +321,20 @@ const yp2::filter::Base *yp2::RouterFleXML::Pos::move(const char *route) if (m_route_it == m_p->m_routes.end()) { std::cout << "no such route " << route << "\n"; - throw yp2::XMLError("bad route " + std::string(route)); + throw mp::XMLError("bad route " + std::string(route)); } m_filter_it = m_route_it->second.m_list.begin(); } if (m_filter_it == m_route_it->second.m_list.end()) return 0; - const yp2::filter::Base *f = (*m_filter_it).get(); + const mp::filter::Base *f = (*m_filter_it).get(); m_filter_it++; return f; } -yp2::RoutePos *yp2::RouterFleXML::createpos() const +mp::RoutePos *mp::RouterFleXML::createpos() const { - yp2::RouterFleXML::Pos *p = new yp2::RouterFleXML::Pos; + mp::RouterFleXML::Pos *p = new mp::RouterFleXML::Pos; p->m_route_it = m_p->m_routes.find(m_p->m_start_route); if (p->m_route_it == m_p->m_routes.end()) @@ -346,16 +347,16 @@ yp2::RoutePos *yp2::RouterFleXML::createpos() const return p; } -yp2::RoutePos *yp2::RouterFleXML::Pos::clone() +mp::RoutePos *mp::RouterFleXML::Pos::clone() { - yp2::RouterFleXML::Pos *p = new yp2::RouterFleXML::Pos; + mp::RouterFleXML::Pos *p = new mp::RouterFleXML::Pos; p->m_filter_it = m_filter_it; p->m_route_it = m_route_it; p->m_p = m_p; return p; } -yp2::RouterFleXML::Pos::~Pos() +mp::RouterFleXML::Pos::~Pos() { } diff --git a/src/router_flexml.hpp b/src/router_flexml.hpp index 6cd78e4..75b119f 100644 --- a/src/router_flexml.hpp +++ b/src/router_flexml.hpp @@ -1,5 +1,5 @@ -/* $Id: router_flexml.hpp,v 1.13 2006-01-11 11:51:50 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: router_flexml.hpp,v 1.14 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -15,16 +15,16 @@ #include -namespace yp2 +namespace metaproxy_1 { - class RouterFleXML : public yp2::Router + class RouterFleXML : public metaproxy_1::Router { class Rep; class Route; class Pos; public: - RouterFleXML(std::string xmlconf, yp2::FactoryFilter &factory); - RouterFleXML(xmlDocPtr doc, yp2::FactoryFilter &factory); + RouterFleXML(std::string xmlconf, metaproxy_1::FactoryFilter &factory); + RouterFleXML(xmlDocPtr doc, metaproxy_1::FactoryFilter &factory); ~RouterFleXML(); diff --git a/src/session.cpp b/src/session.cpp index a67cec0..f64e2da 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -1,5 +1,5 @@ -/* $Id: session.cpp,v 1.2 2005-10-15 14:09:09 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: session.cpp,v 1.3 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -11,9 +11,11 @@ #include "config.hpp" +namespace mp = metaproxy_1; + // defining and initializing static members -boost::mutex yp2::Session::m_mutex; -unsigned long int yp2::Session::m_global_id = 0; +boost::mutex mp::Session::m_mutex; +unsigned long int mp::Session::m_global_id = 0; /* * Local variables: diff --git a/src/session.hpp b/src/session.hpp index 95de4e0..eddd1b1 100644 --- a/src/session.hpp +++ b/src/session.hpp @@ -1,5 +1,5 @@ -/* $Id: session.hpp,v 1.11 2005-10-26 18:53:49 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: session.hpp,v 1.12 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -11,7 +11,7 @@ #include #include -namespace yp2 { +namespace metaproxy_1 { class Session { @@ -73,20 +73,20 @@ namespace yp2 { template class session_map { public: - void create(T &t, const yp2::Session &s) { + void create(T &t, const metaproxy_1::Session &s) { boost::mutex::scoped_lock lock(m_map_mutex); m_map[s] = SessionItem(t); }; - void release(const yp2::Session &s) { + void release(const metaproxy_1::Session &s) { boost::mutex::scoped_lock lock(m_map_mutex); m_map.erase(s); }; #if 0 - T &get_session_data(const yp2::Session &s) { + T &get_session_data(const metaproxy_1::Session &s) { boost::mutex::scoped_lock lock(m_map_mutex); - typename std::map::const_iterator it; + typename std::map::const_iterator it; it = m_map.find(s); if (it == m_map.end()) return 0; @@ -94,8 +94,8 @@ namespace yp2 { new boost::mutex::scoped_lock(it->second->m_item_mutex); }; #endif - bool exist(const yp2::Session &s) { - typename std::map::const_iterator it; + bool exist(const metaproxy_1::Session &s) { + typename std::map::const_iterator it; it = m_map.find(s); return it == m_map.end() ? false : true; } @@ -118,7 +118,7 @@ namespace yp2 { }; private: boost::mutex m_map_mutex; - std::mapm_map; + std::mapm_map; }; } diff --git a/src/test_boost_threads.cpp b/src/test_boost_threads.cpp index db30c39..f53dfe0 100644 --- a/src/test_boost_threads.cpp +++ b/src/test_boost_threads.cpp @@ -1,5 +1,5 @@ -/* $Id: test_boost_threads.cpp,v 1.6 2005-12-02 12:21:07 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: test_boost_threads.cpp,v 1.7 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ diff --git a/src/test_boost_time.cpp b/src/test_boost_time.cpp index fed4a27..af1db2a 100644 --- a/src/test_boost_time.cpp +++ b/src/test_boost_time.cpp @@ -1,5 +1,5 @@ -/* $Id: test_boost_time.cpp,v 1.6 2005-12-02 12:21:07 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: test_boost_time.cpp,v 1.7 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ diff --git a/src/test_filter1.cpp b/src/test_filter1.cpp index 162b209..2dd43aa 100644 --- a/src/test_filter1.cpp +++ b/src/test_filter1.cpp @@ -1,5 +1,5 @@ -/* $Id: test_filter1.cpp,v 1.14 2005-12-02 12:21:07 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: test_filter1.cpp,v 1.15 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -14,10 +14,11 @@ #include using namespace boost::unit_test; +namespace mp = metaproxy_1; -class TFilter: public yp2::filter::Base { +class TFilter: public mp::filter::Base { public: - void process(yp2::Package & package) const {}; + void process(mp::Package & package) const {}; }; diff --git a/src/test_filter2.cpp b/src/test_filter2.cpp index 12d6ef5..c5159dd 100644 --- a/src/test_filter2.cpp +++ b/src/test_filter2.cpp @@ -1,5 +1,5 @@ -/* $Id: test_filter2.cpp,v 1.17 2006-01-09 13:43:59 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: test_filter2.cpp,v 1.18 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -19,11 +19,12 @@ using namespace boost::unit_test; +namespace mp = metaproxy_1; -class FilterConstant: public yp2::filter::Base { +class FilterConstant: public mp::filter::Base { public: FilterConstant() : m_constant(1234) { }; - void process(yp2::Package & package) const { + void process(mp::Package & package) const { package.data() = m_constant; package.move(); }; @@ -109,9 +110,9 @@ bool FilterConstant::parse_xml_text(const xmlNode *xml_ptr, std::string &val) // This filter dose not have a configure function -class FilterDouble: public yp2::filter::Base { +class FilterDouble: public mp::filter::Base { public: - void process(yp2::Package & package) const { + void process(mp::Package & package) const { package.data() = package.data() * 2; package.move(); }; @@ -125,16 +126,16 @@ BOOST_AUTO_UNIT_TEST( testfilter2_1 ) FilterDouble fd; { - yp2::RouterChain router1; + mp::RouterChain router1; // test filter set/get/exception router1.append(fc); router1.append(fd); - yp2::Session session; - yp2::Origin origin; - yp2::Package pack(session, origin); + mp::Session session; + mp::Origin origin; + mp::Package pack(session, origin); pack.router(router1).move(); @@ -143,14 +144,14 @@ BOOST_AUTO_UNIT_TEST( testfilter2_1 ) } { - yp2::RouterChain router2; + mp::RouterChain router2; router2.append(fd); router2.append(fc); - yp2::Session session; - yp2::Origin origin; - yp2::Package pack(session, origin); + mp::Session session; + mp::Origin origin; + mp::Package pack(session, origin); pack.router(router2).move(); @@ -175,7 +176,7 @@ BOOST_AUTO_UNIT_TEST( testfilter2_2 ) FilterConstant fc; BOOST_CHECK_EQUAL(fc.get_constant(), 1234); - yp2::filter::Base *base = &fc; + mp::filter::Base *base = &fc; std::string some_xml = "\n" "\n" diff --git a/src/test_filter_auth_simple.cpp b/src/test_filter_auth_simple.cpp index 9517523..241e7af 100644 --- a/src/test_filter_auth_simple.cpp +++ b/src/test_filter_auth_simple.cpp @@ -1,5 +1,5 @@ -/* $Id: test_filter_auth_simple.cpp,v 1.1 2006-01-12 10:04:34 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: test_filter_auth_simple.cpp,v 1.2 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -18,10 +18,11 @@ #include using namespace boost::unit_test; +namespace mp = metaproxy_1; -class FilterBounceInit: public yp2::filter::Base { +class FilterBounceInit: public mp::filter::Base { public: - void process(yp2::Package & package) const { + void process(mp::Package & package) const { if (package.session().is_closed()) { @@ -32,7 +33,7 @@ public: if (gdu) { // std::cout << "Got PDU. Sending init response\n"; - yp2::odr odr; + mp::odr odr; Z_APDU *apdu = zget_APDU(odr, Z_APDU_initResponse); apdu->u.initResponse->implementationName = "YP2/YAZ"; @@ -48,7 +49,7 @@ BOOST_AUTO_UNIT_TEST( test_filter_auth_simple_1 ) { try { - yp2::filter::AuthSimple lf; + mp::filter::AuthSimple lf; } catch ( ... ) { BOOST_CHECK (false); @@ -59,18 +60,18 @@ BOOST_AUTO_UNIT_TEST( test_filter_auth_simple2 ) { try { - yp2::RouterChain router; + mp::RouterChain router; - yp2::filter::AuthSimple auth; + mp::filter::AuthSimple auth; FilterBounceInit bounce; router.append(auth); router.append(bounce); // Create package with Z39.50 init request in it - yp2::Package pack; + mp::Package pack; - yp2::odr odr; + mp::odr odr; Z_APDU *apdu = zget_APDU(odr, Z_APDU_initRequest); pack.request() = apdu; diff --git a/src/test_filter_backend_test.cpp b/src/test_filter_backend_test.cpp index d23ee5c..b209730 100644 --- a/src/test_filter_backend_test.cpp +++ b/src/test_filter_backend_test.cpp @@ -1,5 +1,5 @@ -/* $Id: test_filter_backend_test.cpp,v 1.6 2005-12-02 12:21:07 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: test_filter_backend_test.cpp,v 1.7 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -24,11 +24,13 @@ #include using namespace boost::unit_test; +namespace mp = metaproxy_1; + BOOST_AUTO_UNIT_TEST( test_filter_backend_test_1 ) { try { - yp2::filter::Backend_test btest; + mp::filter::Backend_test btest; } catch ( ... ) { BOOST_CHECK (false); @@ -39,14 +41,14 @@ BOOST_AUTO_UNIT_TEST( test_filter_backend_test_2 ) { try { - yp2::RouterChain router; + mp::RouterChain router; - yp2::filter::Backend_test btest; + mp::filter::Backend_test btest; router.append(btest); - yp2::Package pack; + mp::Package pack; - yp2::odr odr; + mp::odr odr; Z_APDU *apdu = zget_APDU(odr, Z_APDU_initRequest); BOOST_CHECK(apdu); @@ -77,19 +79,19 @@ BOOST_AUTO_UNIT_TEST( test_filter_backend_test_3 ) { try { - yp2::RouterChain router; + mp::RouterChain router; - yp2::filter::Backend_test btest; + mp::filter::Backend_test btest; router.append(btest); - yp2::Package pack; + mp::Package pack; // send search request as first request.. That should fail with // a close from the backend - yp2::odr odr; + mp::odr odr; Z_APDU *apdu = zget_APDU(odr, Z_APDU_searchRequest); - yp2::util::pqf(odr, apdu, "computer"); + mp::util::pqf(odr, apdu, "computer"); apdu->u.searchRequest->num_databaseNames = 1; apdu->u.searchRequest->databaseNames = (char**) @@ -124,16 +126,16 @@ BOOST_AUTO_UNIT_TEST( test_filter_backend_test_4 ) { try { - yp2::RouterChain router; + mp::RouterChain router; - yp2::filter::Backend_test btest; + mp::filter::Backend_test btest; router.append(btest); - yp2::Package pack; + mp::Package pack; // send present request as first request.. That should fail with // a close from the backend - yp2::odr odr; + mp::odr odr; Z_APDU *apdu = zget_APDU(odr, Z_APDU_presentRequest); BOOST_CHECK(apdu); diff --git a/src/test_filter_factory.cpp b/src/test_filter_factory.cpp index 3b6be2c..2aee42e 100644 --- a/src/test_filter_factory.cpp +++ b/src/test_filter_factory.cpp @@ -1,5 +1,5 @@ -/* $Id: test_filter_factory.cpp,v 1.11 2006-01-19 09:41:01 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: test_filter_factory.cpp,v 1.12 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -17,34 +17,35 @@ #include using namespace boost::unit_test; +namespace mp = metaproxy_1; // XFilter -class XFilter: public yp2::filter::Base { +class XFilter: public mp::filter::Base { public: - void process(yp2::Package & package) const; + void process(mp::Package & package) const; }; -void XFilter::process(yp2::Package & package) const +void XFilter::process(mp::Package & package) const { package.data() = 1; } -static yp2::filter::Base* xfilter_creator(){ +static mp::filter::Base* xfilter_creator(){ return new XFilter; } // YFilter ... -class YFilter: public yp2::filter::Base { +class YFilter: public mp::filter::Base { public: - void process(yp2::Package & package) const; + void process(mp::Package & package) const; }; -void YFilter::process(yp2::Package & package) const +void YFilter::process(mp::Package & package) const { package.data() = 2; } -static yp2::filter::Base* yfilter_creator(){ +static mp::filter::Base* yfilter_creator(){ return new YFilter; } @@ -52,7 +53,7 @@ BOOST_AUTO_UNIT_TEST( test_filter_factory_1 ) { try { - yp2::FactoryFilter ffactory; + mp::FactoryFilter ffactory; XFilter xf; YFilter yf; @@ -65,15 +66,15 @@ BOOST_AUTO_UNIT_TEST( test_filter_factory_1 ) BOOST_CHECK(ffactory.add_creator(xfid, xfilter_creator)); BOOST_CHECK(ffactory.add_creator(yfid, yfilter_creator)); - yp2::filter::Base* xfilter = 0; + mp::filter::Base* xfilter = 0; xfilter = ffactory.create(xfid); - yp2::filter::Base* yfilter = 0; + mp::filter::Base* yfilter = 0; yfilter = ffactory.create(yfid); BOOST_CHECK(0 != xfilter); BOOST_CHECK(0 != yfilter); - yp2::Package pack; + mp::Package pack; xfilter->process(pack); BOOST_CHECK_EQUAL(pack.data(), 1); @@ -91,7 +92,7 @@ BOOST_AUTO_UNIT_TEST( test_filter_factory_1 ) BOOST_AUTO_UNIT_TEST( test_filter_factory_2 ) { try { - yp2::FactoryFilter ffactory; + mp::FactoryFilter ffactory; const std::string id = "dl"; @@ -101,12 +102,12 @@ BOOST_AUTO_UNIT_TEST( test_filter_factory_2 ) // test double load BOOST_CHECK(ffactory.add_creator_dl(id, ".libs")); - yp2::filter::Base* filter = 0; + mp::filter::Base* filter = 0; filter = ffactory.create(id); BOOST_CHECK(0 != filter); - yp2::Package pack; + mp::Package pack; filter->process(pack); BOOST_CHECK_EQUAL(pack.data(), 42); // magic from filter_dl .. } diff --git a/src/test_filter_frontend_net.cpp b/src/test_filter_frontend_net.cpp index 4648222..9eaf40a 100644 --- a/src/test_filter_frontend_net.cpp +++ b/src/test_filter_frontend_net.cpp @@ -1,5 +1,5 @@ -/* $Id: test_filter_frontend_net.cpp,v 1.14 2005-12-02 12:21:07 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: test_filter_frontend_net.cpp,v 1.15 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -19,10 +19,11 @@ #include using namespace boost::unit_test; +namespace mp = metaproxy_1; -class FilterInit: public yp2::filter::Base { +class FilterInit: public mp::filter::Base { public: - void process(yp2::Package & package) const { + void process(mp::Package & package) const { if (package.session().is_closed()) { @@ -33,7 +34,7 @@ public: if (gdu) { // std::cout << "Got PDU. Sending init response\n"; - yp2::odr odr; + mp::odr odr; Z_APDU *apdu = zget_APDU(odr, Z_APDU_initResponse); apdu->u.initResponse->implementationName = "YP2/YAZ"; @@ -50,7 +51,7 @@ BOOST_AUTO_UNIT_TEST( test_filter_frontend_net_1 ) try { { - yp2::filter::FrontendNet nf; + mp::filter::FrontendNet nf; } } catch ( ... ) { @@ -63,16 +64,16 @@ BOOST_AUTO_UNIT_TEST( test_filter_frontend_net_2 ) try { { - yp2::RouterChain router; + mp::RouterChain router; FilterInit tf; router.append(tf); // Create package with Z39.50 init request in it - yp2::Package pack; + mp::Package pack; - yp2::odr odr; + mp::odr odr; Z_APDU *apdu = zget_APDU(odr, Z_APDU_initRequest); pack.request() = apdu; @@ -102,10 +103,10 @@ BOOST_AUTO_UNIT_TEST( test_filter_frontend_net_3 ) try { { - yp2::RouterChain router; + mp::RouterChain router; // put in frontend first - yp2::filter::FrontendNet filter_front; + mp::filter::FrontendNet filter_front; std::vector ports; ports.insert(ports.begin(), "unix:socket"); @@ -117,7 +118,7 @@ BOOST_AUTO_UNIT_TEST( test_filter_frontend_net_3 ) FilterInit filter_init; router.append(filter_init); - yp2::Package pack; + mp::Package pack; pack.router(router).move(); } diff --git a/src/test_filter_log.cpp b/src/test_filter_log.cpp index 1cbf651..b5c1eaf 100644 --- a/src/test_filter_log.cpp +++ b/src/test_filter_log.cpp @@ -1,5 +1,5 @@ -/* $Id: test_filter_log.cpp,v 1.8 2005-12-02 12:21:07 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: test_filter_log.cpp,v 1.9 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -18,10 +18,11 @@ #include using namespace boost::unit_test; +namespace mp = metaproxy_1; -class FilterBounceInit: public yp2::filter::Base { +class FilterBounceInit: public mp::filter::Base { public: - void process(yp2::Package & package) const { + void process(mp::Package & package) const { if (package.session().is_closed()) { @@ -32,7 +33,7 @@ public: if (gdu) { // std::cout << "Got PDU. Sending init response\n"; - yp2::odr odr; + mp::odr odr; Z_APDU *apdu = zget_APDU(odr, Z_APDU_initResponse); apdu->u.initResponse->implementationName = "YP2/YAZ"; @@ -48,7 +49,7 @@ BOOST_AUTO_UNIT_TEST( test_filter_log_1 ) { try { - yp2::filter::Log lf; + mp::filter::Log lf; } catch ( ... ) { BOOST_CHECK (false); @@ -59,18 +60,18 @@ BOOST_AUTO_UNIT_TEST( test_filter_log_2 ) { try { - yp2::RouterChain router; + mp::RouterChain router; - yp2::filter::Log lf; + mp::filter::Log lf; FilterBounceInit bf; router.append(lf); router.append(bf); // Create package with Z39.50 init request in it - yp2::Package pack; + mp::Package pack; - yp2::odr odr; + mp::odr odr; Z_APDU *apdu = zget_APDU(odr, Z_APDU_initRequest); pack.request() = apdu; diff --git a/src/test_filter_multi.cpp b/src/test_filter_multi.cpp index c9d2af2..a43e199 100644 --- a/src/test_filter_multi.cpp +++ b/src/test_filter_multi.cpp @@ -1,5 +1,5 @@ -/* $Id: test_filter_multi.cpp,v 1.1 2006-01-15 20:03:14 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: test_filter_multi.cpp,v 1.2 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -18,10 +18,11 @@ #include using namespace boost::unit_test; +namespace mp = metaproxy_1; -class FilterBounceInit: public yp2::filter::Base { +class FilterBounceInit: public mp::filter::Base { public: - void process(yp2::Package & package) const { + void process(mp::Package & package) const { if (package.session().is_closed()) { @@ -32,7 +33,7 @@ public: if (gdu) { // std::cout << "Got PDU. Sending init response\n"; - yp2::odr odr; + mp::odr odr; Z_APDU *apdu = zget_APDU(odr, Z_APDU_initResponse); apdu->u.initResponse->implementationName = "YP2/YAZ"; @@ -48,7 +49,7 @@ BOOST_AUTO_UNIT_TEST( test_filter_multi_1 ) { try { - yp2::filter::Multi lf; + mp::filter::Multi lf; } catch ( ... ) { BOOST_CHECK (false); @@ -59,18 +60,18 @@ BOOST_AUTO_UNIT_TEST( test_filter_multi_2 ) { try { - yp2::RouterChain router; + mp::RouterChain router; - yp2::filter::Multi multi; + mp::filter::Multi multi; FilterBounceInit bounce; router.append(multi); router.append(bounce); // Create package with Z39.50 init request in it - yp2::Package pack; + mp::Package pack; - yp2::odr odr; + mp::odr odr; Z_APDU *apdu = zget_APDU(odr, Z_APDU_initRequest); pack.request() = apdu; diff --git a/src/test_filter_query_rewrite.cpp b/src/test_filter_query_rewrite.cpp index 4badebe..43efca1 100644 --- a/src/test_filter_query_rewrite.cpp +++ b/src/test_filter_query_rewrite.cpp @@ -1,5 +1,5 @@ -/* $Id: test_filter_query_rewrite.cpp,v 1.8 2006-01-23 08:23:37 mike Exp $ - Copyright (c) 2005, Index Data. +/* $Id: test_filter_query_rewrite.cpp,v 1.9 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -18,11 +18,13 @@ #include using namespace boost::unit_test; -using namespace yp2::util; -class FilterBounceZ3950: public yp2::filter::Base { +namespace mp = metaproxy_1; +using namespace mp::util; + +class FilterBounceZ3950: public mp::filter::Base { public: - void process(yp2::Package & package) const { + void process(mp::Package & package) const { if (package.session().is_closed()) { @@ -61,14 +63,14 @@ public: }; }; -void check_query_rewrite_init(yp2::RouterChain &router) +void check_query_rewrite_init(mp::RouterChain &router) { //std::cout << "QUERY REWRITE INIT\n"; // Create package with Z39.50 init request in it - yp2::Package pack; + mp::Package pack; - yp2::odr odr; + mp::odr odr; Z_APDU *apdu = zget_APDU(odr, Z_APDU_initRequest); pack.request() = apdu; @@ -91,7 +93,7 @@ void check_query_rewrite_init(yp2::RouterChain &router) } } -void check_query_rewrite_search(yp2::RouterChain &router, +void check_query_rewrite_search(mp::RouterChain &router, std::string query_in, std::string query_expect) { @@ -99,13 +101,13 @@ void check_query_rewrite_search(yp2::RouterChain &router, // << query_in << " " << query_expect << "\n"; // Create package with Z39.50 search request in it - yp2::Package pack; + mp::Package pack; - yp2::odr odr; + mp::odr odr; Z_APDU *apdu = zget_APDU(odr, Z_APDU_searchRequest); // create package PQF query here - yp2::util::pqf(odr, apdu, query_in); + mp::util::pqf(odr, apdu, query_in); // create package PDF database info (needed!) apdu->u.searchRequest->num_databaseNames = 1; @@ -143,7 +145,7 @@ BOOST_AUTO_UNIT_TEST( test_filter_query_rewrite_1 ) { try { - yp2::filter::QueryRewrite f_query_rewrite; + mp::filter::QueryRewrite f_query_rewrite; } catch ( ... ) { BOOST_CHECK (false); @@ -154,9 +156,9 @@ BOOST_AUTO_UNIT_TEST( test_filter_query_rewrite2 ) { try { - yp2::RouterChain router; + mp::RouterChain router; - yp2::filter::QueryRewrite f_query_rewrite; + mp::filter::QueryRewrite f_query_rewrite; //FilterBounceZ3950 f_bounce_z3950; router.append(f_query_rewrite); @@ -180,41 +182,13 @@ BOOST_AUTO_UNIT_TEST( test_filter_query_rewrite3 ) try { - yp2::RouterChain router; + mp::RouterChain router; std::string xmlconf = "\n" "\n" - " \n" - " @attrset XYZ\n" - " @attrset Bib-1\n" - " \n" - " \n" - " @attr 1=4\n" - " @attr 1=4 @attr 4=2\n" - " \n" - " \n" - " fish\n" - " cat\n" - " \n" - " \n" - " @attr 1=4\n" - " @attr 1=5 @attr 4=1\n" - " \n" - " \n" - " fish\n" - " mouse\n" - " \n" - " \n" - " ^\n" - " @and @attr1=9999 vdb\n" - " \n" - " \n" - " @attr 1=4 foo\n" - " @attr 1=1034 fish\n" - " \n" "\n" ; @@ -226,7 +200,7 @@ BOOST_AUTO_UNIT_TEST( test_filter_query_rewrite3 ) xmlNode *root_element = xmlDocGetRootElement(doc); // creating and configuring filter - yp2::filter::QueryRewrite f_query_rewrite; + mp::filter::QueryRewrite f_query_rewrite; f_query_rewrite.configure(root_element); // remeber to free XML DOM diff --git a/src/test_filter_virt_db.cpp b/src/test_filter_virt_db.cpp index f095373..d2828d2 100644 --- a/src/test_filter_virt_db.cpp +++ b/src/test_filter_virt_db.cpp @@ -1,5 +1,5 @@ -/* $Id: test_filter_virt_db.cpp,v 1.11 2006-01-16 17:02:55 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: test_filter_virt_db.cpp,v 1.12 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -25,12 +25,13 @@ #include using namespace boost::unit_test; +namespace mp = metaproxy_1; BOOST_AUTO_UNIT_TEST( test_filter_virt_db_1 ) { try { - yp2::filter::Virt_db vdb; + mp::filter::Virt_db vdb; } catch ( ... ) { BOOST_CHECK (false); @@ -41,18 +42,18 @@ BOOST_AUTO_UNIT_TEST( test_filter_virt_db_2 ) { try { - yp2::RouterChain router; + mp::RouterChain router; - yp2::filter::Virt_db vdb; + mp::filter::Virt_db vdb; router.append(vdb); // Create package with Z39.50 init request in it // Since there is not vhost given, the virt will make its // own init response (regardless of backend) - yp2::Package pack; + mp::Package pack; - yp2::odr odr; + mp::odr odr; Z_APDU *apdu = zget_APDU(odr, Z_APDU_initRequest); BOOST_CHECK(apdu); @@ -80,10 +81,10 @@ BOOST_AUTO_UNIT_TEST( test_filter_virt_db_2 ) } -static void init(yp2::Package &pack, yp2::Router &router) +static void init(mp::Package &pack, mp::Router &router) { // Create package with Z39.50 init request in it - yp2::odr odr; + mp::odr odr; Z_APDU *apdu = zget_APDU(odr, Z_APDU_initRequest); BOOST_CHECK(apdu); @@ -108,16 +109,16 @@ static void init(yp2::Package &pack, yp2::Router &router) BOOST_CHECK_EQUAL(z_gdu->u.z3950->which, Z_APDU_initResponse); } -static void search(yp2::Package &pack, yp2::Router &router, +static void search(mp::Package &pack, mp::Router &router, const std::string &query, const char *db, const char *setname) { // Create package with Z39.50 search request in it - yp2::odr odr; + mp::odr odr; Z_APDU *apdu = zget_APDU(odr, Z_APDU_searchRequest); - yp2::util::pqf(odr, apdu, query); + mp::util::pqf(odr, apdu, query); apdu->u.searchRequest->resultSetName = odr_strdup(odr, setname); @@ -151,13 +152,13 @@ static void search(yp2::Package &pack, yp2::Router &router, BOOST_CHECK_EQUAL(z_gdu->u.z3950->which, Z_APDU_searchResponse); } -static void present(yp2::Package &pack, yp2::Router &router, +static void present(mp::Package &pack, mp::Router &router, int start, int number, const char *setname) { // Create package with Z39.50 present request in it - yp2::odr odr; + mp::odr odr; Z_APDU *apdu = zget_APDU(odr, Z_APDU_presentRequest); apdu->u.presentRequest->resultSetId = odr_strdup(odr, setname); @@ -193,43 +194,43 @@ BOOST_AUTO_UNIT_TEST( test_filter_virt_db_3 ) { try { - yp2::RouterChain router; + mp::RouterChain router; - yp2::filter::Log filter_log1("FRONT"); + mp::filter::Log filter_log1("FRONT"); #if 0 router.append(filter_log1); #endif - yp2::filter::Virt_db vdb; + mp::filter::Virt_db vdb; router.append(vdb); vdb.add_map_db2target("Default", "localhost:210", ""); - yp2::filter::Log filter_log2("BACK"); + mp::filter::Log filter_log2("BACK"); #if 0 router.append(filter_log2); #endif - yp2::filter::Backend_test btest; + mp::filter::Backend_test btest; router.append(btest); - yp2::Session session1; - yp2::Origin origin1; + mp::Session session1; + mp::Origin origin1; { - yp2::Package pack(session1, origin1); + mp::Package pack(session1, origin1); init(pack, router); } { // search for database for which there is no map - yp2::Package pack(session1, origin1); + mp::Package pack(session1, origin1); search(pack, router, "computer", "bad_database", "default"); } { // search for database for which there a map - yp2::Package pack(session1, origin1); + mp::Package pack(session1, origin1); search(pack, router, "other", "Default", "default"); } { // present from last search - yp2::Package pack(session1, origin1); + mp::Package pack(session1, origin1); present(pack, router, 1, 2, "default"); } } diff --git a/src/test_filter_z3950_client.cpp b/src/test_filter_z3950_client.cpp index c3cbd2c..3ccdfcc 100644 --- a/src/test_filter_z3950_client.cpp +++ b/src/test_filter_z3950_client.cpp @@ -1,5 +1,5 @@ -/* $Id: test_filter_z3950_client.cpp,v 1.7 2005-12-02 12:21:07 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: test_filter_z3950_client.cpp,v 1.8 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -20,14 +20,15 @@ #include #include -using namespace boost::unit_test; +using namespace boost::unit_test; +namespace mp = metaproxy_1; BOOST_AUTO_UNIT_TEST( test_filter_z3950_client_1 ) { try { - yp2::filter::Z3950Client zc; // can we construct OK? + mp::filter::Z3950Client zc; // can we construct OK? } catch ( ... ) { BOOST_CHECK (false); @@ -38,16 +39,16 @@ BOOST_AUTO_UNIT_TEST( test_filter_z3950_client_2 ) { try { - yp2::RouterChain router; + mp::RouterChain router; - yp2::filter::Z3950Client zc; + mp::filter::Z3950Client zc; router.append(zc); // Create package with Z39.50 init request in it - yp2::Package pack; + mp::Package pack; - yp2::odr odr; + mp::odr odr; Z_APDU *apdu = zget_APDU(odr, Z_APDU_initRequest); BOOST_CHECK(apdu); @@ -79,16 +80,16 @@ BOOST_AUTO_UNIT_TEST( test_filter_z3950_client_3 ) { try { - yp2::RouterChain router; + mp::RouterChain router; - yp2::filter::Z3950Client zc; + mp::filter::Z3950Client zc; router.append(zc); // Create package with Z39.50 present request in it - yp2::Package pack; + mp::Package pack; - yp2::odr odr; + mp::odr odr; Z_APDU *apdu = zget_APDU(odr, Z_APDU_presentRequest); BOOST_CHECK(apdu); @@ -120,16 +121,16 @@ BOOST_AUTO_UNIT_TEST( test_filter_z3950_client_4 ) { try { - yp2::RouterChain router; + mp::RouterChain router; - yp2::filter::Z3950Client zc; + mp::filter::Z3950Client zc; router.append(zc); // Create package with Z39.50 init request in it - yp2::Package pack; + mp::Package pack; - yp2::odr odr; + mp::odr odr; Z_APDU *apdu = zget_APDU(odr, Z_APDU_initRequest); const char *vhost = "localhost:9999"; diff --git a/src/test_package1.cpp b/src/test_package1.cpp index 7b88adf..1607faa 100644 --- a/src/test_package1.cpp +++ b/src/test_package1.cpp @@ -1,5 +1,5 @@ -/* $Id: test_package1.cpp,v 1.4 2005-12-02 12:21:07 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: test_package1.cpp,v 1.5 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -14,15 +14,16 @@ #include using namespace boost::unit_test; +namespace mp = metaproxy_1; BOOST_AUTO_UNIT_TEST( test_package1_1 ) { try { - yp2::Package package1; + mp::Package package1; - yp2::Origin origin; - yp2::Session session; - yp2::Package package2(package1.session(), origin); + mp::Origin origin; + mp::Session session; + mp::Package package2(package1.session(), origin); BOOST_CHECK_EQUAL(package1.session().id(), package2.session().id()); } diff --git a/src/test_pipe.cpp b/src/test_pipe.cpp index 40c67d4..01c06b9 100644 --- a/src/test_pipe.cpp +++ b/src/test_pipe.cpp @@ -1,5 +1,5 @@ -/* $Id: test_pipe.cpp,v 1.4 2005-12-02 12:21:07 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: test_pipe.cpp,v 1.5 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -18,11 +18,12 @@ #include using namespace boost::unit_test; +namespace mp = metaproxy_1; class Timer : public yazpp_1::ISocketObserver { private: yazpp_1::ISocketObservable *m_obs; - yp2::Pipe m_pipe; + mp::Pipe m_pipe; bool m_timeout; public: Timer(yazpp_1::ISocketObservable *obs, int duration); diff --git a/src/test_router_flexml.cpp b/src/test_router_flexml.cpp index b1b79a1..c81bef7 100644 --- a/src/test_router_flexml.cpp +++ b/src/test_router_flexml.cpp @@ -1,5 +1,5 @@ -/* $Id: test_router_flexml.cpp,v 1.15 2006-01-11 14:58:28 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: test_router_flexml.cpp,v 1.16 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -17,15 +17,17 @@ using namespace boost::unit_test; +namespace mp = metaproxy_1; + static int tfilter_ref = 0; -class TFilter: public yp2::filter::Base { +class TFilter: public mp::filter::Base { public: - void process(yp2::Package & package) const {}; + void process(mp::Package & package) const {}; TFilter() { tfilter_ref++; }; ~TFilter() { tfilter_ref--; }; }; -static yp2::filter::Base* filter_creator() +static mp::filter::Base* filter_creator() { return new TFilter; } @@ -62,9 +64,9 @@ BOOST_AUTO_UNIT_TEST( test_router_flexml_1 ) " \n" "\n"; - yp2::FactoryStatic factory; + mp::FactoryStatic factory; factory.add_creator("tfilter", filter_creator); - yp2::RouterFleXML rflexml(xmlconf, factory); + mp::RouterFleXML rflexml(xmlconf, factory); BOOST_CHECK_EQUAL(tfilter_ref, 2); } catch ( std::runtime_error &e) { @@ -90,10 +92,10 @@ BOOST_AUTO_UNIT_TEST( test_router_flexml_2 ) " \n" " @:210\n"; - yp2::FactoryFilter factory; - yp2::RouterFleXML rflexml(xmlconf_invalid, factory); + mp::FactoryFilter factory; + mp::RouterFleXML rflexml(xmlconf_invalid, factory); } - catch ( yp2::XMLError &e) { + catch ( mp::XMLError &e) { std::cout << "XMLError: " << e.what() << "\n"; got_error_as_expected = true; } @@ -130,8 +132,8 @@ BOOST_AUTO_UNIT_TEST( test_router_flexml_3 ) " \n" "\n"; - yp2::FactoryStatic factory; - yp2::RouterFleXML rflexml(xmlconf, factory); + mp::FactoryStatic factory; + mp::RouterFleXML rflexml(xmlconf, factory); } catch ( std::runtime_error &e) { std::cout << "std::runtime error: " << e.what() << "\n"; @@ -163,12 +165,12 @@ BOOST_AUTO_UNIT_TEST( test_router_flexml_4 ) " \n" "\n"; - yp2::FactoryStatic factory; + mp::FactoryStatic factory; factory.add_creator("tfilter", filter_creator); - yp2::RouterFleXML rflexml(xmlconf, factory); + mp::RouterFleXML rflexml(xmlconf, factory); } - catch ( yp2::FactoryFilter::NotFound &e) { - std::cout << "yp2::FactoryFilter::NotFound: " << e.what() << "\n"; + catch ( mp::FactoryFilter::NotFound &e) { + std::cout << "mp::FactoryFilter::NotFound: " << e.what() << "\n"; got_error_as_expected = true; } catch ( std::runtime_error &e) { diff --git a/src/test_ses_map.cpp b/src/test_ses_map.cpp index 6652801..a481b7f 100644 --- a/src/test_ses_map.cpp +++ b/src/test_ses_map.cpp @@ -1,5 +1,5 @@ -/* $Id: test_ses_map.cpp,v 1.2 2005-12-02 12:21:07 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: test_ses_map.cpp,v 1.3 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -24,8 +24,9 @@ #include using namespace boost::unit_test; +namespace mp = metaproxy_1; -namespace yp2 { +namespace metaproxy_1 { class SesMap; @@ -39,13 +40,13 @@ namespace yp2 { private: boost::mutex m_map_mutex; public: - void create(SesMap &sm, const yp2::Session &s, double &t) { + void create(SesMap &sm, const mp::Session &s, double &t) { boost::mutex::scoped_lock lock(m_map_mutex); boost::shared_ptr w_ptr(new Wrap(t)); m_map_ptr[s] = w_ptr; } - std::map >m_map_ptr; + std::map >m_map_ptr; }; } @@ -54,7 +55,7 @@ BOOST_AUTO_UNIT_TEST( test_ses_map_1 ) { try { - yp2::SesMap ses_map; + mp::SesMap ses_map; } catch ( ... ) { BOOST_CHECK (false); diff --git a/src/test_session1.cpp b/src/test_session1.cpp index 5e21cde..de838f5 100644 --- a/src/test_session1.cpp +++ b/src/test_session1.cpp @@ -1,5 +1,5 @@ -/* $Id: test_session1.cpp,v 1.9 2005-12-02 12:21:07 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: test_session1.cpp,v 1.10 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -12,21 +12,22 @@ #include using namespace boost::unit_test; +namespace mp = metaproxy_1; BOOST_AUTO_UNIT_TEST( testsession1 ) { // test session try { - yp2::Session session1; - yp2::Session session2; - yp2::Session session3; - yp2::Session session4; - yp2::Session session5; + mp::Session session1; + mp::Session session2; + mp::Session session3; + mp::Session session4; + mp::Session session5; BOOST_CHECK_EQUAL (session5.id(), (unsigned long) 5); - yp2::Session session = session3; + mp::Session session = session3; BOOST_CHECK_EQUAL (session.id(), (unsigned long) 3); } diff --git a/src/test_session2.cpp b/src/test_session2.cpp index 6e237ad..e4a8161 100644 --- a/src/test_session2.cpp +++ b/src/test_session2.cpp @@ -1,5 +1,5 @@ -/* $Id: test_session2.cpp,v 1.6 2005-12-02 12:21:07 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: test_session2.cpp,v 1.7 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -16,6 +16,7 @@ #include using namespace boost::unit_test; +namespace mp = metaproxy_1; boost::mutex io_mutex; @@ -28,7 +29,7 @@ class Worker void operator() (void) { for (int i=0; i < 100; ++i) { - yp2::Session session; + mp::Session session; m_id = session.id(); //print(); } @@ -66,7 +67,7 @@ BOOST_AUTO_UNIT_TEST( testsession2 ) } thrds.join_all(); - yp2::Session session; + mp::Session session; BOOST_CHECK (session.id() == 10001); } diff --git a/src/test_thread_pool_observer.cpp b/src/test_thread_pool_observer.cpp index f6b08d8..fc508b3 100644 --- a/src/test_thread_pool_observer.cpp +++ b/src/test_thread_pool_observer.cpp @@ -1,10 +1,10 @@ -/* $Id: test_thread_pool_observer.cpp,v 1.8 2005-12-02 12:21:07 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: test_thread_pool_observer.cpp,v 1.9 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ -/* $Id: test_thread_pool_observer.cpp,v 1.8 2005-12-02 12:21:07 adam Exp $ - Copyright (c) 1998-2005, Index Data. +/* $Id: test_thread_pool_observer.cpp,v 1.9 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 1998-2005-2006, Index Data. This file is part of the yaz-proxy. @@ -39,12 +39,13 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA using namespace boost::unit_test; using namespace yazpp_1; +namespace mp = metaproxy_1; class My_Timer_Thread; -class My_Msg : public yp2::IThreadPoolMsg { +class My_Msg : public mp::IThreadPoolMsg { public: - yp2::IThreadPoolMsg *handle(); + mp::IThreadPoolMsg *handle(); void result(); int m_val; My_Timer_Thread *m_timer; @@ -53,18 +54,18 @@ public: class My_Timer_Thread : public ISocketObserver { private: ISocketObservable *m_obs; - yp2::Pipe m_pipe; - yp2::ThreadPoolSocketObserver *m_t; + mp::Pipe m_pipe; + mp::ThreadPoolSocketObserver *m_t; public: int m_sum; int m_requests; int m_responses; - My_Timer_Thread(ISocketObservable *obs, yp2::ThreadPoolSocketObserver *t); + My_Timer_Thread(ISocketObservable *obs, mp::ThreadPoolSocketObserver *t); void socketNotify(int event); }; -yp2::IThreadPoolMsg *My_Msg::handle() +mp::IThreadPoolMsg *My_Msg::handle() { My_Msg *res = new My_Msg; @@ -83,7 +84,7 @@ void My_Msg::result() } My_Timer_Thread::My_Timer_Thread(ISocketObservable *obs, - yp2::ThreadPoolSocketObserver *t) : + mp::ThreadPoolSocketObserver *t) : m_obs(obs), m_pipe(9123) { m_t = t; @@ -107,7 +108,7 @@ BOOST_AUTO_UNIT_TEST( thread_pool_observer1 ) { SocketManager mySocketManager; - yp2::ThreadPoolSocketObserver m(&mySocketManager, 3); + mp::ThreadPoolSocketObserver m(&mySocketManager, 3); My_Timer_Thread t(&mySocketManager, &m) ; while (t.m_responses < 30 && mySocketManager.processEvent() > 0) ; diff --git a/src/thread_pool_observer.cpp b/src/thread_pool_observer.cpp index 9c7dfda..0c99422 100644 --- a/src/thread_pool_observer.cpp +++ b/src/thread_pool_observer.cpp @@ -1,6 +1,6 @@ -/* $Id: thread_pool_observer.cpp,v 1.13 2005-11-07 22:46:42 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: thread_pool_observer.cpp,v 1.14 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -32,7 +32,9 @@ #include "thread_pool_observer.hpp" #include "pipe.hpp" -namespace yp2 { +namespace mp = metaproxy_1; + +namespace metaproxy_1 { class ThreadPoolSocketObserver::Worker { public: Worker(ThreadPoolSocketObserver *s) : m_s(s) {}; @@ -63,7 +65,7 @@ namespace yp2 { using namespace yazpp_1; -using namespace yp2; +using namespace mp; ThreadPoolSocketObserver::Rep::Rep(ISocketObservable *obs) : m_socketObservable(obs), m_pipe(9123) diff --git a/src/thread_pool_observer.hpp b/src/thread_pool_observer.hpp index 9875d30..9ad248a 100644 --- a/src/thread_pool_observer.hpp +++ b/src/thread_pool_observer.hpp @@ -1,5 +1,5 @@ -/* $Id: thread_pool_observer.hpp,v 1.7 2005-11-07 12:31:05 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: thread_pool_observer.hpp,v 1.8 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -12,7 +12,7 @@ #include #include -namespace yp2 { +namespace metaproxy_1 { class IThreadPoolMsg { public: virtual IThreadPoolMsg *handle() = 0; diff --git a/src/tstdl.cpp b/src/tstdl.cpp index f8cc805..a56e123 100644 --- a/src/tstdl.cpp +++ b/src/tstdl.cpp @@ -1,5 +1,5 @@ -/* $Id: tstdl.cpp,v 1.2 2006-01-11 17:57:38 mike Exp $ - Copyright (c) 2005, Index Data. +/* $Id: tstdl.cpp,v 1.3 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ diff --git a/src/util.cpp b/src/util.cpp index 4570c31..8bb34f9 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1,5 +1,5 @@ -/* $Id: util.cpp,v 1.13 2006-01-20 22:38:12 marc Exp $ - Copyright (c) 2005, Index Data. +/* $Id: util.cpp,v 1.14 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -14,7 +14,9 @@ //#include -void yp2::util::piggyback(int smallSetUpperBound, +namespace mp = metaproxy_1; + +void mp::util::piggyback(int smallSetUpperBound, int largeSetLowerBound, int mediumSetPresentNumber, int result_set_size, @@ -42,7 +44,7 @@ void yp2::util::piggyback(int smallSetUpperBound, } -bool yp2::util::pqf(ODR odr, Z_APDU *apdu, const std::string &q) { +bool mp::util::pqf(ODR odr, Z_APDU *apdu, const std::string &q) { YAZ_PQF_Parser pqf_parser = yaz_pqf_create(); Z_RPNQuery *rpn = yaz_pqf_parse(pqf_parser, odr, q.c_str()); @@ -61,7 +63,7 @@ bool yp2::util::pqf(ODR odr, Z_APDU *apdu, const std::string &q) { } -std::string yp2::util::zQueryToString(Z_Query *query) +std::string mp::util::zQueryToString(Z_Query *query) { std::string query_str = ""; @@ -103,7 +105,7 @@ std::string yp2::util::zQueryToString(Z_Query *query) return query_str; } -void yp2::util::get_default_diag(Z_DefaultDiagFormat *r, +void mp::util::get_default_diag(Z_DefaultDiagFormat *r, int &error_code, std::string &addinfo) { error_code = *r->condition; @@ -118,7 +120,7 @@ void yp2::util::get_default_diag(Z_DefaultDiagFormat *r, } } -void yp2::util::get_init_diagnostics(Z_InitResponse *initrs, +void mp::util::get_init_diagnostics(Z_InitResponse *initrs, int &error_code, std::string &addinfo) { Z_External *uif = initrs->userInformationField; @@ -142,7 +144,7 @@ void yp2::util::get_init_diagnostics(Z_InitResponse *initrs, { Z_DiagnosticFormat_s *ds = diag->elements[0]; if (ds->which == Z_DiagnosticFormat_s_defaultDiagRec) - yp2::util::get_default_diag(ds->u.defaultDiagRec, + mp::util::get_default_diag(ds->u.defaultDiagRec, error_code, addinfo); } } @@ -150,7 +152,7 @@ void yp2::util::get_init_diagnostics(Z_InitResponse *initrs, } } -int yp2::util::get_vhost_otherinfo(Z_OtherInformation **otherInformation, +int mp::util::get_vhost_otherinfo(Z_OtherInformation **otherInformation, bool remove_flag, std::list &vhosts) { @@ -171,7 +173,7 @@ int yp2::util::get_vhost_otherinfo(Z_OtherInformation **otherInformation, return cat; } -void yp2::util::set_vhost_otherinfo(Z_OtherInformation **otherInformation, +void mp::util::set_vhost_otherinfo(Z_OtherInformation **otherInformation, ODR odr, const std::list &vhosts) { @@ -184,7 +186,7 @@ void yp2::util::set_vhost_otherinfo(Z_OtherInformation **otherInformation, } } -void yp2::util::split_zurl(std::string zurl, std::string &host, +void mp::util::split_zurl(std::string zurl, std::string &host, std::list &db) { const char *zurl_cstr = zurl.c_str(); @@ -214,7 +216,7 @@ void yp2::util::split_zurl(std::string zurl, std::string &host, } } -bool yp2::util::set_databases_from_zurl(ODR odr, std::string zurl, +bool mp::util::set_databases_from_zurl(ODR odr, std::string zurl, int *db_num, char ***db_strings) { std::string host; @@ -233,27 +235,27 @@ bool yp2::util::set_databases_from_zurl(ODR odr, std::string zurl, return true; } -yp2::odr::odr(int type) +mp::odr::odr(int type) { m_odr = odr_createmem(type); } -yp2::odr::odr() +mp::odr::odr() { m_odr = odr_createmem(ODR_ENCODE); } -yp2::odr::~odr() +mp::odr::~odr() { odr_destroy(m_odr); } -yp2::odr::operator ODR() const +mp::odr::operator ODR() const { return m_odr; } -Z_APDU *yp2::odr::create_close(Z_APDU *in_apdu, +Z_APDU *mp::odr::create_close(Z_APDU *in_apdu, int reason, const char *addinfo) { Z_APDU *apdu = create_APDU(Z_APDU_close, in_apdu); @@ -264,20 +266,20 @@ Z_APDU *yp2::odr::create_close(Z_APDU *in_apdu, return apdu; } -Z_APDU *yp2::odr::create_APDU(int type, Z_APDU *in_apdu) +Z_APDU *mp::odr::create_APDU(int type, Z_APDU *in_apdu) { - return yp2::util::create_APDU(m_odr, type, in_apdu); + return mp::util::create_APDU(m_odr, type, in_apdu); } -Z_APDU *yp2::util::create_APDU(ODR odr, int type, Z_APDU *in_apdu) +Z_APDU *mp::util::create_APDU(ODR odr, int type, Z_APDU *in_apdu) { Z_APDU *out_apdu = zget_APDU(odr, type); - Z_ReferenceId **id_to = yp2::util::get_referenceId(out_apdu); + Z_ReferenceId **id_to = mp::util::get_referenceId(out_apdu); *id_to = 0; if (in_apdu) { - Z_ReferenceId **id_from = yp2::util::get_referenceId(in_apdu); + Z_ReferenceId **id_from = mp::util::get_referenceId(in_apdu); if (id_from && *id_from && id_to) { *id_to = (Z_ReferenceId*) odr_malloc (odr, sizeof(**id_to)); @@ -291,7 +293,7 @@ Z_APDU *yp2::util::create_APDU(ODR odr, int type, Z_APDU *in_apdu) return out_apdu; } -Z_APDU *yp2::odr::create_initResponse(Z_APDU *in_apdu, +Z_APDU *mp::odr::create_initResponse(Z_APDU *in_apdu, int error, const char *addinfo) { Z_APDU *apdu = create_APDU(Z_APDU_initResponse, in_apdu); @@ -304,7 +306,7 @@ Z_APDU *yp2::odr::create_initResponse(Z_APDU *in_apdu, return apdu; } -Z_APDU *yp2::odr::create_searchResponse(Z_APDU *in_apdu, +Z_APDU *mp::odr::create_searchResponse(Z_APDU *in_apdu, int error, const char *addinfo) { Z_APDU *apdu = create_APDU(Z_APDU_searchResponse, in_apdu); @@ -321,7 +323,7 @@ Z_APDU *yp2::odr::create_searchResponse(Z_APDU *in_apdu, return apdu; } -Z_APDU *yp2::odr::create_presentResponse(Z_APDU *in_apdu, +Z_APDU *mp::odr::create_presentResponse(Z_APDU *in_apdu, int error, const char *addinfo) { Z_APDU *apdu = create_APDU(Z_APDU_presentResponse, in_apdu); @@ -338,7 +340,7 @@ Z_APDU *yp2::odr::create_presentResponse(Z_APDU *in_apdu, return apdu; } -Z_APDU *yp2::odr::create_scanResponse(Z_APDU *in_apdu, +Z_APDU *mp::odr::create_scanResponse(Z_APDU *in_apdu, int error, const char *addinfo) { Z_APDU *apdu = create_APDU(Z_APDU_scanResponse, in_apdu); @@ -365,7 +367,7 @@ Z_APDU *yp2::odr::create_scanResponse(Z_APDU *in_apdu, return apdu; } -Z_GDU *yp2::odr::create_HTTP_Response(yp2::Session &session, +Z_GDU *mp::odr::create_HTTP_Response(mp::Session &session, Z_HTTP_Request *hreq, int code) { const char *response_version = "1.0"; @@ -398,7 +400,7 @@ Z_GDU *yp2::odr::create_HTTP_Response(yp2::Session &session, return gdu; } -Z_ReferenceId **yp2::util::get_referenceId(Z_APDU *apdu) +Z_ReferenceId **mp::util::get_referenceId(Z_APDU *apdu) { switch (apdu->which) { diff --git a/src/util.hpp b/src/util.hpp index 5b81d04..ee920f1 100644 --- a/src/util.hpp +++ b/src/util.hpp @@ -1,5 +1,5 @@ -/* $Id: util.hpp,v 1.12 2006-01-25 11:27:19 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: util.hpp,v 1.13 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -16,7 +16,7 @@ #include #include "package.hpp" -namespace yp2 { +namespace metaproxy_1 { namespace util { bool pqf(ODR odr, Z_APDU *apdu, const std::string &q); @@ -70,7 +70,7 @@ namespace yp2 { Z_APDU *create_scanResponse(Z_APDU *in_apdu, int error, const char *addinfo); Z_APDU *create_APDU(int type, Z_APDU *in_apdu); - Z_GDU *create_HTTP_Response(yp2::Session &session, + Z_GDU *create_HTTP_Response(metaproxy_1::Session &session, Z_HTTP_Request *req, int code); private: ODR m_odr; diff --git a/src/xmlutil.cpp b/src/xmlutil.cpp index d4026b9..d1088e7 100644 --- a/src/xmlutil.cpp +++ b/src/xmlutil.cpp @@ -1,12 +1,14 @@ -/* $Id: xmlutil.cpp,v 1.4 2006-01-11 14:58:28 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: xmlutil.cpp,v 1.5 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ #include "xmlutil.hpp" -std::string yp2::xml::get_text(const xmlNode *ptr) +namespace mp = metaproxy_1; + +std::string mp::xml::get_text(const xmlNode *ptr) { std::string c; for (ptr = ptr->children; ptr; ptr = ptr->next) @@ -16,7 +18,7 @@ std::string yp2::xml::get_text(const xmlNode *ptr) } -bool yp2::xml::is_element(const xmlNode *ptr, +bool mp::xml::is_element(const xmlNode *ptr, const std::string &ns, const std::string &name) { @@ -27,22 +29,22 @@ bool yp2::xml::is_element(const xmlNode *ptr, return false; } -bool yp2::xml::is_element_yp2(const xmlNode *ptr, +bool mp::xml::is_element_yp2(const xmlNode *ptr, const std::string &name) { - return yp2::xml::is_element(ptr, "http://indexdata.dk/yp2/config/1", name); + return mp::xml::is_element(ptr, "http://indexdata.dk/yp2/config/1", name); } -bool yp2::xml::check_element_yp2(const xmlNode *ptr, +bool mp::xml::check_element_yp2(const xmlNode *ptr, const std::string &name) { - if (!yp2::xml::is_element_yp2(ptr, name)) - throw yp2::XMLError("Expected element name " + name); + if (!mp::xml::is_element_yp2(ptr, name)) + throw mp::XMLError("Expected element name " + name); return true; } -std::string yp2::xml::get_route(const xmlNode *node) +std::string mp::xml::get_route(const xmlNode *node) { std::string route_value; if (node) @@ -68,7 +70,7 @@ std::string yp2::xml::get_route(const xmlNode *node) } -const xmlNode* yp2::xml::jump_to_children(const xmlNode* node, +const xmlNode* mp::xml::jump_to_children(const xmlNode* node, int xml_node_type) { node = node->children; @@ -77,7 +79,7 @@ const xmlNode* yp2::xml::jump_to_children(const xmlNode* node, return node; } -const xmlNode* yp2::xml::jump_to_next(const xmlNode* node, +const xmlNode* mp::xml::jump_to_next(const xmlNode* node, int xml_node_type) { node = node->next; @@ -86,7 +88,7 @@ const xmlNode* yp2::xml::jump_to_next(const xmlNode* node, return node; } -const xmlNode* yp2::xml::jump_to(const xmlNode* node, +const xmlNode* mp::xml::jump_to(const xmlNode* node, int xml_node_type) { for (; node && node->type != xml_node_type; node = node->next) @@ -94,14 +96,14 @@ const xmlNode* yp2::xml::jump_to(const xmlNode* node, return node; } -void yp2::xml::check_empty(const xmlNode *node) +void mp::xml::check_empty(const xmlNode *node) { if (node) { const xmlNode *n; for (n = node->children; n; n = n->next) if (n->type == XML_ELEMENT_NODE) - throw yp2::XMLError("No child elements allowed inside element " + throw mp::XMLError("No child elements allowed inside element " + std::string((const char *) node->name)); } } diff --git a/src/xmlutil.hpp b/src/xmlutil.hpp index fca73fa..571161c 100644 --- a/src/xmlutil.hpp +++ b/src/xmlutil.hpp @@ -1,5 +1,5 @@ -/* $Id: xmlutil.hpp,v 1.4 2006-01-11 14:58:28 adam Exp $ - Copyright (c) 2005, Index Data. +/* $Id: xmlutil.hpp,v 1.5 2006-03-16 10:40:59 adam Exp $ + Copyright (c) 2005-2006, Index Data. %LICENSE% */ @@ -11,7 +11,7 @@ #include #include -namespace yp2 { +namespace metaproxy_1 { namespace xml { std::string get_text(const xmlNode *ptr); bool is_element(const xmlNode *ptr, diff --git a/src/yp2_prog.cpp b/src/yp2_prog.cpp deleted file mode 100644 index 4109c86..0000000 --- a/src/yp2_prog.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* $Id: yp2_prog.cpp,v 1.2 2006-01-19 09:32:08 adam Exp $ - Copyright (c) 2005, Index Data. - -%LICENSE% - */ - -#include "config.hpp" - -#include -namespace po = boost::program_options; - -#include -#include - -#include "filter.hpp" -#include "package.hpp" -#include "router_flexml.hpp" -#include "factory_static.hpp" - -int main(int argc, char **argv) -{ - try - { - po::options_description desc("Allowed options"); - desc.add_options() - ("help", "produce help message") - ("config", po::value< std::vector >(), "xml config") - ; - - po::positional_options_description p; - p.add("config", -1); - - po::variables_map vm; - po::store(po::command_line_parser(argc, argv). - options(desc).positional(p).run(), vm); - po::notify(vm); - - if (vm.count("help")) { - std::cout << desc << "\n"; - return 1; - } - - xmlDocPtr doc = 0; - if (vm.count("config")) - { - std::vector config_fnames = - vm["config"].as< std::vector >(); - - if (config_fnames.size() != 1) - { - std::cerr << "Only one configuration must be given\n"; - std::exit(1); - } - - doc = xmlParseFile(config_fnames[0].c_str()); - if (!doc) - { - std::cerr << "xmlParseFile failed\n"; - std::exit(1); - } - } - else - { - std::cerr << "No configuration given\n"; - std::exit(1); - } - if (doc) - { - try { - yp2::FactoryStatic factory; - yp2::RouterFleXML router(doc, factory); - yp2::Package pack; - pack.router(router).move(); - } - catch (std::runtime_error &e) { - std::cout << "std::runtime error: " << e.what() << "\n"; - exit(1); - } - xmlFreeDoc(doc); - } - } - catch ( ... ) { - std::cerr << "Unknown Exception" << std::endl; - std::exit(1); - } - std::exit(0); -} - - -/* - * Local variables: - * c-basic-offset: 4 - * indent-tabs-mode: nil - * c-file-style: "stroustrup" - * End: - * vim: shiftwidth=4 tabstop=8 expandtab - */ -- 1.7.10.4