1 /* This file is part of Metaproxy.
2 Copyright (C) 2005-2009 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>
24 #include "package.hpp"
27 namespace mp = metaproxy_1;
29 namespace metaproxy_1 {
31 class Filter_myfilter: public mp::filter::Base {
33 void process(mp::Package & package) const;
34 void configure(const xmlNode *ptr, bool test_only);
39 void mp::filter::Filter_myfilter::process(mp::Package & package) const
40 { // See src/filter_backend_test.cpp for a more comprehensive
41 // example of a dummy Z-server
42 Z_GDU *gdu = package.request().get();
46 if (!gdu || gdu->which != Z_GDU_Z3950)
48 yaz_log(YLOG_LOG, "myfilter::process: Not a Z39.50 packet");
49 package.move(); // Send on to other filters
52 Z_APDU *apdu_req = gdu->u.z3950;
53 if (apdu_req->which == Z_APDU_initRequest)
55 yaz_log(YLOG_LOG, "myfilter::process: Init request");
56 apdu_res= odr.create_initResponse( apdu_req,
57 YAZ_BIB1_PERMANENT_SYSTEM_ERROR, "Not implemented!");
58 package.response() = apdu_res;
62 yaz_log(YLOG_LOG, "myfilter::process: Unknown request type");
63 package.move(); // Send on to other filters
67 void mp::filter::Filter_myfilter::configure(const xmlNode *ptr, bool test_only)
69 yaz_log(YLOG_LOG, "myfilter::configure");
70 for (ptr = ptr->children; ptr; ptr = ptr->next)
72 if (ptr->type != XML_ELEMENT_NODE)
74 if (!strcmp((const char *) ptr->name, "logmsg"))
76 std::string msg = mp::xml::get_text(ptr);
77 yaz_log(YLOG_LOG, "myfilter::configure: %s", msg.c_str() );
82 throw mp::filter::FilterException("Bad element "
83 + std::string((const char *) ptr->name));
90 static mp::filter::Base* filter_creator()
92 return new mp::filter::Filter_myfilter;
96 struct metaproxy_1_filter_struct metaproxy_1_filter_myfilter = {
106 * c-file-style: "Stroustrup"
107 * indent-tabs-mode: nil
109 * vim: shiftwidth=4 tabstop=8 expandtab