Port SENF to compile against boost-1.35
g0dil [Wed, 5 Nov 2008 09:32:30 +0000 (09:32 +0000)]
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@946 270642c3-0616-0410-b53a-bc976706d245

17 files changed:
Packets/PacketInterpreter.test.cc
Scheduler/Console/Executor.cc
Scheduler/Console/Node.cc
Scheduler/Console/Node.test.cc
Scheduler/Console/Parse.test.cc
Scheduler/Console/ParsedCommand.mpp
Scheduler/Console/ProgramOptions.cc
Scheduler/FdEvent.test.cc
Scheduler/Scheduler.test.cc
Socket/Protocols/INet/TCPSocketHandle.test.cc
Socket/Protocols/INet/UDPSocketHandle.test.cc
Utils/Daemon/Daemon.test.cc
Utils/parameter.hh
Utils/range.cti [new file with mode: 0644]
Utils/range.hh [new file with mode: 0644]
debian/control
senfscons/SENFSCons.py

index 77e13ad..49f6ebd 100644 (file)
@@ -80,7 +80,7 @@ BOOST_AUTO_UNIT_TEST(packetInterpreterBase)
         BOOST_CHECK_EQUAL( pi2->data().size(), 1u );
         BOOST_CHECK_EQUAL( pi2b->data().size(), 2u );
 
-        BOOST_CHECK_EQUAL( pi1->data().size(), pi1->nextPacketRange()->size() );
+        BOOST_CHECK_EQUAL( pi1->data().size(), unsigned(pi1->nextPacketRange()->size()) );
         pi1->append(pi2b);
         BOOST_CHECK_EQUAL( pi1->data().size(), 2u );
         BOOST_REQUIRE( pi1->next() );
@@ -286,7 +286,7 @@ BOOST_AUTO_UNIT_TEST(packetInterpreter_factory)
         senf::PacketInterpreterBase::ptr p2 (p->parseNextAs(factory));
         BOOST_CHECK( p2->is<OtherPacket>() );
         BOOST_CHECK( ! p2->is<VoidPacket>() );
-        BOOST_CHECK_EQUAL( boost::size(*p2->nextPacketRange()), 4u );
+        BOOST_CHECK_EQUAL( unsigned(boost::size(*p2->nextPacketRange())), 4u );
     }
 
 }
index 5a6337d..8f054c7 100644 (file)
@@ -33,6 +33,7 @@
 #include "../../Utils/senfassert.hh"
 #include "../../Utils/Range.hh"
 #include "../../Utils/String.hh"
+#include "../../Utils/range.hh"
 
 //#include "Executor.mpp"
 #define prefix_
