std::cout << "Registered packets:\n\n";
senf::dumpPacketRegistries(std::cout);
- if (argc >= 3)
+ if (argc >= 3) {
if (std::string(argv[1]) == "loop")
return loop_main(argc,argv);
else if (std::string(argv[1]) == "scheduler")
return scheduler_main(argc,argv);
+ }
std::cerr << "Usage: sniffer { loop | scheduler } [interface]" << std::endl;
return 1;
};
bool is_close_clock(senf::ClockService::clock_type a, senf::ClockService::clock_type b,
- unsigned long delta = senf::ClockService::milliseconds(100))
+ unsigned long delta)
{
return (a<b ? b-a : a-b ) < delta;
}
senf::ppi::run();
BOOST_CHECK_PREDICATE( is_close_clock,
(senf::ClockService::now())
- (start+senf::ClockService::milliseconds(400)) );
+ (start+senf::ClockService::milliseconds(400))
+ (senf::ClockService::milliseconds(100)) );
}
///////////////////////////////cc.e////////////////////////////////////////
# else
- BOOST_STATIC_ASSERT(( false ));
+ invalid_annotation_check_disabled();
# endif
}
namespace {
bool is_close_clock(senf::ClockService::clock_type a, senf::ClockService::clock_type b,
- unsigned long delta = senf::ClockService::milliseconds(100))
- {
- return (a<b ? b-a : a-b ) < delta;
- }
-
- bool is_close_pt(boost::posix_time::ptime a, boost::posix_time::ptime b,
- boost::posix_time::time_duration delta = boost::posix_time::milliseconds(100) )
+ unsigned long delta)
{
return (a<b ? b-a : a-b ) < delta;
}
senf::ClockService::clock_type t2 (senf::ClockService::now());
BOOST_CHECK_PREDICATE( is_close_clock,
(t1 + senf::ClockService::milliseconds(200))
- (t2) );
+ (t2)
+ (senf::ClockService::milliseconds(100)) );
t1 = t2;
delay(200);
BOOST_CHECK_PREDICATE( is_close_clock,
(t1 + senf::ClockService::milliseconds(200))
- (senf::ClockService::now()) );
+ (senf::ClockService::now())
+ (senf::ClockService::milliseconds(100)) );
// The next check validates that the clock service itimer/heartbeat_ is correctly reset after a
// clock-skew is detected
BOOST_CHECK_PREDICATE( is_close_clock,
(t1 + senf::ClockService::milliseconds(200))
- (senf::ClockService::now()) );
+ (senf::ClockService::now())
+ (senf::ClockService::milliseconds(100)) );
}
///////////////////////////////cc.e////////////////////////////////////////
TempFile cfg ("test.cfg");
cfg << "dir1/fun1 foo; fun2;" << TempFile::close;
- char * argv[] = { "", "--dir1-fun1=bar" };
+ char const * argv[] = { "", "--dir1-fun1=bar" };
senf::console::ConfigBundle bundle(root);
bundle.add( senf::console::FileConfig(cfg.name()) );
// Invalid characters: All chars below \x20 (space) which are not space_p
// (don't put a \0 in the chset<> argument *string* ...)
- invalid_p (
- boost::spirit::chset<>('\0') | boost::spirit::chset<>("\x01-\x20") - space_p ),
+ invalid_p ( (boost::spirit::chset<>('\0')
+ | boost::spirit::chset<>("\x01-\x20")) - space_p ),
// Valid word characters
word_p (
nonOptions_->clear();
if (argc_ <= 1)
return;
- char ** argp (argv_+1);
+ char const ** argp (argv_+1);
int n (argc_-1);
for (; n; --n, ++argp) {
std::string arg (*argp);
///////////////////////////////////////////////////////////////////////////
-prefix_ void senf::console::parseOptions(int argc, char ** argv, DirectoryNode & root)
+prefix_ void senf::console::parseOptions(int argc, char const ** argv, DirectoryNode & root)
{
ProgramOptions opts (argc, argv, root);
opts.parse();
// senf::console::detail::ProgramOptionsSource
prefix_ senf::console::detail::ProgramOptionsSource::ptr
-senf::console::detail::ProgramOptionsSource::create(int argc, char ** argv)
+senf::console::detail::ProgramOptionsSource::create(int argc, char const ** argv)
{
return ptr(new ProgramOptionsSource(argc,argv));
}
prefix_ senf::console::detail::ProgramOptionsSource::ProgramOptionsSource(int argc,
- char ** argv)
+ char const ** argv)
: argc_ (argc), argv_ (argv)
{}
///////////////////////////////////////////////////////////////////////////
// senf::console::ProgramOptions
-prefix_ senf::console::ProgramOptions::ProgramOptions(int argc, char ** argv,
+prefix_ senf::console::ProgramOptions::ProgramOptions(int argc, char const ** argv,
DirectoryNode & root)
: detail::BundleMixin (root), config_ (add(detail::ProgramOptionsSource::create(argc, argv)))
{}
///////////////////////////////////////////////////////////////////////////
prefix_ senf::console::detail::ProgramOptionsSource::ptr
-senf::console::OptionsConfig(int argc, char ** argv)
+senf::console::OptionsConfig(int argc, char const ** argv)
{
return detail::ProgramOptionsSource::create(argc, argv);
}
///\name Structors and default members
///@{
- ProgramOptions(int argc, char ** argv, DirectoryNode & root = root());
+ ProgramOptions(int argc, char const ** argv, DirectoryNode & root = root());
///< Create ProgramOptions parser for given options
/**< The given argc/argv values are those passed to main by
the operating system. Especially argv[0] is \e not an
\related ProgramOptions
*/
- void parseOptions(int argc, char ** argv, DirectoryNode & root = root());
+ void parseOptions(int argc, char const ** argv, DirectoryNode & root = root());
/** \brief ConfigBundle source reading command line options
\related ProgramOptions
*/
- detail::ProgramOptionsSource::ptr OptionsConfig(int argc, char ** argv);
+ detail::ProgramOptionsSource::ptr OptionsConfig(int argc, char const ** argv);
}}
///////////////////////////////hh.e////////////////////////////////////////
public:
typedef boost::intrusive_ptr<ProgramOptionsSource> ptr;
- static ptr create(int argc, char ** argv);
+ static ptr create(int argc, char const ** argv);
template <class Container>
ProgramOptionsSource & nonOptions(Container & container);
ProgramOptionsSource & alias(char letter, std::string const & longOpt, bool withArg=false);
private:
- ProgramOptionsSource(int argc, char ** argv);
+ ProgramOptionsSource(int argc, char const ** argv);
virtual void v_parse(RestrictedExecutor & executor);
typedef std::map<char, ShortOption> ShortOptions;
int argc_;
- char ** argv_;
+ char const ** argv_;
CommandParser parser_;
ShortOptions shortOptions_;
boost::scoped_ptr<NonOptionContainer> nonOptions_;
root.mkdir("name-with-dashes").add("fun-2", &fun2);
{
- char * argv[] = { "", "--dir1-fun1=foo","--fun2" };
+ char const * argv[] = { "", "--dir1-fun1=foo","--fun2" };
senf::console::ProgramOptions opts (sizeof(argv)/sizeof(argv[0]), argv, root);
SENF_CHECK_NO_THROW( opts.parse() );
}
{
- char * argv[] = { "", "--d-f=foo","--fun" };
+ char const * argv[] = { "", "--d-f=foo","--fun" };
senf::console::ProgramOptions opts (sizeof(argv)/sizeof(argv[0]), argv, root);
val1 = "";
}
{
- char * argv[] = { "", "--name-w-fun" };
+ char const * argv[] = { "", "--name-w-fun" };
senf::console::ProgramOptions opts (sizeof(argv)/sizeof(argv[0]), argv, root);
val1 = "";
}
{
- char * argv[] = { "", "-ab" };
+ char const * argv[] = { "", "-ab" };
senf::console::ProgramOptions opts(sizeof(argv)/sizeof(argv[0]), argv, root);
opts
.alias('a', "--dir1-fun1=baz")
}
{
- char * argv[] = { "", "-badoo" };
+ char const * argv[] = { "", "-badoo" };
senf::console::ProgramOptions opts(sizeof(argv)/sizeof(argv[0]), argv, root);
opts
.alias('a', "--dir1-fun1", true)
}
{
- char * argv[] = { "", "-a","dii","-b" };
+ char const * argv[] = { "", "-a","dii","-b" };
senf::console::ProgramOptions opts(sizeof(argv)/sizeof(argv[0]), argv, root);
opts
.alias('a', "--dir1-fun1", true)
prefix_ void senf::console::Server::newClient(int event)
{
- ServerHandle::ClientSocketHandle client (handle_.accept());
+ ServerHandle::ClientHandle client (handle_.accept());
boost::intrusive_ptr<Client> p (new Client(*this, client));
clients_.insert( p );
SENF_LOG(( "Registered new client " << p.get() ));
static const unsigned INTERACTIVE_TIMEOUT = 500; // milliseconds;
public:
- typedef Server::ServerHandle::ClientSocketHandle ClientHandle;
+ typedef Server::ServerHandle::ClientHandle ClientHandle;
~Client();
class ClientReader
{
public:
- typedef ServerHandle::ClientSocketHandle ClientHandle;
+ typedef ServerHandle::ClientHandle ClientHandle;
virtual ~ClientReader() = 0;
/** This class will probably only be usable, if the \c CommunicationPolicy is \c
ConnectedCommunicationPolicy and the \c AddressingPolicy is not \c
NoAddressingPolicy. */
- typedef ServerSocketHandle<SPolicy> ServerSocketHandle;
+ typedef ServerSocketHandle<SPolicy> ServerHandle;
///////////////////////////////////////////////////////////////////////////
///\name Structors and default members
OtherSocketHandle osh (h);
h = senf::static_socket_cast<MySocketHandle>(osh);
- MySocketHandle::ClientSocketHandle client = h.accept();
+ MySocketHandle::ClientHandle client = h.accept();
BOOST_CHECK_EQUAL( client.fd(), -1 );
BOOST_CHECK_EQUAL( h.dumpState(),
prefix_ bool senf::INet6Address::multicast()
const
{
- return (*this)[0] == 0xFFu || inet4Mapped() && inet4address().multicast();
+ return (*this)[0] == 0xFFu || (inet4Mapped() && inet4address().multicast());
}
prefix_ senf::INet6Address::ScopeId senf::INet6Address::scope()
}
template <class SPolicy>
-prefix_ typename senf::ServerSocketHandle<SPolicy>::ClientSocketHandle
+prefix_ typename senf::ServerSocketHandle<SPolicy>::ClientHandle
senf::ServerSocketHandle<SPolicy>::accept()
{
- return ClientSocketHandle(this->body().clone(
- SPolicy::CommunicationPolicy::accept(*this), false));
+ return ClientHandle(this->body().clone(
+ SPolicy::CommunicationPolicy::accept(*this), false));
}
template <class SPolicy>
-prefix_ std::pair<typename senf::ServerSocketHandle<SPolicy>::ClientSocketHandle,
+prefix_ std::pair<typename senf::ServerSocketHandle<SPolicy>::ClientHandle,
typename senf::ServerSocketHandle<SPolicy>::Address>
senf::ServerSocketHandle<SPolicy>::acceptfrom()
{
Address address;
- ClientSocketHandle handle = acceptfrom(address);
+ ClientHandle handle = acceptfrom(address);
return std::make_pair(handle,address);
}
template <class SPolicy>
-prefix_ typename senf::ServerSocketHandle<SPolicy>::ClientSocketHandle
+prefix_ typename senf::ServerSocketHandle<SPolicy>::ClientHandle
senf::ServerSocketHandle<SPolicy>::acceptfrom(Address & addr)
{
- return ClientSocketHandle(this->protocol().clone(),
- SPolicy::CommunicationPolicy::accept(*this,addr));
+ return ClienttHandle(this->protocol().clone(),
+ SPolicy::CommunicationPolicy::accept(*this,addr));
}
///////////////////////////////////////////////////////////////////////////
*/
typedef typename boost::call_traits<Address>::param_type AddressParam;
/// Corresponding client socket handle with the same policy
- typedef ClientSocketHandle<SPolicy> ClientSocketHandle;
+ typedef ClientSocketHandle<SPolicy> ClientHandle;
///////////////////////////////////////////////////////////////////////////
///\name Structors and default members
\returns handle of new client connection
*/
- ClientSocketHandle
- accept ();
- std::pair<ClientSocketHandle, Address>
+ ClientHandle accept ();
+ std::pair<ClientHandle, Address>
acceptfrom (); ///< Accept new connection
/**< This variant will additionally return the remote
address of the client
\returns \c std::pair with client handle and client
address.
\see \ref accept() */
- ClientSocketHandle
- acceptfrom (Address & addr);
+ ClientHandle acceptfrom (Address & addr);
///< Accept new connection
/**< This variant will additionally return the remote
address of the client
BOOST_CHECK_EQUAL( myh.local(), 2u );
{
- MySocketHandle::ClientSocketHandle client = myh.accept();
+ MySocketHandle::ClientHandle client = myh.accept();
BOOST_CHECK_EQUAL( client.fd(), -1 );
}
BOOST_AUTO_UNIT_TEST(testDaemon)
{
- char * args[] = { "run",
- "--console-log=testDaemon.log",
- "--pid-file=testDaemon.pid" };
- BOOST_CHECK_EQUAL( run(sizeof(args)/sizeof(*args),args), 0 );
+ char const * args[] = { "run",
+ "--console-log=testDaemon.log",
+ "--pid-file=testDaemon.pid" };
+
+ 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") );
#include <boost/preprocessor/seq/fold_right.hpp>
#include <boost/preprocessor/seq/pop_back.hpp>
#include <boost/preprocessor/if.hpp>
+#include <boost/preprocessor/facilities/is_empty.hpp>
#include "../preprocessor.hh"
///////////////////////////////ih.p////////////////////////////////////////
}}}
-#define SENF_LOG_SEQ_TO_NAME_(s,state,elem) state::elem
+#define SENF_LOG_CHECK_NA_
+
+#define SENF_LOG_CAT(a,b) SENF_LOG_CAT_I(a,b)
+#define SENF_LOG_CAT_I(a,b) a ## b
+
+#define SENF_LOG_IS_NA(elt) BOOST_PP_IS_EMPTY( SENF_LOG_CAT(SENF_LOG_CHECK_NA, elt) )
+
+#define SENF_LOG_SEQ_TO_NAME_(s,state,elem) \
+ BOOST_PP_IF( SENF_LOG_IS_NA(elem), senf::log::detail::na, state::elem )
#define SENF_LOG_SEQ_TO_NAME(seq) \
BOOST_PP_SEQ_FOLD_LEFT(SENF_LOG_SEQ_TO_NAME_, , seq)
BOOST_PP_SEQ_POP_BACK(seq) )
#define SENF_LOG_PREDECL_short(seq) \
- class SENF_PP_SEQ_BACK(seq);
+ BOOST_PP_IF( SENF_LOG_IS_NA( SENF_PP_SEQ_BACK(seq) ), ; , class SENF_PP_SEQ_BACK(seq); )
#define SENF_LOG_PREDECL(seq) \
BOOST_PP_CAT(SENF_LOG_PREDECL_, \
#ifdef SENF_LOG_CONF
-# define _ senf::log::detail::na
# define SLC_elt(r, data, elt) \
SENF_LOG_CONF_DEFINE elt
BOOST_PP_SEQ_FOR_EACH(SLC_elt, none, SENF_LOG_CONF)
# undef SLC_elt
-# undef _
#endif
test_sources = [ test_sources ]
else:
test_sources = []
- testEnv = env.Copy(**kw)
+ testEnv = env.Clone(**kw)
testEnv.Prepend(_LIBFLAGS = ' -Wl,-Bstatic -l$BOOSTTESTLIB -Wl,-Bdynamic ')
testEnv.Prepend(LIBS = LIBS)
testEnv.Append(LIBS = env['TEST_EXTRA_LIBS'])
objects = Objects(env,sources,testSources,LIBS=LIBS,OBJECTS=OBJECTS)
program = None
if objects:
- progEnv = env.Copy()
+ progEnv = env.Clone()
progEnv.Prepend(LIBS = [ x + '$LIBADDSUFFIX' for x in LIBS ])
program = progEnv.ProgramNoScan(target=binary,source=objects+OBJECTS)
env.Default(program)