1 /* $Id: filter_sru_to_z3950.cpp,v 1.1 2006-09-13 10:43:24 marc Exp $
2 Copyright (c) 2005-2006, Index Data.
4 See the LICENSE file for details
10 #include "package.hpp"
12 #include <boost/thread/mutex.hpp>
15 #include "filter_sru_to_z3950.hpp"
19 namespace mp = metaproxy_1;
20 namespace yf = mp::filter;
22 namespace metaproxy_1 {
24 class SRUtoZ3950::Rep {
25 friend class SRUtoZ3950;
31 yf::SRUtoZ3950::SRUtoZ3950() : m_p(new Rep)
36 yf::SRUtoZ3950::~SRUtoZ3950()
37 { // must have a destructor because of boost::scoped_ptr
40 void yf::SRUtoZ3950::process(mp::Package &package) const
42 Z_GDU *zgdu_req = package.request().get();
44 // ignoring all non HTTP_Request packages
45 if (!zgdu_req || !(zgdu_req->which == Z_GDU_HTTP_Request)){
50 // only working on HTTP_Request packages now
51 Z_HTTP_Request* http_req = zgdu_req->u.HTTP_Request;
53 // TODO: SRU package checking and translation to Z3950 package
55 // sending Z3950 package through pipeline
59 // TODO: Z3950 response parsing and translation to SRU package
60 //Z_HTTP_Response* http_res = 0;
66 = odr.create_HTTP_Response(package.session(),
67 zgdu_req->u.HTTP_Request, 200);
69 //zgdu_res->u.HTTP_Response->content_len = message.str().size();
70 //zgdu_res->u.HTTP_Response->content_buf
71 // = (char*) odr_malloc(odr, zgdu_res->u.HTTP_Response->content_len);
73 //strncpy(zgdu_res->u.HTTP_Response->content_buf,
74 // message.str().c_str(), zgdu_res->u.HTTP_Response->content_len);
76 // z_HTTP_header_add(o, &hres->headers,
77 // "Content-Type", content_type.c_str());
78 package.response() = zgdu_res;
82 static mp::filter::Base* filter_creator()
84 return new mp::filter::SRUtoZ3950;
88 struct metaproxy_1_filter_struct metaproxy_1_filter_sru_to_z3950 = {
99 * indent-tabs-mode: nil
100 * c-file-style: "stroustrup"
102 * vim: shiftwidth=4 tabstop=8 expandtab