# 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)
-## $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
# 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 \
# 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..
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 \
-/* $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%
*/
#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";
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;
for (size_t i = 0; i<ports.size(); i++)
std::cout << "port " << i << " " << ports[i] << "\n";
- yp2::RouterChain router;
+ mp::RouterChain router;
// put frontend filter in router
- yp2::filter::FrontendNet filter_front;
+ mp::filter::FrontendNet filter_front;
filter_front.ports() = ports;
// 0=no time, >0 timeout in seconds
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",
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
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();
}
-/* $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%
*/
#include "router_flexml.hpp"
#include "factory_static.hpp"
+namespace mp = metaproxy_1;
+
int main(int argc, char **argv)
{
try
}
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();
-/* $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%
*/
#include <string>
#include <map>
-namespace yp2 {
+namespace mp = metaproxy_1;
+
+namespace metaproxy_1 {
class FactoryFilter::Rep {
typedef std::map<std::string, CreateFilterCallback> CallbackMap;
typedef std::map<std::string, CreateFilterCallback>::iterator
};
}
-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);
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);
return (it->second());
}
-bool yp2::FactoryFilter::have_dl_support()
+bool mp::FactoryFilter::have_dl_support()
{
#if HAVE_DLFCN_H
return true;
#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
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)
{
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)
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;
-/* $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%
*/
#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:
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);
-/* $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%
*/
#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;
-/* $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%
*/
#include "factory_filter.hpp"
-namespace yp2 {
+namespace metaproxy_1 {
class FactoryStatic : public FactoryFilter {
public:
FactoryStatic();
-/* $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%
*/
#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);
}
/*
-/* $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%
*/
#include <libxml/tree.h>
#include "xmlutil.hpp"
-namespace yp2 {
+namespace metaproxy_1 {
class Package;
}
}
-struct yp2_filter_struct {
+struct metaproxy_1_filter_struct {
int ver;
const char *type;
- yp2::filter::Base* (*creator)();
+ metaproxy_1::filter::Base* (*creator)();
};
#endif
-/* $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%
*/
#include <stdio.h>
#include <errno.h>
-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;
bool got_userRegister, got_targetRegister;
std::map<std::string, PasswordAndDBs> userRegister;
std::map<std::string, std::list<std::string> > targetsByUser;
- std::map<yp2::Session, std::string> userBySession;
+ std::map<mp::Session, std::string> userBySession;
bool discardUnauthorisedTargets;
Rep() { got_userRegister = false;
got_targetRegister = false;
}
-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;
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")) {
}
-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)
// 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)
}
-void yf::AuthSimple::process(yp2::Package &package) const
+void yf::AuthSimple::process(mp::Package &package) const
{
Z_GDU *gdu = package.request().get();
}
-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;
}
-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;
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,
}
-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;
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,
}
-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
}
-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;
std::list<std::string> 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<std::string>::iterator i;
// ### 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
-/* $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%
*/
#include "filter.hpp"
-namespace yp2 {
+namespace metaproxy_1 {
namespace filter {
class AuthSimple : public Base {
class Rep;
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
-/* $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%
*/
#include <yaz/otherinfo.h>
#include <yaz/diagbib1.h>
-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;
}
}
-using namespace yp2;
static const int result_set_size = 42;
{
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()))
std::string addinfo;
int number = 0;
- yp2::util::piggyback(*req->smallSetUpperBound,
+ mp::util::piggyback(*req->smallSetUpperBound,
*req->largeSetLowerBound,
*req->mediumSetPresentNumber,
result_set_size,
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
-/* $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%
*/
#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<Rep> m_p;
};
}
extern "C" {
- extern struct yp2_filter_struct yp2_filter_backend_test;
+ extern struct metaproxy_1_filter_struct metaproxy_1_filter_backend_test;
}
#endif
-/* $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%
*/
#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
-/* $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%
*/
#include <iostream>
-namespace yp2 {
+namespace mp = metaproxy_1;
+
+namespace metaproxy_1 {
namespace filter {
class FrontendNet::Rep {
friend class FrontendNet;
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(
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,
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--;
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;
}
-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())
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;
}
-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)
{
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;
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; i<m_p->m_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)
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<std::string> ports;
for (ptr = ptr->children; ptr; ptr = ptr->next)
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));
}
m_p->m_ports = ports;
}
-std::vector<std::string> &yp2::filter::FrontendNet::ports()
+std::vector<std::string> &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
-/* $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%
*/
#include "filter.hpp"
-namespace yp2 {
+namespace metaproxy_1 {
namespace filter {
class FrontendNet : public Base {
class Rep;
public:
FrontendNet();
~FrontendNet();
- void process(yp2::Package & package) const;
+ void process(metaproxy_1::Package & package) const;
void configure(const xmlNode * ptr);
public:
/// set ports
}
extern "C" {
- extern struct yp2_filter_struct yp2_filter_frontend_net;
+ extern struct metaproxy_1_filter_struct metaproxy_1_filter_frontend_net;
}
#endif
-/* $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%
*/
#include <sys/stat.h>
#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;
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);
};
}
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)
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;
}
}
}
- 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)
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)
{
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);
}
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"
}
else
{
- throw yp2::filter::FilterException
+ throw mp::filter::FilterException
("Bad element "
+ std::string((const char *) ptr->name)
+ " in virt_db filter");
}
}
-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
-/* $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%
*/
#include "filter.hpp"
-namespace yp2 {
+namespace metaproxy_1 {
namespace filter {
class HttpFile : public Base {
class Rep;
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
-/* $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%
*/
#include <yaz/zgdu.h>
-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;
yf::Log::~Log() {}
-void yf::Log::process(yp2::Package &package) const
+void yf::Log::process(mp::Package &package) const
{
Z_GDU *gdu;
gdu = package.request().get();
if (gdu)
{
- yp2::odr odr(ODR_PRINT);
+ mp::odr odr(ODR_PRINT);
z_GDU(odr, &gdu, 0, 0);
}
}
gdu = package.response().get();
if (gdu)
{
- yp2::odr odr(ODR_PRINT);
+ mp::odr odr(ODR_PRINT);
z_GDU(odr, &gdu, 0, 0);
}
}
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
-/* $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%
*/
#include "filter.hpp"
-namespace yp2 {
+namespace metaproxy_1 {
namespace filter {
class Log : public Base {
class Rep;
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
-/* $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%
*/
#include <map>
#include <iostream>
-namespace yf = yp2::filter;
+namespace mp = metaproxy_1;
+namespace yf = mp::filter;
-namespace yp2 {
+namespace metaproxy_1 {
namespace filter {
struct Multi::BackendSet {
std::map<std::string,std::string> m_target_route;
boost::mutex m_mutex;
boost::condition m_cond_session_ready;
- std::map<yp2::Session, FrontendPtr> m_clients;
+ std::map<mp::Session, FrontendPtr> m_clients;
};
}
}
-using namespace yp2;
+using namespace mp;
bool yf::Multi::BackendSet::operator < (const BackendSet &k) const
{
{
boost::mutex::scoped_lock lock(m_mutex);
- std::map<yp2::Session,yf::Multi::FrontendPtr>::iterator it;
+ std::map<mp::Session,yf::Multi::FrontendPtr>::iterator it;
while(true)
{
void yf::Multi::Rep::release_frontend(Package &package)
{
boost::mutex::scoped_lock lock(m_mutex);
- std::map<yp2::Session,yf::Multi::FrontendPtr>::iterator it;
+ std::map<mp::Session,yf::Multi::FrontendPtr>::iterator it;
it = m_clients.find(package.session());
if (it != m_clients.end())
std::list<std::string> targets;
- yp2::util::get_vhost_otherinfo(&req->otherInfo, false, targets);
+ mp::util::get_vhost_otherinfo(&req->otherInfo, false, targets);
if (targets.size() < 1)
{
std::list<BackendPtr>::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::list<std::string>vhost_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;
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;
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))
{
}
}
- 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;
m_sets[resultSet.m_setname] = resultSet;
int number;
- yp2::util::piggyback(smallSetUpperBound,
+ mp::util::piggyback(smallSetUpperBound,
largeSetLowerBound,
mediumSetPresentNumber,
result_set_size,
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,
}
}
- 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;
{
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);
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))
{
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))
{
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;
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;
Z_APDU *apdu = gdu->u.z3950;
if (apdu->which == Z_APDU_initRequest)
{
- yp2::odr odr;
+ mp::odr odr;
package.response() = odr.create_close(
apdu,
}
else
{
- yp2::odr odr;
+ mp::odr odr;
package.response() = odr.create_close(
apdu, Z_Close_protocolError,
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)
{
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;
}
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<std::string>::const_iterator it;
for (it = targets.begin(); it != targets.end(); it++)
}
else
{
- throw yp2::filter::FilterException
+ throw mp::filter::FilterException
("Bad element "
+ std::string((const char *) ptr->name)
+ " in virt_db filter");
}
}
-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
-/* $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%
*/
#include "filter.hpp"
-namespace yp2 {
+namespace metaproxy_1 {
namespace filter {
class Multi : public Base {
class Rep;
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<std::string> hosts,
}
extern "C" {
- extern struct yp2_filter_struct yp2_filter_multi;
+ extern struct metaproxy_1_filter_struct metaproxy_1_filter_multi;
}
#endif
-/* $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%
*/
#include <libxslt/xsltutils.h>
#include <libxslt/transform.h>
-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;
{ // 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();
{
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;
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)
{
{
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");
}
else
{
- throw yp2::filter::FilterException
+ throw mp::filter::FilterException
("Bad element "
+ std::string((const char *) ptr->name)
+ " in query_rewrite filter");
}
}
-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
-/* $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%
*/
#include "filter.hpp"
-namespace yp2 {
+namespace metaproxy_1 {
namespace filter {
class QueryRewrite : public Base {
class Rep;
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
-/* $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%
*/
#include <map>
#include <iostream>
-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;
}
-
-using namespace yp2;
+using namespace mp;
bool yf::SessionShared::InitKey::operator < (const SessionShared::InitKey
&k) const
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,
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");
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
-/* $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%
*/
#include "filter.hpp"
-namespace yp2 {
+namespace metaproxy_1 {
namespace filter {
class SessionShared : public Base {
class Rep;
public:
~SessionShared();
SessionShared();
- void process(yp2::Package & package) const;
+ void process(metaproxy_1::Package & package) const;
private:
boost::scoped_ptr<Rep> m_p;
};
}
extern "C" {
- extern struct yp2_filter_struct yp2_filter_session_shared;
+ extern struct metaproxy_1_filter_struct metaproxy_1_filter_session_shared;
}
#endif
-/* $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%
*/
#include <yaz/zgdu.h>
-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;
{ // 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
-/* $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%
*/
#include "filter.hpp"
-namespace yp2 {
+namespace metaproxy_1 {
namespace filter {
class Template : public Base {
class Rep;
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
-/* $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%
*/
#include <map>
#include <iostream>
-namespace yf = yp2::filter;
+namespace mp = metaproxy_1;
+namespace yf = mp::filter;
-namespace yp2 {
+namespace metaproxy_1 {
namespace filter {
struct Virt_db::Set {
std::string m_route;
};
struct Virt_db::Backend {
- yp2::Session m_backend_session;
+ mp::Session m_backend_session;
std::list<std::string> m_frontend_databases;
std::list<std::string> m_targets;
std::string m_route;
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;
boost::mutex m_mutex;
boost::condition m_cond_session_ready;
- std::map<yp2::Session, FrontendPtr> m_clients;
+ std::map<mp::Session, FrontendPtr> m_clients;
};
}
}
-using namespace yp2;
+using namespace mp;
yf::Virt_db::BackendPtr yf::Virt_db::Frontend::lookup_backend_from_databases(
std::list<std::string> databases)
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;
}
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;
}
Z_SearchRequest *req = apdu_req->u.searchRequest;
std::string vhost;
std::string resultSetId = req->resultSetName;
- yp2::odr odr;
+ mp::odr odr;
std::list<std::string> databases;
int i;
std::list<std::string>::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);
}
{
boost::mutex::scoped_lock lock(m_mutex);
- std::map<yp2::Session,yf::Virt_db::FrontendPtr>::iterator it;
+ std::map<mp::Session,yf::Virt_db::FrontendPtr>::iterator it;
while(true)
{
void yf::Virt_db::Rep::release_frontend(Package &package)
{
boost::mutex::scoped_lock lock(m_mutex);
- std::map<yp2::Session,yf::Virt_db::FrontendPtr>::iterator it;
+ std::map<mp::Session,yf::Virt_db::FrontendPtr>::iterator it;
it = m_clients.find(package.session());
if (it != m_clients.end())
{
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())
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());
{
Z_ScanRequest *req = apdu_req->u.scanRequest;
std::string vhost;
- yp2::odr odr;
+ mp::odr odr;
std::list<std::string> databases;
int i;
std::list<std::string>::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);
}
Z_InitRequest *req = gdu->u.z3950->u.initRequest;
std::list<std::string> 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;
Z_APDU *apdu = gdu->u.z3950;
if (apdu->which == Z_APDU_initRequest)
{
- yp2::odr odr;
+ mp::odr odr;
package.response() = odr.create_close(
apdu,
}
else
{
- yp2::odr odr;
+ mp::odr odr;
package.response() = odr.create_close(
apdu, Z_Close_protocolError,
}
-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)
{
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");
}
}
-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
-/* $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%
*/
#include "filter.hpp"
-namespace yp2 {
+namespace metaproxy_1 {
namespace filter {
class Virt_db : public Base {
class Rep;
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<std::string> targets,
}
extern "C" {
- extern struct yp2_filter_struct yp2_filter_virt_db;
+ extern struct metaproxy_1_filter_struct metaproxy_1_filter_virt_db;
}
#endif
-/* $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%
*/
#include <yaz++/pdu-assoc.h>
#include <yaz++/z-assoc.h>
-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;
int m_timeout_sec;
boost::mutex m_mutex;
boost::condition m_cond_session_ready;
- std::map<yp2::Session,Z3950Client::Assoc *> m_clients;
+ std::map<mp::Session,Z3950Client::Assoc *> m_clients;
Z3950Client::Assoc *get_assoc(Package &package);
void send_and_receive(Package &package,
yf::Z3950Client::Assoc *c);
}
}
-using namespace yp2;
+using namespace mp;
yf::Z3950Client::Assoc::Assoc(yazpp_1::SocketManager *socket_manager,
yazpp_1::IPDU_Observable *PDU_Observable,
{
m_waiting = false;
- yp2::odr odr;
+ mp::odr odr;
if (m_package)
{
{
m_waiting = false;
- yp2::odr odr;
+ mp::odr odr;
if (m_package)
{
// only one thread messes with the clients list at a time
boost::mutex::scoped_lock lock(m_mutex);
- std::map<yp2::Session,yf::Z3950Client::Assoc *>::iterator it;
+ std::map<mp::Session,yf::Z3950Client::Assoc *>::iterator it;
Z_GDU *gdu = package.request().get();
// only deal with Z39.50
// 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,
return 0;
}
std::list<std::string> 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,
}
if (no_vhosts > 1)
{
- yp2::odr odr;
+ mp::odr odr;
package.response() = odr.create_initResponse(
apdu,
YAZ_BIB1_COMBI_OF_SPECIFIED_DATABASES_UNSUPP,
std::list<std::string>::const_iterator v_it = vhosts.begin();
std::list<std::string> dblist;
std::string host;
- yp2::util::split_zurl(*v_it, host, dblist);
+ mp::util::split_zurl(*v_it, host, dblist);
if (dblist.size())
{
void yf::Z3950Client::Rep::release_assoc(Package &package)
{
boost::mutex::scoped_lock lock(m_mutex);
- std::map<yp2::Session,yf::Z3950Client::Assoc *>::iterator it;
+ std::map<mp::Session,yf::Z3950Client::Assoc *>::iterator it;
it = m_clients.find(package.session());
if (it != m_clients.end())
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
-/* $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%
*/
#include "filter.hpp"
-namespace yp2 {
+namespace metaproxy_1 {
namespace filter {
class Z3950Client : public Base {
class Rep;
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<Rep> m_p;
}
extern "C" {
- extern struct yp2_filter_struct yp2_filter_z3950_client;
+ extern struct metaproxy_1_filter_struct metaproxy_1_filter_z3950_client;
}
#endif
--- /dev/null
+/* $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 <boost/program_options.hpp>
+namespace po = boost::program_options;
+
+#include <iostream>
+#include <stdexcept>
+
+#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<std::string> >(), "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<std::string> config_fnames =
+ vm["config"].as< std::vector<std::string> >();
+
+ 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
+ */
-/* $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%
*/
#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)
{
}
}
-void yp2::Package::move(std::string route)
+void mp::Package::move(std::string route)
{
if (m_route_pos)
{
}
-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;
}
-/* $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%
*/
#include "filter.hpp"
#include "session.hpp"
-namespace yp2 {
+namespace metaproxy_1 {
class Origin {
enum origin_t {
~Package();
- Package(yp2::Session &session, yp2::Origin &origin);
+ Package(metaproxy_1::Session &session, metaproxy_1::Origin &origin);
Package & copy_filter(const Package &p);
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;
-/* $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%
*/
#include "pipe.hpp"
-namespace yp2 {
+namespace mp = metaproxy_1;
+
+namespace metaproxy_1 {
class Pipe::Rep : public boost::noncopyable {
friend class Pipe;
Rep();
};
}
-using namespace yp2;
+using namespace mp;
void Pipe::Rep::close(int &fd)
{
-/* $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%
*/
#include <yaz/yconfig.h>
-namespace yp2 {
+namespace metaproxy_1 {
class Pipe {
class Error : public std::runtime_error {
public:
-/* $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%
*/
#define PLAINFILE_MAX_LINE 256
-namespace yp2 {
+namespace mp = metaproxy_1;
+
+namespace metaproxy_1 {
class PlainFile::Rep {
friend class PlainFile;
Rep();
};
}
-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();
return true;
}
-bool yp2::PlainFile::getline(std::vector<std::string> &args)
+bool mp::PlainFile::getline(std::vector<std::string> &args)
{
args.clear();
-/* $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%
*/
#include <string>
#include <stdexcept>
-namespace yp2
+namespace metaproxy_1
{
namespace filter {
class Base;
-/* $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%
*/
#include <list>
-namespace yp2
+namespace mp = metaproxy_1;
+
+namespace metaproxy_1
{
class ChainPos;
virtual RoutePos *clone();
virtual ~Pos();
std::list<const filter::Base *>::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;
-/* $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%
*/
#include <boost/scoped_ptr.hpp>
#include <stdexcept>
-namespace yp2 {
+namespace metaproxy_1 {
class RouterChain : public Router {
class Rep;
class Pos;
-/* $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%
*/
#include <libxml/parser.h>
#include <libxml/tree.h>
+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<boost::shared_ptr<const yp2::filter::Base> > m_list;
+ std::list<boost::shared_ptr<const mp::filter::Base> > 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<std::string,
- boost::shared_ptr<const yp2::filter::Base > >
+ boost::shared_ptr<const mp::filter::Base > >
IdFilterMap ;
IdFilterMap m_id_filter_map;
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<std::string,
RouterFleXML::Route>::iterator m_route_it;
- std::list<boost::shared_ptr <const yp2::filter::Base> >::iterator m_filter_it;
+ std::list<boost::shared_ptr <const mp::filter::Base> >::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++;
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);
}
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<yp2::filter::Base>(filter_base);
+ boost::shared_ptr<mp::filter::Base>(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++;
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);
}
Route route;
// process <filter> 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++;
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<std::string,
- boost::shared_ptr<const yp2::filter::Base > >::iterator it;
+ boost::shared_ptr<const mp::filter::Base > >::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);
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<yp2::filter::Base>(filter_base));
+ boost::shared_ptr<mp::filter::Base>(filter_base));
}
- node3 = yp2::xml::jump_to_next(node3, XML_ELEMENT_NODE);
+ node3 = mp::xml::jump_to_next(node3, XML_ELEMENT_NODE);
}
std::map<std::string,RouterFleXML::Route>::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 <start> 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;
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 <filters> 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 <routes> 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;
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);
}
}
-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)
{
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())
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()
{
}
-/* $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%
*/
#include <boost/scoped_ptr.hpp>
-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();
-/* $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%
*/
#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:
-/* $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%
*/
#include <map>
#include <boost/thread/mutex.hpp>
-namespace yp2 {
+namespace metaproxy_1 {
class Session
{
template <class T> 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<yp2::Session,SessionItem>::const_iterator it;
+ typename std::map<metaproxy_1::Session,SessionItem>::const_iterator it;
it = m_map.find(s);
if (it == m_map.end())
return 0;
new boost::mutex::scoped_lock(it->second->m_item_mutex);
};
#endif
- bool exist(const yp2::Session &s) {
- typename std::map<yp2::Session,SessionItem>::const_iterator it;
+ bool exist(const metaproxy_1::Session &s) {
+ typename std::map<metaproxy_1::Session,SessionItem>::const_iterator it;
it = m_map.find(s);
return it == m_map.end() ? false : true;
}
};
private:
boost::mutex m_map_mutex;
- std::map<yp2::Session,SessionItem>m_map;
+ std::map<metaproxy_1::Session,SessionItem>m_map;
};
}
-/* $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%
*/
-/* $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%
*/
-/* $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%
*/
#include <boost/test/auto_unit_test.hpp>
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 {};
};
-/* $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%
*/
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();
};
// 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();
};
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();
}
{
- 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();
FilterConstant fc;
BOOST_CHECK_EQUAL(fc.get_constant(), 1234);
- yp2::filter::Base *base = &fc;
+ mp::filter::Base *base = &fc;
std::string some_xml = "<?xml version=\"1.0\"?>\n"
"<filter type=\"constant\">\n"
-/* $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%
*/
#include <boost/test/auto_unit_test.hpp>
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())
{
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";
{
try
{
- yp2::filter::AuthSimple lf;
+ mp::filter::AuthSimple lf;
}
catch ( ... ) {
BOOST_CHECK (false);
{
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;
-/* $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%
*/
#include <boost/test/auto_unit_test.hpp>
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);
{
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);
{
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**)
{
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);
-/* $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%
*/
#include <boost/test/auto_unit_test.hpp>
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;
}
{
try {
- yp2::FactoryFilter ffactory;
+ mp::FactoryFilter ffactory;
XFilter xf;
YFilter yf;
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);
BOOST_AUTO_UNIT_TEST( test_filter_factory_2 )
{
try {
- yp2::FactoryFilter ffactory;
+ mp::FactoryFilter ffactory;
const std::string id = "dl";
// 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 ..
}
-/* $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%
*/
#include <boost/test/auto_unit_test.hpp>
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())
{
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";
try
{
{
- yp2::filter::FrontendNet nf;
+ mp::filter::FrontendNet nf;
}
}
catch ( ... ) {
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;
try
{
{
- yp2::RouterChain router;
+ mp::RouterChain router;
// put in frontend first
- yp2::filter::FrontendNet filter_front;
+ mp::filter::FrontendNet filter_front;
std::vector <std::string> ports;
ports.insert(ports.begin(), "unix:socket");
FilterInit filter_init;
router.append(filter_init);
- yp2::Package pack;
+ mp::Package pack;
pack.router(router).move();
}
-/* $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%
*/
#include <boost/test/auto_unit_test.hpp>
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())
{
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";
{
try
{
- yp2::filter::Log lf;
+ mp::filter::Log lf;
}
catch ( ... ) {
BOOST_CHECK (false);
{
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;
-/* $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%
*/
#include <boost/test/auto_unit_test.hpp>
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())
{
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";
{
try
{
- yp2::filter::Multi lf;
+ mp::filter::Multi lf;
}
catch ( ... ) {
BOOST_CHECK (false);
{
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;
-/* $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%
*/
#include <boost/test/auto_unit_test.hpp>
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())
{
};
};
-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;
}
}
-void check_query_rewrite_search(yp2::RouterChain &router,
+void check_query_rewrite_search(mp::RouterChain &router,
std::string query_in,
std::string query_expect)
{
// << 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;
{
try
{
- yp2::filter::QueryRewrite f_query_rewrite;
+ mp::filter::QueryRewrite f_query_rewrite;
}
catch ( ... ) {
BOOST_CHECK (false);
{
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);
try
{
- yp2::RouterChain router;
+ mp::RouterChain router;
std::string xmlconf =
"<?xml version='1.0'?>\n"
"<filter xmlns='http://indexdata.dk/yp2/config/1'\n"
" id='qrw1' type='query_rewrite'>\n"
- " <regex action='all'>\n"
- " <expression>@attrset XYZ</expression>\n"
- " <format>@attrset Bib-1</format>\n"
- " </regex>\n"
- " <regex action='search'>\n"
- " <expression>@attr 1=4</expression>\n"
- " <format>@attr 1=4 @attr 4=2</format>\n"
- " </regex>\n"
- " <regex action='search'>\n"
- " <expression>fish</expression>\n"
- " <format>cat</format>\n"
- " </regex>\n"
- " <regex action='scan'>\n"
- " <expression>@attr 1=4</expression>\n"
- " <format>@attr 1=5 @attr 4=1</format>\n"
- " </regex>\n"
- " <regex action='scan' stop='1'>\n"
- " <expression>fish</expression>\n"
- " <format>mouse</format>\n"
- " </regex>\n"
- " <regex action='all' when='finally'>\n"
- " <expression>^</expression>\n"
- " <format>@and @attr1=9999 vdb</format>\n"
- " </regex>\n"
- " <test action='scan'><!-- unit-test for configuration -->\n"
- " <in>@attr 1=4 foo</in>\n"
- " <out>@attr 1=1034 fish</out>\n"
- " </test>\n"
"</filter>\n"
;
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
-/* $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%
*/
#include <yaz/otherinfo.h>
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);
{
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);
}
-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);
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);
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);
{
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");
}
}
-/* $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%
*/
#include <yaz/zgdu.h>
#include <yaz/otherinfo.h>
-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);
{
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);
{
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);
{
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";
-/* $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%
*/
#include <boost/test/auto_unit_test.hpp>
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());
}
-/* $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%
*/
#include <boost/test/auto_unit_test.hpp>
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);
-/* $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%
*/
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;
}
" </routes>\n"
"</yp2>\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) {
" <filter id=\"front_default\" type=\"frontend_net\">\n"
" <port>@:210</port>\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;
}
" </y:routes>\n"
"</y:yp2>\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";
" </routes>\n"
"</yp2>\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) {
-/* $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%
*/
#include <yaz/otherinfo.h>
using namespace boost::unit_test;
+namespace mp = metaproxy_1;
-namespace yp2 {
+namespace metaproxy_1 {
class SesMap;
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<Wrap> w_ptr(new Wrap(t));
m_map_ptr[s] = w_ptr;
}
- std::map<yp2::Session,boost::shared_ptr<Wrap> >m_map_ptr;
+ std::map<mp::Session,boost::shared_ptr<Wrap> >m_map_ptr;
};
}
{
try
{
- yp2::SesMap ses_map;
+ mp::SesMap ses_map;
}
catch ( ... ) {
BOOST_CHECK (false);
-/* $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%
*/
#include <boost/test/auto_unit_test.hpp>
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);
}
-/* $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%
*/
#include <boost/test/auto_unit_test.hpp>
using namespace boost::unit_test;
+namespace mp = metaproxy_1;
boost::mutex io_mutex;
void operator() (void) {
for (int i=0; i < 100; ++i)
{
- yp2::Session session;
+ mp::Session session;
m_id = session.id();
//print();
}
}
thrds.join_all();
- yp2::Session session;
+ mp::Session session;
BOOST_CHECK (session.id() == 10001);
}
-/* $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.
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;
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;
}
My_Timer_Thread::My_Timer_Thread(ISocketObservable *obs,
- yp2::ThreadPoolSocketObserver *t) :
+ mp::ThreadPoolSocketObserver *t) :
m_obs(obs), m_pipe(9123)
{
m_t = t;
{
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)
;
-/* $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%
*/
#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) {};
using namespace yazpp_1;
-using namespace yp2;
+using namespace mp;
ThreadPoolSocketObserver::Rep::Rep(ISocketObservable *obs)
: m_socketObservable(obs), m_pipe(9123)
-/* $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%
*/
#include <yaz++/socket-observer.h>
#include <yaz/yconfig.h>
-namespace yp2 {
+namespace metaproxy_1 {
class IThreadPoolMsg {
public:
virtual IThreadPoolMsg *handle() = 0;
-/* $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%
*/
-/* $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%
*/
//#include <iostream>
-void yp2::util::piggyback(int smallSetUpperBound,
+namespace mp = metaproxy_1;
+
+void mp::util::piggyback(int smallSetUpperBound,
int largeSetLowerBound,
int mediumSetPresentNumber,
int result_set_size,
}
-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());
}
-std::string yp2::util::zQueryToString(Z_Query *query)
+std::string mp::util::zQueryToString(Z_Query *query)
{
std::string query_str = "";
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;
}
}
-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;
{
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);
}
}
}
}
-int yp2::util::get_vhost_otherinfo(Z_OtherInformation **otherInformation,
+int mp::util::get_vhost_otherinfo(Z_OtherInformation **otherInformation,
bool remove_flag,
std::list<std::string> &vhosts)
{
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<std::string> &vhosts)
{
}
}
-void yp2::util::split_zurl(std::string zurl, std::string &host,
+void mp::util::split_zurl(std::string zurl, std::string &host,
std::list<std::string> &db)
{
const char *zurl_cstr = zurl.c_str();
}
}
-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;
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);
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));
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);
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);
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);
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);
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";
return gdu;
}
-Z_ReferenceId **yp2::util::get_referenceId(Z_APDU *apdu)
+Z_ReferenceId **mp::util::get_referenceId(Z_APDU *apdu)
{
switch (apdu->which)
{
-/* $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%
*/
#include <boost/scoped_ptr.hpp>
#include "package.hpp"
-namespace yp2 {
+namespace metaproxy_1 {
namespace util {
bool pqf(ODR odr, Z_APDU *apdu, const std::string &q);
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;
-/* $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)
}
-bool yp2::xml::is_element(const xmlNode *ptr,
+bool mp::xml::is_element(const xmlNode *ptr,
const std::string &ns,
const std::string &name)
{
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)
}
-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;
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;
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)
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));
}
}
-/* $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%
*/
#include <stdexcept>
#include <libxml/tree.h>
-namespace yp2 {
+namespace metaproxy_1 {
namespace xml {
std::string get_text(const xmlNode *ptr);
bool is_element(const xmlNode *ptr,
+++ /dev/null
-/* $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 <boost/program_options.hpp>
-namespace po = boost::program_options;
-
-#include <iostream>
-#include <stdexcept>
-
-#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<std::string> >(), "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<std::string> config_fnames =
- vm["config"].as< std::vector<std::string> >();
-
- 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
- */