From e6d572ef110d14fa55115021505b808620457bd3 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 11 Jan 2010 11:20:30 +0100 Subject: [PATCH] Public MP headers in include/metaproxy --- Makefile.am | 2 +- configure.ac | 1 + include/Makefile.am | 5 ++ include/metaproxy/Makefile.am | 6 ++ include/metaproxy/filter.hpp | 67 ++++++++++++++ include/metaproxy/origin.hpp | 91 ++++++++++++++++++++ include/metaproxy/package.hpp | 107 +++++++++++++++++++++++ include/metaproxy/router.hpp | 63 ++++++++++++++ include/metaproxy/session.hpp | 148 +++++++++++++++++++++++++++++++ include/metaproxy/util.hpp | 158 ++++++++++++++++++++++++++++++++++ include/metaproxy/xmlutil.hpp | 71 +++++++++++++++ src/Makefile.am | 16 ++-- src/ex_filter_frontend_net.cpp | 5 +- src/ex_router_flexml.cpp | 4 +- src/factory_filter.hpp | 2 +- src/factory_static.cpp | 4 +- src/filter.cpp | 2 +- src/filter.hpp | 67 -------------- src/filter_auth_simple.cpp | 6 +- src/filter_auth_simple.hpp | 2 +- src/filter_backend_test.cpp | 6 +- src/filter_backend_test.hpp | 2 +- src/filter_bounce.cpp | 4 +- src/filter_bounce.hpp | 2 +- src/filter_cql_to_rpn.cpp | 6 +- src/filter_cql_to_rpn.hpp | 2 +- src/filter_dl.cpp | 4 +- src/filter_frontend_net.cpp | 6 +- src/filter_frontend_net.hpp | 2 +- src/filter_http_file.cpp | 6 +- src/filter_http_file.hpp | 2 +- src/filter_limit.cpp | 4 +- src/filter_limit.hpp | 2 +- src/filter_load_balance.cpp | 7 +- src/filter_load_balance.hpp | 2 +- src/filter_log.cpp | 8 +- src/filter_log.hpp | 2 +- src/filter_multi.cpp | 6 +- src/filter_multi.hpp | 2 +- src/filter_query_rewrite.cpp | 7 +- src/filter_query_rewrite.hpp | 2 +- src/filter_record_transform.cpp | 8 +- src/filter_record_transform.hpp | 2 +- src/filter_session_shared.cpp | 6 +- src/filter_session_shared.hpp | 2 +- src/filter_sru_to_z3950.cpp | 5 +- src/filter_sru_to_z3950.hpp | 2 +- src/filter_template.cpp | 5 +- src/filter_template.hpp | 2 +- src/filter_virt_db.cpp | 7 +- src/filter_virt_db.hpp | 2 +- src/filter_z3950_client.cpp | 5 +- src/filter_z3950_client.hpp | 2 +- src/filter_zeerex_explain.cpp | 7 +- src/filter_zeerex_explain.hpp | 2 +- src/gduutil.cpp | 2 +- src/metaproxy_prog.cpp | 4 +- src/origin.cpp | 4 +- src/origin.hpp | 91 -------------------- src/package.cpp | 2 +- src/package.hpp | 107 ----------------------- src/plainfile.cpp | 2 +- src/router.hpp | 63 -------------- src/router_chain.hpp | 2 +- src/router_flexml.cpp | 2 +- src/router_flexml.hpp | 2 +- src/session.cpp | 2 +- src/session.hpp | 148 ------------------------------- src/sru_util.cpp | 5 +- src/sru_util.hpp | 6 +- src/test_filter1.cpp | 2 +- src/test_filter2.cpp | 7 +- src/test_filter_auth_simple.cpp | 5 +- src/test_filter_backend_test.cpp | 5 +- src/test_filter_bounce.cpp | 6 +- src/test_filter_factory.cpp | 4 +- src/test_filter_frontend_net.cpp | 5 +- src/test_filter_log.cpp | 5 +- src/test_filter_multi.cpp | 5 +- src/test_filter_query_rewrite.cpp | 5 +- src/test_filter_record_transform.cpp | 9 +- src/test_filter_sru_to_z3950.cpp | 5 +- src/test_filter_virt_db.cpp | 5 +- src/test_filter_z3950_client.cpp | 5 +- src/test_package1.cpp | 2 +- src/test_pipe.cpp | 2 +- src/test_router_flexml.cpp | 2 +- src/test_ses_map.cpp | 4 +- src/test_session1.cpp | 2 +- src/test_session2.cpp | 2 +- src/util.cpp | 2 +- src/util.hpp | 158 ---------------------------------- src/xmlutil.cpp | 2 +- src/xmlutil.hpp | 71 --------------- 94 files changed, 855 insertions(+), 875 deletions(-) create mode 100644 include/Makefile.am create mode 100644 include/metaproxy/Makefile.am create mode 100644 include/metaproxy/filter.hpp create mode 100644 include/metaproxy/origin.hpp create mode 100644 include/metaproxy/package.hpp create mode 100644 include/metaproxy/router.hpp create mode 100644 include/metaproxy/session.hpp create mode 100644 include/metaproxy/util.hpp create mode 100644 include/metaproxy/xmlutil.hpp delete mode 100644 src/filter.hpp delete mode 100644 src/origin.hpp delete mode 100644 src/package.hpp delete mode 100644 src/router.hpp delete mode 100644 src/session.hpp delete mode 100644 src/util.hpp delete mode 100644 src/xmlutil.hpp diff --git a/Makefile.am b/Makefile.am index 21d1d4c..f9ab81a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,7 @@ ## This file is part of Metaproxy ## Copyright (C) 2005-2010 Index Data -SUBDIRS = xml src etc doc +SUBDIRS = xml include src etc doc ACLOCAL_AMFLAGS = -I m4 diff --git a/configure.ac b/configure.ac index 10887dc..be73fbc 100644 --- a/configure.ac +++ b/configure.ac @@ -56,6 +56,7 @@ AC_CHECK_HEADERS([sys/select.h sys/socket.h]) AC_CONFIG_FILES([ Doxyfile Makefile + include/Makefile include/metaproxy/Makefile src/Makefile xml/Makefile xml/schema/Makefile diff --git a/include/Makefile.am b/include/Makefile.am new file mode 100644 index 0000000..6256287 --- /dev/null +++ b/include/Makefile.am @@ -0,0 +1,5 @@ +## This file is part of Metaproxy +## Copyright (C) 2005-2010 Index Data + +SUBDIRS = metaproxy + diff --git a/include/metaproxy/Makefile.am b/include/metaproxy/Makefile.am new file mode 100644 index 0000000..bd00e30 --- /dev/null +++ b/include/metaproxy/Makefile.am @@ -0,0 +1,6 @@ +## This file is part of Metaproxy +## Copyright (C) 2005-2010 Index Data + +pkginclude_HEADERS= filter.hpp origin.hpp package.hpp \ + router.hpp session.hpp util.hpp xmlutil.hpp + diff --git a/include/metaproxy/filter.hpp b/include/metaproxy/filter.hpp new file mode 100644 index 0000000..691eda4 --- /dev/null +++ b/include/metaproxy/filter.hpp @@ -0,0 +1,67 @@ +/* This file is part of Metaproxy. + Copyright (C) 2005-2010 Index Data + +Metaproxy is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef FILTER_HPP +#define FILTER_HPP + +#include +#include +#include +#include "xmlutil.hpp" + +namespace metaproxy_1 { + + class Package; + + namespace filter { + class Base { + public: + virtual ~Base(){}; + + ///sends Package off to next Filter, returns altered Package + virtual void process(Package & package) const = 0; + + /// configuration during filter load + virtual void configure(const xmlNode * ptr, bool test_only); + }; + + class FilterException : public std::runtime_error { + public: + FilterException(const std::string message) + : std::runtime_error("FilterException: " + message){ + }; + }; + } +} + +struct metaproxy_1_filter_struct { + int ver; + const char *type; + metaproxy_1::filter::Base* (*creator)(); +}; + +#endif +/* + * Local variables: + * c-basic-offset: 4 + * c-file-style: "Stroustrup" + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ + diff --git a/include/metaproxy/origin.hpp b/include/metaproxy/origin.hpp new file mode 100644 index 0000000..29d1124 --- /dev/null +++ b/include/metaproxy/origin.hpp @@ -0,0 +1,91 @@ +/* This file is part of Metaproxy. + Copyright (C) 2005-2010 Index Data + +Metaproxy is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef YP2_ORIGIN_HPP +#define YP2_ORIGIN_HPP + +#include +#include + +namespace metaproxy_1 { + class Origin; +} + +namespace std { + std::ostream& operator<<(std::ostream& os, metaproxy_1::Origin& o); +} + +namespace metaproxy_1 { + + class Origin { + public: + Origin(std::string listen_host = "", unsigned int listen_port = 0); + + /// get function - right val in assignment + std::string listen_host() const; + + /// set function - left val in assignment + std::string & listen_host(); + + /// get function - right val in assignment + unsigned int listen_port() const; + + /// set function - left val in assignment + unsigned int & listen_port(); + + /// set client IP info - left val in assignment + void set_tcpip_address(std::string addr, unsigned long id); + + /// set max sockets (for outgoing connections to a given target) + void set_max_sockets(int max_sockets); + + /// set max sockets (for outgoing connections to a given target) + int get_max_sockets(); + + /// get tcpip address + std::string get_address(); + private: + friend std::ostream& + std::operator<<(std::ostream& os, metaproxy_1::Origin& o); + + enum origin_t { + API, + UNIX, + TCPIP + } m_type; + std::string m_address; // UNIX+TCPIP + unsigned int m_origin_id; + std::string m_listen_host; + unsigned int m_listen_port; + int m_max_sockets; + }; + +} + + + +#endif +/* + * Local variables: + * c-basic-offset: 4 + * c-file-style: "Stroustrup" + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ + diff --git a/include/metaproxy/package.hpp b/include/metaproxy/package.hpp new file mode 100644 index 0000000..69fbcb7 --- /dev/null +++ b/include/metaproxy/package.hpp @@ -0,0 +1,107 @@ +/* This file is part of Metaproxy. + Copyright (C) 2005-2010 Index Data + +Metaproxy is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef YP2_PACKAGE_HPP +#define YP2_PACKAGE_HPP + +#include + +#include + +#include "router.hpp" +#include "filter.hpp" +#include "session.hpp" +#include "origin.hpp" + +namespace metaproxy_1 { + class Package; +} + + +namespace std +{ + std::ostream& operator<<(std::ostream& os, metaproxy_1::Package& p); +} + +namespace metaproxy_1 { + + class Package { + public: + Package(); + + ~Package(); + + Package(metaproxy_1::Session &session, + const metaproxy_1::Origin &origin); + + /// shallow copy constructor which only copies the filter chain info + Package & copy_filter(const Package &p); + + /// send Package to it's next Filter defined in Router + void move(); + + /// send Package to other route + void move(std::string route); + + /// access session - left val in assignment + metaproxy_1::Session & session(); + + /// get function - right val in assignment + Origin origin() const; + + /// set function - left val in assignment + Origin & origin(); + + /// set function - can be chained + Package & origin(const Origin & origin); + + /// set function - can be chained + Package & router(const Router &router); + + yazpp_1::GDU &request(); + + yazpp_1::GDU &response(); + + /// get function - right val in assignment + Session session() const; + + private: + Session m_session; + Origin m_origin; + + RoutePos *m_route_pos; + + //int m_data; + + yazpp_1::GDU m_request_gdu; + yazpp_1::GDU m_response_gdu; + }; +} + + + +#endif +/* + * Local variables: + * c-basic-offset: 4 + * c-file-style: "Stroustrup" + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ + diff --git a/include/metaproxy/router.hpp b/include/metaproxy/router.hpp new file mode 100644 index 0000000..392f048 --- /dev/null +++ b/include/metaproxy/router.hpp @@ -0,0 +1,63 @@ +/* This file is part of Metaproxy. + Copyright (C) 2005-2010 Index Data + +Metaproxy is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef ROUTER_HPP +#define ROUTER_HPP + +#include +#include +#include + +namespace metaproxy_1 +{ + namespace filter { + class Base; + } + class RoutePos; + + class RouterException : public std::runtime_error { + public: + RouterException(const std::string message) + : std::runtime_error("RouterException: " + message){}; + }; + + class Router : boost::noncopyable { + public: + Router(){}; + virtual ~Router(){}; + + virtual RoutePos *createpos() const = 0; + }; + + class RoutePos : boost::noncopyable { + public: + virtual const filter::Base *move(const char *route) = 0; + virtual RoutePos *clone() = 0; + virtual ~RoutePos() {}; + }; +} +#endif +/* + * Local variables: + * c-basic-offset: 4 + * c-file-style: "Stroustrup" + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ + diff --git a/include/metaproxy/session.hpp b/include/metaproxy/session.hpp new file mode 100644 index 0000000..124a8c1 --- /dev/null +++ b/include/metaproxy/session.hpp @@ -0,0 +1,148 @@ +/* This file is part of Metaproxy. + Copyright (C) 2005-2010 Index Data + +Metaproxy is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef SESSION_HPP +#define SESSION_HPP + +//#include +#include +#include + +namespace metaproxy_1 { + + class Session + { + //typedef unsigned long type; + public: + + /// create new session with new unique id + Session() { + boost::mutex::scoped_lock scoped_lock(m_mutex); + ++m_global_id; + m_id = m_global_id; + m_close = false; + } + + /// copy session including old id + Session(const Session &s) : m_id(s.m_id), m_close(s.m_close) {}; + + Session& operator=(const Session &s) { + if (this != &s) + { + m_id = s.m_id; + m_close = s.m_close; + } + return *this; + } + + bool operator<(const Session &s) const { + return m_id < s.m_id ? true : false; + } + + unsigned long id() const { + return m_id; + } + + bool is_closed() const { + return m_close; + } + + /// mark session closed, can not be unset + void close() { + m_close = true; + } + + bool operator == (Session &ses) const { + return ses.m_id == m_id; + } + + private: + + unsigned long int m_id; + bool m_close; + + /// static mutex to lock static m_id + static boost::mutex m_mutex; + + /// static m_id to make sure that there is only one id counter + static unsigned long int m_global_id; + + }; + + template class session_map { + public: + 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 metaproxy_1::Session &s) { + boost::mutex::scoped_lock lock(m_map_mutex); + + m_map.erase(s); + }; +#if 0 + T &get_session_data(const metaproxy_1::Session &s) { + boost::mutex::scoped_lock lock(m_map_mutex); + + typename std::map::const_iterator it; + it = m_map.find(s); + if (it == m_map.end()) + return 0; + boost::mutx::scoped_lock *scoped_ptr = + new boost::mutex::scoped_lock(it->second->m_item_mutex); + }; +#endif + bool exist(const metaproxy_1::Session &s) { + typename std::map::const_iterator it; + it = m_map.find(s); + return it == m_map.end() ? false : true; + } + private: + class SessionItem { + public: + SessionItem() {}; + SessionItem(T &t) : m_t(t) {}; + SessionItem &operator =(const SessionItem &s) { + if (this != &s) { + m_t = s.m_t; + } + return *this; + }; + SessionItem(const SessionItem &s) { + m_t = s.m_t; + }; + T m_t; + boost::mutex m_item_mutex; + }; + private: + boost::mutex m_map_mutex; + std::mapm_map; + }; + +} + +#endif +/* + * Local variables: + * c-basic-offset: 4 + * c-file-style: "Stroustrup" + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ + diff --git a/include/metaproxy/util.hpp b/include/metaproxy/util.hpp new file mode 100644 index 0000000..810afbd --- /dev/null +++ b/include/metaproxy/util.hpp @@ -0,0 +1,158 @@ +/* This file is part of Metaproxy. + Copyright (C) 2005-2010 Index Data + +Metaproxy is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef YP2_UTIL_HPP +#define YP2_UTIL_HPP + +#include "package.hpp" + +#include + +#include +#include + +#include +#include +#include +#include + + +namespace metaproxy_1 { + namespace util { + + + template + std::string to_string(const T& t) + { + std::ostringstream o; + if(o << t) + return o.str(); + return std::string(); + }; + + const char * + record_composition_to_esn(Z_RecordComposition *comp); + + std::string http_header_value(const Z_HTTP_Header* header, + const std::string name); + + std::string http_headers_debug(const Z_HTTP_Request &http_req); + + void http_response(metaproxy_1::Package &package, + const std::string &content, + int http_code = 200); + + + int memcmp2(const void *buf1, int len1, const void *buf2, int len2); + + std::string database_name_normalize(const std::string &s); + + bool pqf(ODR odr, Z_APDU *apdu, const std::string &q); + + std::string zQueryToString(Z_Query *query); + + Z_ReferenceId **get_referenceId(const Z_APDU *apdu); + + void transfer_referenceId(ODR odr, const Z_APDU *src, Z_APDU *dst); + + Z_APDU *create_APDU(ODR odr, int type, const Z_APDU *in_apdu); + + bool set_databases_from_zurl(ODR odr, std::string zurl, + int *db_num, char ***db_strings); + + void split_zurl(std::string zurl, std::string &host, + std::list &db); + + void get_vhost_otherinfo(Z_OtherInformation *otherInformation, + std::list &vhosts); + + int remove_vhost_otherinfo(Z_OtherInformation **otherInformation, + std::list &vhosts); + + void set_vhost_otherinfo(Z_OtherInformation **otherInformation, + ODR odr, + const std::string vhost, + const int cat); + + void set_vhost_otherinfo(Z_OtherInformation **otherInformation, + ODR odr, + const std::list &vhosts); + + int get_or_remove_vhost_otherinfo( + Z_OtherInformation **otherInformation, + bool remove_flag, + std::list &vhosts); + + void get_init_diagnostics(Z_InitResponse *res, + int &error_code, std::string &addinfo); + + void get_default_diag(Z_DefaultDiagFormat *r, + int &error_code, std::string &addinfo); + + void piggyback(int smallSetUpperBound, + int largeSetLowerBound, + int mediumSetPresentNumber, + int result_set_size, + int &number_to_present); + + }; + + class odr : public boost::noncopyable { + public: + odr(int type); + odr(); + ~odr(); + operator ODR() const; + Z_APDU *create_close(const Z_APDU *in_apdu, + int reason, const char *addinfo); + Z_APDU *create_initResponse(const Z_APDU *in_apdu, + int error, const char *addinfo); + Z_APDU *create_searchResponse(const Z_APDU *in_apdu, + int error, const char *addinfo); + Z_APDU *create_presentResponse(const Z_APDU *in_apdu, + int error, const char *addinfo); + Z_APDU *create_scanResponse(const Z_APDU *in_apdu, + int error, const char *addinfo); + Z_APDU *create_APDU(int type, const Z_APDU *in_apdu); + + Z_GDU *create_HTTP_Response(metaproxy_1::Session &session, + Z_HTTP_Request *req, int code); + private: + ODR m_odr; + }; + + class PlainFile { + class Rep; + boost::scoped_ptr m_p; + public: + PlainFile(); + ~PlainFile(); + bool open(const std::string &fname); + bool getline(std::vector &args); + }; +} +#endif +/* + * Local variables: + * c-basic-offset: 4 + * c-file-style: "Stroustrup" + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ + diff --git a/include/metaproxy/xmlutil.hpp b/include/metaproxy/xmlutil.hpp new file mode 100644 index 0000000..5377bb4 --- /dev/null +++ b/include/metaproxy/xmlutil.hpp @@ -0,0 +1,71 @@ +/* This file is part of Metaproxy. + Copyright (C) 2005-2010 Index Data + +Metaproxy is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef XML_UTIL_HPP +#define XML_UTIL_HPP + +#include +#include +#include + +namespace metaproxy_1 { + namespace xml { + std::string get_text(const struct _xmlAttr *ptr); + std::string get_text(const xmlNode *ptr); + bool get_bool(const xmlNode *ptr, bool default_value); + int get_int(const xmlNode *ptr, int default_value); + bool check_attribute(const _xmlAttr *ptr, + const std::string &ns, + const std::string &name); + bool is_attribute(const _xmlAttr *ptr, + const std::string &ns, + const std::string &name); + bool is_element(const xmlNode *ptr, + const std::string &ns, + const std::string &name); + bool is_element_mp(const xmlNode *ptr, const std::string &name); + bool check_element_mp(const xmlNode *ptr, + const std::string &name); + std::string get_route(const xmlNode *node); + + const xmlNode* jump_to(const xmlNode* node, int node_type); + + const xmlNode* jump_to_next(const xmlNode* node, int node_type); + + const xmlNode* jump_to_children(const xmlNode* node, int node_type); + + void check_empty(const xmlNode *node); + + } + class XMLError : public std::runtime_error { + public: + XMLError(const std::string msg) : + std::runtime_error("XMLError : " + msg) {} ; + }; +} + +#endif +/* + * Local variables: + * c-basic-offset: 4 + * c-file-style: "Stroustrup" + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ + diff --git a/src/Makefile.am b/src/Makefile.am index 9dbd951..2940fd6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -5,6 +5,8 @@ MAINTAINERCLEANFILES = Makefile.in config.in config.hpp AM_CXXFLAGS = $(BOOST_CPPFLAGS) +AM_CPPFLAGS = -I$(top_srcdir)/include + AM_LDFLAGS = # Rules for the library.. @@ -15,7 +17,7 @@ libmetaproxy_la_LDFLAGS = -version-info 1:0:0 -export-dynamic libmetaproxy_la_SOURCES = \ factory_filter.cpp factory_filter.hpp \ factory_static.cpp factory_static.hpp \ - filter.hpp filter.cpp \ + filter.cpp \ filter_auth_simple.cpp filter_auth_simple.hpp \ filter_backend_test.cpp filter_backend_test.hpp \ filter_bounce.cpp filter_bounce.hpp \ @@ -35,17 +37,17 @@ libmetaproxy_la_SOURCES = \ filter_z3950_client.cpp filter_z3950_client.hpp \ filter_zeerex_explain.cpp filter_zeerex_explain.hpp \ gduutil.cpp gduutil.hpp \ - origin.cpp origin.hpp \ - package.cpp package.hpp \ + origin.cpp \ + package.cpp \ pipe.cpp pipe.hpp \ plainfile.cpp \ - router.hpp router_chain.hpp router_chain.cpp \ + router_chain.hpp router_chain.cpp \ router_flexml.hpp router_flexml.cpp \ - session.cpp session.hpp \ + session.cpp \ sru_util.cpp sru_util.hpp \ thread_pool_observer.cpp thread_pool_observer.hpp \ - util.cpp util.hpp \ - xmlutil.cpp xmlutil.hpp + util.cpp \ + xmlutil.cpp libmetaproxy_la_LIBADD = $(YAZPPLALIB) $(BOOST_LIB) $(BOOST_THREAD_LIB) diff --git a/src/ex_filter_frontend_net.cpp b/src/ex_filter_frontend_net.cpp index dcfee46..bdf538d 100644 --- a/src/ex_filter_frontend_net.cpp +++ b/src/ex_filter_frontend_net.cpp @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include "util.hpp" +#include #include "filter_frontend_net.hpp" #include "filter_z3950_client.hpp" #include "filter_virt_db.hpp" @@ -31,8 +31,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "filter_log.hpp" #include "router_chain.hpp" -#include "session.hpp" -#include "package.hpp" +#include namespace mp = metaproxy_1; diff --git a/src/ex_router_flexml.cpp b/src/ex_router_flexml.cpp index f19b28d..e068e1e 100644 --- a/src/ex_router_flexml.cpp +++ b/src/ex_router_flexml.cpp @@ -23,8 +23,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include "filter.hpp" -#include "package.hpp" +#include +#include #include "router_flexml.hpp" #include "factory_static.hpp" diff --git a/src/factory_filter.hpp b/src/factory_filter.hpp index 33719bb..8f02939 100644 --- a/src/factory_filter.hpp +++ b/src/factory_filter.hpp @@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include "filter.hpp" +#include namespace metaproxy_1 { class FactoryFilter : public boost::noncopyable diff --git a/src/factory_static.cpp b/src/factory_static.cpp index 95f62ec..0101819 100644 --- a/src/factory_static.cpp +++ b/src/factory_static.cpp @@ -22,8 +22,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "factory_static.hpp" #include "config.hpp" -#include "filter.hpp" -#include "package.hpp" +#include +#include #include "factory_filter.hpp" diff --git a/src/filter.cpp b/src/filter.cpp index 8537d71..430cbbb 100644 --- a/src/filter.cpp +++ b/src/filter.cpp @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include "config.hpp" -#include "filter.hpp" +#include namespace mp = metaproxy_1; diff --git a/src/filter.hpp b/src/filter.hpp deleted file mode 100644 index 691eda4..0000000 --- a/src/filter.hpp +++ /dev/null @@ -1,67 +0,0 @@ -/* This file is part of Metaproxy. - Copyright (C) 2005-2010 Index Data - -Metaproxy is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 2, or (at your option) any later -version. - -Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef FILTER_HPP -#define FILTER_HPP - -#include -#include -#include -#include "xmlutil.hpp" - -namespace metaproxy_1 { - - class Package; - - namespace filter { - class Base { - public: - virtual ~Base(){}; - - ///sends Package off to next Filter, returns altered Package - virtual void process(Package & package) const = 0; - - /// configuration during filter load - virtual void configure(const xmlNode * ptr, bool test_only); - }; - - class FilterException : public std::runtime_error { - public: - FilterException(const std::string message) - : std::runtime_error("FilterException: " + message){ - }; - }; - } -} - -struct metaproxy_1_filter_struct { - int ver; - const char *type; - metaproxy_1::filter::Base* (*creator)(); -}; - -#endif -/* - * Local variables: - * c-basic-offset: 4 - * c-file-style: "Stroustrup" - * indent-tabs-mode: nil - * End: - * vim: shiftwidth=4 tabstop=8 expandtab - */ - diff --git a/src/filter_auth_simple.cpp b/src/filter_auth_simple.cpp index 549085e..9dbb511 100644 --- a/src/filter_auth_simple.cpp +++ b/src/filter_auth_simple.cpp @@ -18,13 +18,13 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "config.hpp" -#include "filter.hpp" -#include "package.hpp" +#include +#include #include #include -#include "util.hpp" +#include #include "filter_auth_simple.hpp" #include diff --git a/src/filter_auth_simple.hpp b/src/filter_auth_simple.hpp index 36a8d0b..9acf1b8 100644 --- a/src/filter_auth_simple.hpp +++ b/src/filter_auth_simple.hpp @@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include -#include "filter.hpp" +#include namespace metaproxy_1 { namespace filter { diff --git a/src/filter_backend_test.cpp b/src/filter_backend_test.cpp index 9b569ac..d14bee2 100644 --- a/src/filter_backend_test.cpp +++ b/src/filter_backend_test.cpp @@ -18,9 +18,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "config.hpp" -#include "filter.hpp" -#include "package.hpp" -#include "util.hpp" +#include +#include +#include #include "filter_backend_test.hpp" #include diff --git a/src/filter_backend_test.hpp b/src/filter_backend_test.hpp index c355d2d..b067fa5 100644 --- a/src/filter_backend_test.hpp +++ b/src/filter_backend_test.hpp @@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include -#include "filter.hpp" +#include namespace metaproxy_1 { namespace filter { diff --git a/src/filter_bounce.cpp b/src/filter_bounce.cpp index 56cdb6d..9675190 100644 --- a/src/filter_bounce.cpp +++ b/src/filter_bounce.cpp @@ -17,8 +17,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "filter_bounce.hpp" -#include "package.hpp" -#include "util.hpp" +#include +#include #include "gduutil.hpp" #include diff --git a/src/filter_bounce.hpp b/src/filter_bounce.hpp index f3fd4d0..5eb8e98 100644 --- a/src/filter_bounce.hpp +++ b/src/filter_bounce.hpp @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include -#include "filter.hpp" +#include namespace metaproxy_1 { namespace filter { diff --git a/src/filter_cql_to_rpn.cpp b/src/filter_cql_to_rpn.cpp index d742024..c1a7057 100644 --- a/src/filter_cql_to_rpn.cpp +++ b/src/filter_cql_to_rpn.cpp @@ -17,10 +17,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "config.hpp" -#include "util.hpp" +#include -#include "filter.hpp" -#include "package.hpp" +#include +#include #include "filter_cql_to_rpn.hpp" diff --git a/src/filter_cql_to_rpn.hpp b/src/filter_cql_to_rpn.hpp index 233b3e4..354d6a7 100644 --- a/src/filter_cql_to_rpn.hpp +++ b/src/filter_cql_to_rpn.hpp @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include "filter.hpp" +#include namespace metaproxy_1 { namespace filter { diff --git a/src/filter_dl.cpp b/src/filter_dl.cpp index 8a8db8f..a9ce43a 100644 --- a/src/filter_dl.cpp +++ b/src/filter_dl.cpp @@ -18,8 +18,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "config.hpp" -#include "filter.hpp" -#include "package.hpp" +#include +#include namespace mp = metaproxy_1; diff --git a/src/filter_frontend_net.cpp b/src/filter_frontend_net.cpp index fb81c76..04322af 100644 --- a/src/filter_frontend_net.cpp +++ b/src/filter_frontend_net.cpp @@ -18,10 +18,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "config.hpp" -#include "util.hpp" +#include #include "pipe.hpp" -#include "filter.hpp" -#include "package.hpp" +#include +#include #include "thread_pool_observer.hpp" #include "filter_frontend_net.hpp" #include diff --git a/src/filter_frontend_net.hpp b/src/filter_frontend_net.hpp index ade014d..f7720c9 100644 --- a/src/filter_frontend_net.hpp +++ b/src/filter_frontend_net.hpp @@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include "filter.hpp" +#include namespace metaproxy_1 { namespace filter { diff --git a/src/filter_http_file.cpp b/src/filter_http_file.cpp index c3014b0..f9dfb42 100644 --- a/src/filter_http_file.cpp +++ b/src/filter_http_file.cpp @@ -17,9 +17,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "config.hpp" -#include "filter.hpp" -#include "package.hpp" -#include "util.hpp" +#include +#include +#include #include "filter_http_file.hpp" #include diff --git a/src/filter_http_file.hpp b/src/filter_http_file.hpp index 21e7909..94ddb26 100644 --- a/src/filter_http_file.hpp +++ b/src/filter_http_file.hpp @@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include -#include "filter.hpp" +#include namespace metaproxy_1 { namespace filter { diff --git a/src/filter_limit.cpp b/src/filter_limit.cpp index b97d3f0..2b58fa6 100644 --- a/src/filter_limit.cpp +++ b/src/filter_limit.cpp @@ -22,8 +22,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include -#include "package.hpp" -#include "util.hpp" +#include +#include namespace mp = metaproxy_1; namespace yf = mp::filter; diff --git a/src/filter_limit.hpp b/src/filter_limit.hpp index fd5528a..e808396 100644 --- a/src/filter_limit.hpp +++ b/src/filter_limit.hpp @@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include -#include "filter.hpp" +#include namespace metaproxy_1 { namespace filter { diff --git a/src/filter_load_balance.cpp b/src/filter_load_balance.cpp index dc80b83..66fbfa2 100644 --- a/src/filter_load_balance.cpp +++ b/src/filter_load_balance.cpp @@ -17,11 +17,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "config.hpp" -#include "session.hpp" -#include "package.hpp" -#include "filter.hpp" +#include +#include #include "filter_load_balance.hpp" -#include "util.hpp" +#include #include diff --git a/src/filter_load_balance.hpp b/src/filter_load_balance.hpp index e0dc5ec..d6166a1 100644 --- a/src/filter_load_balance.hpp +++ b/src/filter_load_balance.hpp @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include -#include "filter.hpp" +#include namespace metaproxy_1 { namespace filter { diff --git a/src/filter_log.cpp b/src/filter_log.cpp index 8e94bff..13957ce 100644 --- a/src/filter_log.cpp +++ b/src/filter_log.cpp @@ -16,9 +16,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "filter_log.hpp" #include "config.hpp" -#include "package.hpp" +#include "filter_log.hpp" +#include #include #include @@ -26,8 +26,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include "gduutil.hpp" -#include "util.hpp" -#include "xmlutil.hpp" +#include +#include #include #include diff --git a/src/filter_log.hpp b/src/filter_log.hpp index 6c736b3..9ac2b70 100644 --- a/src/filter_log.hpp +++ b/src/filter_log.hpp @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include "filter.hpp" +#include namespace metaproxy_1 { namespace filter { diff --git a/src/filter_multi.cpp b/src/filter_multi.cpp index 0072e94..61d001c 100644 --- a/src/filter_multi.cpp +++ b/src/filter_multi.cpp @@ -20,15 +20,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "config.hpp" -#include "filter.hpp" -#include "package.hpp" +#include +#include #include #include #include #include -#include "util.hpp" +#include #include "filter_multi.hpp" #include diff --git a/src/filter_multi.hpp b/src/filter_multi.hpp index 7e85e3d..29c9c61 100644 --- a/src/filter_multi.hpp +++ b/src/filter_multi.hpp @@ -25,7 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include "filter.hpp" +#include namespace metaproxy_1 { namespace filter { diff --git a/src/filter_query_rewrite.cpp b/src/filter_query_rewrite.cpp index 254a33c..9d4ac37 100644 --- a/src/filter_query_rewrite.cpp +++ b/src/filter_query_rewrite.cpp @@ -17,11 +17,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "config.hpp" -#include "filter.hpp" -#include "package.hpp" +#include +#include -#include "util.hpp" -#include "xmlutil.hpp" +#include #include "filter_query_rewrite.hpp" #include diff --git a/src/filter_query_rewrite.hpp b/src/filter_query_rewrite.hpp index 776a755..f954e6b 100644 --- a/src/filter_query_rewrite.hpp +++ b/src/filter_query_rewrite.hpp @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include -#include "filter.hpp" +#include namespace metaproxy_1 { namespace filter { diff --git a/src/filter_record_transform.cpp b/src/filter_record_transform.cpp index cf7af72..70c8d6c 100644 --- a/src/filter_record_transform.cpp +++ b/src/filter_record_transform.cpp @@ -17,19 +17,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "config.hpp" -#include "filter.hpp" #include "filter_record_transform.hpp" -#include "package.hpp" -#include "util.hpp" +#include +#include #include "gduutil.hpp" -#include "xmlutil.hpp" #include #include #include -//#include - #include namespace mp = metaproxy_1; diff --git a/src/filter_record_transform.hpp b/src/filter_record_transform.hpp index 72667e3..c28cb4e 100644 --- a/src/filter_record_transform.hpp +++ b/src/filter_record_transform.hpp @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include -#include "filter.hpp" +#include namespace metaproxy_1 { namespace filter { diff --git a/src/filter_session_shared.cpp b/src/filter_session_shared.cpp index ab518aa..d36fabb 100644 --- a/src/filter_session_shared.cpp +++ b/src/filter_session_shared.cpp @@ -18,8 +18,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "config.hpp" -#include "filter.hpp" -#include "package.hpp" +#include +#include #include #include @@ -28,7 +28,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include "util.hpp" +#include #include "filter_session_shared.hpp" #include diff --git a/src/filter_session_shared.hpp b/src/filter_session_shared.hpp index c186b9c..de65d29 100644 --- a/src/filter_session_shared.hpp +++ b/src/filter_session_shared.hpp @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include "filter.hpp" +#include namespace metaproxy_1 { namespace filter { diff --git a/src/filter_sru_to_z3950.cpp b/src/filter_sru_to_z3950.cpp index c283aa7..96c820b 100644 --- a/src/filter_sru_to_z3950.cpp +++ b/src/filter_sru_to_z3950.cpp @@ -20,9 +20,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define NOMINMAX 1 #include "config.hpp" -#include "filter.hpp" -#include "package.hpp" -#include "util.hpp" +#include +#include #include "gduutil.hpp" #include "sru_util.hpp" #include "filter_sru_to_z3950.hpp" diff --git a/src/filter_sru_to_z3950.hpp b/src/filter_sru_to_z3950.hpp index 27fb110..815182b 100644 --- a/src/filter_sru_to_z3950.hpp +++ b/src/filter_sru_to_z3950.hpp @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include -#include "filter.hpp" +#include namespace metaproxy_1 { namespace filter { diff --git a/src/filter_template.cpp b/src/filter_template.cpp index 01c9d75..807e101 100644 --- a/src/filter_template.cpp +++ b/src/filter_template.cpp @@ -17,10 +17,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "config.hpp" -#include "filter.hpp" #include "filter_template.hpp" -#include "package.hpp" -#include "util.hpp" +#include +#include #include diff --git a/src/filter_template.hpp b/src/filter_template.hpp index 8609b58..79a389f 100644 --- a/src/filter_template.hpp +++ b/src/filter_template.hpp @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include -#include "filter.hpp" +#include namespace metaproxy_1 { namespace filter { diff --git a/src/filter_virt_db.cpp b/src/filter_virt_db.cpp index 55cb6df..56ba946 100644 --- a/src/filter_virt_db.cpp +++ b/src/filter_virt_db.cpp @@ -18,15 +18,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "config.hpp" -#include "filter.hpp" -#include "package.hpp" +#include "filter_virt_db.hpp" +#include #include #include #include -#include "util.hpp" -#include "filter_virt_db.hpp" +#include #include #include diff --git a/src/filter_virt_db.hpp b/src/filter_virt_db.hpp index 03967f6..3a69d17 100644 --- a/src/filter_virt_db.hpp +++ b/src/filter_virt_db.hpp @@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include "filter.hpp" +#include namespace metaproxy_1 { namespace filter { diff --git a/src/filter_z3950_client.cpp b/src/filter_z3950_client.cpp index 4322bda..601af44 100644 --- a/src/filter_z3950_client.cpp +++ b/src/filter_z3950_client.cpp @@ -18,10 +18,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "config.hpp" -#include "filter.hpp" -#include "package.hpp" -#include "util.hpp" #include "filter_z3950_client.hpp" +#include +#include #include #include diff --git a/src/filter_z3950_client.hpp b/src/filter_z3950_client.hpp index 669674c..aaf634e 100644 --- a/src/filter_z3950_client.hpp +++ b/src/filter_z3950_client.hpp @@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include -#include "filter.hpp" +#include namespace metaproxy_1 { namespace filter { diff --git a/src/filter_zeerex_explain.cpp b/src/filter_zeerex_explain.cpp index a696292..fc434e2 100644 --- a/src/filter_zeerex_explain.cpp +++ b/src/filter_zeerex_explain.cpp @@ -17,12 +17,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "config.hpp" -#include "filter.hpp" -#include "package.hpp" -#include "util.hpp" +#include "filter_zeerex_explain.hpp" +#include +#include #include "gduutil.hpp" #include "sru_util.hpp" -#include "filter_zeerex_explain.hpp" #include #include diff --git a/src/filter_zeerex_explain.hpp b/src/filter_zeerex_explain.hpp index 0904312..61774e9 100644 --- a/src/filter_zeerex_explain.hpp +++ b/src/filter_zeerex_explain.hpp @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include -#include "filter.hpp" +#include namespace metaproxy_1 { namespace filter { diff --git a/src/gduutil.cpp b/src/gduutil.cpp index 0eca0c8..50e5bd0 100644 --- a/src/gduutil.cpp +++ b/src/gduutil.cpp @@ -17,7 +17,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "gduutil.hpp" -#include "util.hpp" +#include #include #include diff --git a/src/metaproxy_prog.cpp b/src/metaproxy_prog.cpp index 0aa04f4..9f144b7 100644 --- a/src/metaproxy_prog.cpp +++ b/src/metaproxy_prog.cpp @@ -27,8 +27,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include "filter.hpp" -#include "package.hpp" +#include +#include #include "router_flexml.hpp" #include "factory_static.hpp" diff --git a/src/origin.cpp b/src/origin.cpp index d49ba1e..6168e1a 100644 --- a/src/origin.cpp +++ b/src/origin.cpp @@ -16,8 +16,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -//#include "config.hpp" -#include "origin.hpp" +#include "config.hpp" +#include #include diff --git a/src/origin.hpp b/src/origin.hpp deleted file mode 100644 index 29d1124..0000000 --- a/src/origin.hpp +++ /dev/null @@ -1,91 +0,0 @@ -/* This file is part of Metaproxy. - Copyright (C) 2005-2010 Index Data - -Metaproxy is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 2, or (at your option) any later -version. - -Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef YP2_ORIGIN_HPP -#define YP2_ORIGIN_HPP - -#include -#include - -namespace metaproxy_1 { - class Origin; -} - -namespace std { - std::ostream& operator<<(std::ostream& os, metaproxy_1::Origin& o); -} - -namespace metaproxy_1 { - - class Origin { - public: - Origin(std::string listen_host = "", unsigned int listen_port = 0); - - /// get function - right val in assignment - std::string listen_host() const; - - /// set function - left val in assignment - std::string & listen_host(); - - /// get function - right val in assignment - unsigned int listen_port() const; - - /// set function - left val in assignment - unsigned int & listen_port(); - - /// set client IP info - left val in assignment - void set_tcpip_address(std::string addr, unsigned long id); - - /// set max sockets (for outgoing connections to a given target) - void set_max_sockets(int max_sockets); - - /// set max sockets (for outgoing connections to a given target) - int get_max_sockets(); - - /// get tcpip address - std::string get_address(); - private: - friend std::ostream& - std::operator<<(std::ostream& os, metaproxy_1::Origin& o); - - enum origin_t { - API, - UNIX, - TCPIP - } m_type; - std::string m_address; // UNIX+TCPIP - unsigned int m_origin_id; - std::string m_listen_host; - unsigned int m_listen_port; - int m_max_sockets; - }; - -} - - - -#endif -/* - * Local variables: - * c-basic-offset: 4 - * c-file-style: "Stroustrup" - * indent-tabs-mode: nil - * End: - * vim: shiftwidth=4 tabstop=8 expandtab - */ - diff --git a/src/package.cpp b/src/package.cpp index 3c65cdb..c628523 100644 --- a/src/package.cpp +++ b/src/package.cpp @@ -17,7 +17,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "config.hpp" -#include "package.hpp" +#include #include diff --git a/src/package.hpp b/src/package.hpp deleted file mode 100644 index 69fbcb7..0000000 --- a/src/package.hpp +++ /dev/null @@ -1,107 +0,0 @@ -/* This file is part of Metaproxy. - Copyright (C) 2005-2010 Index Data - -Metaproxy is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 2, or (at your option) any later -version. - -Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef YP2_PACKAGE_HPP -#define YP2_PACKAGE_HPP - -#include - -#include - -#include "router.hpp" -#include "filter.hpp" -#include "session.hpp" -#include "origin.hpp" - -namespace metaproxy_1 { - class Package; -} - - -namespace std -{ - std::ostream& operator<<(std::ostream& os, metaproxy_1::Package& p); -} - -namespace metaproxy_1 { - - class Package { - public: - Package(); - - ~Package(); - - Package(metaproxy_1::Session &session, - const metaproxy_1::Origin &origin); - - /// shallow copy constructor which only copies the filter chain info - Package & copy_filter(const Package &p); - - /// send Package to it's next Filter defined in Router - void move(); - - /// send Package to other route - void move(std::string route); - - /// access session - left val in assignment - metaproxy_1::Session & session(); - - /// get function - right val in assignment - Origin origin() const; - - /// set function - left val in assignment - Origin & origin(); - - /// set function - can be chained - Package & origin(const Origin & origin); - - /// set function - can be chained - Package & router(const Router &router); - - yazpp_1::GDU &request(); - - yazpp_1::GDU &response(); - - /// get function - right val in assignment - Session session() const; - - private: - Session m_session; - Origin m_origin; - - RoutePos *m_route_pos; - - //int m_data; - - yazpp_1::GDU m_request_gdu; - yazpp_1::GDU m_response_gdu; - }; -} - - - -#endif -/* - * Local variables: - * c-basic-offset: 4 - * c-file-style: "Stroustrup" - * indent-tabs-mode: nil - * End: - * vim: shiftwidth=4 tabstop=8 expandtab - */ - diff --git a/src/plainfile.cpp b/src/plainfile.cpp index 6ae38ae..fb87e2d 100644 --- a/src/plainfile.cpp +++ b/src/plainfile.cpp @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include "util.hpp" +#include #define PLAINFILE_MAX_LINE 256 diff --git a/src/router.hpp b/src/router.hpp deleted file mode 100644 index 392f048..0000000 --- a/src/router.hpp +++ /dev/null @@ -1,63 +0,0 @@ -/* This file is part of Metaproxy. - Copyright (C) 2005-2010 Index Data - -Metaproxy is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 2, or (at your option) any later -version. - -Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef ROUTER_HPP -#define ROUTER_HPP - -#include -#include -#include - -namespace metaproxy_1 -{ - namespace filter { - class Base; - } - class RoutePos; - - class RouterException : public std::runtime_error { - public: - RouterException(const std::string message) - : std::runtime_error("RouterException: " + message){}; - }; - - class Router : boost::noncopyable { - public: - Router(){}; - virtual ~Router(){}; - - virtual RoutePos *createpos() const = 0; - }; - - class RoutePos : boost::noncopyable { - public: - virtual const filter::Base *move(const char *route) = 0; - virtual RoutePos *clone() = 0; - virtual ~RoutePos() {}; - }; -} -#endif -/* - * Local variables: - * c-basic-offset: 4 - * c-file-style: "Stroustrup" - * indent-tabs-mode: nil - * End: - * vim: shiftwidth=4 tabstop=8 expandtab - */ - diff --git a/src/router_chain.hpp b/src/router_chain.hpp index 4b7cc0c..4924aca 100644 --- a/src/router_chain.hpp +++ b/src/router_chain.hpp @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define ROUTER_CHAIN_HPP -#include "router.hpp" +#include #include #include diff --git a/src/router_flexml.cpp b/src/router_flexml.cpp index 3375a33..8b30bef 100644 --- a/src/router_flexml.cpp +++ b/src/router_flexml.cpp @@ -17,7 +17,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "config.hpp" -#include "xmlutil.hpp" +#include #include "router_flexml.hpp" #include "factory_filter.hpp" #include "factory_static.hpp" diff --git a/src/router_flexml.hpp b/src/router_flexml.hpp index e2bd856..4dbbb2e 100644 --- a/src/router_flexml.hpp +++ b/src/router_flexml.hpp @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #ifndef ROUTER_FLEXML_HPP #define ROUTER_FLEXML_HPP -#include "router.hpp" +#include #include "factory_filter.hpp" diff --git a/src/session.cpp b/src/session.cpp index 339f0da..b0df3af 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -18,7 +18,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include -#include "session.hpp" +#include #include #include "config.hpp" diff --git a/src/session.hpp b/src/session.hpp deleted file mode 100644 index 124a8c1..0000000 --- a/src/session.hpp +++ /dev/null @@ -1,148 +0,0 @@ -/* This file is part of Metaproxy. - Copyright (C) 2005-2010 Index Data - -Metaproxy is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 2, or (at your option) any later -version. - -Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef SESSION_HPP -#define SESSION_HPP - -//#include -#include -#include - -namespace metaproxy_1 { - - class Session - { - //typedef unsigned long type; - public: - - /// create new session with new unique id - Session() { - boost::mutex::scoped_lock scoped_lock(m_mutex); - ++m_global_id; - m_id = m_global_id; - m_close = false; - } - - /// copy session including old id - Session(const Session &s) : m_id(s.m_id), m_close(s.m_close) {}; - - Session& operator=(const Session &s) { - if (this != &s) - { - m_id = s.m_id; - m_close = s.m_close; - } - return *this; - } - - bool operator<(const Session &s) const { - return m_id < s.m_id ? true : false; - } - - unsigned long id() const { - return m_id; - } - - bool is_closed() const { - return m_close; - } - - /// mark session closed, can not be unset - void close() { - m_close = true; - } - - bool operator == (Session &ses) const { - return ses.m_id == m_id; - } - - private: - - unsigned long int m_id; - bool m_close; - - /// static mutex to lock static m_id - static boost::mutex m_mutex; - - /// static m_id to make sure that there is only one id counter - static unsigned long int m_global_id; - - }; - - template class session_map { - public: - 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 metaproxy_1::Session &s) { - boost::mutex::scoped_lock lock(m_map_mutex); - - m_map.erase(s); - }; -#if 0 - T &get_session_data(const metaproxy_1::Session &s) { - boost::mutex::scoped_lock lock(m_map_mutex); - - typename std::map::const_iterator it; - it = m_map.find(s); - if (it == m_map.end()) - return 0; - boost::mutx::scoped_lock *scoped_ptr = - new boost::mutex::scoped_lock(it->second->m_item_mutex); - }; -#endif - bool exist(const metaproxy_1::Session &s) { - typename std::map::const_iterator it; - it = m_map.find(s); - return it == m_map.end() ? false : true; - } - private: - class SessionItem { - public: - SessionItem() {}; - SessionItem(T &t) : m_t(t) {}; - SessionItem &operator =(const SessionItem &s) { - if (this != &s) { - m_t = s.m_t; - } - return *this; - }; - SessionItem(const SessionItem &s) { - m_t = s.m_t; - }; - T m_t; - boost::mutex m_item_mutex; - }; - private: - boost::mutex m_map_mutex; - std::mapm_map; - }; - -} - -#endif -/* - * Local variables: - * c-basic-offset: 4 - * c-file-style: "Stroustrup" - * indent-tabs-mode: nil - * End: - * vim: shiftwidth=4 tabstop=8 expandtab - */ - diff --git a/src/sru_util.cpp b/src/sru_util.cpp index 5c2b257..1992f9f 100644 --- a/src/sru_util.cpp +++ b/src/sru_util.cpp @@ -17,10 +17,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "sru_util.hpp" -#include "util.hpp" - -//#include -//#include +#include #include #include diff --git a/src/sru_util.hpp b/src/sru_util.hpp index de04fbc..715b845 100644 --- a/src/sru_util.hpp +++ b/src/sru_util.hpp @@ -19,11 +19,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #ifndef YP2_SDU_UTIL_HPP #define YP2_SDU_UTIL_HPP -#include "util.hpp" -#include "package.hpp" +#include +#include -//#include -//#include #include #include diff --git a/src/test_filter1.cpp b/src/test_filter1.cpp index b850e3b..4b14019 100644 --- a/src/test_filter1.cpp +++ b/src/test_filter1.cpp @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include "filter.hpp" +#include #define BOOST_AUTO_TEST_MAIN #define BOOST_TEST_DYN_LINK diff --git a/src/test_filter2.cpp b/src/test_filter2.cpp index 42a0520..68f1e9b 100644 --- a/src/test_filter2.cpp +++ b/src/test_filter2.cpp @@ -16,13 +16,14 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "config.hpp" + #include #include -#include "config.hpp" -#include "filter.hpp" +#include #include "router_chain.hpp" -#include "package.hpp" +#include #include diff --git a/src/test_filter_auth_simple.cpp b/src/test_filter_auth_simple.cpp index f3fccca..fc08997 100644 --- a/src/test_filter_auth_simple.cpp +++ b/src/test_filter_auth_simple.cpp @@ -21,10 +21,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include "filter_auth_simple.hpp" -#include "util.hpp" +#include #include "router_chain.hpp" -#include "session.hpp" -#include "package.hpp" +#include #define BOOST_AUTO_TEST_MAIN #define BOOST_TEST_DYN_LINK diff --git a/src/test_filter_backend_test.cpp b/src/test_filter_backend_test.cpp index a18e69a..1eb796e 100644 --- a/src/test_filter_backend_test.cpp +++ b/src/test_filter_backend_test.cpp @@ -20,13 +20,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include "util.hpp" +#include #include "filter_backend_test.hpp" #include "filter_log.hpp" #include "router_chain.hpp" -#include "session.hpp" -#include "package.hpp" +#include #include #include diff --git a/src/test_filter_bounce.cpp b/src/test_filter_bounce.cpp index 5a1754a..1556c38 100644 --- a/src/test_filter_bounce.cpp +++ b/src/test_filter_bounce.cpp @@ -18,12 +18,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "config.hpp" #include "filter_bounce.hpp" -#include "util.hpp" +#include #include "gduutil.hpp" -//#include "sru_util.hpp" #include "router_chain.hpp" -#include "session.hpp" -#include "package.hpp" +#include #include #include diff --git a/src/test_filter_factory.cpp b/src/test_filter_factory.cpp index 4bb9fc7..e4f62d8 100644 --- a/src/test_filter_factory.cpp +++ b/src/test_filter_factory.cpp @@ -20,8 +20,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include "config.hpp" -#include "filter.hpp" -#include "package.hpp" +#include +#include #include "factory_filter.hpp" diff --git a/src/test_filter_frontend_net.cpp b/src/test_filter_frontend_net.cpp index 524e3c9..727e4b7 100644 --- a/src/test_filter_frontend_net.cpp +++ b/src/test_filter_frontend_net.cpp @@ -20,12 +20,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include "util.hpp" +#include #include "filter_frontend_net.hpp" #include "router_chain.hpp" -#include "session.hpp" -#include "package.hpp" +#include #define BOOST_AUTO_TEST_MAIN #define BOOST_TEST_DYN_LINK diff --git a/src/test_filter_log.cpp b/src/test_filter_log.cpp index 9c33b1e..9b2626c 100644 --- a/src/test_filter_log.cpp +++ b/src/test_filter_log.cpp @@ -21,10 +21,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include "filter_log.hpp" -#include "util.hpp" +#include #include "router_chain.hpp" -#include "session.hpp" -#include "package.hpp" +#include #define BOOST_AUTO_TEST_MAIN #define BOOST_TEST_DYN_LINK diff --git a/src/test_filter_multi.cpp b/src/test_filter_multi.cpp index c429f2a..e0a6f50 100644 --- a/src/test_filter_multi.cpp +++ b/src/test_filter_multi.cpp @@ -21,10 +21,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include "filter_multi.hpp" -#include "util.hpp" +#include #include "router_chain.hpp" -#include "session.hpp" -#include "package.hpp" +#include #define BOOST_AUTO_TEST_MAIN #define BOOST_TEST_DYN_LINK diff --git a/src/test_filter_query_rewrite.cpp b/src/test_filter_query_rewrite.cpp index 1d2d5f8..7567a21 100644 --- a/src/test_filter_query_rewrite.cpp +++ b/src/test_filter_query_rewrite.cpp @@ -21,10 +21,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include "filter_query_rewrite.hpp" -#include "util.hpp" +#include #include "router_chain.hpp" -#include "session.hpp" -#include "package.hpp" +#include #define BOOST_AUTO_TEST_MAIN #define BOOST_TEST_DYN_LINK diff --git a/src/test_filter_record_transform.cpp b/src/test_filter_record_transform.cpp index 3ca3f5f..5fb1040 100644 --- a/src/test_filter_record_transform.cpp +++ b/src/test_filter_record_transform.cpp @@ -18,14 +18,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "config.hpp" #include "filter_record_transform.hpp" -//#include "util.hpp" -//#include "sru_util.hpp" -#include "router_chain.hpp" -#include "session.hpp" -#include "package.hpp" -//#include -//#include +#include "router_chain.hpp" +#include #define BOOST_AUTO_TEST_MAIN #define BOOST_TEST_DYN_LINK diff --git a/src/test_filter_sru_to_z3950.cpp b/src/test_filter_sru_to_z3950.cpp index 75248ca..dec6f98 100644 --- a/src/test_filter_sru_to_z3950.cpp +++ b/src/test_filter_sru_to_z3950.cpp @@ -18,11 +18,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "config.hpp" #include "filter_sru_to_z3950.hpp" -#include "util.hpp" +#include #include "sru_util.hpp" #include "router_chain.hpp" -#include "session.hpp" -#include "package.hpp" +#include #include #include diff --git a/src/test_filter_virt_db.cpp b/src/test_filter_virt_db.cpp index 9273b1f..ed00ff5 100644 --- a/src/test_filter_virt_db.cpp +++ b/src/test_filter_virt_db.cpp @@ -20,14 +20,13 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include "util.hpp" +#include #include "filter_virt_db.hpp" #include "filter_backend_test.hpp" #include "filter_log.hpp" #include "router_chain.hpp" -#include "session.hpp" -#include "package.hpp" +#include #define BOOST_AUTO_TEST_MAIN #define BOOST_TEST_DYN_LINK diff --git a/src/test_filter_z3950_client.cpp b/src/test_filter_z3950_client.cpp index 2c8f5dd..04c3a70 100644 --- a/src/test_filter_z3950_client.cpp +++ b/src/test_filter_z3950_client.cpp @@ -21,11 +21,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include "filter_z3950_client.hpp" -#include "util.hpp" +#include #include "router_chain.hpp" -#include "session.hpp" -#include "package.hpp" +#include #define BOOST_AUTO_TEST_MAIN #define BOOST_TEST_DYN_LINK diff --git a/src/test_package1.cpp b/src/test_package1.cpp index 4550d1f..b98d547 100644 --- a/src/test_package1.cpp +++ b/src/test_package1.cpp @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include "package.hpp" +#include #define BOOST_AUTO_TEST_MAIN #define BOOST_TEST_DYN_LINK diff --git a/src/test_pipe.cpp b/src/test_pipe.cpp index 7536715..3420483 100644 --- a/src/test_pipe.cpp +++ b/src/test_pipe.cpp @@ -35,7 +35,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include "util.hpp" +#include #include "pipe.hpp" #define BOOST_AUTO_TEST_MAIN diff --git a/src/test_router_flexml.cpp b/src/test_router_flexml.cpp index c39f5db..f656278 100644 --- a/src/test_router_flexml.cpp +++ b/src/test_router_flexml.cpp @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include "filter.hpp" +#include #include "router_flexml.hpp" #include "factory_static.hpp" diff --git a/src/test_ses_map.cpp b/src/test_ses_map.cpp index 121e756..47b9865 100644 --- a/src/test_ses_map.cpp +++ b/src/test_ses_map.cpp @@ -20,9 +20,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include "router.hpp" -#include "session.hpp" -#include "package.hpp" +#include #include diff --git a/src/test_session1.cpp b/src/test_session1.cpp index a8b8672..9526e03 100644 --- a/src/test_session1.cpp +++ b/src/test_session1.cpp @@ -17,7 +17,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "config.hpp" -#include "session.hpp" +#include #include diff --git a/src/test_session2.cpp b/src/test_session2.cpp index e271a00..0a6130e 100644 --- a/src/test_session2.cpp +++ b/src/test_session2.cpp @@ -17,7 +17,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "config.hpp" -#include "session.hpp" +#include #include #include diff --git a/src/util.cpp b/src/util.cpp index cb9a435..0e6c50b 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -17,7 +17,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "config.hpp" -#include "util.hpp" +#include #include #include diff --git a/src/util.hpp b/src/util.hpp deleted file mode 100644 index 810afbd..0000000 --- a/src/util.hpp +++ /dev/null @@ -1,158 +0,0 @@ -/* This file is part of Metaproxy. - Copyright (C) 2005-2010 Index Data - -Metaproxy is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 2, or (at your option) any later -version. - -Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef YP2_UTIL_HPP -#define YP2_UTIL_HPP - -#include "package.hpp" - -#include - -#include -#include - -#include -#include -#include -#include - - -namespace metaproxy_1 { - namespace util { - - - template - std::string to_string(const T& t) - { - std::ostringstream o; - if(o << t) - return o.str(); - return std::string(); - }; - - const char * - record_composition_to_esn(Z_RecordComposition *comp); - - std::string http_header_value(const Z_HTTP_Header* header, - const std::string name); - - std::string http_headers_debug(const Z_HTTP_Request &http_req); - - void http_response(metaproxy_1::Package &package, - const std::string &content, - int http_code = 200); - - - int memcmp2(const void *buf1, int len1, const void *buf2, int len2); - - std::string database_name_normalize(const std::string &s); - - bool pqf(ODR odr, Z_APDU *apdu, const std::string &q); - - std::string zQueryToString(Z_Query *query); - - Z_ReferenceId **get_referenceId(const Z_APDU *apdu); - - void transfer_referenceId(ODR odr, const Z_APDU *src, Z_APDU *dst); - - Z_APDU *create_APDU(ODR odr, int type, const Z_APDU *in_apdu); - - bool set_databases_from_zurl(ODR odr, std::string zurl, - int *db_num, char ***db_strings); - - void split_zurl(std::string zurl, std::string &host, - std::list &db); - - void get_vhost_otherinfo(Z_OtherInformation *otherInformation, - std::list &vhosts); - - int remove_vhost_otherinfo(Z_OtherInformation **otherInformation, - std::list &vhosts); - - void set_vhost_otherinfo(Z_OtherInformation **otherInformation, - ODR odr, - const std::string vhost, - const int cat); - - void set_vhost_otherinfo(Z_OtherInformation **otherInformation, - ODR odr, - const std::list &vhosts); - - int get_or_remove_vhost_otherinfo( - Z_OtherInformation **otherInformation, - bool remove_flag, - std::list &vhosts); - - void get_init_diagnostics(Z_InitResponse *res, - int &error_code, std::string &addinfo); - - void get_default_diag(Z_DefaultDiagFormat *r, - int &error_code, std::string &addinfo); - - void piggyback(int smallSetUpperBound, - int largeSetLowerBound, - int mediumSetPresentNumber, - int result_set_size, - int &number_to_present); - - }; - - class odr : public boost::noncopyable { - public: - odr(int type); - odr(); - ~odr(); - operator ODR() const; - Z_APDU *create_close(const Z_APDU *in_apdu, - int reason, const char *addinfo); - Z_APDU *create_initResponse(const Z_APDU *in_apdu, - int error, const char *addinfo); - Z_APDU *create_searchResponse(const Z_APDU *in_apdu, - int error, const char *addinfo); - Z_APDU *create_presentResponse(const Z_APDU *in_apdu, - int error, const char *addinfo); - Z_APDU *create_scanResponse(const Z_APDU *in_apdu, - int error, const char *addinfo); - Z_APDU *create_APDU(int type, const Z_APDU *in_apdu); - - Z_GDU *create_HTTP_Response(metaproxy_1::Session &session, - Z_HTTP_Request *req, int code); - private: - ODR m_odr; - }; - - class PlainFile { - class Rep; - boost::scoped_ptr m_p; - public: - PlainFile(); - ~PlainFile(); - bool open(const std::string &fname); - bool getline(std::vector &args); - }; -} -#endif -/* - * Local variables: - * c-basic-offset: 4 - * c-file-style: "Stroustrup" - * indent-tabs-mode: nil - * End: - * vim: shiftwidth=4 tabstop=8 expandtab - */ - diff --git a/src/xmlutil.cpp b/src/xmlutil.cpp index a39863a..209b7f1 100644 --- a/src/xmlutil.cpp +++ b/src/xmlutil.cpp @@ -16,7 +16,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "xmlutil.hpp" +#include #include diff --git a/src/xmlutil.hpp b/src/xmlutil.hpp deleted file mode 100644 index 5377bb4..0000000 --- a/src/xmlutil.hpp +++ /dev/null @@ -1,71 +0,0 @@ -/* This file is part of Metaproxy. - Copyright (C) 2005-2010 Index Data - -Metaproxy is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 2, or (at your option) any later -version. - -Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef XML_UTIL_HPP -#define XML_UTIL_HPP - -#include -#include -#include - -namespace metaproxy_1 { - namespace xml { - std::string get_text(const struct _xmlAttr *ptr); - std::string get_text(const xmlNode *ptr); - bool get_bool(const xmlNode *ptr, bool default_value); - int get_int(const xmlNode *ptr, int default_value); - bool check_attribute(const _xmlAttr *ptr, - const std::string &ns, - const std::string &name); - bool is_attribute(const _xmlAttr *ptr, - const std::string &ns, - const std::string &name); - bool is_element(const xmlNode *ptr, - const std::string &ns, - const std::string &name); - bool is_element_mp(const xmlNode *ptr, const std::string &name); - bool check_element_mp(const xmlNode *ptr, - const std::string &name); - std::string get_route(const xmlNode *node); - - const xmlNode* jump_to(const xmlNode* node, int node_type); - - const xmlNode* jump_to_next(const xmlNode* node, int node_type); - - const xmlNode* jump_to_children(const xmlNode* node, int node_type); - - void check_empty(const xmlNode *node); - - } - class XMLError : public std::runtime_error { - public: - XMLError(const std::string msg) : - std::runtime_error("XMLError : " + msg) {} ; - }; -} - -#endif -/* - * Local variables: - * c-basic-offset: 4 - * c-file-style: "Stroustrup" - * indent-tabs-mode: nil - * End: - * vim: shiftwidth=4 tabstop=8 expandtab - */ - -- 1.7.10.4