[complement-svn] SF.net SVN: complement: [1853] trunk/complement/explore/app/SMTP-tools
Status: Pre-Alpha
Brought to you by:
complement
From: <com...@us...> - 2008-04-23 09:22:17
|
Revision: 1853 http://complement.svn.sourceforge.net/complement/?rev=1853&view=rev Author: complement Date: 2008-04-23 02:22:13 -0700 (Wed, 23 Apr 2008) Log Message: ----------- compiled with modern xmt/date_time Modified Paths: -------------- trunk/complement/explore/app/SMTP-tools/DoSclient/Makefile trunk/complement/explore/app/SMTP-tools/smtp-ut/smtp-batch/Makefile trunk/complement/explore/app/SMTP-tools/smtp-ut/smtp-batch/smtp-batch.cc Property Changed: ---------------- trunk/complement/explore/app/SMTP-tools/smtp-ut/smtp-batch/ trunk/complement/explore/app/SMTP-tools/smtp_server_ut/ Modified: trunk/complement/explore/app/SMTP-tools/DoSclient/Makefile =================================================================== --- trunk/complement/explore/app/SMTP-tools/DoSclient/Makefile 2008-04-23 09:20:23 UTC (rev 1852) +++ trunk/complement/explore/app/SMTP-tools/DoSclient/Makefile 2008-04-23 09:22:13 UTC (rev 1853) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <08/04/23 09:38:04 ptr> +# -*- Makefile -*- Time-stamp: <08/04/23 09:48:37 ptr> SRCROOT := ../../.. @@ -13,7 +13,7 @@ # LIBFS_DIR = ${CoMT_DIR}/../extern/custom/boost/libs/filesystem DEFS += -D_NO_TEST -INCLUDES += -I$(SRCROOT)/include -I$(STLPORT_INCLUDE_DIR) -I$(BOOST_INCLUDE_DIR) +INCLUDES += -I$(SRCROOT)/include -I$(BOOST_INCLUDE_DIR) release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBSOCKIOS_DIR}/${OUTPUT_DIR} -L${LIBMISC_DIR}/${OUTPUT_DIR} dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBSOCKIOS_DIR}/${OUTPUT_DIR_DBG} -L${LIBMISC_DIR}/${OUTPUT_DIR_DBG} Property changes on: trunk/complement/explore/app/SMTP-tools/smtp-ut/smtp-batch ___________________________________________________________________ Name: svn:ignore + obj Modified: trunk/complement/explore/app/SMTP-tools/smtp-ut/smtp-batch/Makefile =================================================================== --- trunk/complement/explore/app/SMTP-tools/smtp-ut/smtp-batch/Makefile 2008-04-23 09:20:23 UTC (rev 1852) +++ trunk/complement/explore/app/SMTP-tools/smtp-ut/smtp-batch/Makefile 2008-04-23 09:22:13 UTC (rev 1853) @@ -1,28 +1,26 @@ # -*- Makefile -*- Time-stamp: <04/05/06 14:30:08 ptr> -# $Id: Makefile,v 1.1 2004/06/16 14:24:07 ptr Exp $ -#SRCROOT := ../../../../extern/complement -SRCROOT := ../../../../../../island/workshop/explore -COMPILER_NAME := gcc +SRCROOT := ../../../.. include Makefile.inc -include ${SRCROOT}/Makefiles/top.mak +include ${SRCROOT}/Makefiles/gmake/top.mak +LIBMT_DIR = ${CoMT_DIR}/lib/mt +LIBSOCKIOS_DIR = ${CoMT_DIR}/lib/sockios +LIBMISC_DIR = ${CoMT_DIR}/lib/misc +LIBBOOSTRE_DIR = ${CoMT_DIR}/../extern/custom/boost/lib/regex DEFS += -D_NO_TEST -INCLUDES += -I$(SRCROOT)/include -I$(STLPORT_INCLUDE_DIR) -I$(BOOST_INCLUDE_DIR) +INCLUDES += -I$(SRCROOT)/include -I$(BOOST_INCLUDE_DIR) -release-shared: LDSEARCH = -L${STLPORT_LIB_DIR} -L${CoMT_LIB_DIR} -Wl,-rpath=${STLPORT_LIB_DIR} -stldbg-shared: LDSEARCH = -L${STLPORT_LIB_DIR} -L${CoMT_LIB_DIR_STLDBG} -Wl,-rpath=${STLPORT_LIB_DIR} -dbg-shared: LDSEARCH = -L${STLPORT_LIB_DIR} -L${CoMT_LIB_DIR_DBG} -Wl,-rpath=${STLPORT_LIB_DIR} - -ifeq ($(OSNAME),sunos) -release-shared : LDLIBS = -lstlport_gcc -lrt -stldbg-shared : LDLIBS = -lstlport_gcc_stldebug -lrt -dbg-shared : LDLIBS = -lstlport_gcc_debug -lrt -else -release-shared : LDLIBS = -lstlport_gcc -lxmt_gcc -lsockios_gcc -lmisc_gcc -lboost_regex_gcc -stldbg-shared : LDLIBS = -lstlport_gcc_stldebug -lxmt_gcc_stl-g -lsockios_gcc_stl-g -lmisc_gcc_stl-g -lboost_regex_gcc_stl-g -dbg-shared : LDLIBS = -lstlport_gcc_debug -lxmt_gcc-g -lsockios_gcc-g -lmisc_gcc-g -lboost_regex_gcc-g +release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBSOCKIOS_DIR}/${OUTPUT_DIR} -L${LIBMISC_DIR}/${OUTPUT_DIR} -L$(LIBBOOSTRE_DIR)/${OUTPUT_DIR} +dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBSOCKIOS_DIR}/${OUTPUT_DIR_DBG} -L${LIBMISC_DIR}/${OUTPUT_DIR_DBG} -L$(LIBBOOSTRE_DIR)/${OUTPUT_DIR_DBG} +ifndef WITHOUT_STLPORT +stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSOCKIOS_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBMISC_DIR}/${OUTPUT_DIR_STLDBG} -L$(LIBBOOSTRE_DIR)/${OUTPUT_DIR_STLDBG} endif +release-shared : LDLIBS += -lxmt -lsockios -lmisc -lboost_regex +dbg-shared : LDLIBS += -lxmtg -lsockiosg -lmiscg -lboost_regexg +ifndef WITHOUT_STLPORT +stldbg-shared: LDLIBS += -lxmtstlg -lsockiosstl -lmiscstlg -lboost_regexstlg +endif Modified: trunk/complement/explore/app/SMTP-tools/smtp-ut/smtp-batch/smtp-batch.cc =================================================================== --- trunk/complement/explore/app/SMTP-tools/smtp-ut/smtp-batch/smtp-batch.cc 2008-04-23 09:20:23 UTC (rev 1852) +++ trunk/complement/explore/app/SMTP-tools/smtp-ut/smtp-batch/smtp-batch.cc 2008-04-23 09:22:13 UTC (rev 1853) @@ -1,16 +1,11 @@ // -*- C++ -*- Time-stamp: <04/06/16 12:51:35 ptr> -#ifdef __unix -# ifdef __HP_aCC -#pragma VERSIONID "@(#)$Id: smtp-batch.cc,v 1.1 2004/06/16 14:24:07 ptr Exp $" -# else -#ident "@(#)$Id: smtp-batch.cc,v 1.1 2004/06/16 14:24:07 ptr Exp $" -# endif -#endif +#include <mt/thread> +#include <mt/mutex> +#include <mt/condition_variable> +#include <mt/date_time> -#include <mt/xmt.h> -#include <mt/time.h> #include <sockios/sockstream> #include <misc/args.h> @@ -23,6 +18,7 @@ using namespace std; using namespace boost; +using namespace std::tr2; struct conn { @@ -68,7 +64,8 @@ map<command_type,string> CMD; sockstream tecol; -__impl::Condition tecol_ready; +mutex tecol_ready_lk; +condition_variable tecol_ready; void init_map() { @@ -405,14 +402,14 @@ send_flag = true; { stringstream ss; - timespec t; - __impl::Thread::gettime( &t ); - ss << t.tv_sec << "." + system_time t = get_system_time(); + ss << t.seconds_since_epoch() << "." << setiosflags(ios_base::right) << setfill('0') << setw(9) - << t.tv_nsec << "-" << my_host_name; + << (t.nanoseconds_since_epoch() - seconds(t.seconds_since_epoch()) ).count() << "-" << my_host_name; if ( !tecol.is_open() ) { + lock_guard<mutex> lk( tecol_ready_lk ); tecol.open( host.c_str(), port ); - tecol_ready.set( true ); + tecol_ready.notify_one(); }// else if ( host changed or port changed ) { // } tecol << "id=" << ss.str() << " " << "action=out" << endl; @@ -461,19 +458,17 @@ getline( ss, rest ); if ( !nodelay ) { istringstream str( rest ); - timespec t; - str >> t.tv_sec; + int tsec; + str >> tsec; + seconds sec( tsec ); + nanoseconds t( sec ); if ( !str.fail() ) { - if ( t.tv_sec > 0 ) { - t.tv_nsec = lrand48() % 2000000000; - if ( t.tv_nsec > 1000000000 ) { - --t.tv_sec; - t.tv_nsec -= 1000000000; - } + if ( sec.count() > 0 ) { + t += nanoseconds( (lrand48() % 2000000000) - 1000000000 ); } else { - t.tv_nsec = lrand48() % 1000000000; + t += nanoseconds( lrand48() % 1000000000 ); } - __impl::Thread::delay( &t ); + this_thread::sleep( t ); } } break; @@ -501,9 +496,10 @@ } } -int read_tecol( void * ) +void read_tecol() { - tecol_ready.try_wait(); + unique_lock<mutex> lk( tecol_ready_lk ); + tecol_ready.wait( lk ); string s; @@ -513,8 +509,6 @@ cout << s << endl; } } - - return 0; } int main( int argc, char * const *argv ) @@ -524,7 +518,7 @@ try { Argv arg; - arg.copyright( "Copyright (C) K sky Lab, 2003, 2004" ); + arg.copyright( "Copyright (C) Petr Ovtchenkov 2003, 2004, 2008" ); arg.brief( "Mail script interpreter" ); arg.option( "-h", false, "print this help message" ); arg.option( "-f", string( "" ), "script file, default stdin" ); @@ -547,10 +541,8 @@ string fname; arg.assign( "-f", fname ); - tecol_ready.set( false ); + basic_thread<thread_base::detached,0> t( read_tecol ); - __impl::Thread t( read_tecol, 0, 0, __impl::Thread::detached ); - if ( fname.length() != 0 ) { ifstream script( fname.c_str() ); interpret( script, arg ); Property changes on: trunk/complement/explore/app/SMTP-tools/smtp_server_ut ___________________________________________________________________ Name: svn:ignore + obj This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |