-import sys
-sys.path.extend(('senf/senfscons','/usr/lib/senf/senfscons'))
-try:
- import os.path, glob, senfutil
-except ImportError:
- print "\nModule import failed. 'senf' symlink missing?\n"
- raise
+# -*- python -*-
+import sys, os, os.path
+try: sys.path.append(((_ for _ in (os.path.join(os.path.sep.join(('..' for _ in range(_))),d,
+ 'site_scons') for d in ('','senf','Senf') for _ in range(len(os.getcwd().split('/'))))
+ if os.path.exists(_))).next())
+except: pass
+import senfutil
env = Environment()
-senfutil.SetupForSENF( env )
-
-env.Append(
-
- LIBS = [ ],
- CXXFLAGS = [ '-Wall', '-Woverloaded-virtual' ],
- LINKFLAGS = [ ],
-
- CXXFLAGS_debug = [ ],
- LINKFLAGS_debug = [ ],
- LOGLEVELS_debug = [ 'senf::log::Debug||VERBOSE' ],
-
- CXXFLAGS_final = [ '-O3' ],
- LINKFLAGS_final = [ ],
- LOGLEVELS_final = [ ],
-
- SENF_BUILDOPTS = [ ],
-
-)
+senfutil.SetupForSENF(env)
+senfutil.DefaultOptions(env)
env.Default(
env.Program( target = 'udpcat',
- source = glob.glob('*.cc') )
+ source = env.Glob('*.cc') )
)
+
+env.Alias('all', '.')
+env.Clean(['.', 'all'], [ '.sconf_temp', 'config.log', '.sconsign.dblite' ])
-// $Id$
+// $Id: udpcat.cc 56 2009-05-13 13:33:24Z g0dil $
//
// Copyright (C) 2009
// Fraunhofer Institute for Open Communication Systems (FOKUS)
#define prefix_
///////////////////////////////cc.p////////////////////////////////////////
-int main(int argc, char ** argv)
+void udpIn(senf::INet4SocketAddress addr)
{
- senf::UDPv4ClientSocketHandle handle (
- senf::INet4SocketAddress(boost::lexical_cast<unsigned>(std::string(argv[1]))));
-
+ senf::UDPv4ClientSocketHandle handle (addr);
for (;;)
std::cout << handle.read() << std::flush;
}
+void udpOut(senf::INet4SocketAddress addr)
+{
+ senf::UDPv4ClientSocketHandle handle;
+ std::string line;
+ while (getline(std::cin, line)) {
+ line += "\n";
+ handle.writeto(addr, line);
+ }
+}
+
+int main(int argc, char ** argv)
+{
+ switch (argc) {
+ case 2:
+ udpIn(senf::INet4SocketAddress(boost::lexical_cast<unsigned>(std::string(argv[1]))));
+ break;
+ case 3:
+ udpOut(senf::INet4SocketAddress(senf::INet4Address::from_string(argv[1]),
+ boost::lexical_cast<unsigned>(std::string(argv[2]))));
+ break;
+ default:
+ std::cerr << "Usage:\n" " udpcat ip port\n" " udpcat port\n" << std::flush;
+ break;
+ }
+ return 1;
+}
+
///////////////////////////////cc.e////////////////////////////////////////
#undef prefix_
//#include "udpcat.mpp"