1 /* This file is part of Metaproxy.
2 Copyright (C) 2005-2013 Index Data
4 Metaproxy is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
9 Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #include <yaz/diagbib1.h>
22 #include <metaproxy/filter.hpp>
23 #include <metaproxy/package.hpp>
24 #include <metaproxy/util.hpp>
26 namespace mp = metaproxy_1;
28 namespace metaproxy_1 {
30 class Filter_myfilter: public mp::filter::Base {
32 void process(mp::Package & package) const;
33 void configure(const xmlNode *ptr, bool test_only, const char *path);
38 void mp::filter::Filter_myfilter::process(mp::Package & package) const
39 { // See src/filter_backend_test.cpp for a more comprehensive
40 // example of a dummy Z-server
41 Z_GDU *gdu = package.request().get();
45 if (!gdu || gdu->which != Z_GDU_Z3950)
47 yaz_log(YLOG_LOG, "myfilter::process: Not a Z39.50 packet");
48 package.move(); // Send on to other filters
51 Z_APDU *apdu_req = gdu->u.z3950;
52 if (apdu_req->which == Z_APDU_initRequest)
54 yaz_log(YLOG_LOG, "myfilter::process: Init request");
55 apdu_res= odr.create_initResponse( apdu_req,
56 YAZ_BIB1_PERMANENT_SYSTEM_ERROR, "Not implemented!");
57 package.response() = apdu_res;
61 yaz_log(YLOG_LOG, "myfilter::process: Unknown request type");
62 package.move(); // Send on to other filters
66 void mp::filter::Filter_myfilter::configure(const xmlNode *ptr, bool test_only, const char *path)
68 yaz_log(YLOG_LOG, "myfilter::configure called with test_only %d and %s", test_only, path);
69 for (ptr = ptr->children; ptr; ptr = ptr->next)
71 if (ptr->type != XML_ELEMENT_NODE)
73 if (!strcmp((const char *) ptr->name, "logmsg"))
75 std::string msg = mp::xml::get_text(ptr);
76 yaz_log(YLOG_LOG, "myfilter::configure: %s", msg.c_str() );
81 throw mp::filter::FilterException("Bad element "
82 + std::string((const char *) ptr->name));
89 static mp::filter::Base* filter_creator()
91 return new mp::filter::Filter_myfilter;
95 struct metaproxy_1_filter_struct metaproxy_1_filter_myfilter = {
105 * c-file-style: "Stroustrup"
106 * indent-tabs-mode: nil
108 * vim: shiftwidth=4 tabstop=8 expandtab