@@ -301,7 +302,7 @@ prefix_ std::string senf::console::Executor::complete(DirectoryNode & dir,
 {
     if (! dir.hasChild(name)) {
         DirectoryNode::ChildrenRange completions (dir.completions(name));
-        if (completions.size() == 1)
+        if (has_one_elt(completions))
             return completions.begin()->first;
     }
     return name;
index fddf01a..39c2685 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "Node.hh"
 #include "Node.ih"
+#include "../../Utils/range.hh"
 
 // Custom includes
 
@@ -173,7 +174,7 @@ prefix_ void senf::console::detail::NodeTraverser::operator()(std::string const
         else if (elt_ != "" && elt_ != ".") {
             if (! dir_->hasChild(elt_) && autocomplete_) {
                 DirectoryNode::ChildrenRange completions (dir_->completions(elt_));
-                if (completions.size() == 1)
+                if (has_one_elt(completions))
                     elt_ = completions.begin()->first;
             }
             // Why does g++ give an error on this line ???? :
@@ -190,7 +191,7 @@ prefix_ senf::console::GenericNode & senf::console::detail::NodeTraverser::node(
     if (elt_ != "" && elt_ != ".") {
         if (! dir_->hasChild(elt_) && autocomplete_) {
             DirectoryNode::ChildrenRange completions (dir_->completions(elt_));
-            if (completions.size() == 1)
+            if (has_one_elt(completions))
                 elt_ = completions.begin()->first;
         }
         return dir_->get(elt_);
index cc786dc..810ce25 100644 (file)
@@ -116,7 +116,8 @@ BOOST_AUTO_UNIT_TEST(directoryNode)
     senf::console::root().remove("dir2");
     senf::console::root().remove("fn");
 
-    BOOST_CHECK_EQUAL( senf::console::root().children().size(), 1u );
+    BOOST_CHECK_EQUAL( std::distance(senf::console::root().children().begin(),
+                                     senf::console::root().children().end()), 1 );
 }
 
 BOOST_AUTO_UNIT_TEST(linkNode)
index 472b9a3..4570fb0 100644 (file)
@@ -211,7 +211,7 @@ BOOST_AUTO_UNIT_TEST(commandParser)
 
         BOOST_CHECK_EQUAL_COLLECTIONS( info.commandPath().begin(), info.commandPath().end(),
                                        path, path + sizeof(path)/sizeof(path[0]) );
-        BOOST_CHECK_EQUAL( info.tokens().size(), 15u );
+        BOOST_CHECK_EQUAL( unsigned(info.tokens().size()), 15u );
         
         char const * tokens[] = { "arg", 
                                   "flab::blub", 
@@ -222,7 +222,7 @@ BOOST_AUTO_UNIT_TEST(commandParser)
 
         senf::console::ParseCommandInfo::argument_iterator args (info.arguments().begin());
         BOOST_REQUIRE( args != info.arguments().end() );
-        BOOST_REQUIRE_EQUAL( args->size(), 1u );
+        BOOST_REQUIRE_EQUAL( unsigned(args->size()), 1u );
         BOOST_CHECK_EQUAL( args->begin()->value(), tokens[0] );
         
         ++ args;
index c5ffd18..f444a6b 100644 (file)
@@ -254,12 +254,13 @@ v_execute(std::ostream & os, ParseCommandInfo const & command)
 {
     // We NEED to know the number of arguments beforehand so we can assign default values
     // correctly ... hrmpf ...
-    unsigned nArgs ( command.arguments().size() );
+    unsigned nArgs ( std::distance(command.arguments().begin(), command.arguments().end()) );
     if ( nArgs > BOOST_PP_ITERATION() )
         throw SyntaxErrorException("invalid number of arguments");
     int nDefaults ( BOOST_PP_ITERATION() - nArgs );
+    (void) nDefaults;
 
-    typedef typename boost::range_const_reverse_iterator<ParseCommandInfo::ArgumentsRange>::type
+    typedef typename boost::range_reverse_iterator<const ParseCommandInfo::ArgumentsRange>::type
         riterator;
     riterator i (boost::rbegin(command.arguments()));
     riterator const i_end (boost::rend(command.arguments()));
@@ -293,12 +294,13 @@ v_execute(std::ostream & os, ParseCommandInfo const & command)
 {
     // We NEED to know the number of arguments beforehand so we can assign default values
     // correctly ... hrmpf ...
-    unsigned nArgs ( command.arguments().size() );
+    unsigned nArgs ( std::distance(command.arguments().begin(), command.arguments().end()) );
     if ( nArgs > BOOST_PP_ITERATION() )
         throw SyntaxErrorException("invalid number of arguments");
     int nDefaults ( BOOST_PP_ITERATION() - nArgs );
+    (void) nDefaults;
 
-    typedef typename boost::range_const_reverse_iterator<ParseCommandInfo::ArgumentsRange>::type
+    typedef typename boost::range_reverse_iterator<const ParseCommandInfo::ArgumentsRange>::type
         riterator;
     riterator i (boost::rbegin(command.arguments()));
     riterator const i_end (boost::rend(command.arguments()));
index 9f14736..63bcfb1 100644 (file)
@@ -29,6 +29,7 @@
 // Custom includes
 #include <boost/algorithm/string/predicate.hpp>
 #include <boost/format.hpp>
+#include "../../Utils/range.hh"
 
 //#include "ProgramOptions.mpp"
 #define prefix_
@@ -115,7 +116,7 @@ senf::console::detail::ProgramOptionsSource::parseLongOption(std::string const &
             std::string key (name.substr(b,e-b));
             if (! cwd->hasChild(key)) {
                 DirectoryNode::ChildrenRange completions (cwd->completions(key));
-                if (completions.size() == 1)
+                if (has_one_elt(completions))
                     key = completions.begin()->first;
                 else
                     continue;
index 6ca3572..21f3add 100644 (file)
@@ -102,6 +102,7 @@ namespace {
         unlink(SOCK_PATH);
         int pid = fork();
         if (pid == 0) {
+            signal(SIGCHLD, SIG_IGN);
             server();
             _exit(0);
         }
@@ -109,6 +110,7 @@ namespace {
             error("fork");
             return 0;
         }
+        signal(SIGCHLD, SIG_DFL);
 
         sleep(1); // Wait for the server socket to be opened
         return pid;
index a46aa18..bc627a3 100644 (file)
@@ -102,6 +102,7 @@ namespace {
         unlink(SOCK_PATH);
         int pid = fork();
         if (pid == 0) {
+            signal(SIGCHLD, SIG_IGN);
             server();
             _exit(0);
         }
@@ -109,6 +110,7 @@ namespace {
             error("fork");
             return 0;
         }
+        signal(SIGCHLD, SIG_DFL);
 
         sleep(1); // Wait for the server socket to be opened
         return pid;
index 3ed3a0a..70d599e 100644 (file)
@@ -61,9 +61,11 @@ namespace {
         server_pid = ::fork();
         if (server_pid < 0) BOOST_FAIL("fork()");
         if (server_pid == 0) {
+            signal(SIGCHLD, SIG_IGN);
             (*fn)();
             _exit(0);
         }
+        signal(SIGCHLD, SIG_DFL);
         ::sleep(1);
     }
 
@@ -174,10 +176,10 @@ BOOST_AUTO_UNIT_TEST(tcpv4ClientSocketHandle)
         BOOST_CHECK_EQUAL( sock.protocol().rcvbuf(), 2048u );
         BOOST_CHECK_NO_THROW( sock.protocol().sndbuf(2048) );
         BOOST_CHECK_EQUAL( sock.protocol().sndbuf(), 2048u );
-        BOOST_CHECK_NO_THROW( sock.write("TEST-WRITE") );
-        BOOST_CHECK_EQUAL( sock.read(), "TEST-WRITE" );
+        BOOST_CHECK_NO_THROW( sock.write(std::string("TEST-WRITE")) );
+        BOOST_CHECK_EQUAL( sock.read(), std::string("TEST-WRITE") );
         BOOST_CHECK( !sock.eof() );
-        sock.write("QUIT");
+        sock.write(std::string("QUIT"));
         sleep(1);
         stop();
         sleep(1);
@@ -245,12 +247,12 @@ BOOST_AUTO_UNIT_TEST(tcpv6ClientSocketHandle)
         BOOST_CHECK_EQUAL( sock.protocol().rcvbuf(), 2048u );
         BOOST_CHECK_NO_THROW( sock.protocol().sndbuf(2048) );
         BOOST_CHECK_EQUAL( sock.protocol().sndbuf(), 2048u );
-        BOOST_CHECK_NO_THROW( sock.write("TEST-WRITE") );
-        BOOST_CHECK_EQUAL( sock.read(), "TEST-WRITE" );
+        BOOST_CHECK_NO_THROW( sock.write(std::string("TEST-WRITE")) );
+        BOOST_CHECK_EQUAL( sock.read(), std::string("TEST-WRITE") );
         // this fails with ENOFILE ... why ????
         // BOOST_CHECK_NO_THROW( sock.protocol().timestamp() );
         BOOST_CHECK( !sock.eof() );
-        sock.write("QUIT");
+        sock.write(std::string("QUIT"));
         sleep(1);
         stop();
         sleep(1);
@@ -347,7 +349,7 @@ BOOST_AUTO_UNIT_TEST(tcpv4ServerSocketHandle)
 
         BOOST_CHECKPOINT("Accepting connection");
         senf::TCPv4ClientSocketHandle client = server.accept();
-        BOOST_CHECK_NO_THROW(client.write("QUIT"));
+        BOOST_CHECK_NO_THROW(client.write(std::string("QUIT")));
 
         BOOST_CHECKPOINT("Stopping client");
         sleep(1);
@@ -373,7 +375,7 @@ BOOST_AUTO_UNIT_TEST(tcpv6ServerSocketHandle)
 
         BOOST_CHECKPOINT("Accepting connection");
         senf::TCPv6ClientSocketHandle client = server.accept();
-        BOOST_CHECK_NO_THROW(client.write("QUIT"));
+        BOOST_CHECK_NO_THROW(client.write(std::string("QUIT")));
 
         BOOST_CHECKPOINT("Stopping client");
         sleep(1);
index 39cece6..44c51ec 100644 (file)
@@ -62,9 +62,11 @@ namespace {
         server_pid = ::fork();
         if (server_pid < 0) BOOST_FAIL("fork()");
         if (server_pid == 0) {
+            signal(SIGCHLD, SIG_IGN);
             (*fn)();
             _exit(0);
         }
+        signal(SIGCHLD, SIG_DFL);
     }
 
     void wait()
@@ -154,7 +156,7 @@ BOOST_AUTO_UNIT_TEST(udpv4ClientSocketHandle)
                                            std::string("TEST-WRITE")) );
         BOOST_CHECK_EQUAL( sock.read(), "TEST-WRITE" );
         BOOST_CHECK_NO_THROW( sock.protocol().timestamp() );
-        sock.writeto(senf::INet4SocketAddress("127.0.0.1:12345"),"QUIT");
+        sock.writeto(senf::INet4SocketAddress("127.0.0.1:12345"), std::string("QUIT"));
         sleep(1);
         stop();
         sleep(1);
index d9e4a3e..6d991c4 100644 (file)
@@ -94,6 +94,7 @@ namespace {
         if (pid < 0) throw senf::SystemException("::fork()");
         if (pid == 0) {
             signal(SIGABRT, &backtrace);
+            signal(SIGCHLD, SIG_IGN);
             try {
                 ::_exit(myMain(argc, argv));
             } catch (std::exception & ex) {
@@ -103,6 +104,7 @@ namespace {
             }
             ::_exit(125);
         }
+        signal(SIGCHLD, SIG_DFL);
         int status;
         if (::waitpid(pid, &status, 0) < 0) 
             throw senf::SystemException("::waitpid()");
@@ -122,7 +124,7 @@ BOOST_AUTO_UNIT_TEST(testDaemon)
                             "--console-log=testDaemon.log", 
                             "--pid-file=testDaemon.pid" };
 
-    BOOST_CHECK_EQUAL( run(sizeof(args)/sizeof(*args), const_cast<char **>(args)), 0 );
+    SENF_CHECK_NO_THROW( BOOST_CHECK_EQUAL( run(sizeof(args)/sizeof(*args), const_cast<char **>(args)), 0 ) );
 
     BOOST_CHECK( ! boost::filesystem::exists("invalid.log") );
     BOOST_CHECK( ! boost::filesystem::exists("invalid.pid") );
index 478925a..7ea462c 100644 (file)
@@ -58,7 +58,7 @@ namespace senf {
     template <class ArgumentPack, class TagType>
     struct has_parameter
         : public boost::mpl::not_< 
-              boost::is_same< typename boost::parameter::binding< ArgumentPack, TagType>::type,
+              boost::is_same< typename boost::parameter::binding< ArgumentPack, TagType, void>::type,
                                                                   void > >::type
     {};
 
diff --git a/Utils/range.cti b/Utils/range.cti
new file mode 100644 (file)
index 0000000..197e10c
--- /dev/null
@@ -0,0 +1,52 @@
+// $Id$
+//
+// Copyright (C) 2008 
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+//     Stefan Bund <g0dil@berlios.de>
+//
+// This program 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 of the License, or
+// (at your option) any later version.
+//
+// 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, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+/** \file
+    \brief range inline template implementation */
+
+//#include "range.ih"
+
+// Custom includes
+#include <boost/utility.hpp>
+
+#define prefix_ inline
+///////////////////////////////cti.p///////////////////////////////////////
+
+template <class Range>
+prefix_ bool senf::has_one_elt(Range r)
+{
+    return ! r.empty() && boost::next(r.begin()) == r.end();
+}
+
+///////////////////////////////cti.e///////////////////////////////////////
+#undef prefix_
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// comment-column: 40
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// End:
diff --git a/Utils/range.hh b/Utils/range.hh
new file mode 100644 (file)
index 0000000..9d4109b
--- /dev/null
@@ -0,0 +1,56 @@
+// $Id$
+//
+// Copyright (C) 2008 
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+//     Stefan Bund <g0dil@berlios.de>
+//
+// This program 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 of the License, or
+// (at your option) any later version.
+//
+// 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, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+/** \file
+    \brief range public header */
+
+#ifndef HH_range_
+#define HH_range_ 1
+
+// Custom includes
+
+//#include "range.mpp"
+///////////////////////////////hh.p////////////////////////////////////////
+
+namespace senf {
+
+    template <class Range>
+    bool has_one_elt(Range r);
+
+}
+
+///////////////////////////////hh.e////////////////////////////////////////
+//#include "range.cci"
+//#include "range.ct"
+#include "range.cti"
+#endif
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// comment-column: 40
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// End:
index bb564cd..92aedad 100644 (file)
@@ -1,7 +1,7 @@
 Source: libsenf
 Priority: extra
 Maintainer: Stefan Bund <senf-dev@lists.berlios.de>
-Build-Depends: debhelper (>= 5), scons (>= 0.97), binutils-dev, libboost-dev, 
+Build-Depends: debhelper (>= 5), scons (>= 0.97), g++, binutils-dev, libboost-dev, 
        libboost-test-dev, libboost-date-time-dev, libboost-regex-dev, 
        libboost-filesystem-dev, libboost-serialization-dev, libboost-iostreams-dev,
        doxygen (>= 1.5.5), libreadline-dev, dia, tidy, xsltproc, graphviz, perl-base, 
index 7f08d0b..4c3f3b8 100644 (file)
@@ -137,6 +137,8 @@ def UseBoost():
     opts.Add('BOOST_RUNTIME', 'The boost runtime to use', '')
     opts.Add('BOOST_DEBUG_RUNTIME', 'The boost debug runtime to use', '')
     opts.Add('BOOST_LIBDIR', 'The directory of the boost libraries', '')
+    opts.Add('BOOST_PREFIX', 'The prefix into which boost is installed', '')
+    opts.Add('BOOST_VERSION', 'The version of boost to use', '')
     Finalizer(FinalizeBoost)
 
 ## \brief Finalize Boost environment
@@ -152,14 +154,26 @@ def FinalizeBoost(env):
         if runtime: runtime = "-" + runtime
         env['BOOST_VARIANT'] = "-" + env['BOOST_TOOLSET'] + runtime
 
+    if env['BOOST_VARIANT'] and env['BOOST_VERSION']:
+        env['BOOST_VARIANT'] = env['BOOST_VARIANT'] + '-%s' % env['BOOST_VERSION'].replace('.','_')
+
     env['BOOSTTESTLIB'] = 'boost_unit_test_framework' + env['BOOST_VARIANT']
     env['BOOSTREGEXLIB'] = 'boost_regex' + env['BOOST_VARIANT']
     env['BOOSTFSLIB'] = 'boost_filesystem' + env['BOOST_VARIANT']
     env['BOOSTIOSTREAMSLIB'] = 'boost_iostreams' + env['BOOST_VARIANT']
 
+    if env['BOOST_PREFIX']:
+        env['BOOST_LIBDIR'] = os.path.join(env['BOOST_PREFIX'], 'lib')
+        env['BOOST_INCLUDES'] = os.path.join(env['BOOST_PREFIX'],
+                                             'include/boost-%s'
+                                                 % env['BOOST_VERSION'].replace('.','_'))
+
     env.Append(LIBPATH = [ '$BOOST_LIBDIR' ],
                CPPPATH = [ '$BOOST_INCLUDES' ])
 
+    if env['BOOST_LIBDIR']:
+        env.Append(ENV = { 'LD_LIBRARY_PATH': env['BOOST_LIBDIR'] })
+
 ## \brief Use STLPort as STL replacement if available
 #
 # Use <a href="http://www.stlport.org">STLPort</a> as a replacement