-## $Id: Makefile.am,v 1.17 2005-10-13 20:06:45 adam Exp $
+## $Id: Makefile.am,v 1.18 2005-10-14 11:18:59 adam Exp $
MAINTAINERCLEANFILES = Makefile.in config.in config.hpp
LDADD= libyp2.la $(YAZPPLALIB) $(XSLT_LIBS)
bin_PROGRAMS =
-noinst_PROGRAMS = p2
+noinst_PROGRAMS = ex_filter_frontend_net
-p2_SOURCES=p2_frontend.cpp p2_msg.cpp p2.cpp p2_frontend.h \
- p2_config.cpp p2_config.h \
- p2_backend.h p2_backend_dummy.cpp \
- p2_modules.cpp p2_modules.h \
- p2_xmlerror.cpp p2_xmlerror.h
+ex_filter_frontend_net_SOURCES = ex_filter_frontend_net.cpp
# Rules for test programs..
--- /dev/null
+
+#include <cstdlib>
+#include <iostream>
+#include <stdexcept>
+
+#include "config.hpp"
+
+#include "filter_frontend_net.hpp"
+
+#include "router.hpp"
+#include "session.hpp"
+#include "package.hpp"
+
+class FilterInit: public yp2::Filter {
+public:
+ void process(yp2::Package & package) const {
+
+ if (package.session().is_closed())
+ {
+ // std::cout << "Got Close.\n";
+ }
+
+ Z_GDU *gdu = package.request().get();
+ if (gdu)
+ {
+ // std::cout << "Got PDU. Sending init response\n";
+ ODR odr = odr_createmem(ODR_ENCODE);
+ Z_APDU *apdu = zget_APDU(odr, Z_APDU_initResponse);
+
+ apdu->u.initResponse->implementationName = "YP2/YAZ";
+
+ package.response() = apdu;
+ odr_destroy(odr);
+ }
+ return package.move();
+ };
+};
+
+int main(int argc, char **argv)
+{
+ try
+ {
+ {
+ yp2::RouterChain router;
+
+ // put in frontend first
+ yp2::FilterFrontendNet filter_front;
+ filter_front.listen_address() = "tcp:@:9999";
+ //filter_front.listen_duration() = 1; // listen a short time only
+ router.rule(filter_front);
+
+ // put in a backend
+ FilterInit filter_init;
+ router.rule(filter_init);
+
+ yp2::Session session;
+ yp2::Origin origin;
+ yp2::Package pack(session, origin);
+
+ pack.router(router).move();
+ }
+ }
+ catch ( ... ) {
+ std::cerr << "unknown exception\n";
+ std::exit(1);
+ }
+}
+
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */