Add skeleton MP module
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 27 May 2014 13:54:23 +0000 (15:54 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 27 May 2014 13:54:23 +0000 (15:54 +0200)
src/Makefile
src/metaproxy_filter_xquery.cpp [new file with mode: 0644]

index dc991bf..31d2ba1 100644 (file)
@@ -1,17 +1,28 @@
+ROOT=..
+ZORBA := $(ROOT)/../zorba/zorba-3.0/build/dist
 
-O=tst.o
+ifeq "${MP_CONFIG}" ""
+MP_CONFIG := $(shell if test -x $(ROOT)/../metaproxy/metaproxy-config; then echo $(ROOT)/../metaproxy/metaproxy-config; else echo metaproxy-config; fi)
+endif
 
-ZORBA := ../../zorba/zorba-3.0/build/dist
+MP_CFLAGS := $(shell $(MP_CONFIG) --cflags)
+MP_LIBS := $(shell $(MP_CONFIG) --libs)
+MP_SO := metaproxy_filter_xquery.so
 
-CXXFLAGS=-I$(ZORBA)/include
+ZORBA_LIBS := -L $(ZORBA)/lib -lzorba_simplestore
+ZORBA_CFLAGS := -I$(ZORBA)/include $(MP_CFLAGS)
+CXXFLAGS := $(ZORBA_CFLAGS) $(MP_CFLAGS) -fPIC
 
-LIB=-L $(ZORBA)/lib -lzorba_simplestore
+all: tst $(MP_SO)
 
-tst: $(O)
-       $(CXX) $^ -o $@ $(LIB)
+tst: tst.o
+       $(CXX) $^ -o $@ $(ZORBA_LIBS)
+
+$(MP_SO): metaproxy_filter_xquery.o
+       $(CXX) -shared $(CXXFLAGS) $(LDFLAGS) $^ -o $@ $(MP_LIBS) $(ZORBA_LIBS)
 
 clean:
-       rm -f *.o tst
+       rm -f *.o tst $(MP_SO)
 
 run: tst
        LD_LIBRARY_PATH=$(ZORBA)/lib ./tst
diff --git a/src/metaproxy_filter_xquery.cpp b/src/metaproxy_filter_xquery.cpp
new file mode 100644 (file)
index 0000000..c7fe809
--- /dev/null
@@ -0,0 +1,82 @@
+/* This file is part of mp-xquery
+   Copyright (C) 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
+*/
+
+#include <metaproxy/package.hpp>
+#include <metaproxy/util.hpp>
+
+namespace mp = metaproxy_1;
+namespace yf = mp::filter;
+using namespace mp;
+
+namespace metaproxy_1 {
+    namespace filter {
+        class XQuery : public Base {
+        public:
+            ~XQuery();
+            XQuery();
+            void process(metaproxy_1::Package & package) const;
+            void configure(const xmlNode * ptr, bool test_only,
+                           const char *path);
+            void start() const;
+            void stop(int signo) const;
+        private:
+        };
+    }
+}
+
+void yf::XQuery::start() const
+{
+}
+
+void yf::XQuery::stop(int signo) const
+{
+}
+
+void yf::XQuery::process(Package &package) const
+{
+    package.move();
+}
+
+void yf::XQuery::configure(const xmlNode * ptr, bool test_only,
+                           const char *path)
+{
+}
+
+static yf::Base* filter_creator()
+{
+    return new mp::filter::XQuery;
+}
+
+extern "C" {
+    struct metaproxy_1_filter_struct metaproxy_1_filter_xquery = {
+        0,
+        "xquery",
+        filter_creator
+    };
+}
+
+
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * c-file-style: "Stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+