../dbus/libdbus.la \
$(JSONC_LIBS)
-check_PROGRAMS = regex.test
-TESTS = $(check_PROGRAMS)
+check_PROGRAMS = regex.test forwarding-zypp-plugin
+
+forwarding_zypp_plugin_SOURCES = \
+ forwarding_zypp_plugin.cc \
+ zypp_plugin.cc zypp_plugin.h
+forwarding_zypp_plugin_LDADD = \
+ ../snapper/libsnapper.la \
+ -lpthread
+
+TESTS = regex.test
regex_test_SOURCES = regex_test.cc \
solvable_matcher.cc solvable_matcher.h
regex_test_LDADD = \
--- /dev/null
+/*
+ * Copyright (c) 2020 SUSE LLC
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program 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, contact SUSE LLC.
+ *
+ * To contact SUSE about this file by physical or electronic mail, you may
+ * find current contact information at www.suse.com.
+ */
+
+#include <string>
+using namespace std;
+
+#include <boost/process.hpp>
+namespace bp = boost::process;
+
+#include "zypp_plugin.h"
+
+class ForwardingZyppPlugin : public ZyppPlugin {
+public:
+ ForwardingZyppPlugin(const string& another_plugin);
+
+ virtual int main() override;
+ virtual Message dispatch(const Message&) override;
+private:
+ string child_program;
+ bp::ipstream childs_out; // we read this
+ // bp::ipstream childs_err; // we read this
+ bp::opstream childs_in; // we write this
+};
+
+ForwardingZyppPlugin::ForwardingZyppPlugin(const string& another_plugin)
+ : child_program(another_plugin)
+{
+}
+
+int ForwardingZyppPlugin::main() {
+ bp::child c(child_program,
+ bp::std_out > childs_out,
+ // bp::std_err > childs_err,
+ bp::std_in < childs_in);
+
+ int result = ZyppPlugin::main();
+
+ // c.wait();
+ return result;
+}
+
+ZyppPlugin::Message ForwardingZyppPlugin::dispatch(const Message& msg) {
+ write_message(childs_in, msg);
+ Message reply = read_message(childs_out);
+ return reply;
+}
+
+int main(int argc, char** argv) {
+ if (argc != 2)
+ throw runtime_error("Usage: forwarding-zypp-plugin ANOTHER_ZYPP_PLUGIN");
+ ForwardingZyppPlugin plugin(argv[1]);
+ return plugin.main();
+}