complement-svn Mailing List for Complement (Page 4)
Status: Pre-Alpha
Brought to you by:
complement
You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(61) |
Nov
(76) |
Dec
(39) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(33) |
Feb
(41) |
Mar
(16) |
Apr
|
May
(22) |
Jun
(14) |
Jul
(64) |
Aug
(60) |
Sep
(35) |
Oct
(34) |
Nov
(10) |
Dec
(5) |
2008 |
Jan
(4) |
Feb
(24) |
Mar
(10) |
Apr
(30) |
May
(15) |
Jun
(50) |
Jul
(20) |
Aug
(7) |
Sep
(8) |
Oct
(10) |
Nov
|
Dec
|
From: <com...@us...> - 2008-06-26 05:40:47
|
Revision: 1903 http://complement.svn.sourceforge.net/complement/?rev=1903&view=rev Author: complement Date: 2008-06-25 22:40:45 -0700 (Wed, 25 Jun 2008) Log Message: ----------- use $(DESTDIR) as in common practice (change root of installation, but don't change run paths); fix options for ctags/etags. Modified Paths: -------------- branches/complement-sockios/explore/Makefiles/ChangeLog branches/complement-sockios/explore/Makefiles/gmake/depend.mak branches/complement-sockios/explore/Makefiles/gmake/targetdirs.mak Modified: branches/complement-sockios/explore/Makefiles/ChangeLog =================================================================== --- branches/complement-sockios/explore/Makefiles/ChangeLog 2008-06-26 05:40:30 UTC (rev 1902) +++ branches/complement-sockios/explore/Makefiles/ChangeLog 2008-06-26 05:40:45 UTC (rev 1903) @@ -1,3 +1,10 @@ +2008-06-06 Petr Ovtchenkov <pt...@is...> + + * gmake/targetdirs.mak: use $(DESTDIR) as in common practice + (change root of installation, but don't change run paths); + + * gmake/depend.mak: fix options for ctags/etags. + 2008-02-27 Petr Ovtchenkov <pt...@is...> * gmake/lib/gcc.mak: 3.3 is normal compiler, just some Modified: branches/complement-sockios/explore/Makefiles/gmake/depend.mak =================================================================== --- branches/complement-sockios/explore/Makefiles/gmake/depend.mak 2008-06-26 05:40:30 UTC (rev 1902) +++ branches/complement-sockios/explore/Makefiles/gmake/depend.mak 2008-06-26 05:40:45 UTC (rev 1903) @@ -1,6 +1,6 @@ # Time-stamp: <07/02/05 12:57:11 ptr> # -# Copyright (c) 1997-1999, 2002, 2003, 2005, 2006 +# Copyright (c) 1997-1999, 2002, 2003, 2005, 2006, 2008 # Petr Ovtchenkov # # Portion Copyright (c) 1999-2001 @@ -35,9 +35,9 @@ @cat -s $(_ALL_DEP) /dev/null > $(DEPENDS_COLLECTION) TAGS: $(OUTPUT_DIRS) ${_DASH_DEP} - @cat -s $(_ALL_DEP) /dev/null | sed -e 's/^.*://;s/^ *//;s/\\$$//;s/ $$//;s/ /\n/g' | sort | uniq | xargs etags -i -m + @cat -s $(_ALL_DEP) /dev/null | sed -e 's/^.*://;s/^ *//;s/\\$$//;s/ $$//;s/ /\n/g' | sort | uniq | xargs etags -I --declarations tags: $(OUTPUT_DIRS) ${_DASH_DEP} - @cat -s $(_ALL_DEP) /dev/null | sed -e 's/^.*://;s/^ *//;s/\\$$//;s/ $$//;s/ /\n/g' | sort | uniq | ctags -d --globals --declarations -t -w + @cat -s $(_ALL_DEP) /dev/null | sed -e 's/^.*://;s/^ *//;s/\\$$//;s/ $$//;s/ /\n/g' | sort | uniq | xargs ctags -d --globals --declarations -t -T -include $(DEPENDS_COLLECTION) Modified: branches/complement-sockios/explore/Makefiles/gmake/targetdirs.mak =================================================================== --- branches/complement-sockios/explore/Makefiles/gmake/targetdirs.mak 2008-06-26 05:40:30 UTC (rev 1902) +++ branches/complement-sockios/explore/Makefiles/gmake/targetdirs.mak 2008-06-26 05:40:45 UTC (rev 1903) @@ -36,12 +36,11 @@ OUTPUT_DIR_A_STLDBG := $(OUTPUT_DIR_STLDBG) endif -# BASE_INSTALL_DIR ?= ${SRCROOT}/build/$(TARGET_NAME) -BASE_INSTALL_DIR ?= $(DESTDIR)/usr/local +BASE_INSTALL_DIR ?= /usr/local -BASE_INSTALL_LIB_DIR ?= ${BASE_INSTALL_DIR} -BASE_INSTALL_BIN_DIR ?= ${BASE_INSTALL_DIR} -BASE_INSTALL_HDR_DIR ?= ${BASE_INSTALL_DIR} +BASE_INSTALL_LIB_DIR ?= $(DESTDIR)${BASE_INSTALL_DIR} +BASE_INSTALL_BIN_DIR ?= $(DESTDIR)${BASE_INSTALL_DIR} +BASE_INSTALL_HDR_DIR ?= $(DESTDIR)${BASE_INSTALL_DIR} INSTALL_LIB_DIR ?= ${BASE_INSTALL_LIB_DIR}/${TARGET_NAME}lib INSTALL_LIB_DIR_DBG ?= ${BASE_INSTALL_LIB_DIR}/${TARGET_NAME}lib This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2008-06-26 05:40:33
|
Revision: 1902 http://complement.svn.sourceforge.net/complement/?rev=1902&view=rev Author: complement Date: 2008-06-25 22:40:30 -0700 (Wed, 25 Jun 2008) Log Message: ----------- Sockets service with central control for incoming data. server's part moved into socksrv.* files. sockmgr (control incoming data for _all_ sockets) delegate sockstream creation to server part (derived from sock_processor_base), but require pointer to to sockbuf from it; dstruction of streams and Connect objects delegated to server part (derived from sock_processor_base); Current unit tests pass. Modified Paths: -------------- branches/complement-sockios/explore/include/sockios/sockstream branches/complement-sockios/explore/include/sockios/sockstream.cc branches/complement-sockios/explore/include/sockios/sp.cc branches/complement-sockios/explore/include/sockios/sp.h branches/complement-sockios/explore/lib/sockios/ut/sockios2_test.cc branches/complement-sockios/explore/lib/sockios/ut/sockios_test_suite.cc Added Paths: ----------- branches/complement-sockios/explore/include/sockios/socksrv.cc branches/complement-sockios/explore/include/sockios/socksrv.h Added: branches/complement-sockios/explore/include/sockios/socksrv.cc =================================================================== --- branches/complement-sockios/explore/include/sockios/socksrv.cc (rev 0) +++ branches/complement-sockios/explore/include/sockios/socksrv.cc 2008-06-26 05:40:30 UTC (rev 1902) @@ -0,0 +1,316 @@ +// -*- C++ -*- Time-stamp: <08/06/11 21:41:27 yeti> + +/* + * Copyright (c) 2008 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License Version 3.0 + * + */ + +namespace std { + +template<class charT, class traits, class _Alloc> +void sock_processor_base<charT,traits,_Alloc>::open( const in_addr& addr, int port, sock_base::stype type, sock_base::protocol prot ) +{ + std::tr2::lock_guard<std::tr2::mutex> lk(_fd_lck); + if ( basic_socket_t::is_open_unsafe() ) { + return; + } + _mode = ios_base::in | ios_base::out; + _state = ios_base::goodbit; +#ifdef WIN32 + ::WSASetLastError( 0 ); +#endif + if ( prot == sock_base::inet ) { + basic_socket_t::_fd = socket( PF_INET, type, 0 ); + if ( basic_socket_t::_fd == -1 ) { + _state |= ios_base::failbit | ios_base::badbit; + return; + } + // _open = true; + basic_socket_t::_address.inet.sin_family = AF_INET; + basic_socket_t::_address.inet.sin_port = htons( port ); + basic_socket_t::_address.inet.sin_addr.s_addr = addr.s_addr; + + if ( type == sock_base::sock_stream || type == sock_base::sock_seqpacket ) { + // let's try reuse local address + setoptions_unsafe( sock_base::so_reuseaddr, true ); + } + + if ( ::bind( basic_socket_t::_fd, &basic_socket_t::_address.any, sizeof(basic_socket_t::_address) ) == -1 ) { + _state |= ios_base::failbit; +#ifdef WIN32 + ::closesocket( basic_socket_t::_fd ); +#else + ::close( basic_socket_t::_fd ); +#endif + basic_socket_t::_fd = -1; + return; + } + + if ( type == sock_base::sock_stream || type == sock_base::sock_seqpacket ) { + // I am shure, this is socket of type SOCK_STREAM | SOCK_SEQPACKET, + // so don't check return code from listen + ::listen( basic_socket_t::_fd, SOMAXCONN ); + basic_socket_t::mgr->push( *this ); + } + } else if ( prot == sock_base::local ) { + return; + } else { + return; + } + _state = ios_base::goodbit; + + return; +} + +template<class charT, class traits, class _Alloc> +void sock_processor_base<charT,traits,_Alloc>::close() +{ + std::tr2::lock_guard<std::tr2::mutex> lk(_fd_lck); + if ( !basic_socket_t::is_open_unsafe() ) { + return; + } + basic_socket<charT,traits,_Alloc>::mgr->pop( *this, basic_socket_t::_fd ); +#ifdef WIN32 + ::closesocket( basic_socket_t::_fd ); +#else + ::shutdown( basic_socket_t::_fd, 2 ); + ::close( basic_socket_t::_fd ); +#endif + basic_socket_t::_fd = -1; +} + +template<class charT, class traits, class _Alloc> +void sock_processor_base<charT,traits,_Alloc>::shutdown( sock_base::shutdownflg dir ) +{ + std::tr2::lock_guard<std::tr2::mutex> lk(_fd_lck); + if ( basic_socket_t::is_open_unsafe() ) { + if ( (dir & (sock_base::stop_in | sock_base::stop_out)) == + (sock_base::stop_in | sock_base::stop_out) ) { + ::shutdown( basic_socket_t::_fd, 2 ); + } else if ( dir & sock_base::stop_in ) { + ::shutdown( basic_socket_t::_fd, 0 ); + } else if ( dir & sock_base::stop_out ) { + ::shutdown( basic_socket_t::_fd, 1 ); + } + } +} + +template<class charT, class traits, class _Alloc> +void sock_processor_base<charT,traits,_Alloc>::setoptions_unsafe( sock_base::so_t optname, bool on_off, int __v ) +{ +#ifdef __unix + if ( basic_socket_t::is_open_unsafe() ) { + if ( optname != sock_base::so_linger ) { + int turn = on_off ? 1 : 0; + if ( setsockopt( basic_socket_t::_fd, SOL_SOCKET, (int)optname, (const void *)&turn, + (socklen_t)sizeof(int) ) != 0 ) { + _state |= ios_base::failbit; + } + } else { + linger l; + l.l_onoff = on_off ? 1 : 0; + l.l_linger = __v; + if ( setsockopt( basic_socket_t::_fd, SOL_SOCKET, (int)optname, (const void *)&l, + (socklen_t)sizeof(linger) ) != 0 ) { + _state |= ios_base::failbit; + } + + } + } else { + _state |= ios_base::failbit; + } +#endif // __unix +} + + +template<class Connect, class charT, class traits, class _Alloc, void (Connect::*C)( std::basic_sockstream<charT,traits,_Alloc>& )> +int connect_processor<Connect, charT, traits, _Alloc, C>::Init::_count = 0; + +template<class Connect, class charT, class traits, class _Alloc, void (Connect::*C)( std::basic_sockstream<charT,traits,_Alloc>& )> +bool connect_processor<Connect, charT, traits, _Alloc, C>::Init::_at_fork = false; + +template<class Connect, class charT, class traits, class _Alloc, void (Connect::*C)( std::basic_sockstream<charT,traits,_Alloc>& )> +std::tr2::mutex connect_processor<Connect, charT, traits, _Alloc, C>::Init::_init_lock; + +template<class Connect, class charT, class traits, class _Alloc, void (Connect::*C)( std::basic_sockstream<charT,traits,_Alloc>& )> +void connect_processor<Connect, charT, traits, _Alloc, C>::Init::_guard( int direction ) +{ + if ( direction ) { + std::tr2::lock_guard<std::tr2::mutex> lk( _init_lock ); + if ( _count++ == 0 ) { +#ifdef __FIT_PTHREADS + if ( !_at_fork ) { // call only once + if ( pthread_atfork( __at_fork_prepare, __at_fork_parent, __at_fork_child ) ) { + // throw system_error + } + _at_fork = true; + } +#endif +// _sock_processor_base::_idx = std::tr2::this_thread::xalloc(); + } + } else { + std::tr2::lock_guard<std::tr2::mutex> lk( _init_lock ); + if ( --_count == 0 ) { + + } + } +} + +template<class Connect, class charT, class traits, class _Alloc, void (Connect::*C)( std::basic_sockstream<charT,traits,_Alloc>& )> +void connect_processor<Connect, charT, traits, _Alloc, C>::Init::__at_fork_prepare() +{ _init_lock.lock(); } + +template<class Connect, class charT, class traits, class _Alloc, void (Connect::*C)( std::basic_sockstream<charT,traits,_Alloc>& )> +void connect_processor<Connect, charT, traits, _Alloc, C>::Init::__at_fork_child() +{ + _init_lock.unlock(); + + if ( _count != 0 ) { + // std::cerr << "SHOULD NEVER HAPPEN!!!!\n"; + throw std::logic_error( "Fork while connect_processor working may has unexpected behaviour in child process" ); + } + // _sock_processor_base::_idx = std::tr2::this_thread::xalloc(); +} + +template<class Connect, class charT, class traits, class _Alloc, void (Connect::*C)( std::basic_sockstream<charT,traits,_Alloc>& )> +void connect_processor<Connect, charT, traits, _Alloc, C>::Init::__at_fork_parent() +{ _init_lock.unlock(); } + +template<class Connect, class charT, class traits, class _Alloc, void (Connect::*C)( std::basic_sockstream<charT,traits,_Alloc>& )> +char connect_processor<Connect, charT, traits, _Alloc, C>::Init_buf[128]; + +template <class Connect, class charT, class traits, class _Alloc, void (Connect::*C)( std::basic_sockstream<charT,traits,_Alloc>& )> +void connect_processor<Connect, charT, traits, _Alloc, C>::close() +{ + base_t::close(); + + { + std::tr2::lock_guard<std::tr2::mutex> lk(inwlock); + _in_work = false; // <--- set before cnd.notify_one(); (below in this func) + } + + std::tr2::lock_guard<std::tr2::mutex> lk2( rdlock ); + ready_pool.push_back( processor() ); // make ready_pool not empty + // std::cerr << "=== " << ready_pool.size() << std::endl; + cnd.notify_one(); +} + +template <class Connect, class charT, class traits, class _Alloc, void (Connect::*C)( std::basic_sockstream<charT,traits,_Alloc>& )> +typename connect_processor<Connect, charT, traits, _Alloc, C>::base_t::sockbuf_t* connect_processor<Connect, charT, traits, _Alloc, C>::operator ()( sock_base::socket_type fd, const sockaddr& addr ) +{ + typename base_t::sockstream_t* s = base_t::create_stream( fd, addr ); + + Connect* c = new Connect( *s ); // bad point! I can't read from s in ctor indeed! + + if ( s->rdbuf()->in_avail() ) { + std::tr2::lock_guard<std::tr2::mutex> lk( rdlock ); + ready_pool.push_back( processor( c, s ) ); + cnd.notify_one(); + } else { + std::tr2::lock_guard<std::tr2::mutex> lk( wklock ); + worker_pool.insert( std::make_pair( fd, processor( c, s ) ) ); + } + + return s->rdbuf(); +} + +template <class Connect, class charT, class traits, class _Alloc, void (Connect::*C)( std::basic_sockstream<charT,traits,_Alloc>& )> +void connect_processor<Connect, charT, traits, _Alloc, C>::operator ()( sock_base::socket_type fd, const typename connect_processor<Connect, charT, traits, _Alloc, C>::base_t::adopt_close_t& ) +{ + { + std::tr2::lock_guard<std::tr2::mutex> lk( wklock ); + typename worker_pool_t::iterator i = worker_pool.find( fd ); + if ( i != worker_pool.end() ) { + delete i->second.c; + delete i->second.s; + // std::cerr << "oops\n"; + worker_pool.erase( i ); + return; + } + } + + processor p; + { + std::tr2::lock_guard<std::tr2::mutex> lk( rdlock ); + typename ready_pool_t::iterator j = std::find( ready_pool.begin(), ready_pool.end(), /* std::bind2nd( typename processor::equal_to(), &s ) */ fd ); + if ( j != ready_pool.end() ) { + // std::cerr << "oops 2\n"; + p = *j; + ready_pool.erase( j ); + } + } + if ( p.c != 0 ) { + // (*p.c)( *p.s ); + delete p.c; + delete p.s; + } +} + +template <class Connect, class charT, class traits, class _Alloc, void (Connect::*C)( std::basic_sockstream<charT,traits,_Alloc>& )> +void connect_processor<Connect, charT, traits, _Alloc, C>::operator ()( sock_base::socket_type fd ) +{ + processor p; + + { + std::tr2::lock_guard<std::tr2::mutex> lk( wklock ); + typename worker_pool_t::const_iterator i = worker_pool.find( fd ); + if ( i == worker_pool.end() ) { + return; + } + p = i->second; + worker_pool.erase( i ); + } + + std::tr2::lock_guard<std::tr2::mutex> lk( rdlock ); + ready_pool.push_back( p ); + cnd.notify_one(); + // std::cerr << "notify data " << (void *)c << " " << ready_pool.size() << std::endl; +} + +template <class Connect, class charT, class traits, class _Alloc, void (Connect::*C)( std::basic_sockstream<charT,traits,_Alloc>& )> +bool connect_processor<Connect, charT, traits, _Alloc, C>::pop_ready( processor& p ) +{ + { + std::tr2::unique_lock<std::tr2::mutex> lk( rdlock ); + + cnd.wait( lk, not_empty ); + p = ready_pool.front(); // it may contain p.c == 0, p.s == 0, if !in_work() + ready_pool.pop_front(); + // std::cerr << "pop 1\n"; + if ( p.c == 0 ) { // wake up, but _in_work may be still true here (in processor pipe?), + return false; // even I know that _in_work <- false before notification... + } // so, check twice + } + + // std::cerr << "pop 2\n"; + + std::tr2::lock_guard<std::tr2::mutex> lk(inwlock); + return _in_work ? true : false; +} + +template <class Connect, class charT, class traits, class _Alloc, void (Connect::*C)( std::basic_sockstream<charT,traits,_Alloc>& )> +void connect_processor<Connect, charT, traits, _Alloc, C>::worker() +{ + _in_work = true; + + processor p; + + while ( pop_ready( p ) ) { + // std::cerr << "worker 1\n"; + (p.c->*C)( *p.s ); + // std::cerr << "worker 2\n"; + if ( p.s->rdbuf()->in_avail() ) { + std::tr2::lock_guard<std::tr2::mutex> lk( rdlock ); + ready_pool.push_back( p ); + } else { + std::tr2::lock_guard<std::tr2::mutex> lk( wklock ); + worker_pool[p.s->rdbuf()->fd()] = p; + } + // std::cerr << "worker 3\n"; + } +} + +} // namespace std Added: branches/complement-sockios/explore/include/sockios/socksrv.h =================================================================== --- branches/complement-sockios/explore/include/sockios/socksrv.h (rev 0) +++ branches/complement-sockios/explore/include/sockios/socksrv.h 2008-06-26 05:40:30 UTC (rev 1902) @@ -0,0 +1,317 @@ +// -*- C++ -*- Time-stamp: <08/06/11 21:40:56 yeti> + +/* + * Copyright (c) 2008 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License Version 3.0 + * + */ + +#ifndef __SOCKIOS_SOCKSRV_H +#define __SOCKIOS_SOCKSRV_H + +#include <cerrno> +#include <mt/thread> +#include <mt/mutex> +#include <mt/condition_variable> + +#ifdef STLPORT +# include <unordered_map> +# include <unordered_set> +# define __USE_STLPORT_TR1 +#else +# if defined(__GNUC__) && (__GNUC__ < 4) +# include <ext/hash_map> +# include <ext/hash_set> +# define __USE_STD_HASH +# else +# include <tr1/unordered_map> +# include <tr1/unordered_set> +# define __USE_STD_TR1 +# endif +#endif + +#include <sockios/sockstream> +#include <deque> +#include <functional> + +namespace std { + +template <class charT, class traits, class _Alloc> class basic_sockbuf; +template <class charT, class traits, class _Alloc> class basic_sockstream; +template <class charT, class traits, class _Alloc> class sock_processor_base; + +template <class charT, class traits, class _Alloc> +class sock_processor_base : + public sock_base, + public basic_socket<charT,traits,_Alloc> +{ + private: + typedef basic_socket<charT,traits,_Alloc> basic_socket_t; + + public: + typedef basic_sockstream<charT,traits,_Alloc> sockstream_t; + typedef basic_sockbuf<charT,traits,_Alloc> sockbuf_t; + + struct adopt_close_t { }; + + sock_processor_base() : + _mode( ios_base::in | ios_base::out ), + _state( ios_base::goodbit ) + { } + + explicit sock_processor_base( int port, sock_base::stype t = sock_base::sock_stream ) + { sock_processor_base::open( port, t, sock_base::inet ); } + + virtual ~sock_processor_base() + { + sock_processor_base::close(); + + std::cerr << __FILE__ << ":" << __LINE__ << " " << (void*)this << " " << std::tr2::getpid() << std::endl; + // Never uncomment next line: + // basic_socket<charT,traits,_Alloc>::mgr->final( *this ); + // this lead to virtual fuction call, that is already pure here. + } + + void open( const in_addr& addr, int port, sock_base::stype type, sock_base::protocol prot ); + + void open( unsigned long addr, int port, sock_base::stype type, sock_base::protocol prot ) + { + in_addr _addr; + _addr.s_addr = htonl( addr ); + sock_processor_base::open( _addr, port, type, prot ); + } + + void open( int port, sock_base::stype type, sock_base::protocol prot ) + { sock_processor_base::open(INADDR_ANY, port, type, prot); } + + virtual void close(); + + virtual sockbuf_t* operator ()( sock_base::socket_type fd, const sockaddr& ) = 0; + virtual void operator ()( sock_base::socket_type fd, const adopt_close_t& ) = 0; + virtual void operator ()( sock_base::socket_type fd ) = 0; + + private: + sock_processor_base( const sock_processor_base& ); + sock_processor_base& operator =( const sock_processor_base& ); + + protected: + void setoptions_unsafe( sock_base::so_t optname, bool on_off = true, int __v = 0 ); + sockstream_t* create_stream( int fd, const sockaddr& addr ) + { + sockstream_t* s = new sockstream_t(); + s->rdbuf()->_open_sockmgr( fd, addr ); + return s; + } + + public: + bool is_open() const + { std::tr2::lock_guard<std::tr2::mutex> lk(_fd_lck); return basic_socket_t::is_open_unsafe(); } + bool good() const + { return _state == ios_base::goodbit; } + + sock_base::socket_type fd() const + { std::tr2::lock_guard<std::tr2::mutex> lk(_fd_lck); sock_base::socket_type tmp = basic_socket_t::fd_unsafe(); return tmp; } + + void shutdown( sock_base::shutdownflg dir ); + void setoptions( sock_base::so_t optname, bool on_off = true, int __v = 0 ) + { + std::tr2::lock_guard<std::tr2::mutex> lk(_fd_lck); + setoptions_unsafe( optname, on_off, __v ); + } + + private: + unsigned long _mode; // open mode + unsigned long _state; // state flags + + protected: + std::tr2::mutex _fd_lck; +}; + +typedef sock_processor_base<char,char_traits<char>,allocator<char> > sock_basic_processor; + +template <class Connect, class charT = char, class traits = std::char_traits<charT>, class _Alloc = std::allocator<charT>, void (Connect::*C)( std::basic_sockstream<charT,traits,_Alloc>& ) = &Connect::connect > +class connect_processor : + public sock_processor_base<charT,traits,_Alloc> +{ + private: + typedef sock_processor_base<charT,traits,_Alloc> base_t; + + class Init + { + public: + Init() + { _guard( 1 ); } + ~Init() + { _guard( 0 ); } + + private: + static void _guard( int direction ); + static void __at_fork_prepare(); + static void __at_fork_child(); + static void __at_fork_parent(); + static std::tr2::mutex _init_lock; + static int _count; + static bool _at_fork; + }; + + static char Init_buf[]; + + public: + connect_processor() : + not_empty( *this ), + _in_work( false ), + ploop( loop, this ) + { new( Init_buf ) Init(); } + + explicit connect_processor( int port ) : + base_t( port, sock_base::sock_stream ), + not_empty( *this ), + _in_work( false ), + ploop( loop, this ) + { new( Init_buf ) Init(); } + + virtual ~connect_processor() + { + connect_processor::close(); + if ( ploop.joinable() ) { + ploop.join(); + } + // { + // std::tr2::lock_guard<std::tr2::mutex> lk( wklock ); + for ( typename worker_pool_t::iterator i = worker_pool.begin(); i != worker_pool.end(); ++i ) { + // delete i->second; + delete i->second.s; + delete i->second.c; + } + worker_pool.clear(); + // } + for ( typename ready_pool_t::iterator j = ready_pool.begin(); j != ready_pool.end(); ++j ) { + delete j->c; + } + ready_pool.clear(); + + std::cerr << __FILE__ << ":" << __LINE__ << " " << (void*)this << " " << std::tr2::getpid() << std::endl; + basic_socket<charT,traits,_Alloc>::mgr->final( *this ); + + ((Init *)Init_buf)->~Init(); + } + + virtual void close(); + + void wait() + { if ( ploop.joinable() ) { ploop.join(); } } + + private: + virtual typename base_t::sockbuf_t* operator ()( sock_base::socket_type fd, const sockaddr& ); + virtual void operator ()( sock_base::socket_type fd, const typename base_t::adopt_close_t& ); + virtual void operator ()( sock_base::socket_type fd ); + + static void loop( connect_processor* me ) + { me->worker(); } + + void worker(); + + private: + connect_processor( const connect_processor& ) + { } + + connect_processor& operator =( const connect_processor& ) + { return *this; } + + + struct processor + { + processor() : + c(0), + s(0) + { } + processor( Connect* __c, typename sock_processor_base<charT,traits,_Alloc>::sockstream_t* __s ) : + c(__c), + s(__s) + { } + processor( const processor& p ) : + c( p.c ), + s( p.s ) + { } + + processor& operator =( const processor& p ) + { c = p.c; s = p.s; return *this; } + + Connect* c; + typename sock_processor_base<charT,traits,_Alloc>::sockstream_t* s; + + bool operator ==( const processor& p ) const + { return s == p.s; } + bool operator ==( const typename sock_processor_base<charT,traits,_Alloc>::sockstream_t* st ) const + { return const_cast<const typename sock_processor_base<charT,traits,_Alloc>::sockstream_t*>(s) == st; } + bool operator ==( sock_base::socket_type fd ) const + { return s == 0 ? (fd == -1) : (s->rdbuf()->fd() == fd); } + +/* + struct equal_to : + public std::binary_function<processor, typename sock_processor_base<charT,traits,_Alloc>::sockstream_t*, bool> + { + bool operator()(const processor& __x, const typename sock_processor_base<charT,traits,_Alloc>::sockstream_t* __y) const + { return __x == __y; } + }; +*/ + }; + + bool pop_ready( processor& ); + +#ifdef __USE_STLPORT_HASH + typedef std::hash_map<sock_base::socket_type, processor> worker_pool_t; +#endif +#ifdef __USE_STD_HASH + typedef __gnu_cxx::hash_map<sock_base::socket_type, processor> worker_pool_t; +#endif +#if defined(__USE_STLPORT_TR1) || defined(__USE_STD_TR1) + typedef std::tr1::unordered_map<sock_base::socket_type, processor> worker_pool_t; +#endif + typedef std::deque<processor> ready_pool_t; + + struct _not_empty + { + _not_empty( connect_processor& p ) : + me( p ) + { } + + bool operator()() const + { return !me.ready_pool.empty(); } + + connect_processor& me; + } not_empty; + + worker_pool_t worker_pool; + ready_pool_t ready_pool; + bool _in_work; + std::tr2::mutex wklock; + std::tr2::mutex rdlock; + std::tr2::condition_variable cnd; + std::tr2::mutex inwlock; + std::tr2::condition_variable cnd_inwk; + std::tr2::thread ploop; + + friend struct _not_empty; +}; + +} // namesapce std + +#ifdef __USE_STLPORT_HASH +# undef __USE_STLPORT_HASH +#endif +#ifdef __USE_STD_HASH +# undef __USE_STD_HASH +#endif +#ifdef __USE_STLPORT_TR1 +# undef __USE_STLPORT_TR1 +#endif +#ifdef __USE_STD_TR1 +# undef __USE_STD_TR1 +#endif + +#include <sockios/socksrv.cc> + +#endif /* __SOCKIOS_SOCKSRV_H */ Modified: branches/complement-sockios/explore/include/sockios/sockstream =================================================================== --- branches/complement-sockios/explore/include/sockios/sockstream 2008-06-16 14:59:26 UTC (rev 1901) +++ branches/complement-sockios/explore/include/sockios/sockstream 2008-06-26 05:40:30 UTC (rev 1902) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/06/09 22:22:05 yeti> +// -*- C++ -*- Time-stamp: <08/06/11 14:45:16 yeti> /* * Copyright (c) 1997-1999, 2002, 2003, 2005-2008 @@ -252,7 +252,8 @@ void wrtimeout() // infinite { _use_wrtimeout = false; } - sock_base::socket_type fd() const { return _fd;} + sock_base::socket_type fd() const + { return _fd; } bool is_open() const { return _fd != -1; } @@ -373,8 +374,8 @@ template<class charT, class traits, class _Alloc> class basic_sockbuf : - public basic_streambuf<charT, traits> - // public basic_socket<charT,traits,_Alloc> + public basic_streambuf<charT, traits>, + public basic_socket<charT,traits,_Alloc> { private: typedef basic_socket<charT,traits,_Alloc> basic_socket_t; @@ -383,7 +384,6 @@ typedef basic_ios<charT, traits> ios_type; typedef basic_sockbuf<charT, traits, _Alloc> sockbuf_type; typedef typename traits::state_type state_t; - typedef typename basic_socket_t::family_type family_type; public: /* Inherited from basic_streambuf : */ @@ -395,23 +395,62 @@ /* */ basic_sockbuf() : - impl( 0 ) + rdready( *this ), +#if !defined(STLPORT) && defined(__GNUC__) +#if ((__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 4))) // hmm, 3.3.6 + _mode( ios_base::openmode(__ios_flags::_S_in | __ios_flags::_S_out) ), +#else // 4.1.1 + _mode( _S_in | _S_out ), +#endif // __GNUC__ +#else // STLPORT + _mode( 0 ), +#endif // STLPORT + _bbuf(0), + _ebuf(0), + _allocated( true ) { } basic_sockbuf( const char *hostname, int port, sock_base::stype type = sock_base::sock_stream, sock_base::protocol prot = sock_base::inet ) : - impl( 0 ) + rdready( *this ), +#if !defined(STLPORT) && defined(__GNUC__) +#if ((__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 4))) + _mode( ios_base::openmode(__ios_flags::_S_in | __ios_flags::_S_out) ), +#else // 4.1.1 + _mode( _S_in | _S_out ), +#endif // __GNUC__ +#else // STLPORT + _mode( 0 ), +#endif // STLPORT + _bbuf(0), + _ebuf(0), + _allocated( true ) { open( hostname, port, type, prot ); } basic_sockbuf( const in_addr& addr, int port, sock_base::stype type = sock_base::sock_stream, sock_base::protocol prot = sock_base::inet ) : - impl( 0 ) + rdready( *this ), +#if !defined(STLPORT) && defined(__GNUC__) +#if ((__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 4))) + _mode( ios_base::openmode(__ios_flags::_S_in | __ios_flags::_S_out) ), +#else // 4.1.1 + _mode( _S_in | _S_out ), +#endif // __GNUC__ +#else // STLPORT + _mode( 0 ), +#endif // STLPORT + _bbuf(0), + _ebuf(0), + _allocated( true ) { open( addr, type, prot ); } virtual ~basic_sockbuf() - { close(); } + { + close(); + _M_deallocate_block(); + } sockbuf_type *open( const char *hostname, int port, sock_base::stype type = sock_base::sock_stream, @@ -419,15 +458,13 @@ sockbuf_type *open( const in_addr& addr, int port, sock_base::stype type = sock_base::sock_stream, - sock_base::protocol prot = sock_base::inet ) - { return impl->open( addr, port, type, prot ) ? this : 0; } + sock_base::protocol prot = sock_base::inet ); sockbuf_type *open( sock_base::socket_type s, sock_base::stype t = sock_base::sock_stream ); sockbuf_type *open( sock_base::socket_type s, const sockaddr& addr, - sock_base::stype t = sock_base::sock_stream ) - { return impl->open( s, addr, t ) ? this : 0; } + sock_base::stype t = sock_base::sock_stream ); sockbuf_type *attach( sock_base::socket_type s, sock_base::stype t = sock_base::sock_stream ); @@ -435,65 +472,156 @@ sockbuf_type *attach( sock_base::socket_type s, const sockaddr& addr, sock_base::stype t = sock_base::sock_stream ); - sockbuf_type *close() - { return impl->close() ? this : 0; } + sockbuf_type *close(); + void shutdown( sock_base::shutdownflg dir ); - void shutdown( sock_base::shutdownflg dir ) - { impl->shutdown( dir ); } - sock_base::stype stype() const - { return impl->stype(); } + { return _type; } - template <class Duration> - void rdtimeout( const Duration& d ) - { impl->rdtimeout( d ); } - void rdtimeout() // infinite - { impl->rdtimeout(); } + protected: + virtual streamsize showmanyc() + { return this->egptr() - this->gptr(); } - template <class Duration> - void wrtimeout( const Duration& d ) - { impl->wrtimeout( d ); } - void wrtimeout() // infinite - { impl->wrtimeout(); } + virtual int_type underflow(); + virtual int_type overflow( int_type c = traits::eof() ); + virtual int_type pbackfail( int_type c = traits::eof() ) + { + if ( !basic_socket_t::is_open() ) + return traits::eof(); - sock_base::socket_type fd() const { return impl->fd();} - bool is_open() const - { return impl->is_open(); } + if ( this->gptr() <= this->eback() ) { + return traits::eof(); + } - family_type family() const - { return impl->family(); } + this->gbump(-1); + if ( !traits::eq_int_type(c,traits::eof()) ) { + *this->gptr() = traits::to_char_type(c); + return c; + } - int port() const - { return impl->port(); } + return traits::not_eof(c); + } - unsigned long inet_addr() const - { return impl->inet_addr(); } + // Buffer managment and positioning: + virtual basic_streambuf<charT, traits> *setbuf(char_type *s, streamsize n ) + { + if ( s != 0 && n != 0 ) { + _M_deallocate_block(); + _allocated = false; + _bbuf = s; + _ebuf = s + n; + } + return this; + } - const sockaddr_in& inet_sockaddr() const throw( std::domain_error ) - { return impl->inet_sockaddr(); } + virtual int sync(); + virtual streamsize xsputn(const char_type *s, streamsize n); + private: // Helper functions + charT* _bbuf; + charT* _ebuf; + bool _allocated; // true, if _bbuf should be deallocated - protected: - virtual streamsize showmanyc() - { return impl->showmanyc(); } + // Precondition: 0 < __n <= max_size(). + charT* _M_allocate( size_t __n ) { return _M_data_allocator.allocate(__n); } + void _M_deallocate( charT* __p, size_t __n ) + { if (__p) _M_data_allocator.deallocate(__p, __n); } - virtual int_type underflow() - { return impl->underflow(); } - virtual int_type overflow( int_type c = traits::eof() ) - { return impl->overflow(c); } - virtual int_type pbackfail( int_type c = traits::eof() ) - { return impl->pbackfail( c ); } - // Buffer managment and positioning: - virtual basic_streambuf<charT, traits> *setbuf(char_type *s, streamsize n ) - { impl->setbuf( s, n ); return this; } + void _M_allocate_block(size_t __n) + { + if ( _allocated ) { + if ( __n <= max_size() ) { + _bbuf = _M_allocate(__n); + _ebuf = _bbuf + __n; + // _STLP_ASSERT( __n > 0 ? _bbuf != 0 : _bbuf == 0 ); + } else + this->_M_throw_length_error(); + } + } - virtual int sync() - { return impl->sync(); } - virtual streamsize xsputn(const char_type *s, streamsize n) - { return impl->xsputn( s, n ); } + void _M_deallocate_block() + { if ( _allocated ) _M_deallocate(_bbuf, _ebuf - _bbuf); } + + size_t max_size() const { return (size_t(-1) / sizeof(charT)) - 1; } +#ifdef STLPORT + void _M_throw_length_error() const + { _STLP_THROW(length_error("basic_sockbuf")); } +#else + void _M_throw_length_error() const + { throw length_error("basic_sockbuf"); } +#endif + +#ifdef STLPORT + typedef typename _Alloc_traits<charT, _Alloc>::allocator_type allocator_type; +#else + typedef _Alloc allocator_type; +#endif + /* typedef __allocator<charT, _Alloc> _Alloc_type; */ + + /* _Alloc_type */ allocator_type _M_data_allocator; + + class rdready_t + { + public: + rdready_t( sockbuf_type& self ) : + b( self ) + { } + bool operator ()() const + { return b.showmanyc() != 0; } + private: + sockbuf_type& b; + } rdready; + + sockbuf_type *_open_sockmgr( sock_base::socket_type s, const sockaddr& addr, + sock_base::stype t = sock_base::sock_stream ); + private: - detail::basic_sockbuf_aux<charT,traits,_Alloc> *impl; + typedef basic_sockbuf<charT,traits,_Alloc> _Self_type; + int (basic_sockbuf<charT,traits,_Alloc>::*_xwrite)( const void *, size_t ); + int (basic_sockbuf<charT,traits,_Alloc>::*_xread)( void *, size_t ); + int write( const void *buf, size_t n ) +#ifndef WIN32 + { return ::write( basic_socket_t::_fd, buf, n ); } +#else + { return ::send( basic_socket_t::_fd, (const char *)buf, n, 0 ); } +#endif + int send( const void *buf, size_t n ) +#ifdef WIN32 + { return ::send( basic_socket_t::_fd, (const char *)buf, n, 0 ); } +#else + { return ::send( basic_socket_t::_fd, buf, n, 0 ); } +#endif + int sendto( const void *buf, size_t n ) +#ifdef WIN32 + { return ::sendto( basic_socket_t::_fd, (const char *)buf, n, 0, &basic_socket_t::_address.any, sizeof( sockaddr_in ) ); } +#else + { return ::sendto( basic_socket_t::_fd, buf, n, 0, &basic_socket_t::_address.any, sizeof( sockaddr_in ) ); } +#endif + + int read( void *buf, size_t n ) +#ifdef WIN32 + { return ::recv( basic_socket_t::_fd, (char *)buf, n, 0 ); } +#else + { return ::read( basic_socket_t::_fd, buf, n ); } +#endif + int recv( void *buf, size_t n ) +#ifdef WIN32 + { return ::recv( basic_socket_t::_fd, (char *)buf, n, 0 ); } +#else + { return ::recv( basic_socket_t::_fd, buf, n, 0 ); } +#endif + int recvfrom( void *buf, size_t n ); + void __hostname(); + + ios_base::openmode _mode; + sock_base::stype _type; + + std::tr2::mutex ulck; + std::tr2::condition_variable ucnd; + + friend class detail::sockmgr<charT,traits,_Alloc>; + friend class sock_processor_base<charT,traits,_Alloc>; }; template <class charT, class traits, class _Alloc> Modified: branches/complement-sockios/explore/include/sockios/sockstream.cc =================================================================== --- branches/complement-sockios/explore/include/sockios/sockstream.cc 2008-06-16 14:59:26 UTC (rev 1901) +++ branches/complement-sockios/explore/include/sockios/sockstream.cc 2008-06-26 05:40:30 UTC (rev 1902) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/06/09 21:59:13 yeti> +// -*- C++ -*- Time-stamp: <08/06/11 14:47:58 yeti> /* * Copyright (c) 1997-1999, 2002, 2003, 2005-2008 @@ -32,7 +32,111 @@ sock_base::protocol prot ) { return basic_sockbuf<charT, traits, _Alloc>::open( std::findhost( name ), port, type, prot ); } +template<class charT, class traits, class _Alloc> +basic_sockbuf<charT, traits, _Alloc> * +basic_sockbuf<charT, traits, _Alloc>::open( const in_addr& addr, int port, + sock_base::stype type, + sock_base::protocol prot ) +{ + if ( basic_socket_t::is_open() ) { + return 0; + } + try { + _mode = ios_base::in | ios_base::out; + _type = type; +#ifdef WIN32 + WSASetLastError( 0 ); +#endif + if ( prot == sock_base::inet ) { + basic_socket_t::_fd = socket( PF_INET, type, 0 ); + if ( basic_socket_t::_fd == -1 ) { + throw std::runtime_error( "can't open socket" ); + } + basic_socket_t::_address.inet.sin_family = AF_INET; + // htons is a define at least in Linux 2.2.5-15, and it's expantion fail + // for gcc 2.95.3 +#if defined(linux) && defined(htons) && defined(__bswap_16) + basic_socket_t::_address.inet.sin_port = ((((port) >> 8) & 0xff) | (((port) & 0xff) << 8)); +#else + basic_socket_t::_address.inet.sin_port = htons( port ); +#endif // linux && htons + basic_socket_t::_address.inet.sin_addr = addr; + + // Generally, stream sockets may successfully connect() only once + if ( connect( basic_socket_t::_fd, &basic_socket_t::_address.any, sizeof( basic_socket_t::_address ) ) == -1 ) { + throw std::domain_error( "connect fail" ); + } + if ( type == sock_base::sock_stream ) { + _xwrite = &_Self_type::write; + _xread = &_Self_type::read; + } else if ( type == sock_base::sock_dgram ) { + _xwrite = &_Self_type::send; + _xread = &_Self_type::recv; + } + } else if ( prot == sock_base::local ) { + basic_socket_t::_fd = socket( PF_UNIX, type, 0 ); + if ( basic_socket_t::_fd == -1 ) { + throw std::runtime_error( "can't open socket" ); + } + } else { // other protocols not implemented yet + throw std::invalid_argument( "protocol not implemented" ); + } + if ( _bbuf == 0 ) { + struct ifconf ifc; + struct ifreq ifr; + ifc.ifc_len = sizeof(ifreq); + ifc.ifc_req = 𝔦 + int mtu = ((ioctl(basic_socket_t::_fd, SIOCGIFMTU, &ifc) < 0 ? 1500 : ifr.ifr_mtu) - 20 - (type == sock_base::sock_stream ? 20 : 8 )) / sizeof(charT); + int qlen = ioctl(basic_socket_t::_fd, SIOCGIFTXQLEN, &ifc) < 0 ? 2 : ifr.ifr_qlen; + _M_allocate_block( type == sock_base::sock_stream ? mtu * qlen * 2 : mtu * 2 ); + } + + if ( _bbuf == 0 ) { + throw std::length_error( "can't allocate block" ); + } + + if ( fcntl( basic_socket_t::_fd, F_SETFL, fcntl( basic_socket_t::_fd, F_GETFL ) | O_NONBLOCK ) != 0 ) { + throw std::runtime_error( "can't establish nonblock mode" ); + } + setp( _bbuf, _bbuf + ((_ebuf - _bbuf)>>1) ); + setg( this->epptr(), this->epptr(), this->epptr() ); + basic_socket_t::_notify_close = true; + basic_socket_t::mgr->push( *this ); + } + catch ( std::domain_error& ) { +#ifdef WIN32 + // _errno = WSAGetLastError(); + ::closesocket( basic_socket_t::_fd ); +#else + ::close( basic_socket_t::_fd ); +#endif + basic_socket_t::_fd = -1; + return 0; + } + catch ( std::length_error& ) { +#ifdef WIN32 + ::closesocket( basic_socket_t::_fd ); +#else + ::close( basic_socket_t::_fd ); +#endif + basic_socket_t::_fd = -1; + return 0; + } + catch ( std::runtime_error& ) { +#ifdef WIN32 + // _errno = WSAGetLastError(); +#else +#endif + return 0; + } + catch ( std::invalid_argument& ) { + return 0; + } + + return this; +} + template<class charT, class traits, class _Alloc> basic_sockbuf<charT, traits, _Alloc> * basic_sockbuf<charT, traits, _Alloc>::open( sock_base::socket_type s, sock_base::stype t ) @@ -50,6 +154,20 @@ template<class charT, class traits, class _Alloc> basic_sockbuf<charT, traits, _Alloc> * +basic_sockbuf<charT, traits, _Alloc>::open( sock_base::socket_type s, + const sockaddr& addr, + sock_base::stype t ) +{ + basic_sockbuf<charT, traits, _Alloc>* ret = _open_sockmgr( s, addr, t ); + if ( ret != 0 ) { + basic_socket_t::_notify_close = true; + basic_socket_t::mgr->push( *this ); + } + return ret; +} + +template<class charT, class traits, class _Alloc> +basic_sockbuf<charT, traits, _Alloc> * basic_sockbuf<charT, traits, _Alloc>::attach( sock_base::socket_type s, sock_base::stype t ) { @@ -79,6 +197,316 @@ } template<class charT, class traits, class _Alloc> +basic_sockbuf<charT, traits, _Alloc> * +basic_sockbuf<charT, traits, _Alloc>::_open_sockmgr( sock_base::socket_type s, + const sockaddr& addr, + sock_base::stype t ) +{ + if ( basic_socket_t::is_open() || s == -1 ) { + return 0; + } + basic_socket_t::_fd = s; + memcpy( (void *)&basic_socket_t::_address.any, (const void *)&addr, sizeof(sockaddr) ); + _mode = ios_base::in | ios_base::out; + _type = t; +#ifdef WIN32 + WSASetLastError( 0 ); +#endif + if ( t == sock_base::sock_stream ) { + _xwrite = &_Self_type::write; + _xread = &_Self_type::read; + } else if ( t == sock_base::sock_dgram ) { + _xwrite = &_Self_type::sendto; + _xread = &_Self_type::recvfrom; + } else { + basic_socket_t::_fd = -1; + return 0; // unsupported type + } + + if ( _bbuf == 0 ) { + struct ifconf ifc; + struct ifreq ifr; + ifc.ifc_len = sizeof(ifreq); + ifc.ifc_req = 𝔦 + int mtu = ((ioctl(basic_socket_t::_fd, SIOCGIFMTU, &ifc) < 0 ? 1500 : ifr.ifr_mtu) - 20 - (t == sock_base::sock_stream ? 20 : 8 )) / sizeof(charT); + int qlen = ioctl(basic_socket_t::_fd, SIOCGIFTXQLEN, &ifc) < 0 ? 2 : ifr.ifr_qlen; + _M_allocate_block( t == sock_base::sock_stream ? mtu * qlen * 2 : mtu * 2); + } + + if ( _bbuf == 0 ) { +#ifdef WIN32 + ::closesocket( basic_socket_t::_fd ); +#else + ::close( basic_socket_t::_fd ); +#endif + basic_socket_t::_fd = -1; + return 0; + } + + if ( fcntl( basic_socket_t::_fd, F_SETFL, fcntl( basic_socket_t::_fd, F_GETFL ) | O_NONBLOCK ) != 0 ) { + throw std::runtime_error( "can't establish nonblock mode" ); + } + setp( _bbuf, _bbuf + ((_ebuf - _bbuf)>>1) ); + setg( this->epptr(), this->epptr(), this->epptr() ); + + return this; +} + +template<class charT, class traits, class _Alloc> +basic_sockbuf<charT, traits, _Alloc> * +basic_sockbuf<charT, traits, _Alloc>::close() +{ + if ( !basic_socket_t::is_open() ) + return 0; + + // if ( _doclose ) { +#ifdef WIN32 + ::closesocket( basic_socket_t::_fd ); +#else + ::close( basic_socket_t::_fd ); +#endif + // } + + // _STLP_ASSERT( _bbuf != 0 ); + // put area before get area + setp( _bbuf, _bbuf + ((_ebuf - _bbuf)>>1) ); + setg( this->epptr(), this->epptr(), this->epptr() ); + + if ( basic_socket_t::_notify_close ) { + basic_socket_t::mgr->exit_notify( this, basic_socket_t::_fd ); + basic_socket_t::_notify_close = false; + } + + basic_socket_t::_fd = -1; + + return this; +} + +template<class charT, class traits, class _Alloc> +void basic_sockbuf<charT, traits, _Alloc>::shutdown( sock_base::shutdownflg dir ) +{ + if ( basic_socket_t::is_open_unsafe() ) { + if ( (dir & (sock_base::stop_in | sock_base::stop_out)) == + (sock_base::stop_in | sock_base::stop_out) ) { + ::shutdown( basic_socket_t::_fd, 2 ); + } else if ( dir & sock_base::stop_in ) { + ::shutdown( basic_socket_t::_fd, 0 ); + } else if ( dir & sock_base::stop_out ) { + ::shutdown( basic_socket_t::_fd, 1 ); + } + } +} + +template<class charT, class traits, class _Alloc> +__FIT_TYPENAME basic_sockbuf<charT, traits, _Alloc>::int_type +basic_sockbuf<charT, traits, _Alloc>::underflow() +{ + if( !basic_socket_t::is_open() ) + return traits::eof(); + + std::tr2::unique_lock<std::tr2::mutex> lk( ulck ); + + if ( this->gptr() < this->egptr() ) + return traits::to_int_type(*this->gptr()); + + if ( this->egptr() == this->gptr() ) { // fullfilled: _ebuf == gptr() + setg( this->eback(), this->eback(), this->eback() ); + } + + // setg( this->eback(), this->eback(), this->eback() + offset ); + // wait on condition + if ( basic_socket_t::_use_rdtimeout ) { + ucnd.timed_wait( lk, basic_socket_t::_rdtimeout, rdready ); + } else { + ucnd.wait( lk, rdready ); + } + + return traits::to_int_type(*this->gptr()); +} + +template<class charT, class traits, class _Alloc> +__FIT_TYPENAME basic_sockbuf<charT, traits, _Alloc>::int_type +basic_sockbuf<charT, traits, _Alloc>::overflow( int_type c ) +{ + if ( !basic_socket_t::is_open() ) + return traits::eof(); + + if ( !traits::eq_int_type( c, traits::eof() ) && this->pptr() < this->epptr() ) { + sputc( traits::to_char_type(c) ); + return c; + } + + long count = this->pptr() - this->pbase(); + + if ( count ) { + count *= sizeof(charT); + long offset = (this->*_xwrite)( this->pbase(), count ); + if ( offset < 0 ) { + if ( errno == EAGAIN ) { + pollfd wpfd; + wpfd.fd = basic_socket_t::_fd; + wpfd.events = POLLOUT | POLLHUP | POLLWRNORM; + wpfd.revents = 0; + while ( poll( &wpfd, 1, basic_socket_t::_use_wrtimeout ? basic_socket_t::_wrtimeout.count() : -1 ) <= 0 ) { // wait infinite + if ( errno == EINTR ) { // may be interrupted, check and ignore + errno = 0; + continue; + } + return traits::eof(); + } + if ( (wpfd.revents & POLLERR) != 0 ) { + return traits::eof(); + } + offset = (this->*_xwrite)( this->pbase(), count ); + if ( offset < 0 ) { + return traits::eof(); + } + } else { + return traits::eof(); + } + } + if ( offset < count ) { + // MUST BE: (offset % sizeof(char_traits)) == 0 ! + offset /= sizeof(charT); + count /= sizeof(charT); + traits::move( this->pbase(), this->pbase() + offset, count - offset ); + // std::copy_backword( this->pbase() + offset, this->pbase() + count, this->pbase() ); + setp( this->pbase(), this->epptr() ); // require: set pptr + this->pbump( count - offset ); + if( !traits::eq_int_type(c,traits::eof()) ) { + sputc( traits::to_char_type(c) ); + } + + return traits::not_eof(c); + } + } + + setp( this->pbase(), this->epptr() ); // require: set pptr + if( !traits::eq_int_type(c,traits::eof()) ) { + sputc( traits::to_char_type(c) ); + } + + return traits::not_eof(c); +} + +template<class charT, class traits, class _Alloc> +int basic_sockbuf<charT, traits, _Alloc>::sync() +{ + if ( !basic_socket_t::is_open() ) { + return -1; + } + + long count = this->pptr() - this->pbase(); + if ( count ) { + // _STLP_ASSERT( this->pbase() != 0 ); + count *= sizeof(charT); + long start = 0; + while ( count > 0 ) { + long offset = (this->*_xwrite)( this->pbase() + start, count ); + if ( offset < 0 ) { + if ( errno == EAGAIN ) { + pollfd wpfd; + wpfd.fd = basic_socket_t::_fd; + wpfd.events = POLLOUT | POLLHUP | POLLWRNORM; + wpfd.revents = 0; + while ( poll( &wpfd, 1, basic_socket_t::_use_wrtimeout ? basic_socket_t::_wrtimeout.count() : -1 ) <= 0 ) { // wait infinite + if ( errno == EINTR ) { // may be interrupted, check and ignore + errno = 0; + continue; + } + return -1; + } + if ( (wpfd.revents & POLLERR) != 0 ) { + return -1; + } + offset = (this->*_xwrite)( this->pbase() + start, count ); + if ( offset < 0 ) { + return -1; + } + } else { + return -1; + } + } + count -= offset; + start += offset; + } + setp( this->pbase(), this->epptr() ); // require: set pptr + } + + return 0; +} + +template<class charT, class traits, class _Alloc> +streamsize basic_sockbuf<charT, traits, _Alloc>::xsputn( const char_type *s, streamsize n ) +{ + if ( !basic_socket_t::is_open() || s == 0 || n == 0 ) { + return 0; + } + + if ( this->epptr() - this->pptr() > n ) { + traits::copy( this->pptr(), s, n ); + this->pbump( n ); + } else { + streamsize __n_put = this->epptr() - this->pptr(); + traits::copy( this->pptr(), s, __n_put ); + this->pbump( __n_put ); + + if ( traits::eq_int_type(overflow(),traits::eof()) ) + return 0; + + setp( (char_type *)(s + __n_put), (char_type *)(s + n) ); + this->pbump( n - __n_put ); + + if ( traits::eq_int_type(overflow(),traits::eof()) ) { + setp( _bbuf, _bbuf + ((_ebuf - _bbuf) >> 1) ); + return 0; + } + setp( _bbuf, _bbuf + ((_ebuf - _bbuf) >> 1) ); + } + return n; +} + +template<class charT, class traits, class _Alloc> +int basic_sockbuf<charT, traits, _Alloc>::recvfrom( void *buf, size_t n ) +{ +#if defined(_WIN32) || (defined(__hpux) && !defined(_INCLUDE_POSIX1C_SOURCE)) + int sz = sizeof( sockaddr_in ); +#else + socklen_t sz = sizeof( sockaddr_in ); +#endif + + typename basic_socket_t::sockaddr_t addr; + +#ifdef __FIT_POLL + pollfd pfd; + pfd.fd = basic_socket_t::_fd; + pfd.events = POLLIN; +#endif // __FIT_POLL + do { +#ifdef __FIT_POLL + pfd.revents = 0; + if ( poll( &pfd, 1, /* _timeout */ -1 ) > 0 ) { // wait infinite + // get address of caller only + char buff[32]; + ::recvfrom( basic_socket_t::_fd, buff, 32, MSG_PEEK, &addr.any, &sz ); + } else { + return 0; // poll wait infinite, so it can't return 0 (timeout), so it return -1. + } +#endif // __FIT_POLL + if ( memcmp( &basic_socket_t::_address.inet, &addr.inet, sizeof(sockaddr_in) ) == 0 ) { +#ifdef WIN32 + return ::recvfrom( basic_socket_t::_fd, (char *)buf, n, 0, &basic_socket_t::_address.any, &sz ); +#else + return ::recvfrom( basic_socket_t::_fd, buf, n, 0, &basic_socket_t::_address.any, &sz ); +#endif + } + // xmt::Thread::yield(); + } while ( true ); + + return 0; // never +} + +template<class charT, class traits, class _Alloc> void basic_sockstream<charT, traits, _Alloc>::setoptions( sock_base::so_t optname, bool on_off, int __v ) { #ifdef __unix Modified: branches/complement-sockios/explore/include/sockios/sp.cc =================================================================== --- branches/complement-sockios/explore/include/sockios/sp.cc 2008-06-16 14:59:26 UTC (rev 1901) +++ branches/complement-sockios/explore/include/sockios/sp.cc 2008-06-26 05:40:30 UTC (rev 1902) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/06/09 23:51:34 ptr> +// -*- C++ -*- Time-stamp: <08/06/11 21:42:37 yeti> /* * Copyright (c) 2008 @@ -10,741 +10,9 @@ namespace std { -template<class charT, class traits, class _Alloc> -void sock_processor_base<charT,traits,_Alloc>::open( const in_addr& addr, int port, sock_base::stype type, sock_base::protocol prot ) -{ - std::tr2::lock_guard<std::tr2::mutex> lk(_fd_lck); - if ( basic_socket_t::is_open_unsafe() ) { - return; - } - _mode = ios_base::in | ios_base::out; - _state = ios_base::goodbit; -#ifdef WIN32 - ::WSASetLastError( 0 ); -#endif - if ( prot == sock_base::inet ) { - basic_socket_t::_fd = socket( PF_INET, type, 0 ); - if ( basic_socket_t::_fd == -1 ) { - _state |= ios_base::failbit | ios_base::badbit; - return; - } - // _open = true; - basic_socket_t::_address.inet.sin_family = AF_INET; - basic_socket_t::_address.inet.sin_port = htons( port ); - basic_socket_t::_address.inet.sin_addr.s_addr = addr.s_addr; - - if ( type == sock_base::sock_stream || type == sock_base::sock_seqpacket ) { - // let's try reuse local address - setoptions_unsafe( sock_base::so_reuseaddr, true ); - } - - if ( ::bind( basic_socket_t::_fd, &basic_socket_t::_address.any, sizeof(basic_socket_t::_address) ) == -1 ) { - _state |= ios_base::failbit; -#ifdef WIN32 - ::closesocket( basic_socket_t::_fd ); -#else - ::close( basic_socket_t::_fd ); -#endif - basic_socket_t::_fd = -1; - return; - } - - if ( type == sock_base::sock_stream || type == sock_base::sock_seqpacket ) { - // I am shure, this is socket of type SOCK_STREAM | SOCK_SEQPACKET, - // so don't check return code from listen - ::listen( basic_socket_t::_fd, SOMAXCONN ); - basic_socket_t::mgr->push( *this ); - } - } else if ( prot == sock_base::local ) { - return; - } else { - return; - } - _state = ios_base::goodbit; - - return; -} - -template<class charT, class traits, class _Alloc> -void sock_processor_base<charT,traits,_Alloc>::close() -{ - std::tr2::lock_guard<std::tr2::mutex> lk(_fd_lck); - if ( !basic_socket_t::is_open_unsafe() ) { - return; - } - basic_socket<charT,traits,_Alloc>::mgr->pop( *this, basic_socket_t::_fd ); -#ifdef WIN32 - ::closesocket( basic_socket_t::_fd ); -#else - ::shutdown( basic_socket_t::_fd, 2 ); - ::close( basic_socket_t::_fd ); -#endif - basic_socket_t::_fd = -1; -} - -template<class charT, class traits, class _Alloc> -void sock_processor_base<charT,traits,_Alloc>::shutdown( sock_base::shutdownflg dir ) -{ - std::tr2::lock_guard<std::tr2::mutex> lk(_fd_lck); - if ( basic_socket_t::is_open_unsafe() ) { - if ( (dir & (sock_base::stop_in | sock_base::stop_out)) == - (sock_base::stop_in | sock_base::stop_out) ) { - ::shutdown( basic_socket_t::_fd, 2 ); - } else if ( dir & sock_base::stop_in ) { - ::shutdown( basic_socket_t::_fd, 0 ); - } else if ( dir & sock_base::stop_out ) { - ::shutdown( basic_socket_t::_fd, 1 ); - } - } -} - -template<class charT, class traits, class _Alloc> -void sock_processor_base<charT,traits,_Alloc>::setoptions_unsafe( sock_base::so_t optname, bool on_off, int __v ) -{ -#ifdef __unix - if ( basic_socket_t::is_open_unsafe() ) { - if ( optname != sock_base::so_linger ) { - int turn = on_off ? 1 : 0; - if ( setsockopt( basic_socket_t::_fd, SOL_SOCKET, (int)optname, (const void *)&turn, - (socklen_t)sizeof(int) ) != 0 ) { - _state |= ios_base::failbit; - } - } else { - linger l; - l.l_onoff = on_off ? 1 : 0; - l.l_linger = __v; - if ( setsockopt( basic_socket_t::_fd, SOL_SOCKET, (int)optname, (const void *)&l, - (socklen_t)sizeof(linger) ) != 0 ) { - _state |= ios_base::failbit; - } - - } - } else { - _state |= ios_base::failbit; - } -#endif // __unix -} - - -template<class Connect, class charT, class traits, class _Alloc, void (Connect::*C)( std::basic_sockstream<charT,traits,_Alloc>& )> -int connect_processor<Connect, charT, traits, _Alloc, C>::Init::_count = 0; - -template<class Connect, class charT, class traits, class _Alloc, void (Connect::*C)( std::basic_sockstream<charT,traits,_Alloc>& )> -bool connect_processor<Connect, charT, traits, _Alloc, C>::Init::_at_fork = false; - -template<class Connect, class charT, class traits, class _Alloc, void (Connect::*C)( std::basic_sockstream<charT,traits,_Alloc>& )> -std::tr2::mutex connect_processor<Connect, charT, traits, _Alloc, C>::Init::_init_lock; - -template<class Connect, class charT, class traits, class _Alloc, void (Connect::*C)( std::basic_sockstream<charT,traits,_Alloc>& )> -void connect_processor<Connect, charT, traits, _Alloc, C>::Init::_guard( int direction ) -{ - if ( direction ) { - std::tr2::lock_guard<std::tr2::mutex> lk( _init_lock ); - if ( _count++ == 0 ) { -#ifdef __FIT_PTHREADS - if ( !_at_fork ) { // call only once - if ( pthread_atfork( __at_fork_prepare, __at_fork_parent, __at_fork_child ) ) { - // throw system_error - } - _at_fork = true; - } -#endif -// _sock_processor_base::_idx = std::tr2::this_thread::xalloc(); - } - } else { - std::tr2::lock_guard<std::tr2::mutex> lk( _init_lock ); - if ( --_count == 0 ) { - - } - } -} - -template<class Connect, class charT, class traits, class _Alloc, void (Connect::*C)( std::basic_sockstream<charT,traits,_Alloc>& )> -void connect_processor<Connect, charT, traits, _Alloc, C>::Init::__at_fork_prepare() -{ _init_lock.lock(); } - -template<class Connect, class charT, class traits, class _Alloc, void (Connect::*C)( std::basic_sockstream<charT,traits,_Alloc>& )> -void connect_processor<Connect, charT, traits, _Alloc, C>::Init::__at_fork_child() -{ - _init_lock.unlock(); - - if ( _count != 0 ) { - // std::cerr << "SHOULD NEVER HAPPEN!!!!\n"; - throw std::logic_error( "Fork while connect_processor working may has unexpected behaviour in child process" ); - } - // _sock_processor_base::_idx = std::tr2::this_thread::xalloc(); -} - -template<class Connect, class charT, class traits, class _Alloc, void (Connect::*C)( std::basic_sockstream<charT,traits,_Alloc>& )> -void connect_processor<Connect, charT, traits, _Alloc, C>::Init::__at_fork_parent() -{ _init_lock.unlock(); } - -template<class Connect, class charT, class traits, class _Alloc, void (Connect::*C)( std::basic_sockstream<charT,traits,_Alloc>& )> -char connect_processor<Connect, charT, traits, _Alloc, C>::Init_buf[128]; - -template <class Connect, class charT, class traits, class _Alloc, void (Connect::*C)( std::basic_sockstream<charT,traits,_Alloc>& )> -void connect_processor<Connect, charT, traits, _Alloc, C>::close() -{ - base_t::close(); - - { - std::tr2::lock_guard<std::tr2::mutex> lk(inwlock); - _in_work = false; // <--- set before cnd.notify_one(); (below in this func) - } - - std::tr2::lock_guard<std::tr2::mutex> lk2( rdlock ); - ready_pool.push_back( processor() ); // make ready_pool not empty - // std::cerr << "=== " << ready_pool.size() << std::endl; - cnd.notify_one(); -} - -template <class Connect, class charT, class traits, class _Alloc, void (Connect::*C)( std::basic_sockstream<charT,traits,_Alloc>& )> -void connect_processor<Connect, charT, traits, _Alloc, C>::operator ()( int fd, const sockaddr& addr ) -{ - typename base_t::sockstream_t* s = base_t::create_stream( fd, addr ); - - Connect* c = new Connect( *s ); // bad point! I can't read from s in ctor indeed! - - if ( s->rdbuf()->in_avail() ) { - std::tr2::lock_guard<std::tr2::mutex> lk( rdlock ); - ready_pool.push_back( processor( c, s ) ); - cnd.notify_one(); - } else { - std::tr2::lock_guard<std::tr2::mutex> lk( wklock ); - worker_pool.insert( std::make_pair( fd, processor( c, s ) ) ); - } -} - -template <class Connect, class charT, class traits, class _Alloc, void (Connect::*C)( std::basic_sockstream<charT,traits,_Alloc>& )> -void connect_processor<Connect, charT, traits, _Alloc, C>::operator ()( int fd, const typename connect_processor<Connect, charT, traits, _Alloc, C>::base_t::adopt_close_t& ) -{ - { - std::tr2::lock_guard<std::tr2::mutex> lk( wklock ); - typename worker_pool_t::iterator i = worker_pool.find( fd ); - if ( i != worker_pool.end() ) { - delete i->second.s; - delete i->second.c; - // std::cerr << "oops\n"; - worker_pool.erase( i ); - return; - } - } - - Connect* c = 0; - { - std::tr2::lock_guard<std::tr2::mutex> lk( rdlock ); - typename ready_pool_t::iterator j = std::find( ready_pool.begin(), ready_pool.end(), /* std::bind2nd( typename processor::equal_to(), &s ) */ fd ); - if ( j != ready_pool.end() ) { - // std::cerr << "oops 2\n"; - c = j->c; - ready_pool.erase( j ); - } - } - if ( c != 0 ) { -//using unknown variable s -// (c->*C)( s ); - delete c; - } -} - -template <class Connect, class charT, class traits, class _Alloc, void (Connect::*C)( std::basic_sockstream<charT,traits,_Alloc>& )> -void connect_processor<Connect, charT, traits, _Alloc, C>::operator ()( int fd, const typename connect_processor<Connect, charT, traits, _Alloc, C>::base_t::adopt_data_t& ) -{ - processor p; - - { - std::tr2::lock_guard<std::tr2::mutex> lk( wklock ); - typename worker_pool_t::const_iterator i = worker_pool.find( fd ); - if ( i == worker_pool.end() ) { - return; - } - p = i->second; - worker_pool.erase( i ); - } - - std::tr2::lock_guard<std::tr2::mutex> lk( rdlock ); - ready_pool.push_back( p ); - cnd.notify_one(); - // std::cerr << "notify data " << (void *)c << " " << ready_pool.size() << std::endl; -} - -template <class Connect, class charT, class traits, class _Alloc, void (Connect::*C)( std::basic_sockstream<charT,traits,_Alloc>& )> -bool connect_processor<Connect, charT, traits, _Alloc, C>::pop_ready( processor& p ) -{ - { - std::tr2::unique_lock<std::tr2::mutex> lk( rdlock ); - - cnd.wait( lk, not_empty ); - p = ready_pool.front(); // it may contain p.c == 0, p.s == 0, if !in_work() - ready_pool.pop_front(); - // std::cerr << "pop 1\n"; - if ( p.c == 0 ) { // wake up, but _in_work may be still true here (in processor pipe?), - return false; // even I know that _in_work <- false before notification... - } // so, check twice - } - - // std::cerr << "pop 2\n"; - - std::tr2::lock_guard<std::tr2::mutex> lk(inwlock); - return _in_work ? true : false; -} - - -template <class Connect, class charT, class traits, class _Alloc, void (Connect::*C)( std::basic_sockstream<charT,traits,_Alloc>& )> -void connect_processor<Connect, charT, traits, _Alloc, C>::worker() -{ - _in_work = true; - - processor p; - - while ( pop_ready( p ) ) { - // std::cerr << "worker 1\n"; - (p.c->*C)( *p.s ); - // std::cerr << "worker 2\n"; - if ( p.s->rdbuf()->in_avail() ) { - std::tr2::lock_guard<std::tr2::mutex> lk( rdlock ); - ready_pool.push_back( p ); - } else { - std::tr2::lock_guard<std::tr2::mutex> lk( wklock ); - worker_pool[p.s->rdbuf()->fd()] = p; - ... [truncated message content] |
From: <Dmi...@us...> - 2008-06-16 15:00:20
|
Revision: 1901 http://complement.svn.sourceforge.net/complement/?rev=1901&view=rev Author: DmitryOsmakov Date: 2008-06-16 07:59:26 -0700 (Mon, 16 Jun 2008) Log Message: ----------- opts.cpp to opts.cc Modified Paths: -------------- trunk/complement/explore/lib/exam/ut/Makefile.inc Modified: trunk/complement/explore/lib/exam/ut/Makefile.inc =================================================================== --- trunk/complement/explore/lib/exam/ut/Makefile.inc 2008-06-16 13:31:12 UTC (rev 1900) +++ trunk/complement/explore/lib/exam/ut/Makefile.inc 2008-06-16 14:59:26 UTC (rev 1901) @@ -2,5 +2,5 @@ PRGNAME = exam_self_test SRC_CC = exam_self_test.cc \ - exam_test_suite.cc -SRC_CPP = ./../../misc/opts.cpp + exam_test_suite.cc \ + ../../misc/opts.cc This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2008-06-16 13:31:14
|
Revision: 1900 http://complement.svn.sourceforge.net/complement/?rev=1900&view=rev Author: complement Date: 2008-06-16 06:31:12 -0700 (Mon, 16 Jun 2008) Log Message: ----------- libmisc 1.9.1: added options parser Modified Paths: -------------- trunk/complement/explore/lib/misc/ChangeLog trunk/complement/explore/lib/misc/Makefile.inc Added Paths: ----------- trunk/complement/explore/lib/misc/opts.cc Removed Paths: ------------- trunk/complement/explore/lib/misc/opts.cpp Modified: trunk/complement/explore/lib/misc/ChangeLog =================================================================== --- trunk/complement/explore/lib/misc/ChangeLog 2008-06-16 13:30:53 UTC (rev 1899) +++ trunk/complement/explore/lib/misc/ChangeLog 2008-06-16 13:31:12 UTC (rev 1900) @@ -1,3 +1,9 @@ +2008-06-16 Petr Ovtchenkov <ye...@ya...> + + * opts.cc, opts.h: options parser, by Dmitry Osmakov. + + * libmisc: version 1.9.1. + 2008-04-23 Petr Ovtchenkov <pt...@is...> * Removed directory utils and node, not used a long time. Modified: trunk/complement/explore/lib/misc/Makefile.inc =================================================================== --- trunk/complement/explore/lib/misc/Makefile.inc 2008-06-16 13:30:53 UTC (rev 1899) +++ trunk/complement/explore/lib/misc/Makefile.inc 2008-06-16 13:31:12 UTC (rev 1900) @@ -10,6 +10,6 @@ LIBNAME = misc MAJOR = 1 MINOR = 9 -PATCH = 0 -SRC_CC = CyrMoney.cc args.cc arguments.cc +PATCH = 1 +SRC_CC = CyrMoney.cc args.cc arguments.cc opts.cc SRC_C = md5.c Copied: trunk/complement/explore/lib/misc/opts.cc (from rev 1899, trunk/complement/explore/lib/misc/opts.cpp) =================================================================== --- trunk/complement/explore/lib/misc/opts.cc (rev 0) +++ trunk/complement/explore/lib/misc/opts.cc 2008-06-16 13:31:12 UTC (rev 1900) @@ -0,0 +1,206 @@ +#include <vector> +#include <string> +#include <sstream> +#include <typeinfo> +#include <cassert> + +#include <misc/opts.h> + +using namespace std; + +string Opts::get_pname() const { return pname; } + +bool Opts::is_opt_name(const string& s) +{ + return (s.size() > 1) && (s[0] == '-') && !is_flag_group(s); +} + +bool Opts::is_substr(const string& small,const string& big) +{ + if (small.size() > big.size()) + return false; + for (int i = 0;i < small.size();i++) + if (small[i] != big[i]) + return false; + + return true; +} + +bool Opts::is_flag_group(const string& s) +{ + if (s.size() > 2 && s[0] == '-') + { + for (int i = 1;i < s.size();i++) + if (!isalnum(s[i])) + return false; + return true; + } + else + return false; +} + +// this function assumes that is_opt_name(s) = true; +Opts::options_container_type::iterator Opts::get_opt_index(string s) +{ + assert(is_opt_name(s)); + if (s.size() == 2 && isalnum(s[1]) ) // is short name + { + options_container_type::iterator i; + for (i = storage.begin();i != storage.end();++i) + if (i->shortname == s[1]) + break; + return i; + } + + if (s.size() > 2 && s[1] == '-') + { + options_container_type::iterator i; + s = s.substr(2); + + // exact match + for (i = storage.begin();i != storage.end();++i) + if (i->longname == s) + return i; + + vector< options_container_type::iterator > matches; + for (i = storage.begin();i != storage.end();++i) + if (is_substr(s,i->longname)) + matches.push_back(i); + + if (matches.size() == 1) + return matches[0]; + else + return storage.end(); + } + + return storage.end(); +} + +ostream& operator<<(ostream& out,const Opt& opt) +{ + if (opt.shortname == ' ') + { + out << "--" << opt.longname << '\t' << (opt.has_arg ? (string("[") + opt.default_v + "]\t") : "" ) << opt.desc; + } + else + { + out << '-' << opt.shortname << '\t' << (!opt.longname.empty() ? (string("[--") + opt.longname +"]\t") : "") << (opt.has_arg ? string("[") + opt.default_v + ("]\t") : "") << opt.desc; + } + + return out; +} + +void Opts::help(ostream& out) +{ + if (!brief.empty()) + out << brief << endl; + if (!author.empty()) + out << author << endl; + if (!copyright.empty()) + out << copyright << endl; + + out << "Valid options:" << endl; + options_container_type::const_iterator i; + for (i = storage.begin();i != storage.end();++i) + { + out << *i << endl; + } +} + +int Opts::addflag(char _shortname,const string& _longname,const string& _desc) +{ + Opt opt; + opt.shortname = _shortname; + opt.longname = _longname; + opt.desc = _desc; + opt.has_arg = false; + opt.token = ++free_token; + storage.push_back(opt); + return opt.token; +} + +int Opts::addflag(const string& _longname,const string& _desc) +{ + Opt opt; + opt.longname = _longname; + opt.desc = _desc; + opt.has_arg = false; + opt.token = ++free_token; + storage.push_back(opt); + return opt.token; +} + +void Opts::parse(int& ac,const char** av) +{ + pname = av[0]; + + int i = 1; + int j = 1; + int q = 0; + while ( (i < ac) && (string(av[i]) != "--") ) + { + if (is_opt_name(av[i])) + { + string opt = av[i]; + string arg; + + int k = opt.find("="); + + if (k != string::npos) + { + arg = opt.substr(k + 1); + opt = opt.substr(0,k); + } + + options_container_type::iterator p = get_opt_index(opt); + + if (p == storage.end()) + throw unknown_option(opt); + else + { + p->pos.push_back(++q); + if (p->has_arg) + { + if (!arg.empty()) + p->args.push_back(arg); + else + if (i + 1 < ac) + p->args.push_back(av[++i]); + else + throw missing_arg(opt); + } + else + if (!arg.empty()) //unexpected arg (not exactly mismatch) + throw arg_typemismatch(opt,arg); + } + } + else + if (is_flag_group(av[i])) + { + string optgroup = av[i]; + for (int j = 1;j < optgroup.size();j++) + { + options_container_type::iterator p = get_opt_index(string("-") + optgroup[j]); + if (p == storage.end()) + { + throw unknown_option( "-" + string(1,optgroup[j]) ); + } + else + { + p->pos.push_back(++q); + if (p->has_arg) + throw missing_arg( "-" + string(1,optgroup[j]) ); + } + } + } + else + av[j++] = av[i]; + i++; + } + + i += ( i < ac ); + + while (i < ac) + av[j++] = av[i++]; + ac = j; +} Deleted: trunk/complement/explore/lib/misc/opts.cpp =================================================================== --- trunk/complement/explore/lib/misc/opts.cpp 2008-06-16 13:30:53 UTC (rev 1899) +++ trunk/complement/explore/lib/misc/opts.cpp 2008-06-16 13:31:12 UTC (rev 1900) @@ -1,206 +0,0 @@ -#include <vector> -#include <string> -#include <sstream> -#include <typeinfo> -#include <cassert> - -#include <misc/opts.h> - -using namespace std; - -string Opts::get_pname() const { return pname; } - -bool Opts::is_opt_name(const string& s) -{ - return (s.size() > 1) && (s[0] == '-') && !is_flag_group(s); -} - -bool Opts::is_substr(const string& small,const string& big) -{ - if (small.size() > big.size()) - return false; - for (int i = 0;i < small.size();i++) - if (small[i] != big[i]) - return false; - - return true; -} - -bool Opts::is_flag_group(const string& s) -{ - if (s.size() > 2 && s[0] == '-') - { - for (int i = 1;i < s.size();i++) - if (!isalnum(s[i])) - return false; - return true; - } - else - return false; -} - -// this function assumes that is_opt_name(s) = true; -Opts::options_container_type::iterator Opts::get_opt_index(string s) -{ - assert(is_opt_name(s)); - if (s.size() == 2 && isalnum(s[1]) ) // is short name - { - options_container_type::iterator i; - for (i = storage.begin();i != storage.end();++i) - if (i->shortname == s[1]) - break; - return i; - } - - if (s.size() > 2 && s[1] == '-') - { - options_container_type::iterator i; - s = s.substr(2); - - // exact match - for (i = storage.begin();i != storage.end();++i) - if (i->longname == s) - return i; - - vector< options_container_type::iterator > matches; - for (i = storage.begin();i != storage.end();++i) - if (is_substr(s,i->longname)) - matches.push_back(i); - - if (matches.size() == 1) - return matches[0]; - else - return storage.end(); - } - - return storage.end(); -} - -ostream& operator<<(ostream& out,const Opt& opt) -{ - if (opt.shortname == ' ') - { - out << "--" << opt.longname << '\t' << (opt.has_arg ? (string("[") + opt.default_v + "]\t") : "" ) << opt.desc; - } - else - { - out << '-' << opt.shortname << '\t' << (!opt.longname.empty() ? (string("[--") + opt.longname +"]\t") : "") << (opt.has_arg ? string("[") + opt.default_v + ("]\t") : "") << opt.desc; - } - - return out; -} - -void Opts::help(ostream& out) -{ - if (!brief.empty()) - out << brief << endl; - if (!author.empty()) - out << author << endl; - if (!copyright.empty()) - out << copyright << endl; - - out << "Valid options:" << endl; - options_container_type::const_iterator i; - for (i = storage.begin();i != storage.end();++i) - { - out << *i << endl; - } -} - -int Opts::addflag(char _shortname,const string& _longname,const string& _desc) -{ - Opt opt; - opt.shortname = _shortname; - opt.longname = _longname; - opt.desc = _desc; - opt.has_arg = false; - opt.token = ++free_token; - storage.push_back(opt); - return opt.token; -} - -int Opts::addflag(const string& _longname,const string& _desc) -{ - Opt opt; - opt.longname = _longname; - opt.desc = _desc; - opt.has_arg = false; - opt.token = ++free_token; - storage.push_back(opt); - return opt.token; -} - -void Opts::parse(int& ac,const char** av) -{ - pname = av[0]; - - int i = 1; - int j = 1; - int q = 0; - while ( (i < ac) && (string(av[i]) != "--") ) - { - if (is_opt_name(av[i])) - { - string opt = av[i]; - string arg; - - int k = opt.find("="); - - if (k != string::npos) - { - arg = opt.substr(k + 1); - opt = opt.substr(0,k); - } - - options_container_type::iterator p = get_opt_index(opt); - - if (p == storage.end()) - throw unknown_option(opt); - else - { - p->pos.push_back(++q); - if (p->has_arg) - { - if (!arg.empty()) - p->args.push_back(arg); - else - if (i + 1 < ac) - p->args.push_back(av[++i]); - else - throw missing_arg(opt); - } - else - if (!arg.empty()) //unexpected arg (not exactly mismatch) - throw arg_typemismatch(opt,arg); - } - } - else - if (is_flag_group(av[i])) - { - string optgroup = av[i]; - for (int j = 1;j < optgroup.size();j++) - { - options_container_type::iterator p = get_opt_index(string("-") + optgroup[j]); - if (p == storage.end()) - { - throw unknown_option( "-" + string(1,optgroup[j]) ); - } - else - { - p->pos.push_back(++q); - if (p->has_arg) - throw missing_arg( "-" + string(1,optgroup[j]) ); - } - } - } - else - av[j++] = av[i]; - i++; - } - - i += ( i < ac ); - - while (i < ac) - av[j++] = av[i++]; - ac = j; -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2008-06-16 13:30:56
|
Revision: 1899 http://complement.svn.sourceforge.net/complement/?rev=1899&view=rev Author: complement Date: 2008-06-16 06:30:53 -0700 (Mon, 16 Jun 2008) Log Message: ----------- function to pass tag for make in subdirs Modified Paths: -------------- trunk/complement/explore/Makefiles/ChangeLog trunk/complement/explore/Makefiles/gmake/subdirs.mak Modified: trunk/complement/explore/Makefiles/ChangeLog =================================================================== --- trunk/complement/explore/Makefiles/ChangeLog 2008-06-16 10:39:08 UTC (rev 1898) +++ trunk/complement/explore/Makefiles/ChangeLog 2008-06-16 13:30:53 UTC (rev 1899) @@ -1,3 +1,8 @@ +2008-06-16 Petr Ovtchenkov <pt...@is...> + + * gmake/subdirs.mak: function to pass tag for make in + subdirs. + 2008-06-07 Petr Ovtchenkov <pt...@is...> * configure: don't duplicate options in config.mak, that Modified: trunk/complement/explore/Makefiles/gmake/subdirs.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/subdirs.mak 2008-06-16 10:39:08 UTC (rev 1898) +++ trunk/complement/explore/Makefiles/gmake/subdirs.mak 2008-06-16 13:30:53 UTC (rev 1899) @@ -1,12 +1,17 @@ -# Time-stamp: <06/11/01 22:55:23 ptr> +# Time-stamp: <08/06/16 16:31:11 yeti> # -# Copyright (c) 2006, 2007 +# Copyright (c) 2006-2008 # Petr Ovtchenkov # # Licensed under the Academic Free License version 3.0 # -# Do the same target in all catalogs as arg +# Do the same target in all catalogs specified in arg define doinsubdirs $(foreach d,$(1),${MAKE} -C ${d} $@;) endef + +# Do specified target (first arg) in all catalogs specified by second arg +define dotaginsubdirs +$(foreach d,$(2),${MAKE} -C ${d} $(1);) +endef This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2008-06-16 10:39:12
|
Revision: 1898 http://complement.svn.sourceforge.net/complement/?rev=1898&view=rev Author: complement Date: 2008-06-16 03:39:08 -0700 (Mon, 16 Jun 2008) Log Message: ----------- Review options, exit status (coupled with options) and coding style. Modified Paths: -------------- trunk/complement/explore/lib/exam/ut/exam_self_test.cc Modified: trunk/complement/explore/lib/exam/ut/exam_self_test.cc =================================================================== --- trunk/complement/explore/lib/exam/ut/exam_self_test.cc 2008-06-16 10:38:45 UTC (rev 1897) +++ trunk/complement/explore/lib/exam/ut/exam_self_test.cc 2008-06-16 10:39:08 UTC (rev 1898) @@ -40,32 +40,43 @@ Opts opts; - opts.addflag('h',"help","print this help message"); - opts.addflag('l',"list","list all test cases"); - opts.add('n',0,"num","run tests by number"); + opts.addflag( 'h', "help", "print this help message" ); + opts.addflag( 'l', "list", "list all test cases" ); + opts.add( 'r', 0, "run", "run tests by number" ); + opts.addflag( 'v', "verbose", "print status of tests within test suite" ); + opts.addflag( 't', "trace", "trace checks" ); - try - { - opts.parse(argc,argv); + try { + opts.parse( argc, argv ); } - catch(...) - { - cout << "there were errors" << endl; + catch (...) { + opts.help( cerr ); + return 1; } - if (opts.is_set('h')) - opts.help(cout); + if ( opts.is_set( 'h' ) ) { + opts.help( cerr ); + return 0; + } - if (opts.is_set('l')) - t.print_graph(cout); + if ( opts.is_set( 'l' ) ) { + t.print_graph( cerr ); + return 0; + } - if (opts.is_set('n')) - { - stringstream ss(opts.get('n')); + if ( opts.is_set( 'v' ) ) { + t.flags( t.flags() | exam::base_logger::verbose ); + } + + if ( opts.is_set( 't' ) ) { + t.flags( t.flags() | exam::base_logger::trace ); + } + + if ( opts.is_set( 'r' ) ) { + stringstream ss( opts.get( 'r' ) ); int n; - while (ss >> n) - { - t.single(n); + while ( ss >> n ) { + t.single( n ); } return 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2008-06-16 10:38:54
|
Revision: 1897 http://complement.svn.sourceforge.net/complement/?rev=1897&view=rev Author: complement Date: 2008-06-16 03:38:45 -0700 (Mon, 16 Jun 2008) Log Message: ----------- Don't assume STLport presence Modified Paths: -------------- trunk/complement/explore/lib/exam/ut/Makefile Modified: trunk/complement/explore/lib/exam/ut/Makefile =================================================================== --- trunk/complement/explore/lib/exam/ut/Makefile 2008-06-14 21:50:39 UTC (rev 1896) +++ trunk/complement/explore/lib/exam/ut/Makefile 2008-06-16 10:38:45 UTC (rev 1897) @@ -11,8 +11,6 @@ LIBEXAM_DIR = ${CoMT_DIR}/lib/exam LIBXMT_DIR = ${CoMT_DIR}/lib/mt -LDFLAGS += -Wl,-rpath=${STLPORT_LIB_DIR} - ifeq ($(OSNAME),linux) release-shared: LDFLAGS += -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L$(LIBXMT_DIR)/${OUTPUT_DIR} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR}:$(LIBXMT_DIR)/${OUTPUT_DIR}:${STLPORT_LIB_DIR} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dmi...@us...> - 2008-06-14 21:50:44
|
Revision: 1896 http://complement.svn.sourceforge.net/complement/?rev=1896&view=rev Author: dmitryosmakov Date: 2008-06-14 14:50:39 -0700 (Sat, 14 Jun 2008) Log Message: ----------- Added basic options support to exam Modified Paths: -------------- trunk/complement/explore/include/exam/suite.h trunk/complement/explore/include/misc/opts.h trunk/complement/explore/lib/exam/suite.cc trunk/complement/explore/lib/exam/ut/Makefile.inc trunk/complement/explore/lib/exam/ut/exam_self_test.cc trunk/complement/explore/lib/misc/opts.cpp trunk/complement/explore/lib/misc/ut/misc_test_suite.cc trunk/complement/explore/lib/misc/ut/opts_test.cc trunk/complement/explore/lib/misc/ut/opts_test.h Modified: trunk/complement/explore/include/exam/suite.h =================================================================== --- trunk/complement/explore/include/exam/suite.h 2008-06-12 12:57:36 UTC (rev 1895) +++ trunk/complement/explore/include/exam/suite.h 2008-06-14 21:50:39 UTC (rev 1896) @@ -212,6 +212,7 @@ base_logger *set_logger( base_logger * ); test_case_type test_by_name( const std::string& ); + void print_graph( std::ostream& ); private: enum { Modified: trunk/complement/explore/include/misc/opts.h =================================================================== --- trunk/complement/explore/include/misc/opts.h 2008-06-12 12:57:36 UTC (rev 1895) +++ trunk/complement/explore/include/misc/opts.h 2008-06-14 21:50:39 UTC (rev 1896) @@ -62,10 +62,18 @@ template < class T ,class V > T get( V field ); + + + template < class V > + std::string get( V field ); + template <class T , class V> T get_default( V field ); + template < class V > + std::string get_default( V field ); + template < class V , class BackInsertIterator> void getemall( V field , BackInsertIterator bi); @@ -161,6 +169,31 @@ return ( (i == storage.end()) ? 0 : i->pos.size()); } +template <class V> +std::string Opts::get( V field ) +{ + options_container_type::const_iterator i = find(all(storage),field); + std::string res; + + if (i != storage.end()) + { + if ( !i->has_arg ) + { + throw std::logic_error("using Opts::get for option without arguments"); + } + + res = i->args.empty() ? i->default_v : i->args[0]; + } + else + { + std::stringstream ss1; + ss1 << field; + throw unknown_option( ss1.str() ); + } + + return res; +} + template < class T , class V > T Opts::get( V field ) { @@ -195,6 +228,29 @@ } +template < class V> +std::string Opts::get_default( V field ) +{ + options_container_type::const_iterator i = find(all(storage),field); + std::string res; + + if (i != storage.end()) + { + if (!i->has_arg) + throw std::logic_error("using Opts::get for option without arguments"); + + res = i->default_v; + } + else + { + std::stringstream ss1; + ss1 << field; + throw unknown_option( ss1.str() ); + } + + return res; +} + template <class T , class V> T Opts::get_default( V field ) { Modified: trunk/complement/explore/lib/exam/suite.cc =================================================================== --- trunk/complement/explore/lib/exam/suite.cc 2008-06-12 12:57:36 UTC (rev 1895) +++ trunk/complement/explore/lib/exam/suite.cc 2008-06-14 21:50:39 UTC (rev 1896) @@ -389,4 +389,19 @@ return dry_girdle( 0 ); } +void test_suite::print_graph(ostream& out) +{ + out << _suite_name << endl; + for (test_case_type i = 1;i <= _count;i++) + { + out << i << " ( "; + for (list<edge_t>::const_iterator j = _edges.begin();j != _edges.end();++j) + { + if (j->second == i && j->first != 0) + out << j->first << ' '; + } + out << ") " << _test[i].name << endl; + } +} + } // namespace exam Modified: trunk/complement/explore/lib/exam/ut/Makefile.inc =================================================================== --- trunk/complement/explore/lib/exam/ut/Makefile.inc 2008-06-12 12:57:36 UTC (rev 1895) +++ trunk/complement/explore/lib/exam/ut/Makefile.inc 2008-06-14 21:50:39 UTC (rev 1896) @@ -3,3 +3,4 @@ PRGNAME = exam_self_test SRC_CC = exam_self_test.cc \ exam_test_suite.cc +SRC_CPP = ./../../misc/opts.cpp Modified: trunk/complement/explore/lib/exam/ut/exam_self_test.cc =================================================================== --- trunk/complement/explore/lib/exam/ut/exam_self_test.cc 2008-06-12 12:57:36 UTC (rev 1895) +++ trunk/complement/explore/lib/exam/ut/exam_self_test.cc 2008-06-14 21:50:39 UTC (rev 1896) @@ -8,14 +8,69 @@ */ #include "exam_test_suite.h" +#include "misc/opts.h" +#include <vector> +#include <string> -int main( int, char ** ) +using namespace std; + +int main( int argc,const char** argv) { // exam::test_suite t( "exam self test" ); // t.add( exam_self_test, "exam self test suite" ); // // return t.girdle(); - return exam_self_test(0); + // return exam_self_test(0); + + exam::test_suite t( "exam self test" ); + exam_basic_test exam_basic; + + exam::test_suite::test_case_type d0 = t.add( &exam_basic_test::function_good, exam_basic, "call test, good calls" ); + t.add( &exam_basic_test::function, exam_basic, "call test, fail calls", d0 ); + exam::test_suite::test_case_type d = t.add( &exam_basic_test::dep, exam_basic, "call test, tests dependency", d0 ); + t.add( &exam_basic_test::trace, exam_basic, "trace flags test", d ); + t.add( &exam_basic_test::dep_test_suite, exam_basic, "test suites grouping", d ); + exam::test_suite::test_case_type d2 = t.add( &exam_basic_test::multiple_dep, exam_basic, "multiple dependencies", d ); + t.add( &exam_basic_test::multiple_dep_complex, exam_basic, "complex multiple dependencies", d2 ); + + t.add( &exam_basic_test::perf, exam_basic, "performance timer test", d0 ); + t.add( &exam_basic_test::dry, exam_basic, "complex multiple dependencies, dry run", d2 ); + t.add( &exam_basic_test::single, exam_basic, "complex multiple dependencies, single test", d2 ); + + Opts opts; + + opts.addflag('h',"help","print this help message"); + opts.addflag('l',"list","list all test cases"); + opts.add('n',0,"num","run tests by number"); + + try + { + opts.parse(argc,argv); + } + catch(...) + { + cout << "there were errors" << endl; + } + + if (opts.is_set('h')) + opts.help(cout); + + if (opts.is_set('l')) + t.print_graph(cout); + + if (opts.is_set('n')) + { + stringstream ss(opts.get('n')); + int n; + while (ss >> n) + { + t.single(n); + } + + return 0; + } + + return t.girdle(); } Modified: trunk/complement/explore/lib/misc/opts.cpp =================================================================== --- trunk/complement/explore/lib/misc/opts.cpp 2008-06-12 12:57:36 UTC (rev 1895) +++ trunk/complement/explore/lib/misc/opts.cpp 2008-06-14 21:50:39 UTC (rev 1896) @@ -10,7 +10,6 @@ string Opts::get_pname() const { return pname; } - bool Opts::is_opt_name(const string& s) { return (s.size() > 1) && (s[0] == '-') && !is_flag_group(s); Modified: trunk/complement/explore/lib/misc/ut/misc_test_suite.cc =================================================================== --- trunk/complement/explore/lib/misc/ut/misc_test_suite.cc 2008-06-12 12:57:36 UTC (rev 1895) +++ trunk/complement/explore/lib/misc/ut/misc_test_suite.cc 2008-06-14 21:50:39 UTC (rev 1896) @@ -103,5 +103,7 @@ t.add( &opts_test::help, opts, "help"); + t.add( &opts_test::long_string, opts, "long string"); + return t.girdle(); } Modified: trunk/complement/explore/lib/misc/ut/opts_test.cc =================================================================== --- trunk/complement/explore/lib/misc/ut/opts_test.cc 2008-06-12 12:57:36 UTC (rev 1895) +++ trunk/complement/explore/lib/misc/ut/opts_test.cc 2008-06-14 21:50:39 UTC (rev 1896) @@ -15,7 +15,7 @@ #include <vector> #include <list> #include <fstream> - #include <iostream> +#include <iostream> using namespace std; @@ -209,13 +209,13 @@ EXAM_CHECK( opts.is_set('t') ); EXAM_CHECK( opts.get_cnt(t_token) == 1 ); EXAM_CHECK( opts.get<int>('t') == 20); - EXAM_CHECK( opts.get_default<int>(t_token) == 10 ); + //EXAM_CHECK( opts.get_default<int>(t_token) == 10 ); EXAM_CHECK( opts.is_set(name_token) ); EXAM_CHECK( opts.get_cnt("name") == 1 ); EXAM_CHECK( opts.get<string>(name_token) == "torwalds"); EXAM_CHECK( opts.get_default<string>("name") == "linus"); EXAM_CHECK( !opts.is_set('p') ); - EXAM_CHECK( !opts.is_set("num") && opts.get<int>(num_token) == opts.get_default<int>("num") ) ; + //EXAM_CHECK( !opts.is_set("num") && opts.get<int>(num_token) == opts.get_default<int>("num") ) ; return EXAM_RESULT; } @@ -690,7 +690,7 @@ opts.getemall('I',vs.begin()); EXAM_CHECK( opts.get_default<string>("include") == "/usr/include"); - + EXAM_CHECK( vs[0] == "first" ); EXAM_CHECK( vs[1] == "second" ); EXAM_CHECK( vs[2] == "third" ); @@ -728,3 +728,25 @@ return EXAM_RESULT; } + +int EXAM_IMPL(opts_test::long_string) +{ + { + const char* argv[] = { "name" , "--string" , "long string"}; + int argc = sizeof( argv ) / sizeof(argv[0]); + + Opts opts; + + opts.add('s',string("default value"),"string","some string param"); + + EXAM_CHECK( opts.get('s') == "default value"); + + opts.parse(argc,argv); + + EXAM_CHECK( opts.get('s') == "long string"); + + } + + return EXAM_RESULT; +} + Modified: trunk/complement/explore/lib/misc/ut/opts_test.h =================================================================== --- trunk/complement/explore/lib/misc/ut/opts_test.h 2008-06-12 12:57:36 UTC (rev 1895) +++ trunk/complement/explore/lib/misc/ut/opts_test.h 2008-06-14 21:50:39 UTC (rev 1896) @@ -41,6 +41,7 @@ int EXAM_DECL(autocomplement_failure); int EXAM_DECL(multiple_args); int EXAM_DECL(help); + int EXAM_DECL(long_string); }; #endif // __MISC_TEST_H This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2008-06-12 12:58:27
|
Revision: 1895 http://complement.svn.sourceforge.net/complement/?rev=1895&view=rev Author: complement Date: 2008-06-12 05:57:36 -0700 (Thu, 12 Jun 2008) Log Message: ----------- sync with STLport for cygwin/mingw Modified Paths: -------------- trunk/complement/explore/Makefiles/gmake/app/gcc.mak trunk/complement/explore/Makefiles/gmake/lib/gcc.mak Modified: trunk/complement/explore/Makefiles/gmake/app/gcc.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/app/gcc.mak 2008-06-12 12:55:26 UTC (rev 1894) +++ trunk/complement/explore/Makefiles/gmake/app/gcc.mak 2008-06-12 12:57:36 UTC (rev 1895) @@ -1,6 +1,6 @@ -# -*- Makefile -*- Time-stamp: <08/06/12 13:54:55 ptr> +# -*- Makefile -*- Time-stamp: <08/06/12 16:01:09 ptr> # -# Copyright (c) 1997-1999, 2002, 2003, 2005-2007 +# Copyright (c) 1997-1999, 2002, 2003, 2005-2008 # Petr Ovtchenkov # # Portion Copyright (c) 1999-2001 @@ -63,6 +63,7 @@ ifndef WITHOUT_STLPORT ifeq (${STLPORT_LIB_DIR},) +ifneq ($(OSNAME),windows) release-shared: STLPORT_LIB = -lstlport release-static: STLPORT_LIB = -Wl,-Bstatic -lstlport -Wl,-Bdynamic dbg-shared: STLPORT_LIB = -lstlportg @@ -70,20 +71,27 @@ stldbg-shared: STLPORT_LIB = -lstlportstlg stldbg-static: STLPORT_LIB = -Wl,-Bstatic -lstlportstlg -Wl,-Bdynamic else +LIB_VERSION = ${LIBMAJOR}.${LIBMINOR} +release-shared : STLPORT_LIB = -lstlport.${LIB_VERSION} +dbg-shared : STLPORT_LIB = -lstlportg.${LIB_VERSION} +stldbg-shared : STLPORT_LIB = -lstlportstlg.${LIB_VERSION} +endif +else +# STLPORT_LIB_DIR not empty +ifneq ($(OSNAME),windows) release-shared: STLPORT_LIB = -L${STLPORT_LIB_DIR} -lstlport release-static: STLPORT_LIB = -L${STLPORT_LIB_DIR} -Wl,-Bstatic -lstlport -Wl,-Bdynamic dbg-shared: STLPORT_LIB = -L${STLPORT_LIB_DIR} -lstlportg dbg-static: STLPORT_LIB = -L${STLPORT_LIB_DIR} -Wl,-Bstatic -lstlportg -Wl,-Bdynamic stldbg-shared: STLPORT_LIB = -L${STLPORT_LIB_DIR} -lstlportstlg stldbg-static: STLPORT_LIB = -L${STLPORT_LIB_DIR} -Wl,-Bstatic -lstlportstlg -Wl,-Bdynamic -endif - -ifeq ($(OSNAME),windows) +else LIB_VERSION = ${LIBMAJOR}.${LIBMINOR} -release-shared : STLPORT_LIB = -lstlport.${LIB_VERSION} -dbg-shared : STLPORT_LIB = -lstlportg.${LIB_VERSION} -stldbg-shared : STLPORT_LIB = -lstlportstlg.${LIB_VERSION} +release-shared : STLPORT_LIB = -L${STLPORT_LIB_DIR} -lstlport.${LIB_VERSION} +dbg-shared : STLPORT_LIB = -L${STLPORT_LIB_DIR} -lstlportg.${LIB_VERSION} +stldbg-shared : STLPORT_LIB = -L${STLPORT_LIB_DIR} -lstlportstlg.${LIB_VERSION} endif +endif endif Modified: trunk/complement/explore/Makefiles/gmake/lib/gcc.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/lib/gcc.mak 2008-06-12 12:55:26 UTC (rev 1894) +++ trunk/complement/explore/Makefiles/gmake/lib/gcc.mak 2008-06-12 12:57:36 UTC (rev 1895) @@ -1,4 +1,4 @@ -# -*- makefile -*- Time-stamp: <08/06/12 14:08:48 ptr> +# -*- makefile -*- Time-stamp: <08/06/12 15:44:41 ptr> # # Copyright (c) 1997-1999, 2002, 2003, 2005-2008 # Petr Ovtchenkov @@ -73,21 +73,29 @@ ifndef WITHOUT_STLPORT ifeq (${STLPORT_LIB_DIR},) +ifneq ($(OSNAME),windows) release-shared: STLPORT_LIB = -lstlport dbg-shared: STLPORT_LIB = -lstlportg stldbg-shared: STLPORT_LIB = -lstlportstlg else +LIB_VERSION = ${LIBMAJOR}.${LIBMINOR} +release-shared: STLPORT_LIB = -lstlport.${LIB_VERSION} +dbg-shared: STLPORT_LIB = -lstlportg.${LIB_VERSION} +stldbg-shared: STLPORT_LIB = -lstlportstlg.${LIB_VERSION} +endif +else +# STLPORT_LIB_DIR not empty +ifneq ($(OSNAME),windows) release-shared: STLPORT_LIB = -L${STLPORT_LIB_DIR} -lstlport dbg-shared: STLPORT_LIB = -L${STLPORT_LIB_DIR} -lstlportg stldbg-shared: STLPORT_LIB = -L${STLPORT_LIB_DIR} -lstlportstlg -endif - -ifeq ($(OSNAME),windows) +else LIB_VERSION = ${LIBMAJOR}.${LIBMINOR} -release-shared : STLPORT_LIB = -lstlport.${LIB_VERSION} -dbg-shared : STLPORT_LIB = -lstlportg.${LIB_VERSION} -stldbg-shared : STLPORT_LIB = -lstlportstlg.${LIB_VERSION} +release-shared: STLPORT_LIB = -L${STLPORT_LIB_DIR} -lstlport.${LIB_VERSION} +dbg-shared: STLPORT_LIB = -L${STLPORT_LIB_DIR} -lstlportg.${LIB_VERSION} +stldbg-shared: STLPORT_LIB = -L${STLPORT_LIB_DIR} -lstlportstlg.${LIB_VERSION} endif +endif endif @@ -126,7 +134,7 @@ _LSUPCPP := $(shell ${CXX} ${CXXFLAGS} -print-file-name=libsupc++.a) ifeq (${OSNAME},darwin) ifdef GCC_APPLE_CC -_LSUPCPP := $(shell lipo ${_LSUPCPP} -thin ${M_ARCH} -output $(PRE_OUTPUT_DIR)/libsupc++.a && echo $(PRE_OUTPUT_DIR)/libsupc++.a) +_LSUPCPP := $(shell mkdir -p $(PRE_OUTPUT_DIR) && lipo ${_LSUPCPP} -thin ${M_ARCH} -output $(PRE_OUTPUT_DIR)/libsupc++.a && echo $(PRE_OUTPUT_DIR)/libsupc++.a) endif endif ifneq (${_LSUPCPP},libsupc++.a) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2008-06-12 12:57:06
|
Revision: 1894 http://complement.svn.sourceforge.net/complement/?rev=1894&view=rev Author: complement Date: 2008-06-12 05:55:26 -0700 (Thu, 12 Jun 2008) Log Message: ----------- Remove LDSEARCH macro; add option for STLport includes in configure Modified Paths: -------------- trunk/complement/explore/Makefiles/gmake/app/gcc.mak trunk/complement/explore/Makefiles/gmake/app/top.mak trunk/complement/explore/Makefiles/gmake/extern.mak trunk/complement/explore/Makefiles/gmake/icc.mak trunk/complement/explore/Makefiles/gmake/lib/CC.mak trunk/complement/explore/Makefiles/gmake/lib/aCC.mak trunk/complement/explore/Makefiles/gmake/lib/gcc.mak trunk/complement/explore/Makefiles/gmake/lib/icc.mak trunk/complement/explore/Makefiles/gmake/lib/vc6.mak trunk/complement/explore/configure trunk/complement/explore/lib/DB/PgSQL/Makefile trunk/complement/explore/lib/exam/ut/Makefile trunk/complement/explore/lib/janus/Makefile trunk/complement/explore/lib/janus/ut/Makefile trunk/complement/explore/lib/misc/ut/Makefile trunk/complement/explore/lib/mt/ut/Makefile trunk/complement/explore/lib/net/samples/httpclient/Makefile trunk/complement/explore/lib/net/ut/Makefile trunk/complement/explore/lib/sockios/perf/Makefile trunk/complement/explore/lib/sockios/ut/Makefile trunk/complement/explore/lib/stem/ut/Makefile trunk/complement/explore/lib/stem/ut/dl/Makefile Removed Paths: ------------- trunk/complement/explore/lib/mt/Makefile.mwccnlm trunk/complement/explore/lib/mt/gcc-libstd.mak trunk/complement/explore/lib/mt/mwccnlm.mak trunk/complement/explore/lib/mt/ut/gcc-libstd.mak Modified: trunk/complement/explore/Makefiles/gmake/app/gcc.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/app/gcc.mak 2008-06-10 05:12:41 UTC (rev 1893) +++ trunk/complement/explore/Makefiles/gmake/app/gcc.mak 2008-06-12 12:55:26 UTC (rev 1894) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <07/05/30 23:54:39 ptr> +# -*- Makefile -*- Time-stamp: <08/06/12 13:54:55 ptr> # # Copyright (c) 1997-1999, 2002, 2003, 2005-2007 # Petr Ovtchenkov @@ -62,14 +62,21 @@ endif ifndef WITHOUT_STLPORT -LDSEARCH += -L${STLPORT_LIB_DIR} - +ifeq (${STLPORT_LIB_DIR},) release-shared: STLPORT_LIB = -lstlport release-static: STLPORT_LIB = -Wl,-Bstatic -lstlport -Wl,-Bdynamic dbg-shared: STLPORT_LIB = -lstlportg dbg-static: STLPORT_LIB = -Wl,-Bstatic -lstlportg -Wl,-Bdynamic stldbg-shared: STLPORT_LIB = -lstlportstlg stldbg-static: STLPORT_LIB = -Wl,-Bstatic -lstlportstlg -Wl,-Bdynamic +else +release-shared: STLPORT_LIB = -L${STLPORT_LIB_DIR} -lstlport +release-static: STLPORT_LIB = -L${STLPORT_LIB_DIR} -Wl,-Bstatic -lstlport -Wl,-Bdynamic +dbg-shared: STLPORT_LIB = -L${STLPORT_LIB_DIR} -lstlportg +dbg-static: STLPORT_LIB = -L${STLPORT_LIB_DIR} -Wl,-Bstatic -lstlportg -Wl,-Bdynamic +stldbg-shared: STLPORT_LIB = -L${STLPORT_LIB_DIR} -lstlportstlg +stldbg-static: STLPORT_LIB = -L${STLPORT_LIB_DIR} -Wl,-Bstatic -lstlportstlg -Wl,-Bdynamic +endif ifeq ($(OSNAME),windows) LIB_VERSION = ${LIBMAJOR}.${LIBMINOR} Modified: trunk/complement/explore/Makefiles/gmake/app/top.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/app/top.mak 2008-06-10 05:12:41 UTC (rev 1893) +++ trunk/complement/explore/Makefiles/gmake/app/top.mak 2008-06-12 12:55:26 UTC (rev 1894) @@ -1,6 +1,6 @@ -# -*- makefile -*- Time-stamp: <07/06/08 23:35:09 ptr> +# -*- makefile -*- Time-stamp: <08/06/12 13:55:47 ptr> # -# Copyright (c) 1997-1999, 2002, 2003, 2005-2007 +# Copyright (c) 1997-1999, 2002, 2003, 2005-2008 # Petr Ovtchenkov # # Portion Copyright (c) 1999-2001 @@ -31,8 +31,6 @@ $(foreach prg,$(PRGNAMES),$(eval $(call prog_prog,$(prg)))) -LDFLAGS += ${LDSEARCH} - include ${RULESBASE}/gmake/app/${COMPILER_NAME}.mak include ${RULESBASE}/gmake/app/rules.mak include ${RULESBASE}/gmake/app/rules-install.mak Modified: trunk/complement/explore/Makefiles/gmake/extern.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/extern.mak 2008-06-10 05:12:41 UTC (rev 1893) +++ trunk/complement/explore/Makefiles/gmake/extern.mak 2008-06-12 12:55:26 UTC (rev 1894) @@ -31,10 +31,12 @@ # STLport library ifndef STLPORT_DIR +ifndef STLPORT_INCLUDE_DIR ifndef WITHOUT_STLPORT WITHOUT_STLPORT = 1 endif endif +endif ifdef STLPORT_DIR STLPORT_LIB_DIR ?= $(STLPORT_DIR)/${TARGET_NAME}lib Modified: trunk/complement/explore/Makefiles/gmake/icc.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/icc.mak 2008-06-10 05:12:41 UTC (rev 1893) +++ trunk/complement/explore/Makefiles/gmake/icc.mak 2008-06-12 12:55:26 UTC (rev 1894) @@ -1,6 +1,6 @@ -# Time-stamp: <07/03/08 21:41:21 ptr> +# Time-stamp: <08/06/12 14:57:58 ptr> # -# Copyright (c) 1997-1999, 2002, 2003, 2005-2007 +# Copyright (c) 1997-1999, 2002, 2003, 2005-2008 # Petr Ovtchenkov # # Portion Copyright (c) 1999-2001 Modified: trunk/complement/explore/Makefiles/gmake/lib/CC.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/lib/CC.mak 2008-06-10 05:12:41 UTC (rev 1893) +++ trunk/complement/explore/Makefiles/gmake/lib/CC.mak 2008-06-12 12:55:26 UTC (rev 1894) @@ -1,6 +1,6 @@ -# -*- makefile -*- Time-stamp: <07/03/08 21:39:22 ptr> +# -*- makefile -*- Time-stamp: <08/06/12 14:58:49 ptr> # -# Copyright (c) 1997-1999, 2002, 2003, 2005-2007 +# Copyright (c) 1997-1999, 2002, 2003, 2005-2008 # Petr Ovtchenkov # # Portion Copyright (c) 1999-2001 @@ -11,12 +11,9 @@ OPT += -xcode=pic32 -dbg-shared: LDFLAGS += -G -Qoption ld -z,initfirst -h$(SO_NAME_DBGxx) ${LDSEARCH} ${NOSTDLIB} -stldbg-shared: LDFLAGS += -G -Qoption ld -z,initfirst -h$(SO_NAME_STLDBGxx) ${LDSEARCH} ${NOSTDLIB} -release-shared: LDFLAGS += -G -Qoption ld -z,initfirst -h$(SO_NAMExx) ${LDSEARCH} ${NOSTDLIB} -dbg-static: LDFLAGS += ${LDSEARCH} -stldbg-static: LDFLAGS += ${LDSEARCH} -release-static: LDFLAGS += ${LDSEARCH} +dbg-shared: LDFLAGS += -G -Qoption ld -z,initfirst -h$(SO_NAME_DBGxx) ${NOSTDLIB} +stldbg-shared: LDFLAGS += -G -Qoption ld -z,initfirst -h$(SO_NAME_STLDBGxx) ${NOSTDLIB} +release-shared: LDFLAGS += -G -Qoption ld -z,initfirst -h$(SO_NAMExx) ${NOSTDLIB} DEPENDS_COLLECTION_SUNPRO := $(DEPENDS_COLLECTION).sunpro Modified: trunk/complement/explore/Makefiles/gmake/lib/aCC.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/lib/aCC.mak 2008-06-10 05:12:41 UTC (rev 1893) +++ trunk/complement/explore/Makefiles/gmake/lib/aCC.mak 2008-06-12 12:55:26 UTC (rev 1894) @@ -1,6 +1,6 @@ -# -*- makefile -*- Time-stamp: <07/05/31 00:50:40 ptr> +# -*- makefile -*- Time-stamp: <08/06/12 14:59:23 ptr> # -# Copyright (c) 1997-1999, 2002, 2003, 2005-2007 +# Copyright (c) 1997-1999, 2002, 2003, 2005-2008 # Petr Ovtchenkov # # Portion Copyright (c) 1999-2001 @@ -9,6 +9,6 @@ # Licensed under the Academic Free License version 3.0 # -dbg-shared: LDFLAGS += -b +nostl -Wl,+h$(SO_NAME_DBGxx) ${LDSEARCH} -stldbg-shared: LDFLAGS += -b +nostl -Wl,+h$(SO_NAME_STLDBGxx) ${LDSEARCH} -release-shared: LDFLAGS += -b +nostl -Wl,+h$(SO_NAMExx) ${LDSEARCH} +dbg-shared: LDFLAGS += -b +nostl -Wl,+h$(SO_NAME_DBGxx) +stldbg-shared: LDFLAGS += -b +nostl -Wl,+h$(SO_NAME_STLDBGxx) +release-shared: LDFLAGS += -b +nostl -Wl,+h$(SO_NAMExx) Modified: trunk/complement/explore/Makefiles/gmake/lib/gcc.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/lib/gcc.mak 2008-06-10 05:12:41 UTC (rev 1893) +++ trunk/complement/explore/Makefiles/gmake/lib/gcc.mak 2008-06-12 12:55:26 UTC (rev 1894) @@ -1,6 +1,6 @@ -# -*- makefile -*- Time-stamp: <07/05/31 00:55:13 ptr> +# -*- makefile -*- Time-stamp: <08/06/12 14:08:48 ptr> # -# Copyright (c) 1997-1999, 2002, 2003, 2005-2007 +# Copyright (c) 1997-1999, 2002, 2003, 2005-2008 # Petr Ovtchenkov # # Portion Copyright (c) 1999-2001 @@ -71,11 +71,16 @@ endif ifndef WITHOUT_STLPORT -LDSEARCH += -L${STLPORT_LIB_DIR} +ifeq (${STLPORT_LIB_DIR},) release-shared: STLPORT_LIB = -lstlport dbg-shared: STLPORT_LIB = -lstlportg stldbg-shared: STLPORT_LIB = -lstlportstlg +else +release-shared: STLPORT_LIB = -L${STLPORT_LIB_DIR} -lstlport +dbg-shared: STLPORT_LIB = -L${STLPORT_LIB_DIR} -lstlportg +stldbg-shared: STLPORT_LIB = -L${STLPORT_LIB_DIR} -lstlportstlg +endif ifeq ($(OSNAME),windows) LIB_VERSION = ${LIBMAJOR}.${LIBMINOR} @@ -196,64 +201,52 @@ endif ifeq ($(OSNAME),hp-ux) -dbg-shared: LDFLAGS += -shared -Wl,-dynamic -Wl,+h$(SO_NAME_DBGxx) ${LDSEARCH} -stldbg-shared: LDFLAGS += -shared -Wl,-dynamic -Wl,+h$(SO_NAME_STLDBGxx) ${LDSEARCH} -release-shared: LDFLAGS += -shared -Wl,-dynamic -Wl,+h$(SO_NAMExx) ${LDSEARCH} +dbg-shared: LDFLAGS += -shared -Wl,-dynamic -Wl,+h$(SO_NAME_DBGxx) +stldbg-shared: LDFLAGS += -shared -Wl,-dynamic -Wl,+h$(SO_NAME_STLDBGxx) +release-shared: LDFLAGS += -shared -Wl,-dynamic -Wl,+h$(SO_NAMExx) endif ifeq ($(OSNAME),sunos) -dbg-shared: LDFLAGS += -shared -Wl,-h$(SO_NAME_DBGxx) ${NOSTDLIB} ${LDSEARCH} -stldbg-shared: LDFLAGS += -shared -Wl,-h$(SO_NAME_STLDBGxx) ${NOSTDLIB} ${LDSEARCH} -release-shared: LDFLAGS += -shared -Wl,-h$(SO_NAMExx) ${NOSTDLIB} ${LDSEARCH} -dbg-static: LDFLAGS += ${LDSEARCH} -stldbg-static: LDFLAGS += ${LDSEARCH} -release-static: LDFLAGS += ${LDSEARCH} +dbg-shared: LDFLAGS += -shared -Wl,-h$(SO_NAME_DBGxx) ${NOSTDLIB} +stldbg-shared: LDFLAGS += -shared -Wl,-h$(SO_NAME_STLDBGxx) ${NOSTDLIB} +release-shared: LDFLAGS += -shared -Wl,-h$(SO_NAMExx) ${NOSTDLIB} endif ifeq ($(OSNAME),linux) -dbg-shared: LDFLAGS += -shared -Wl,-h$(SO_NAME_DBGxx) ${NOSTDLIB} ${LDSEARCH} -stldbg-shared: LDFLAGS += -shared -Wl,-h$(SO_NAME_STLDBGxx) ${NOSTDLIB} ${LDSEARCH} -release-shared: LDFLAGS += -shared -Wl,-h$(SO_NAMExx) ${NOSTDLIB} ${LDSEARCH} -dbg-static: LDFLAGS += ${LDSEARCH} -stldbg-static: LDFLAGS += ${LDSEARCH} -release-static: LDFLAGS += ${LDSEARCH} +dbg-shared: LDFLAGS += -shared -Wl,-h$(SO_NAME_DBGxx) ${NOSTDLIB} +stldbg-shared: LDFLAGS += -shared -Wl,-h$(SO_NAME_STLDBGxx) ${NOSTDLIB} +release-shared: LDFLAGS += -shared -Wl,-h$(SO_NAMExx) ${NOSTDLIB} endif ifeq ($(OSNAME),windows) dbg-shared: LDFLAGS += -shared -Wl,--out-implib=${LIB_NAME_OUT_DBG},--enable-auto-image-base stldbg-shared: LDFLAGS += -shared -Wl,--out-implib=${LIB_NAME_OUT_STLDBG},--enable-auto-image-base release-shared: LDFLAGS += -shared -Wl,--out-implib=${LIB_NAME_OUT},--enable-auto-image-base -dbg-static: LDFLAGS += -static ${LDSEARCH} -stldbg-static: LDFLAGS += -static ${LDSEARCH} -release-static: LDFLAGS += -static ${LDSEARCH} +dbg-static: LDFLAGS += -static +stldbg-static: LDFLAGS += -static +release-static: LDFLAGS += -static endif ifeq ($(OSNAME),freebsd) -dbg-shared: LDFLAGS += -shared -Wl,-h$(SO_NAME_DBGxx) ${NOSTDLIB} ${LDSEARCH} -stldbg-shared: LDFLAGS += -shared -Wl,-h$(SO_NAME_STLDBGxx) ${NOSTDLIB} ${LDSEARCH} -release-shared: LDFLAGS += -shared -Wl,-h$(SO_NAMExx) ${NOSTDLIB} ${LDSEARCH} -dbg-static: LDFLAGS += ${LDSEARCH} -stldbg-static: LDFLAGS += ${LDSEARCH} -release-static: LDFLAGS += ${LDSEARCH} +dbg-shared: LDFLAGS += -shared -Wl,-h$(SO_NAME_DBGxx) ${NOSTDLIB} +stldbg-shared: LDFLAGS += -shared -Wl,-h$(SO_NAME_STLDBGxx) ${NOSTDLIB} +release-shared: LDFLAGS += -shared -Wl,-h$(SO_NAMExx) ${NOSTDLIB} endif ifeq ($(OSNAME),darwin) CURRENT_VERSION := ${MAJOR}.${MINOR}.${PATCH} COMPATIBILITY_VERSION := $(CURRENT_VERSION) -dbg-shared: LDFLAGS += -dynamic -dynamiclib -compatibility_version $(COMPATIBILITY_VERSION) -current_version $(CURRENT_VERSION) -install_name $(SO_NAME_DBGxx) ${LDSEARCH} ${NOSTDLIB} -stldbg-shared: LDFLAGS += -dynamic -dynamiclib -compatibility_version $(COMPATIBILITY_VERSION) -current_version $(CURRENT_VERSION) -install_name $(SO_NAME_STLDBGxx) ${LDSEARCH} ${NOSTDLIB} -release-shared: LDFLAGS += -dynamic -dynamiclib -compatibility_version $(COMPATIBILITY_VERSION) -current_version $(CURRENT_VERSION) -install_name $(SO_NAMExx) ${LDSEARCH} ${NOSTDLIB} -dbg-static: LDFLAGS += -staticlib ${LDSEARCH} -stldbg-static: LDFLAGS += -staticlib ${LDSEARCH} -release-static: LDFLAGS += -staticlib ${LDSEARCH} +dbg-shared: LDFLAGS += -dynamic -dynamiclib -compatibility_version $(COMPATIBILITY_VERSION) -current_version $(CURRENT_VERSION) -install_name $(SO_NAME_DBGxx) ${NOSTDLIB} +stldbg-shared: LDFLAGS += -dynamic -dynamiclib -compatibility_version $(COMPATIBILITY_VERSION) -current_version $(CURRENT_VERSION) -install_name $(SO_NAME_STLDBGxx) ${NOSTDLIB} +release-shared: LDFLAGS += -dynamic -dynamiclib -compatibility_version $(COMPATIBILITY_VERSION) -current_version $(CURRENT_VERSION) -install_name $(SO_NAMExx) ${NOSTDLIB} +dbg-static: LDFLAGS += -staticlib +stldbg-static: LDFLAGS += -staticlib +release-static: LDFLAGS += -staticlib endif ifeq ($(OSNAME),openbsd) -dbg-shared: LDFLAGS += -shared -Wl,-soname -Wl,$(SO_NAME_DBGxx) ${NOSTDLIB} ${LDSEARCH} -stldbg-shared: LDFLAGS += -shared -Wl,-soname -Wl,$(SO_NAME_STLDBGxx) ${NOSTDLIB} ${LDSEARCH} -release-shared: LDFLAGS += -shared -Wl,-soname -Wl,$(SO_NAMExx) ${NOSTDLIB} ${LDSEARCH} -dbg-static: LDFLAGS += ${LDSEARCH} -stldbg-static: LDFLAGS += ${LDSEARCH} -release-static: LDFLAGS += ${LDSEARCH} +dbg-shared: LDFLAGS += -shared -Wl,-soname -Wl,$(SO_NAME_DBGxx) ${NOSTDLIB} +stldbg-shared: LDFLAGS += -shared -Wl,-soname -Wl,$(SO_NAME_STLDBGxx) ${NOSTDLIB} +release-shared: LDFLAGS += -shared -Wl,-soname -Wl,$(SO_NAMExx) ${NOSTDLIB} endif Modified: trunk/complement/explore/Makefiles/gmake/lib/icc.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/lib/icc.mak 2008-06-10 05:12:41 UTC (rev 1893) +++ trunk/complement/explore/Makefiles/gmake/lib/icc.mak 2008-06-12 12:55:26 UTC (rev 1894) @@ -1,6 +1,6 @@ -# -*- makefile -*- Time-stamp: <07/03/08 21:37:08 ptr> +# -*- makefile -*- Time-stamp: <08/06/12 15:00:07 ptr> # -# Copyright (c) 1997-1999, 2002, 2003, 2005-2007 +# Copyright (c) 1997-1999, 2002, 2003, 2005-2008 # Petr Ovtchenkov # # Portion Copyright (c) 1999-2001 @@ -9,19 +9,11 @@ # Licensed under the Academic Free License version 3.0 # -# Oh, the commented below work for gmake 3.78.1 and above, -# but phrase without tag not work for it. Since gmake 3.79 -# tag with assignment fail, but work assignment for all tags -# (really that more correct). - OPT += -KPIC ifeq ($(OSNAME),linux) -dbg-shared: LDFLAGS += -shared -Wl,-h$(SO_NAME_DBGxx) ${LDSEARCH} -stldbg-shared: LDFLAGS += -shared -Wl,-h$(SO_NAME_STLDBGxx) ${LDSEARCH} -release-shared: LDFLAGS += -shared -Wl,-h$(SO_NAMExx) ${LDSEARCH} -dbg-static: LDFLAGS += ${LDSEARCH} -stldbg-static: LDFLAGS += ${LDSEARCH} -release-static: LDFLAGS += ${LDSEARCH} +dbg-shared: LDFLAGS += -shared -Wl,-h$(SO_NAME_DBGxx) +stldbg-shared: LDFLAGS += -shared -Wl,-h$(SO_NAME_STLDBGxx) +release-shared: LDFLAGS += -shared -Wl,-h$(SO_NAMExx) endif Modified: trunk/complement/explore/Makefiles/gmake/lib/vc6.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/lib/vc6.mak 2008-06-10 05:12:41 UTC (rev 1893) +++ trunk/complement/explore/Makefiles/gmake/lib/vc6.mak 2008-06-12 12:55:26 UTC (rev 1894) @@ -1,6 +1,6 @@ -# -*- makefile -*- Time-stamp: <07/03/08 21:35:57 ptr> +# -*- makefile -*- Time-stamp: <08/06/12 15:03:15 ptr> # -# Copyright (c) 1997-1999, 2002, 2003, 2005-2007 +# Copyright (c) 1997-1999, 2002, 2003, 2005-2008 # Petr Ovtchenkov # # Portion Copyright (c) 1999-2001 @@ -9,13 +9,7 @@ # Licensed under the Academic Free License version 3.0 # -# Oh, the commented below work for gmake 3.78.1 and above, -# but phrase without tag not work for it. Since gmake 3.79 -# tag with assignment fail, but work assignment for all tags -# (really that more correct). - LDLIBS ?= -LDSEARCH += /LIBPATH:"$(MSVC_LIB_DIR)" dbg-shared: OPT += /MDd stldbg-shared: OPT += /MDd @@ -30,11 +24,8 @@ stldbg-static: DEFS += /D_LIB -dbg-shared: LDFLAGS += /DLL ${LDSEARCH} -stldbg-shared: LDFLAGS += /DLL ${LDSEARCH} -release-shared: LDFLAGS += /DLL ${LDSEARCH} -dbg-static: LDFLAGS += ${LDSEARCH} -stldbg-static: LDFLAGS += ${LDSEARCH} -release-static: LDFLAGS += ${LDSEARCH} +dbg-shared: LDFLAGS += /DLL +stldbg-shared: LDFLAGS += /DLL +release-shared: LDFLAGS += /DLL -LDFLAGS += /VERSION:$(MAJOR).$(MINOR) +LDFLAGS += /LIBPATH:"$(MSVC_LIB_DIR)" /VERSION:$(MAJOR).$(MINOR) Modified: trunk/complement/explore/configure =================================================================== --- trunk/complement/explore/configure 2008-06-10 05:12:41 UTC (rev 1893) +++ trunk/complement/explore/configure 2008-06-12 12:55:26 UTC (rev 1894) @@ -40,6 +40,7 @@ --help print this help message and exit --with-stlport=<dir> use STLport in catalog <dir> + --with-stlport-headers=<dir> use STLport headers in catalog <dir> --without-stlport compile without STLport (default) --with-boost=<dir> use boost headers in catalog <dir> --with-system-boost use boost installed on this system @@ -82,6 +83,7 @@ } default_settings () { + : # if [ "$boost_set" = "" ]; then # write_option "${PWD}/external/boost" BOOST_DIR # fi @@ -140,6 +142,10 @@ write_option "$option" STLPORT_DIR stlport_set=y ;; + --with-stlport-headers=*) + write_option "$option" STLPORT_INCLUDE_DIR + stlport_set=y + ;; --without-stlport) write_option "1" WITHOUT_STLPORT stlport_set=y Modified: trunk/complement/explore/lib/DB/PgSQL/Makefile =================================================================== --- trunk/complement/explore/lib/DB/PgSQL/Makefile 2008-06-10 05:12:41 UTC (rev 1893) +++ trunk/complement/explore/lib/DB/PgSQL/Makefile 2008-06-12 12:55:26 UTC (rev 1894) @@ -1,14 +1,21 @@ -# -*- Makefile -*- Time-stamp: <03/09/25 12:02:31 ptr> +# -*- Makefile -*- Time-stamp: <08/06/12 15:09:05 ptr> SRCROOT := ../../.. -PG_INCLUDE := /opt/pgsql/include -PG_LIB := /opt/pgsql/lib +# PG_INCLUDE := /opt/pgsql/include +# PG_LIB_DIR := /opt/pgsql/lib include Makefile.inc include ${SRCROOT}/Makefiles/gmake/top.mak -INCLUDES += -I$(SRCROOT)/include -I${PG_INCLUDE} +INCLUDES += -I$(SRCROOT)/include -LDSEARCH += -L${PG_LIB} +ifneq (${PG_INCLUDE},) +INCLUDES += -I${PG_INCLUDE} +endif + +ifneq (${PG_LIB_DIR},) +LDFLAGS += -L${PG_LIB_DIR} +endif + LDLIBS = -lpq Modified: trunk/complement/explore/lib/exam/ut/Makefile =================================================================== --- trunk/complement/explore/lib/exam/ut/Makefile 2008-06-10 05:12:41 UTC (rev 1893) +++ trunk/complement/explore/lib/exam/ut/Makefile 2008-06-12 12:55:26 UTC (rev 1894) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <07/09/03 22:27:45 ptr> +# -*- Makefile -*- Time-stamp: <08/06/12 14:00:05 ptr> SRCROOT := ../../.. @@ -15,12 +15,12 @@ ifeq ($(OSNAME),linux) -release-shared: LDSEARCH += -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L$(LIBXMT_DIR)/${OUTPUT_DIR} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR}:$(LIBXMT_DIR)/${OUTPUT_DIR}:${STLPORT_LIB_DIR} +release-shared: LDFLAGS += -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L$(LIBXMT_DIR)/${OUTPUT_DIR} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR}:$(LIBXMT_DIR)/${OUTPUT_DIR}:${STLPORT_LIB_DIR} -dbg-shared: LDSEARCH += -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L$(LIBXMT_DIR)/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:$(LIBXMT_DIR)/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} +dbg-shared: LDFLAGS += -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L$(LIBXMT_DIR)/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:$(LIBXMT_DIR)/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} ifndef WITHOUT_STLPORT -stldbg-shared: LDSEARCH += -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L$(LIBXMT_DIR)/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:$(LIBXMT_DIR)/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} +stldbg-shared: LDFLAGS += -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L$(LIBXMT_DIR)/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:$(LIBXMT_DIR)/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} endif endif Modified: trunk/complement/explore/lib/janus/Makefile =================================================================== --- trunk/complement/explore/lib/janus/Makefile 2008-06-10 05:12:41 UTC (rev 1893) +++ trunk/complement/explore/lib/janus/Makefile 2008-06-12 12:55:26 UTC (rev 1894) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <07/02/07 12:28:46 ptr> +# -*- Makefile -*- Time-stamp: <08/06/12 15:26:16 ptr> SRCROOT := ../.. COMPILER_NAME := gcc @@ -12,7 +12,7 @@ LIBSOCK_DIR = ${CoMT_DIR}/lib/sockios LIBSTEM_DIR = ${CoMT_DIR}/lib/stem -LDSEARCH += -L${CoMT_LIB_DIR} -Wl,--rpath=${CoMT_LIB_DIR} +LDFLAGS += -L${CoMT_LIB_DIR} -Wl,--rpath=${CoMT_LIB_DIR} release-shared : LDLIBS = -lxmt -lsockios -lstem ifndef WITHOUT_STLPORT Modified: trunk/complement/explore/lib/janus/ut/Makefile =================================================================== --- trunk/complement/explore/lib/janus/ut/Makefile 2008-06-10 05:12:41 UTC (rev 1893) +++ trunk/complement/explore/lib/janus/ut/Makefile 2008-06-12 12:55:26 UTC (rev 1894) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <08/02/25 19:21:09 ptr> +# -*- Makefile -*- Time-stamp: <08/06/12 15:26:38 ptr> SRCROOT := ../../.. COMPILER_NAME := gcc @@ -20,12 +20,12 @@ ifeq ($(OSNAME),linux) -release-shared: LDSEARCH += -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L$(LIBXMT_DIR)/${OUTPUT_DIR} -L$(LIBSOCKIOS_DIR)/${OUTPUT_DIR} -L$(LIBSTEM_DIR)/${OUTPUT_DIR} -L$(LIBJANUS_DIR)/${OUTPUT_DIR} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR}:$(LIBXMT_DIR)/${OUTPUT_DIR}:${LIBSOCKIOS_DIR}/${OUTPUT_DIR}:${LIBSTEM_DIR}/${OUTPUT_DIR}:${LIBJANUS_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} +release-shared: LDFLAGS += -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L$(LIBXMT_DIR)/${OUTPUT_DIR} -L$(LIBSOCKIOS_DIR)/${OUTPUT_DIR} -L$(LIBSTEM_DIR)/${OUTPUT_DIR} -L$(LIBJANUS_DIR)/${OUTPUT_DIR} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR}:$(LIBXMT_DIR)/${OUTPUT_DIR}:${LIBSOCKIOS_DIR}/${OUTPUT_DIR}:${LIBSTEM_DIR}/${OUTPUT_DIR}:${LIBJANUS_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} -dbg-shared: LDSEARCH += -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L$(LIBXMT_DIR)/${OUTPUT_DIR_DBG} -L$(LIBSOCKIOS_DIR)/${OUTPUT_DIR_DBG} -L$(LIBSTEM_DIR)/${OUTPUT_DIR_DBG} -L$(LIBJANUS_DIR)/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:$(LIBXMT_DIR)/${OUTPUT_DIR_DBG}:${LIBSOCKIOS_DIR}/${OUTPUT_DIR_DBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_DBG}:${LIBJANUS_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} +dbg-shared: LDFLAGS += -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L$(LIBXMT_DIR)/${OUTPUT_DIR_DBG} -L$(LIBSOCKIOS_DIR)/${OUTPUT_DIR_DBG} -L$(LIBSTEM_DIR)/${OUTPUT_DIR_DBG} -L$(LIBJANUS_DIR)/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:$(LIBXMT_DIR)/${OUTPUT_DIR_DBG}:${LIBSOCKIOS_DIR}/${OUTPUT_DIR_DBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_DBG}:${LIBJANUS_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} ifndef WITHOUT_STLPORT -stldbg-shared: LDSEARCH += -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L$(LIBXMT_DIR)/${OUTPUT_DIR_STLDBG} -L$(LIBSOCKIOS_DIR)/${OUTPUT_DIR_STLDBG} -L$(LIBSTEM_DIR)/${OUTPUT_DIR_STLDBG} -L$(LIBJANUS_DIR)/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:$(LIBXMT_DIR)/${OUTPUT_DIR_STLDBG}:${LIBSOCKIOS_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBJANUS_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} +stldbg-shared: LDFLAGS += -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L$(LIBXMT_DIR)/${OUTPUT_DIR_STLDBG} -L$(LIBSOCKIOS_DIR)/${OUTPUT_DIR_STLDBG} -L$(LIBSTEM_DIR)/${OUTPUT_DIR_STLDBG} -L$(LIBJANUS_DIR)/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:$(LIBXMT_DIR)/${OUTPUT_DIR_STLDBG}:${LIBSOCKIOS_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBJANUS_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} endif endif Modified: trunk/complement/explore/lib/misc/ut/Makefile =================================================================== --- trunk/complement/explore/lib/misc/ut/Makefile 2008-06-10 05:12:41 UTC (rev 1893) +++ trunk/complement/explore/lib/misc/ut/Makefile 2008-06-12 12:55:26 UTC (rev 1894) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <07/11/23 23:30:57 ptr> +# -*- Makefile -*- Time-stamp: <08/06/12 15:20:10 ptr> SRCROOT := ../../.. @@ -14,24 +14,22 @@ ifeq ($(OSNAME),linux) -release-shared: LDSEARCH += -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L${LIBXMT_DIR}/${OUTPUT_DIR} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR}:${LIBXMT_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} +release-shared: LDFLAGS += -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L${LIBXMT_DIR}/${OUTPUT_DIR} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR}:${LIBXMT_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} -dbg-shared: LDSEARCH += -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBXMT_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBXMT_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} +dbg-shared: LDFLAGS += -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBXMT_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBXMT_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} ifndef WITHOUT_STLPORT -stldbg-shared: LDSEARCH += -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBXMT_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBXMT_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} +stldbg-shared: LDFLAGS += -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBXMT_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBXMT_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} endif endif ifeq ($(OSNAME),openbsd) -release-shared: LDSEARCH += -Wl,-R:${STLPORT_LIB_DIR} - -dbg-shared: LDSEARCH += -Wl,-R:${STLPORT_LIB_DIR} - ifndef WITHOUT_STLPORT -stldbg-shared: LDSEARCH += -Wl,-R:${STLPORT_LIB_DIR} +release-shared: LDFLAGS += -Wl,-R:${STLPORT_LIB_DIR} +dbg-shared: LDFLAGS += -Wl,-R:${STLPORT_LIB_DIR} +stldbg-shared: LDFLAGS += -Wl,-R:${STLPORT_LIB_DIR} endif endif Deleted: trunk/complement/explore/lib/mt/Makefile.mwccnlm =================================================================== --- trunk/complement/explore/lib/mt/Makefile.mwccnlm 2008-06-10 05:12:41 UTC (rev 1893) +++ trunk/complement/explore/lib/mt/Makefile.mwccnlm 2008-06-12 12:55:26 UTC (rev 1894) @@ -1,32 +0,0 @@ -# -*- Makefile -*- Time-stamp: <03/06/13 16:51:25 ptr> -# $Id$ - -BASEDIR := $(shell xtmp=`pwd`; xtmp=`dirname $$xtmp`; dirname $$xtmp) -LIBDIR := $(shell xtmp=`pwd`; dirname $$xtmp) - -COMPILER_NAME = mwccnlm -include $(BASEDIR)/lib/mt/Makefile.inc - -all: all-release all-debug - -install: install-dbg-shared install-stldbg-shared install-release-shared - -all-shared: release-shared dbg-shared stldbg-shared - -all-debug: dbg-shared stldbg-shared - -all-release: release-shared - -include ${BASEDIR}/Makefiles/lib/Makefile.inc - -INCLUDES += -I$(STLPORT_INCLUDE_DIR) -I../../include - -release-shared: LDSEARCH = -L${STLPORT_LIB_DIR} -stldbg-shared: LDSEARCH = -L${STLPORT_LIB_DIR} -dbg-shared: LDSEARCH = -L${STLPORT_LIB_DIR} - -release-shared : LDLIBS = -lstlport_gcc -stldbg-shared : LDLIBS = -lstlport_gcc_stldebug -dbg-shared : LDLIBS = -lstlport_gcc - - Deleted: trunk/complement/explore/lib/mt/gcc-libstd.mak =================================================================== --- trunk/complement/explore/lib/mt/gcc-libstd.mak 2008-06-10 05:12:41 UTC (rev 1893) +++ trunk/complement/explore/lib/mt/gcc-libstd.mak 2008-06-12 12:55:26 UTC (rev 1894) @@ -1,13 +0,0 @@ -# -*- Makefile -*- Time-stamp: <03/09/25 12:02:31 ptr> -# $Id$ - -SRCROOT := ../.. -COMPILER_NAME := gcc - -ALL_TAGS = release-shared dbg-shared - -include Makefile.inc -include ${SRCROOT}/Makefiles/top.mak - -INCLUDES += -I$(SRCROOT)/include - Deleted: trunk/complement/explore/lib/mt/mwccnlm.mak =================================================================== --- trunk/complement/explore/lib/mt/mwccnlm.mak 2008-06-10 05:12:41 UTC (rev 1893) +++ trunk/complement/explore/lib/mt/mwccnlm.mak 2008-06-12 12:55:26 UTC (rev 1894) @@ -1,11 +0,0 @@ -# -*- Makefile -*- Time-stamp: <05/06/03 21:45:55 ptr> -# $Id$ - -SRCROOT := ../.. -COMPILER_NAME := mwccnlm - -STLPORT_DIR := ../../../Novell-STLP/STLport -include Makefile.inc -include ${SRCROOT}/Makefiles/top.mak - -INCLUDES += -I$(SRCROOT)/include -I$(STLPORT_INCLUDE_DIR) Modified: trunk/complement/explore/lib/mt/ut/Makefile =================================================================== --- trunk/complement/explore/lib/mt/ut/Makefile 2008-06-10 05:12:41 UTC (rev 1893) +++ trunk/complement/explore/lib/mt/ut/Makefile 2008-06-12 12:55:26 UTC (rev 1894) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <07/08/03 22:38:12 ptr> +# -*- Makefile -*- Time-stamp: <08/06/12 15:11:40 ptr> SRCROOT := ../../.. @@ -27,24 +27,24 @@ ifeq ($(OSNAME),linux) -release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L${LIBFS_DIR}/${OUTPUT_DIR} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR}:${LIBEXAM_DIR}/${OUTPUT_DIR}:${LIBFS_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} +release-shared: LDFLAGS += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L${LIBFS_DIR}/${OUTPUT_DIR} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR}:${LIBEXAM_DIR}/${OUTPUT_DIR}:${LIBFS_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} -dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBFS_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBFS_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} +dbg-shared: LDFLAGS += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBFS_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBFS_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} ifndef WITHOUT_STLPORT -stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBFS_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBFS_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} +stldbg-shared: LDFLAGS += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBFS_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBFS_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} endif endif ifeq ($(OSNAME),openbsd) -release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -Wl,-R${LIBMT_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} +release-shared: LDFLAGS += -L${LIBMT_DIR}/${OUTPUT_DIR} -Wl,-R${LIBMT_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} -dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -Wl,-R${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} +dbg-shared: LDFLAGS += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -Wl,-R${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} ifndef WITHOUT_STLPORT -stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -Wl,-R${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} +stldbg-shared: LDFLAGS += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -Wl,-R${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} endif endif Deleted: trunk/complement/explore/lib/mt/ut/gcc-libstd.mak =================================================================== --- trunk/complement/explore/lib/mt/ut/gcc-libstd.mak 2008-06-10 05:12:41 UTC (rev 1893) +++ trunk/complement/explore/lib/mt/ut/gcc-libstd.mak 2008-06-12 12:55:26 UTC (rev 1894) @@ -1,48 +0,0 @@ -# -*- Makefile -*- Time-stamp: <03/11/21 08:02:55 ptr> -# $Id$ - -SRCROOT := ../../.. -COMPILER_NAME := gcc -ALL_TAGS = release-shared dbg-shared - -include Makefile.inc -include ${SRCROOT}/Makefiles/top.mak - - -INCLUDES += -I$(SRCROOT)/include -I$(BOOST_INCLUDE_DIR) - -# temporary, before dums fix strings: -# DEFS += -D_STLP_DONT_USE_TEMPLATE_EXPRESSION - -ifeq ($(OSNAME),linux) -release-shared: LDSEARCH = -L${CoMT_LIB_DIR} -Wl,--rpath=${CoMT_LIB_DIR} -stldbg-shared: LDSEARCH = -L${CoMT_LIB_DIR_STLDBG} -Wl,--rpath=${CoMT_LIB_DIR_STLDBG} -dbg-shared: LDSEARCH = -L${CoMT_LIB_DIR_DBG} -Wl,--rpath=${CoMT_LIB_DIR_DBG} -endif - -ifeq ($(OSNAME),openbsd) -release-shared: LDSEARCH = -L${CoMT_LIB_DIR} -Wl,-R${CoMT_LIB_DIR} -stldbg-shared: LDSEARCH = -L${CoMT_LIB_DIR_STLDBG} -Wl,-R${CoMT_LIB_DIR_STLDBG} -dbg-shared: LDSEARCH = -L${CoMT_LIB_DIR_DBG} -Wl,-R${CoMT_LIB_DIR_DBG} -endif - -release-shared : LDLIBS = -lxmt_gcc -lboost_test_utf_gcc -stldbg-shared : LDLIBS = -lxmt_gcc_stl-g -lboost_test_utf_gcc_stl-g -dbg-shared : LDLIBS = -lxmt_gcc-g -lboost_test_utf_gcc-g - -ifeq ($(OSNAME),freebsd) -release-shared : LDLIBS += -lthr -stldbg-shared : LDLIBS += -lthr -dbg-shared : LDLIBS += -lthr -endif - -ifeq ($(OSNAME),sunos) -release-shared : LDLIBS += -lrt -stldbg-shared : LDLIBS += -lrt -dbg-shared : LDLIBS += -lrt -endif - -ifeq ($(OSNAME),openbsd) -release-shared: LDLIBS = -lxmt_gcc -lboost_test_utf_gcc -endif - Modified: trunk/complement/explore/lib/net/samples/httpclient/Makefile =================================================================== --- trunk/complement/explore/lib/net/samples/httpclient/Makefile 2008-06-10 05:12:41 UTC (rev 1893) +++ trunk/complement/explore/lib/net/samples/httpclient/Makefile 2008-06-12 12:55:26 UTC (rev 1894) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <07/02/21 15:30:59 ptr> +# -*- Makefile -*- Time-stamp: <08/06/12 15:27:19 ptr> SRCROOT := ../../../.. # CoMT_DIR := ../../external/complement/explore @@ -18,15 +18,15 @@ ifeq ($(OSNAME),linux) -release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L${LIBSOCK_DIR}/${OUTPUT_DIR} -L${LIBSTEM_DIR}/${OUTPUT_DIR} -L${LIBBOOSTFS_DIR}/${OUTPUT_DIR} -L${LIBBOOSTRE_DIR}/${OUTPUT_DIR} -L${LIBNET_DIR}/${OUTPUT_DIR} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR}:${LIBEXAM_DIR}/${OUTPUT_DIR}:${LIBSOCK_DIR}/${OUTPUT_DIR}:${LIBSTEM_DIR}/${OUTPUT_DIR}:${LIBBOOSTFS_DIR}/${OUTPUT_DIR}:${LIBBOOSTRE_DIR}/${OUTPUT_DIR}:${LIBNET_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} +release-shared: LDFLAGS += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L${LIBSOCK_DIR}/${OUTPUT_DIR} -L${LIBSTEM_DIR}/${OUTPUT_DIR} -L${LIBBOOSTFS_DIR}/${OUTPUT_DIR} -L${LIBBOOSTRE_DIR}/${OUTPUT_DIR} -L${LIBNET_DIR}/${OUTPUT_DIR} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR}:${LIBEXAM_DIR}/${OUTPUT_DIR}:${LIBSOCK_DIR}/${OUTPUT_DIR}:${LIBSTEM_DIR}/${OUTPUT_DIR}:${LIBBOOSTFS_DIR}/${OUTPUT_DIR}:${LIBBOOSTRE_DIR}/${OUTPUT_DIR}:${LIBNET_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} ifndef WITHOUT_STLPORT -stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBBOOSTFS_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBBOOSTRE_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBNET_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBBOOSTFS_DIR}/${OUTPUT_DIR_STLDBG}:${LIBBOOSTRE_DIR}/${OUTPUT_DIR_STLDBG}:${LIBNET_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} +stldbg-shared: LDFLAGS += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBBOOSTFS_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBBOOSTRE_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBNET_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBBOOSTFS_DIR}/${OUTPUT_DIR_STLDBG}:${LIBBOOSTRE_DIR}/${OUTPUT_DIR_STLDBG}:${LIBNET_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} endif -dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_DBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_DBG} -L${LIBBOOSTFS_DIR}/${OUTPUT_DIR_DBG} -L${LIBBOOSTRE_DIR}/${OUTPUT_DIR_DBG} -L${LIBNET_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_DBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_DBG}:${LIBBOOSTFS_DIR}/${OUTPUT_DIR_DBG}:${LIBBOOSTRE_DIR}/${OUTPUT_DIR_DBG}:${LIBNET_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} +dbg-shared: LDFLAGS += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_DBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_DBG} -L${LIBBOOSTFS_DIR}/${OUTPUT_DIR_DBG} -L${LIBBOOSTRE_DIR}/${OUTPUT_DIR_DBG} -L${LIBNET_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_DBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_DBG}:${LIBBOOSTFS_DIR}/${OUTPUT_DIR_DBG}:${LIBBOOSTRE_DIR}/${OUTPUT_DIR_DBG}:${LIBNET_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} endif Modified: trunk/complement/explore/lib/net/ut/Makefile =================================================================== --- trunk/complement/explore/lib/net/ut/Makefile 2008-06-10 05:12:41 UTC (rev 1893) +++ trunk/complement/explore/lib/net/ut/Makefile 2008-06-12 12:55:26 UTC (rev 1894) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <07/02/21 15:30:59 ptr> +# -*- Makefile -*- Time-stamp: <08/06/12 15:17:05 ptr> SRCROOT := ../../.. # CoMT_DIR := ../../external/complement/explore @@ -18,15 +18,15 @@ ifeq ($(OSNAME),linux) -release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L${LIBSOCK_DIR}/${OUTPUT_DIR} -L${LIBSTEM_DIR}/${OUTPUT_DIR} -L${LIBBOOSTFS_DIR}/${OUTPUT_DIR} -L${LIBBOOSTRE_DIR}/${OUTPUT_DIR} -L${LIBNET_DIR}/${OUTPUT_DIR} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR}:${LIBEXAM_DIR}/${OUTPUT_DIR}:${LIBSOCK_DIR}/${OUTPUT_DIR}:${LIBSTEM_DIR}/${OUTPUT_DIR}:${LIBBOOSTFS_DIR}/${OUTPUT_DIR}:${LIBBOOSTRE_DIR}/${OUTPUT_DIR}:${LIBNET_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} +release-shared: LDFLAGS += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L${LIBSOCK_DIR}/${OUTPUT_DIR} -L${LIBSTEM_DIR}/${OUTPUT_DIR} -L${LIBBOOSTFS_DIR}/${OUTPUT_DIR} -L${LIBBOOSTRE_DIR}/${OUTPUT_DIR} -L${LIBNET_DIR}/${OUTPUT_DIR} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR}:${LIBEXAM_DIR}/${OUTPUT_DIR}:${LIBSOCK_DIR}/${OUTPUT_DIR}:${LIBSTEM_DIR}/${OUTPUT_DIR}:${LIBBOOSTFS_DIR}/${OUTPUT_DIR}:${LIBBOOSTRE_DIR}/${OUTPUT_DIR}:${LIBNET_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} ifndef WITHOUT_STLPORT -stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBBOOSTFS_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBBOOSTRE_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBNET_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBBOOSTFS_DIR}/${OUTPUT_DIR_STLDBG}:${LIBBOOSTRE_DIR}/${OUTPUT_DIR_STLDBG}:${LIBNET_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} +stldbg-shared: LDFLAGS += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBBOOSTFS_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBBOOSTRE_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBNET_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBBOOSTFS_DIR}/${OUTPUT_DIR_STLDBG}:${LIBBOOSTRE_DIR}/${OUTPUT_DIR_STLDBG}:${LIBNET_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} endif -dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_DBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_DBG} -L${LIBBOOSTFS_DIR}/${OUTPUT_DIR_DBG} -L${LIBBOOSTRE_DIR}/${OUTPUT_DIR_DBG} -L${LIBNET_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_DBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_DBG}:${LIBBOOSTFS_DIR}/${OUTPUT_DIR_DBG}:${LIBBOOSTRE_DIR}/${OUTPUT_DIR_DBG}:${LIBNET_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} +dbg-shared: LDFLAGS += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_DBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_DBG} -L${LIBBOOSTFS_DIR}/${OUTPUT_DIR_DBG} -L${LIBBOOSTRE_DIR}/${OUTPUT_DIR_DBG} -L${LIBNET_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_DBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_DBG}:${LIBBOOSTFS_DIR}/${OUTPUT_DIR_DBG}:${LIBBOOSTRE_DIR}/${OUTPUT_DIR_DBG}:${LIBNET_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} endif Modified: trunk/complement/explore/lib/sockios/perf/Makefile =================================================================== --- trunk/complement/explore/lib/sockios/perf/Makefile 2008-06-10 05:12:41 UTC (rev 1893) +++ trunk/complement/explore/lib/sockios/perf/Makefile 2008-06-12 12:55:26 UTC (rev 1894) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <07/09/05 22:48:46 ptr> +# -*- Makefile -*- Time-stamp: <08/06/12 15:23:48 ptr> SRCROOT := ../../.. @@ -18,11 +18,11 @@ # LIBUTF_DIR = ${CoMT_DIR}/../extern/custom/boost/libs/test/unit_test_framework ifeq ($(OSNAME),linux) -release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L${LIBSOCK_DIR}/${OUTPUT_DIR} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR}:${LIBEXAM_DIR}/${OUTPUT_DIR}:${LIBSOCK_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} +release-shared: LDFLAGS += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L${LIBSOCK_DIR}/${OUTPUT_DIR} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR}:${LIBEXAM_DIR}/${OUTPUT_DIR}:${LIBSOCK_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} ifndef WITHOUT_STLPORT -stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} +stldbg-shared: LDFLAGS += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} endif -dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} +dbg-shared: LDFLAGS += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} endif release-shared : LDLIBS = -lxmt -lsockios -lexam Modified: trunk/complement/explore/lib/sockios/ut/Makefile =================================================================== --- trunk/complement/explore/lib/sockios/ut/Makefile 2008-06-10 05:12:41 UTC (rev 1893) +++ trunk/complement/explore/lib/sockios/ut/Makefile 2008-06-12 12:55:26 UTC (rev 1894) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <07/08/03 23:06:43 ptr> +# -*- Makefile -*- Time-stamp: <08/06/12 15:24:26 ptr> SRCROOT := ../../.. @@ -18,11 +18,11 @@ # LIBUTF_DIR = ${CoMT_DIR}/../extern/custom/boost/libs/test/unit_test_framework ifeq ($(OSNAME),linux) -release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L${LIBSOCK_DIR}/${OUTPUT_DIR} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR}:${LIBEXAM_DIR}/${OUTPUT_DIR}:${LIBSOCK_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} +release-shared: LDFLAGS += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L${LIBSOCK_DIR}/${OUTPUT_DIR} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR}:${LIBEXAM_DIR}/${OUTPUT_DIR}:${LIBSOCK_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} ifndef WITHOUT_STLPORT -stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} +stldbg-shared: LDFLAGS += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} endif -dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} +dbg-shared: LDFLAGS += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} endif release-shared : LDLIBS = -lxmt -lsockios -lexam Modified: trunk/complement/explore/lib/stem/ut/Makefile =================================================================== --- trunk/complement/explore/lib/stem/ut/Makefile 2008-06-10 05:12:41 UTC (rev 1893) +++ trunk/complement/explore/lib/stem/ut/Makefile 2008-06-12 12:55:26 UTC (rev 1894) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <07/08/03 23:55:05 ptr> +# -*- Makefile -*- Time-stamp: <08/06/12 15:25:10 ptr> SRCROOT := ../../.. @@ -19,15 +19,15 @@ ifeq ($(OSNAME),linux) -release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L${LIBSOCK_DIR}/${OUTPUT_DIR} -L${LIBSTEM_DIR}/${OUTPUT_DIR} -Wl,--rpath=./dl/${OUTPUT_DIR}:${LIBMT_DIR}/${OUTPUT_DIR}:${LIBEXAM_DIR}/${OUTPUT_DIR}:${LIBSOCK_DIR}/${OUTPUT_DIR}:${LIBSTEM_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} +release-shared: LDFLAGS += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L${LIBSOCK_DIR}/${OUTPUT_DIR} -L${LIBSTEM_DIR}/${OUTPUT_DIR} -Wl,--rpath=./dl/${OUTPUT_DIR}:${LIBMT_DIR}/${OUTPUT_DIR}:${LIBEXAM_DIR}/${OUTPUT_DIR}:${LIBSOCK_DIR}/${OUTPUT_DIR}:${LIBSTEM_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} ifndef WITHOUT_STLPORT -stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=./dl/${OUTPUT_DIR_STLDBG}:${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} +stldbg-shared: LDFLAGS += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=./dl/${OUTPUT_DIR_STLDBG}:${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} endif -dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_DBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=./dl/${OUTPUT_DIR_DBG}:${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_DBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} +dbg-shared: LDFLAGS += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_DBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=./dl/${OUTPUT_DIR_DBG}:${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_DBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} endif Modified: trunk/complement/explore/lib/stem/ut/dl/Makefile =================================================================== --- trunk/complement/explore/lib/stem/ut/dl/Makefile 2008-06-10 05:12:41 UTC (rev 1893) +++ trunk/complement/explore/lib/stem/ut/dl/Makefile 2008-06-12 12:55:26 UTC (rev 1894) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <07/08/03 23:59:51 ptr> +# -*- Makefile -*- Time-stamp: <08/06/12 15:25:51 ptr> SRCROOT := ../../../.. @@ -12,11 +12,11 @@ INCLUDES += -I$(SRCROOT)/include -#LDSEARCH = -L${STLPORT_LIB_DIR} -L${CoMT_LIB_DIR} -release-shared: LDSEARCH += -L${LIBSTEM_DIR}/${OUTPUT_DIR} -dbg-shared: LDSEARCH += -L${LIBSTEM_DIR}/${OUTPUT_DIR_DBG} +#LDFLAGS = -L${STLPORT_LIB_DIR} -L${CoMT_LIB_DIR} +release-shared: LDFLAGS += -L${LIBSTEM_DIR}/${OUTPUT_DIR} +dbg-shared: LDFLAGS += -L${LIBSTEM_DIR}/${OUTPUT_DIR_DBG} ifndef WITHOUT_STLPORT -stldbg-shared: LDSEARCH += -L${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG} +stldbg-shared: LDFLAGS += -L${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG} endif #release-shared : LDLIBS = -lxmt -lsockios -lstem -lboost_test_utf This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2008-06-10 05:12:43
|
Revision: 1893 http://complement.svn.sourceforge.net/complement/?rev=1893&view=rev Author: complement Date: 2008-06-09 22:12:41 -0700 (Mon, 09 Jun 2008) Log Message: ----------- merge with local changes; nothing significant Modified Paths: -------------- branches/complement-sockios/explore/include/sockios/sp.cc branches/complement-sockios/explore/include/sockios/sp.h branches/complement-sockios/explore/lib/sockios/ut/sockios2_test.cc branches/complement-sockios/explore/lib/sockios/ut/sockios_test_suite.cc Modified: branches/complement-sockios/explore/include/sockios/sp.cc =================================================================== --- branches/complement-sockios/explore/include/sockios/sp.cc 2008-06-09 18:31:16 UTC (rev 1892) +++ branches/complement-sockios/explore/include/sockios/sp.cc 2008-06-10 05:12:41 UTC (rev 1893) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/06/09 22:13:05 yeti> +// -*- C++ -*- Time-stamp: <08/06/09 23:51:34 ptr> /* * Copyright (c) 2008 Modified: branches/complement-sockios/explore/include/sockios/sp.h =================================================================== --- branches/complement-sockios/explore/include/sockios/sp.h 2008-06-09 18:31:16 UTC (rev 1892) +++ branches/complement-sockios/explore/include/sockios/sp.h 2008-06-10 05:12:41 UTC (rev 1893) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/06/09 22:17:26 yeti> +// -*- C++ -*- Time-stamp: <08/06/10 00:01:15 ptr> /* * Copyright (c) 2008 @@ -596,7 +596,7 @@ sockstream_t* s; sockbuf_t* b; } s; - socks_processor_t *p; + socks_processor_t* p; }; struct ctl Modified: branches/complement-sockios/explore/lib/sockios/ut/sockios2_test.cc =================================================================== --- branches/complement-sockios/explore/lib/sockios/ut/sockios2_test.cc 2008-06-09 18:31:16 UTC (rev 1892) +++ branches/complement-sockios/explore/lib/sockios/ut/sockios2_test.cc 2008-06-10 05:12:41 UTC (rev 1893) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/06/09 20:40:57 yeti> +// -*- C++ -*- Time-stamp: <08/06/09 23:49:35 ptr> /* * Modified: branches/complement-sockios/explore/lib/sockios/ut/sockios_test_suite.cc =================================================================== --- branches/complement-sockios/explore/lib/sockios/ut/sockios_test_suite.cc 2008-06-09 18:31:16 UTC (rev 1892) +++ branches/complement-sockios/explore/lib/sockios/ut/sockios_test_suite.cc 2008-06-10 05:12:41 UTC (rev 1893) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/06/09 20:28:59 yeti> +// -*- C++ -*- Time-stamp: <08/06/10 00:41:49 ptr> /* * @@ -80,12 +80,12 @@ sockios2_test test2; - t.add( &sockios2_test::read0, test2, "sockios2_test::read0", - t.add( &sockios2_test::srv_sigpipe, test2, "sockios2_test::srv_sigpipe", - t.add( &sockios2_test::fork, test2, "sockios2_test::fork", - t.add( &sockios2_test::processor_core, test2, "sockios2_test::processor_core", +// t.add( &sockios2_test::read0, test2, "sockios2_test::read0", +// t.add( &sockios2_test::srv_sigpipe, test2, "sockios2_test::srv_sigpipe", +// t.add( &sockios2_test::fork, test2, "sockios2_test::fork", +// t.add( &sockios2_test::processor_core, test2, "sockios2_test::processor_core", t.add( &sockios2_test::connect_disconnect, test2, "sockios2_test::connect_disconnect", - t.add( &sockios2_test::srv_core, test2, "sockios2_test::srv_core" ) ) ) ) ) ); + t.add( &sockios2_test::srv_core, test2, "sockios2_test::srv_core" ) );// ) ) ) ); return t.girdle(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2008-06-09 18:32:08
|
Revision: 1892 http://complement.svn.sourceforge.net/complement/?rev=1892&view=rev Author: complement Date: 2008-06-09 11:31:16 -0700 (Mon, 09 Jun 2008) Log Message: ----------- sockstream2 family renamed to sockstream; basic_sockbuf become proxy, real implementation is basic_sockbuf_aux and should be controlled from sockmgr; just compile, not really work Modified Paths: -------------- branches/complement-sockios/explore/include/sockios/sp.cc branches/complement-sockios/explore/include/sockios/sp.h branches/complement-sockios/explore/lib/sockios/ut/Makefile.inc branches/complement-sockios/explore/lib/sockios/ut/sockios2_test.cc branches/complement-sockios/explore/lib/sockios/ut/sockios_test.cc branches/complement-sockios/explore/lib/sockios/ut/sockios_test.h branches/complement-sockios/explore/lib/sockios/ut/sockios_test_suite.cc Added Paths: ----------- branches/complement-sockios/explore/include/sockios/sockstream branches/complement-sockios/explore/include/sockios/sockstream.cc Removed Paths: ------------- branches/complement-sockios/explore/include/sockios/sockstream branches/complement-sockios/explore/include/sockios/sockstream.cc branches/complement-sockios/explore/include/sockios/sockstream2 branches/complement-sockios/explore/include/sockios/sockstream2.cc Deleted: branches/complement-sockios/explore/include/sockios/sockstream =================================================================== --- branches/complement-sockios/explore/include/sockios/sockstream 2008-06-07 17:06:27 UTC (rev 1891) +++ branches/complement-sockios/explore/include/sockios/sockstream 2008-06-09 18:31:16 UTC (rev 1892) @@ -1,623 +0,0 @@ -// -*- C++ -*- Time-stamp: <07/09/06 23:42:19 ptr> - -/* - * Copyright (c) 1997-1999, 2002, 2003, 2005-2007 - * Petr Ovtchenkov - * - * Portion Copyright (c) 1999-2001 - * Parallel Graphics Ltd. - * - * Licensed under the Academic Free License version 3.0 - * - */ - -#ifndef __SOCKSTREAM__ -#define __SOCKSTREAM__ - -#ifndef __config_feature_h -#include <config/feature.h> -#endif - -#if !defined(__sun) && !defined(_WIN32) // i.e. __linux and __hpux -#include <sys/poll.h> // pollfd -#endif - -#ifndef __XMT_H -#include <mt/xmt.h> -#endif - -#include <netdb.h> -#include <netinet/in.h> - -#include <iosfwd> -#include <ios> -#include <streambuf> -#include <iostream> -#include <string> -#include <stdexcept> - -#ifdef WIN32 -# include <winsock2.h> -#else // WIN32 -# include <unistd.h> -# include <sys/types.h> -# if defined(__hpux) && !defined(_INCLUDE_XOPEN_SOURCE_EXTENDED) -# define _INCLUDE_XOPEN_SOURCE_EXTENDED -# endif -# include <sys/socket.h> -# if !defined(__UCLIBC__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) -# include <stropts.h> -# endif -# ifdef __sun -# include <sys/conf.h> -# endif -# include <netinet/in.h> -# include <arpa/inet.h> -# include <netdb.h> -# ifdef __hpux -// # ifndef socklen_t // HP-UX 10.01 -// typedef int socklen_t; -// # endif -# endif -# include <cerrno> -#endif // !WIN32 - -#include <sockios/netinfo.h> - -#ifdef STLPORT -_STLP_BEGIN_NAMESPACE -#else -namespace std { -#endif - -class sock_base -{ - public: - typedef unsigned long shutdownflg; -#ifdef __unix - typedef int socket_type; -#endif -#ifdef WIN32 - typedef SOCKET socket_type; -#endif - - enum stype { - sock_stream = SOCK_STREAM, // stream socket - sock_dgram = SOCK_DGRAM, // datagram socket - sock_raw = SOCK_RAW, // raw-protocol interface - sock_rdm = SOCK_RDM, // reliably-delivered message - sock_seqpacket = SOCK_SEQPACKET // sequenced packet stream - }; - - enum protocol { - local, // local to host (pipes, portals) - inet // internetwork: UDP, TCP, etc. - }; - - // Option flags per-socket. - enum so_t { - so_debug = SO_DEBUG, // turn on debugging info recording -#ifndef __linux - so_acceptconn = SO_ACCEPTCONN, // socket has had listen() -#endif - so_reuseaddr = SO_REUSEADDR, // allow local address reuse - so_keepalive = SO_KEEPALIVE, // keep connections alive - so_dontroute = SO_DONTROUTE, // just use interface addresses - so_broadcast = SO_BROADCAST, // permit sending of broadcast msgs -#ifndef __linux - so_useloopback = SO_USELOOPBACK, // bypass hardware when possible -#endif - so_linger = SO_LINGER, // linger on close if data present - so_oobinline = SO_OOBINLINE, // leave received OOB data in line - // Additional options, not kept in so_options. - so_sndbuf = SO_SNDBUF, // send buffer size - so_rcvbuf = SO_RCVBUF, // receive buffer size - so_sndlowat = SO_SNDLOWAT, // send low-water mark - so_rcvlowat = SO_RCVLOWAT, // receive low-water mark - so_sndtimeo = SO_SNDTIMEO, // send timeout - so_rcvtimeo = SO_RCVTIMEO, // receive timeout - so_error = SO_ERROR, // get error status and clear - so_type = SO_TYPE // get socket type -#ifdef __sun // indeed HP-UX 11.00 also has it, but 10.01 not - , - so_prototype = SO_PROTOTYPE // get/set protocol type -#endif - }; - - // Level number for (get/set)sockopt() to apply to socket itself. -// enum _level { -// sol_socket = SOL_SOCKET -// }; - - enum shutdownflags { - stop_in = 0x1, - stop_out = 0x2 - }; - -#ifdef WIN32 - class Init - { - // sometimes I need Init outside sock_base... - // private: - public: - __FIT_DECLSPEC Init(); - __FIT_DECLSPEC ~Init(); - - friend class sock_base; - }; - - protected: - __FIT_DECLSPEC sock_base(); - __FIT_DECLSPEC ~sock_base(); -#endif -}; - -template<class charT, class traits, class _Alloc> -class basic_sockbuf : - public basic_streambuf<charT, traits> -{ - public: - typedef basic_ios<charT, traits> ios_type; - typedef basic_sockbuf<charT, traits, _Alloc> sockbuf_type; - typedef typename traits::state_type state_t; -#ifdef WIN32 - typedef u_short family_type; -#else -# ifdef sa_family_t - typedef sa_family_t family_type; -# else // HP-UX 10.01 - typedef unsigned short family_type; -# endif -#endif - - public: - /* Inherited from basic_streambuf : */ - typedef charT char_type; - typedef typename traits::int_type int_type; - typedef typename traits::pos_type pos_type; - typedef typename traits::off_type off_type; - typedef traits traits_type; - /* */ - - basic_sockbuf() : - _fd( -1 ), -#if !defined(STLPORT) && defined(__GNUC__) -#if ((__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 4))) // hmm, 3.3.6 - _mode( ios_base::openmode(__ios_flags::_S_in | __ios_flags::_S_out) ), -#else // 4.1.1 - _mode( _S_in | _S_out ), -#endif // __GNUC__ -#else // STLPORT - _mode( 0 ), -#endif // STLPORT - _bbuf(0), _ebuf(0), _allocated( true ) - // , _doclose( true ) - { -#ifdef __FIT_POLL - _timeout = -1; -#endif -#ifdef __FIT_SELECT - _timeout_ref = 0; -#endif - } - basic_sockbuf( const char *hostname, int port, - sock_base::stype type = sock_base::sock_stream, - sock_base::protocol prot = sock_base::inet, - const timespec *timeout = 0 ) : - _fd( -1 ), -#if !defined(STLPORT) && defined(__GNUC__) -#if ((__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 4))) - _mode( ios_base::openmode(__ios_flags::_S_in | __ios_flags::_S_out) ), -#else // 4.1.1 - _mode( _S_in | _S_out ), -#endif // __GNUC__ -#else // STLPORT - _mode( 0 ), -#endif // STLPORT - _bbuf(0), _ebuf(0), _allocated( true ) - // , _doclose( true ) - { - open( hostname, port, type, prot, timeout ); - } - basic_sockbuf( const in_addr& addr, int port, - sock_base::stype type = sock_base::sock_stream, - sock_base::protocol prot = sock_base::inet, - const timespec *timeout = 0 ) : - _fd( -1 ), -#if !defined(STLPORT) && defined(__GNUC__) -#if ((__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 4))) - _mode( ios_base::openmode(__ios_flags::_S_in | __ios_flags::_S_out) ), -#else // 4.1.1 - _mode( _S_in | _S_out ), -#endif // __GNUC__ -#else // STLPORT - _mode( 0 ), -#endif // STLPORT - _bbuf(0), _ebuf(0), _allocated( true ) - // , _doclose( true ) - { - open( addr, type, prot, timeout ); - } - virtual ~basic_sockbuf() - { - close(); - _M_deallocate_block(); - } - - bool is_open() const - { return _fd != -1; } - - sockbuf_type *open( const char *hostname, int port, - sock_base::stype type = sock_base::sock_stream, - sock_base::protocol prot = sock_base::inet, - const timespec *timeout = 0 ); - - sockbuf_type *open( const in_addr& addr, int port, - sock_base::stype type = sock_base::sock_stream, - sock_base::protocol prot = sock_base::inet, - const timespec *timeout = 0 ); - - sockbuf_type *open( sock_base::socket_type s, - sock_base::stype t = sock_base::sock_stream, - const timespec *timeout = 0 ); - - sockbuf_type *open( sock_base::socket_type s, const sockaddr& addr, - sock_base::stype t = sock_base::sock_stream, - const timespec *timeout = 0 ); - - sockbuf_type *attach( sock_base::socket_type s, - sock_base::stype t = sock_base::sock_stream, - const timespec *timeout = 0 ); - - sockbuf_type *attach( sock_base::socket_type s, const sockaddr& addr, - sock_base::stype t = sock_base::sock_stream, - const timespec *timeout = 0 ); - - sockbuf_type *close(); - void shutdown( sock_base::shutdownflg dir ); - - sock_base::socket_type fd() const { return _fd;} - - family_type family() const - { return /* is_open() ? */ _address.any.sa_family /* : 0 */; } - - int port() const - { return /* is_open() && */ _address.any.sa_family == AF_INET ? - _address.inet.sin_port : 0; } - - unsigned long inet_addr() const - { return /* is_open() && */ _address.any.sa_family == AF_INET ? - _address.inet.sin_addr.s_addr : 0; } - - const sockaddr_in& inet_sockaddr() const throw( std::domain_error ) - { - if ( _address.any.sa_family != AF_INET ) { - throw domain_error( "socket not belongs to inet type" ); - } - return /* is_open() && */ _address.inet; - } - - sock_base::stype stype() const - { return _type; } - - // const string& hostname() const - // { return _hostname; } - - protected: - // bool findhost( const char *hostname ); - - virtual streamsize showmanyc() - { return this->egptr() - this->gptr(); } - - virtual int_type underflow(); - virtual int_type overflow( int_type c = traits::eof() ); - virtual int_type pbackfail( int_type c = traits::eof() ) - { - if ( !is_open() ) - return traits::eof(); - - if ( this->gptr() <= this->eback() ) { - return traits::eof(); - } - - this->gbump(-1); - if ( !traits::eq_int_type(c,traits::eof()) ) { - *this->gptr() = traits::to_char_type(c); - return c; - } - - return traits::not_eof(c); - } - - // Buffer managment and positioning: - virtual basic_streambuf<charT, traits> *setbuf(char_type *s, streamsize n ) - { - if ( s != 0 && n != 0 ) { - _M_deallocate_block(); - _allocated = false; - _bbuf = s; - _ebuf = s + n; - } - return this; - } - - virtual int sync(); - virtual streamsize xsputn(const char_type *s, streamsize n); - - public: - xmt::mutex _M_lock_w; // lock for writing - - private: // Helper functions - charT* _bbuf; - charT* _ebuf; - bool _allocated; // true, if _bbuf should be deallocated -#ifdef __FIT_POLL - pollfd pfd; - int _timeout; // milliseconds -#endif -#ifdef __FIT_SELECT - fd_set pfd; - struct timeval _timeout; - struct timeval *_timeout_ref; -#endif - - // Precondition: 0 < __n <= max_size(). - charT* _M_allocate( size_t __n ) { return _M_data_allocator.allocate(__n); } - void _M_deallocate( charT* __p, size_t __n ) - { if (__p) _M_data_allocator.deallocate(__p, __n); } - - void _M_allocate_block(size_t __n) - { - if ( _allocated ) { - if ( __n <= max_size() ) { - _bbuf = _M_allocate(__n); - _ebuf = _bbuf + __n; - // _STLP_ASSERT( __n > 0 ? _bbuf != 0 : _bbuf == 0 ); - } else - this->_M_throw_length_error(); - } - } - - void _M_deallocate_block() - { if ( _allocated ) _M_deallocate(_bbuf, _ebuf - _bbuf); } - - size_t max_size() const { return (size_t(-1) / sizeof(charT)) - 1; } - -#ifdef STLPORT - void _M_throw_length_error() const - { _STLP_THROW(length_error("basic_sockbuf")); } -#else - void _M_throw_length_error() const - { throw length_error("basic_sockbuf"); } -#endif - -#ifdef STLPORT - typedef typename _Alloc_traits<charT, _Alloc>::allocator_type allocator_type; -#else - typedef _Alloc allocator_type; -#endif - /* typedef __allocator<charT, _Alloc> _Alloc_type; */ - - /* _Alloc_type */ allocator_type _M_data_allocator; - - private: - typedef basic_sockbuf<charT,traits,_Alloc> _Self_type; - int (basic_sockbuf<charT,traits,_Alloc>::*_xwrite)( const void *, size_t ); - int (basic_sockbuf<charT,traits,_Alloc>::*_xread)( void *, size_t ); - int write( const void *buf, size_t n ) -#ifndef WIN32 - { return ::write( _fd, buf, n ); } -#else - { return ::send( _fd, (const char *)buf, n, 0 ); } -#endif - int send( const void *buf, size_t n ) -#ifdef WIN32 - { return ::send( _fd, (const char *)buf, n, 0 ); } -#else - { return ::send( _fd, buf, n, 0 ); } -#endif - int sendto( const void *buf, size_t n ) -#ifdef WIN32 - { return ::sendto( _fd, (const char *)buf, n, 0, &_address.any, sizeof( sockaddr_in ) ); } -#else - { return ::sendto( _fd, buf, n, 0, &_address.any, sizeof( sockaddr_in ) ); } -#endif - - int read( void *buf, size_t n ) -#ifdef WIN32 - { return ::recv( _fd, (char *)buf, n, 0 ); } -#else - { return ::read( _fd, buf, n ); } -#endif - int recv( void *buf, size_t n ) -#ifdef WIN32 - { return ::recv( _fd, (char *)buf, n, 0 ); } -#else - { return ::recv( _fd, buf, n, 0 ); } -#endif - int recvfrom( void *buf, size_t n ); - void __hostname(); - - sock_base::socket_type _fd; - union sockaddr_t { - sockaddr_in inet; - sockaddr any; - } _address; - - ios_base::openmode _mode; - int _errno; - sock_base::stype _type; - // bool _doclose; -}; - -template <class charT, class traits, class _Alloc> -class basic_sockstream : - public sock_base, - public basic_iostream<charT,traits> -{ - public: - /* Inherited from basic_iostream - typedef charT char_type; - typedef typename traits::int_type int_type; - typedef typename traits::pos_type pos_type; - typedef typename traits::off_type off_type; - */ - basic_sockstream() : - sock_base(), - basic_iostream<charT,traits>( 0 ) - { basic_ios<charT,traits>::init(&_sb); } - basic_sockstream( const char *hostname, int port, - sock_base::stype type = sock_base::sock_stream, - sock_base::protocol pro = sock_base::inet, - const timespec *timeout = 0 ) : - sock_base(), - basic_iostream<charT,traits>( 0 ) - { - basic_ios<charT,traits>::init(&_sb); - basic_iostream<charT,traits>::clear(); - if ( _sb.open( hostname, port, type, pro, timeout ) == 0 ) { - basic_ios<charT,traits>::setstate( ios_base::failbit | ios_base::badbit ); - } - } - - basic_sockstream( const in_addr& addr, int port, - sock_base::stype type = sock_base::sock_stream, - sock_base::protocol pro = sock_base::inet, - const timespec *timeout = 0 ) : - sock_base(), - basic_iostream<charT,traits>( 0 ) - { - basic_ios<charT,traits>::init(&_sb); - basic_iostream<charT,traits>::clear(); - if ( _sb.open( addr, port, type, pro, timeout ) == 0 ) { - basic_ios<charT,traits>::setstate( ios_base::failbit | ios_base::badbit ); - } - } - - basic_sockstream( sock_base::socket_type s, const sockaddr& addr, - sock_base::stype type = sock_base::sock_stream, - const timespec *timeout = 0 ) : - sock_base(), - basic_iostream<charT,traits>( 0 ) - { - basic_ios<charT,traits>::init(&_sb); - basic_iostream<charT,traits>::clear(); - if ( _sb.open( s, addr, type, timeout ) == 0 ) { - basic_ios<charT,traits>::setstate( ios_base::failbit | ios_base::badbit ); - } - } - - basic_sockstream( sock_base::socket_type s, - sock_base::stype type = sock_base::sock_stream, - const timespec *timeout = 0 ) : - sock_base(), - basic_iostream<charT,traits>( 0 ) - { - basic_ios<charT,traits>::init(&_sb); - basic_iostream<charT,traits>::clear(); - if ( _sb.open( s, type, timeout ) == 0 ) { - basic_ios<charT,traits>::setstate( ios_base::failbit | ios_base::badbit ); - } - } - - basic_sockbuf<charT,traits,_Alloc>* rdbuf() const - { return const_cast<basic_sockbuf<charT,traits,_Alloc>*>(&_sb); } - bool is_open() const - { return _sb.is_open(); } - void open( const char *hostname, int port, - sock_base::stype type = sock_base::sock_stream, - sock_base::protocol pro = sock_base::inet, - const timespec *timeout = 0 ) - { - basic_iostream<charT,traits>::clear(); - if ( _sb.open( hostname, port, type, pro, timeout ) == 0 ) { - basic_ios<charT,traits>::setstate( ios_base::failbit | ios_base::badbit ); - } - } - - void open( const in_addr& addr, int port, - sock_base::stype type = sock_base::sock_stream, - sock_base::protocol pro = sock_base::inet, - const timespec *timeout = 0 ) - { - basic_iostream<charT,traits>::clear(); - if ( _sb.open( addr, port, type, pro, timeout ) == 0 ) { - basic_ios<charT,traits>::setstate( ios_base::failbit | ios_base::badbit ); - } - } - - // only for sock_stream : inet now! - void open( sock_base::socket_type s, const sockaddr& addr, - sock_base::stype type = sock_base::sock_stream, - const timespec *timeout = 0 ) - { - basic_iostream<charT,traits>::clear(); - if ( _sb.open( s, addr, type, timeout ) == 0 ) { - basic_ios<charT,traits>::setstate( ios_base::failbit | ios_base::badbit ); - } - } - - void open( sock_base::socket_type s, - sock_base::stype type = sock_base::sock_stream, - const timespec *timeout = 0 ) - { - basic_iostream<charT,traits>::clear(); - if ( _sb.open( s, type, timeout ) == 0 ) { - basic_ios<charT,traits>::setstate( ios_base::failbit | ios_base::badbit ); - } - } - - void attach( sock_base::socket_type s, const sockaddr& addr, - sock_base::stype type = sock_base::sock_stream, - const timespec *timeout = 0 ) - { - basic_iostream<charT,traits>::clear(); - if ( _sb.attach( s, addr, type, timeout ) == 0 ) { - basic_ios<charT,traits>::setstate( ios_base::failbit | ios_base::badbit ); - } - } - - void attach( sock_base::socket_type s, - sock_base::stype type = sock_base::sock_stream, - const timespec *timeout = 0 ) - { - basic_iostream<charT,traits>::clear(); - if ( _sb.attach( s, type, timeout ) == 0 ) { - basic_ios<charT,traits>::setstate( ios_base::failbit | ios_base::badbit ); - } - } - - void close() - { - if ( _sb.is_open() ) { - if ( _sb.close() == 0 ) { - basic_ios<charT,traits>::setstate( ios_base::failbit ); - } else { - basic_iostream<charT,traits>::clear(); - } - } - } - - void setoptions( sock_base::so_t optname, bool on_off = true, - int __v = 0 ); - - private: - basic_sockbuf<charT,traits,_Alloc> _sb; -}; - -typedef basic_sockbuf<char,char_traits<char>,allocator<char> > sockbuf; -typedef basic_sockbuf<wchar_t,char_traits<wchar_t>,allocator<wchar_t> > wsockbuf; -typedef basic_sockstream<char,char_traits<char>,allocator<char> > sockstream; -typedef basic_sockstream<wchar_t,char_traits<wchar_t>,allocator<wchar_t> > wsockstream; - -#ifdef STLPORT -_STLP_END_NAMESPACE -#else -} // namespace std -#endif - -#ifndef __STL_LINK_TIME_INSTANTIATION -#include <sockios/sockstream.cc> -#endif - -#endif // __SOCKSTREAM__ Copied: branches/complement-sockios/explore/include/sockios/sockstream (from rev 1886, branches/complement-sockios/explore/include/sockios/sockstream2) =================================================================== --- branches/complement-sockios/explore/include/sockios/sockstream (rev 0) +++ branches/complement-sockios/explore/include/sockios/sockstream 2008-06-09 18:31:16 UTC (rev 1892) @@ -0,0 +1,661 @@ +// -*- C++ -*- Time-stamp: <08/06/09 22:22:05 yeti> + +/* + * Copyright (c) 1997-1999, 2002, 2003, 2005-2008 + * Petr Ovtchenkov + * + * Portion Copyright (c) 1999-2001 + * Parallel Graphics Ltd. + * + * Licensed under the Academic Free License version 3.0 + * + */ + +#ifndef __SOCKIOS_SOCKSTREAM +#define __SOCKIOS_SOCKSTREAM + +#ifndef __config_feature_h +#include <config/feature.h> +#endif + +#if !defined(__sun) && !defined(_WIN32) // i.e. __linux and __hpux +#include <sys/poll.h> // pollfd +#endif + +#include <mt/mutex> +#include <mt/condition_variable> +#include <mt/date_time> +#include <mt/thread> + +#include <netdb.h> +#include <netinet/in.h> + +#include <iosfwd> +#include <ios> +#include <streambuf> +#include <iostream> +#include <string> +#include <stdexcept> + +#ifdef WIN32 +# include <winsock2.h> +#else // WIN32 +# include <unistd.h> +# include <sys/types.h> +# if defined(__hpux) && !defined(_INCLUDE_XOPEN_SOURCE_EXTENDED) +# define _INCLUDE_XOPEN_SOURCE_EXTENDED +# endif +# include <sys/socket.h> +# if !defined(__UCLIBC__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) +# include <stropts.h> +# endif +# ifdef __sun +# include <sys/conf.h> +# endif +# include <netinet/in.h> +# include <arpa/inet.h> +# include <netdb.h> +# ifdef __hpux +// # ifndef socklen_t // HP-UX 10.01 +// typedef int socklen_t; +// # endif +# endif +# include <cerrno> +#endif // !WIN32 + +#include <sockios/netinfo.h> + +#ifdef STLPORT +_STLP_BEGIN_NAMESPACE +#else +namespace std { +#endif + +class sock_base +{ + public: + typedef unsigned long shutdownflg; +#ifdef __unix + typedef int socket_type; +#endif +#ifdef WIN32 + typedef SOCKET socket_type; +#endif + + enum stype { + sock_stream = SOCK_STREAM, // stream socket + sock_dgram = SOCK_DGRAM, // datagram socket + sock_raw = SOCK_RAW, // raw-protocol interface + sock_rdm = SOCK_RDM, // reliably-delivered message + sock_seqpacket = SOCK_SEQPACKET // sequenced packet stream + }; + + enum protocol { + local, // local to host (pipes, portals) + inet // internetwork: UDP, TCP, etc. + }; + + // Option flags per-socket. + enum so_t { + so_debug = SO_DEBUG, // turn on debugging info recording +#ifndef __linux + so_acceptconn = SO_ACCEPTCONN, // socket has had listen() +#endif + so_reuseaddr = SO_REUSEADDR, // allow local address reuse + so_keepalive = SO_KEEPALIVE, // keep connections alive + so_dontroute = SO_DONTROUTE, // just use interface addresses + so_broadcast = SO_BROADCAST, // permit sending of broadcast msgs +#ifndef __linux + so_useloopback = SO_USELOOPBACK, // bypass hardware when possible +#endif + so_linger = SO_LINGER, // linger on close if data present + so_oobinline = SO_OOBINLINE, // leave received OOB data in line + // Additional options, not kept in so_options. + so_sndbuf = SO_SNDBUF, // send buffer size + so_rcvbuf = SO_RCVBUF, // receive buffer size + so_sndlowat = SO_SNDLOWAT, // send low-water mark + so_rcvlowat = SO_RCVLOWAT, // receive low-water mark + so_sndtimeo = SO_SNDTIMEO, // send timeout + so_rcvtimeo = SO_RCVTIMEO, // receive timeout + so_error = SO_ERROR, // get error status and clear + so_type = SO_TYPE // get socket type +#ifdef __sun // indeed HP-UX 11.00 also has it, but 10.01 not + , + so_prototype = SO_PROTOTYPE // get/set protocol type +#endif + }; + + // Level number for (get/set)sockopt() to apply to socket itself. +// enum _level { +// sol_socket = SOL_SOCKET +// }; + + enum shutdownflags { + stop_in = 0x1, + stop_out = 0x2 + }; + +#ifdef WIN32 + class Init + { + // sometimes I need Init outside sock_base... + // private: + public: + __FIT_DECLSPEC Init(); + __FIT_DECLSPEC ~Init(); + + friend class sock_base; + }; + + protected: + __FIT_DECLSPEC sock_base(); + __FIT_DECLSPEC ~sock_base(); +#endif +}; + +class socket_timeout : + public std::exception +{ + public: + socket_timeout() + { } + + virtual char const *what() throw() + { return "socket timeout"; } +}; + +class socket_read_timeout : + public socket_timeout +{ + public: + socket_read_timeout() + { } + + virtual char const *what() throw() + { return "socket read timeout"; } +}; + +class socket_write_timeout : + public socket_timeout +{ + public: + socket_write_timeout() + { } + + virtual char const *what() throw() + { return "socket write timeout"; } +}; + +namespace detail { +template <class charT, class traits, class _Alloc> class sockmgr; +} // namespace detail + +template <class charT, class traits, class _Alloc> +class sock_processor_base; + +template<class charT, class traits, class _Alloc> +class basic_socket +{ + protected: + basic_socket() : + _fd( -1 ), + _use_rdtimeout( false ), + _use_wrtimeout( false ), + _notify_close( false ) + { new( Init_buf ) Init(); } + + ~basic_socket() + { ((Init *)Init_buf)->~Init(); } + + bool is_open_unsafe() const + { return _fd != -1; } + sock_base::socket_type fd_unsafe() const + { return _fd; } + + class Init + { + public: + Init() + { _guard( 1 ); } + ~Init() + { _guard( 0 ); } + + private: + static void _guard( int direction ); + static void __at_fork_prepare(); + static void __at_fork_child(); + static void __at_fork_parent(); + static int _count; + static bool _at_fork; + }; + + static char Init_buf[]; + + public: +#ifdef WIN32 + typedef u_short family_type; +#else +# ifdef sa_family_t + typedef sa_family_t family_type; +# else // HP-UX 10.01 + typedef unsigned short family_type; +# endif +#endif + + template <class Duration> + void rdtimeout( const Duration& ); + void rdtimeout() // infinite + { _use_rdtimeout = false; } + + template <class Duration> + void wrtimeout( const Duration& ); + void wrtimeout() // infinite + { _use_wrtimeout = false; } + + sock_base::socket_type fd() const { return _fd;} + bool is_open() const + { return _fd != -1; } + + family_type family() const + { return /* is_open() ? */ _address.any.sa_family /* : 0 */; } + + int port() const + { return /* is_open() && */ _address.any.sa_family == AF_INET ? _address.inet.sin_port : 0; } + + unsigned long inet_addr() const + { return /* is_open() && */ _address.any.sa_family == AF_INET ? _address.inet.sin_addr.s_addr : 0; } + + const sockaddr_in& inet_sockaddr() const throw( std::domain_error ) + { + if ( _address.any.sa_family != AF_INET ) { + throw domain_error( "socket not belongs to inet type" ); + } + return /* is_open() && */ _address.inet; + } + + protected: + sock_base::socket_type _fd; + + union sockaddr_t { + sockaddr_in inet; + sockaddr any; + } _address; + + std::tr2::milliseconds _rdtimeout; + std::tr2::milliseconds _wrtimeout; + bool _use_rdtimeout; + bool _use_wrtimeout; + bool _notify_close; + + static detail::sockmgr<charT,traits,_Alloc>* mgr; + friend class Init; +}; + +template<class charT, class traits, class _Alloc> +int basic_socket<charT,traits,_Alloc>::Init::_count = 0; + +template<class charT, class traits, class _Alloc> +bool basic_socket<charT,traits,_Alloc>::Init::_at_fork = false; + +template<class charT, class traits, class _Alloc> +void basic_socket<charT,traits,_Alloc>::Init::_guard( int direction ) +{ + static std::tr2::mutex _init_lock; + + if ( direction ) { + std::tr2::lock_guard<std::tr2::mutex> lk( _init_lock ); + if ( _count++ == 0 ) { + basic_socket<charT,traits,_Alloc>::mgr = new detail::sockmgr<charT,traits,_Alloc>(); +#ifdef __FIT_PTHREADS + if ( !_at_fork ) { // call only once + if ( pthread_atfork( __at_fork_prepare, __at_fork_parent, __at_fork_child ) ) { + // throw system_error; + } + _at_fork = true; + } +#endif +// _sock_processor_base::_idx = std::tr2::this_thread::xalloc(); + std::cerr << __FILE__ << ":" << __LINE__ << " new mgr " << std::tr2::getpid() << std::endl; + } + } else { + std::tr2::lock_guard<std::tr2::mutex> lk( _init_lock ); + if ( --_count == 0 ) { + if ( basic_socket<charT,traits,_Alloc>::mgr == 0 ) { + std::cerr << __FILE__ << ":" << __LINE__ << " shit happens\n"; + } + std::cerr << __FILE__ << ":" << __LINE__ << " mgr destroyed " << std::tr2::getpid() << std::endl; + delete basic_socket<charT,traits,_Alloc>::mgr; + basic_socket<charT,traits,_Alloc>::mgr = 0; + } + } +} + +template<class charT, class traits, class _Alloc> +void basic_socket<charT,traits,_Alloc>::Init::__at_fork_prepare() +{ +} + +template<class charT, class traits, class _Alloc> +void basic_socket<charT,traits,_Alloc>::Init::__at_fork_child() +{ + if ( _count != 0 ) { + // stop mgr + _count = 1; + delete basic_socket<charT,traits,_Alloc>::mgr; + basic_socket<charT,traits,_Alloc>::mgr = new detail::sockmgr<charT,traits,_Alloc>(); + } + // _sock_processor_base::_idx = std::tr2::this_thread::xalloc(); +} + +template<class charT, class traits, class _Alloc> +void basic_socket<charT,traits,_Alloc>::Init::__at_fork_parent() +{ } + +template<class charT, class traits, class _Alloc> +char basic_socket<charT,traits,_Alloc>::Init_buf[128]; + +template <class charT, class traits, class _Alloc> +detail::sockmgr<charT,traits,_Alloc>* basic_socket<charT,traits,_Alloc>::mgr = 0; + +#ifdef STLPORT +_STLP_END_NAMESPACE +#else +} // namespace std +#endif + +#include <sockios/sp.h> + +#ifdef STLPORT +_STLP_BEGIN_NAMESPACE +#else +namespace std { +#endif + +template<class charT, class traits, class _Alloc> +class basic_sockbuf : + public basic_streambuf<charT, traits> + // public basic_socket<charT,traits,_Alloc> +{ + private: + typedef basic_socket<charT,traits,_Alloc> basic_socket_t; + + public: + typedef basic_ios<charT, traits> ios_type; + typedef basic_sockbuf<charT, traits, _Alloc> sockbuf_type; + typedef typename traits::state_type state_t; + typedef typename basic_socket_t::family_type family_type; + + public: + /* Inherited from basic_streambuf : */ + typedef charT char_type; + typedef typename traits::int_type int_type; + typedef typename traits::pos_type pos_type; + typedef typename traits::off_type off_type; + typedef traits traits_type; + /* */ + + basic_sockbuf() : + impl( 0 ) + { } + + basic_sockbuf( const char *hostname, int port, + sock_base::stype type = sock_base::sock_stream, + sock_base::protocol prot = sock_base::inet ) : + impl( 0 ) + { open( hostname, port, type, prot ); } + + basic_sockbuf( const in_addr& addr, int port, + sock_base::stype type = sock_base::sock_stream, + sock_base::protocol prot = sock_base::inet ) : + impl( 0 ) + { open( addr, type, prot ); } + + virtual ~basic_sockbuf() + { close(); } + + sockbuf_type *open( const char *hostname, int port, + sock_base::stype type = sock_base::sock_stream, + sock_base::protocol prot = sock_base::inet ); + + sockbuf_type *open( const in_addr& addr, int port, + sock_base::stype type = sock_base::sock_stream, + sock_base::protocol prot = sock_base::inet ) + { return impl->open( addr, port, type, prot ) ? this : 0; } + + sockbuf_type *open( sock_base::socket_type s, + sock_base::stype t = sock_base::sock_stream ); + + sockbuf_type *open( sock_base::socket_type s, const sockaddr& addr, + sock_base::stype t = sock_base::sock_stream ) + { return impl->open( s, addr, t ) ? this : 0; } + + sockbuf_type *attach( sock_base::socket_type s, + sock_base::stype t = sock_base::sock_stream ); + + sockbuf_type *attach( sock_base::socket_type s, const sockaddr& addr, + sock_base::stype t = sock_base::sock_stream ); + + sockbuf_type *close() + { return impl->close() ? this : 0; } + + void shutdown( sock_base::shutdownflg dir ) + { impl->shutdown( dir ); } + + sock_base::stype stype() const + { return impl->stype(); } + + template <class Duration> + void rdtimeout( const Duration& d ) + { impl->rdtimeout( d ); } + void rdtimeout() // infinite + { impl->rdtimeout(); } + + template <class Duration> + void wrtimeout( const Duration& d ) + { impl->wrtimeout( d ); } + void wrtimeout() // infinite + { impl->wrtimeout(); } + + sock_base::socket_type fd() const { return impl->fd();} + bool is_open() const + { return impl->is_open(); } + + family_type family() const + { return impl->family(); } + + int port() const + { return impl->port(); } + + unsigned long inet_addr() const + { return impl->inet_addr(); } + + const sockaddr_in& inet_sockaddr() const throw( std::domain_error ) + { return impl->inet_sockaddr(); } + + + protected: + virtual streamsize showmanyc() + { return impl->showmanyc(); } + + virtual int_type underflow() + { return impl->underflow(); } + virtual int_type overflow( int_type c = traits::eof() ) + { return impl->overflow(c); } + virtual int_type pbackfail( int_type c = traits::eof() ) + { return impl->pbackfail( c ); } + // Buffer managment and positioning: + virtual basic_streambuf<charT, traits> *setbuf(char_type *s, streamsize n ) + { impl->setbuf( s, n ); return this; } + + virtual int sync() + { return impl->sync(); } + virtual streamsize xsputn(const char_type *s, streamsize n) + { return impl->xsputn( s, n ); } + + private: + detail::basic_sockbuf_aux<charT,traits,_Alloc> *impl; +}; + +template <class charT, class traits, class _Alloc> +class basic_sockstream : + public sock_base, + public basic_iostream<charT,traits> +{ + public: + /* Inherited from basic_iostream + typedef charT char_type; + typedef typename traits::int_type int_type; + typedef typename traits::pos_type pos_type; + typedef typename traits::off_type off_type; + */ + basic_sockstream() : + sock_base(), + basic_iostream<charT,traits>( 0 ) + { basic_ios<charT,traits>::init(&_sb); } + basic_sockstream( const char *hostname, int port, + sock_base::stype type = sock_base::sock_stream, + sock_base::protocol pro = sock_base::inet ) : + sock_base(), + basic_iostream<charT,traits>( 0 ) + { + basic_ios<charT,traits>::init(&_sb); + basic_iostream<charT,traits>::clear(); + if ( _sb.open( hostname, port, type, pro ) == 0 ) { + basic_ios<charT,traits>::setstate( ios_base::failbit | ios_base::badbit ); + } + } + + basic_sockstream( const in_addr& addr, int port, + sock_base::stype type = sock_base::sock_stream, + sock_base::protocol pro = sock_base::inet ) : + sock_base(), + basic_iostream<charT,traits>( 0 ) + { + basic_ios<charT,traits>::init(&_sb); + basic_iostream<charT,traits>::clear(); + if ( _sb.open( addr, port, type, pro ) == 0 ) { + basic_ios<charT,traits>::setstate( ios_base::failbit | ios_base::badbit ); + } + } + + basic_sockstream( sock_base::socket_type s, const sockaddr& addr, + sock_base::stype type = sock_base::sock_stream ) : + sock_base(), + basic_iostream<charT,traits>( 0 ) + { + basic_ios<charT,traits>::init(&_sb); + basic_iostream<charT,traits>::clear(); + if ( _sb.open( s, addr, type ) == 0 ) { + basic_ios<charT,traits>::setstate( ios_base::failbit | ios_base::badbit ); + } + } + + basic_sockstream( sock_base::socket_type s, + sock_base::stype type = sock_base::sock_stream ) : + sock_base(), + basic_iostream<charT,traits>( 0 ) + { + basic_ios<charT,traits>::init(&_sb); + basic_iostream<charT,traits>::clear(); + if ( _sb.open( s, type ) == 0 ) { + basic_ios<charT,traits>::setstate( ios_base::failbit | ios_base::badbit ); + } + } + + basic_sockbuf<charT,traits,_Alloc>* rdbuf() const + { return const_cast<basic_sockbuf<charT,traits,_Alloc>*>(&_sb); } + + bool is_open() const + { return _sb.is_open(); } + + void open( const char *hostname, int port, + sock_base::stype type = sock_base::sock_stream, + sock_base::protocol pro = sock_base::inet ) + { + basic_iostream<charT,traits>::clear(); + if ( _sb.open( hostname, port, type, pro ) == 0 ) { + basic_ios<charT,traits>::setstate( ios_base::failbit | ios_base::badbit ); + } + } + + void open( const in_addr& addr, int port, + sock_base::stype type = sock_base::sock_stream, + sock_base::protocol pro = sock_base::inet ) + { + basic_iostream<charT,traits>::clear(); + if ( _sb.open( addr, port, type, pro ) == 0 ) { + basic_ios<charT,traits>::setstate( ios_base::failbit | ios_base::badbit ); + } + } + + // only for sock_stream : inet now! + void open( sock_base::socket_type s, const sockaddr& addr, + sock_base::stype type = sock_base::sock_stream ) + { + basic_iostream<charT,traits>::clear(); + if ( _sb.open( s, addr, type ) == 0 ) { + basic_ios<charT,traits>::setstate( ios_base::failbit | ios_base::badbit ); + } + } + + void open( sock_base::socket_type s, + sock_base::stype type = sock_base::sock_stream ) + { + basic_iostream<charT,traits>::clear(); + if ( _sb.open( s, type ) == 0 ) { + basic_ios<charT,traits>::setstate( ios_base::failbit | ios_base::badbit ); + } + } + + void attach( sock_base::socket_type s, const sockaddr& addr, + sock_base::stype type = sock_base::sock_stream ) + { + basic_iostream<charT,traits>::clear(); + if ( _sb.attach( s, addr, type ) == 0 ) { + basic_ios<charT,traits>::setstate( ios_base::failbit | ios_base::badbit ); + } + } + + void attach( sock_base::socket_type s, + sock_base::stype type = sock_base::sock_stream ) + { + basic_iostream<charT,traits>::clear(); + if ( _sb.attach( s, type ) == 0 ) { + basic_ios<charT,traits>::setstate( ios_base::failbit | ios_base::badbit ); + } + } + + void close() + { + if ( _sb.is_open() ) { + if ( _sb.close() == 0 ) { + basic_ios<charT,traits>::setstate( ios_base::failbit ); + } else { + basic_iostream<charT,traits>::clear(); + } + } + } + + void setoptions( sock_base::so_t optname, bool on_off = true, + int __v = 0 ); + + private: + basic_sockbuf<charT,traits,_Alloc> _sb; +}; + +typedef basic_sockbuf<char,char_traits<char>,allocator<char> > sockbuf; +// typedef basic_sockbuf<wchar_t,char_traits<wchar_t>,allocator<wchar_t> > wsockbuf; +typedef basic_sockstream<char,std::char_traits<char>,std::allocator<char> > sockstream; +// typedef basic_sockstream<wchar_t,char_traits<wchar_t>,allocator<wchar_t> > wsockstream; + +#ifdef STLPORT +_STLP_END_NAMESPACE +#else +} // namespace std +#endif + +#ifndef __STL_LINK_TIME_INSTANTIATION +#include <sockios/sockstream.cc> +#endif + +#endif // __SOCKIOS_SOCKSTREAM Deleted: branches/complement-sockios/explore/include/sockios/sockstream.cc =================================================================== --- branches/complement-sockios/explore/include/sockios/sockstream.cc 2008-06-07 17:06:27 UTC (rev 1891) +++ branches/complement-sockios/explore/include/sockios/sockstream.cc 2008-06-09 18:31:16 UTC (rev 1892) @@ -1,777 +0,0 @@ -// -*- C++ -*- Time-stamp: <07/09/06 23:48:33 ptr> - -/* - * Copyright (c) 1997-1999, 2002, 2003, 2005-2008 - * Petr Ovtchenkov - * - * Portion Copyright (c) 1999-2001 - * Parallel Graphics Ltd. - * - * Licensed under the Academic Free License version 3.0 - * - */ - -#include <sockios/netinfo.h> - -#ifdef __unix -extern "C" int nanosleep(const struct timespec *, struct timespec *); -#endif - -#if defined(__unix) && !defined(__UCLIBC__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) -# include <stropts.h> // for ioctl() call -#endif - -#ifdef __FIT_NONBLOCK_SOCKETS -# include <fcntl.h> -#endif - -#ifdef STLPORT -_STLP_BEGIN_NAMESPACE -#else -namespace std { -#endif - -template<class charT, class traits, class _Alloc> -basic_sockbuf<charT, traits, _Alloc> * -basic_sockbuf<charT, traits, _Alloc>::open( const char *name, int port, - sock_base::stype type, - sock_base::protocol prot, - const timespec *timeout ) -{ - if ( is_open() ) { - return 0; - } - try { - _mode = ios_base::in | ios_base::out; - _errno = 0; - _type = type; -#ifdef WIN32 - WSASetLastError( 0 ); -#endif -#ifdef __FIT_POLL - if ( timeout != 0 ) { - _timeout = timeout->tv_sec * 1000 + timeout->tv_nsec / 1000000; - } else { - _timeout = -1; - } -#endif -#ifdef __FIT_SELECT - if ( timeout != 0 ) { - _timeout.tv_sec = timeout->tv_sec; - _timeout.tv_usec = timeout->tv_nsec / 1000; - _timeout_ref = &_timeout; - } else { - _timeout_ref = 0; - } -#endif - if ( prot == sock_base::inet ) { - _fd = socket( PF_INET, type, 0 ); - if ( _fd == -1 ) { - throw std::runtime_error( "can't open socket" ); - } - _address.inet.sin_family = AF_INET; - // htons is a define at least in Linux 2.2.5-15, and it's expantion fail - // for gcc 2.95.3 -#if defined(linux) && defined(htons) && defined(__bswap_16) - _address.inet.sin_port = ((((port) >> 8) & 0xff) | (((port) & 0xff) << 8)); -#else - _address.inet.sin_port = htons( port ); -#endif // linux && htons - _address.inet.sin_addr = std::findhost( name ); - - // Generally, stream sockets may successfully connect() only once - if ( connect( _fd, &_address.any, sizeof( _address ) ) == -1 ) { - throw std::domain_error( "connect fail" ); - } - if ( type == sock_base::sock_stream ) { - _xwrite = &_Self_type::write; - _xread = &_Self_type::read; - } else if ( type == sock_base::sock_dgram ) { - _xwrite = &_Self_type::send; - _xread = &_Self_type::recv; - } - } else if ( prot == sock_base::local ) { - _fd = socket( PF_UNIX, type, 0 ); - if ( _fd == -1 ) { - throw std::runtime_error( "can't open socket" ); - } - } else { // other protocols not implemented yet - throw std::invalid_argument( "protocol not implemented" ); - } - if ( _bbuf == 0 ) - _M_allocate_block( type == sock_base::sock_stream ? 0xb00 : 0xffff ); // max 1460 (dec) [0x5b4] --- single segment - if ( _bbuf == 0 ) { - throw std::length_error( "can't allocate block" ); - } - -#ifdef __FIT_NONBLOCK_SOCKETS - if ( fcntl( _fd, F_SETFL, fcntl( _fd, F_GETFL ) | O_NONBLOCK ) != 0 ) { - throw std::runtime_error( "can't establish nonblock mode" ); - } -#endif -#ifdef __FIT_POLL - pfd.fd = _fd; - pfd.events = POLLIN | POLLHUP | POLLRDNORM; -#endif - setp( _bbuf, _bbuf + ((_ebuf - _bbuf)>>1) ); - setg( this->epptr(), this->epptr(), this->epptr() ); - - _errno = 0; // if any - } - catch ( std::domain_error& ) { -#ifdef WIN32 - _errno = WSAGetLastError(); - ::closesocket( _fd ); -#else - _errno = errno; - ::close( _fd ); -#endif - _fd = -1; - return 0; - } - catch ( std::length_error& ) { -#ifdef WIN32 - ::closesocket( _fd ); -#else - ::close( _fd ); -#endif - _fd = -1; - return 0; - } - catch ( std::runtime_error& ) { -#ifdef WIN32 - _errno = WSAGetLastError(); -#else - _errno = errno; -#endif - return 0; - } - catch ( std::invalid_argument& ) { - return 0; - } - - return this; -} - -// -- -template<class charT, class traits, class _Alloc> -basic_sockbuf<charT, traits, _Alloc> * -basic_sockbuf<charT, traits, _Alloc>::open( const in_addr& addr, int port, - sock_base::stype type, - sock_base::protocol prot, - const timespec *timeout ) -{ - if ( is_open() ) { - return 0; - } - try { - _mode = ios_base::in | ios_base::out; - _errno = 0; - _type = type; -#ifdef WIN32 - WSASetLastError( 0 ); -#endif -#ifdef __FIT_POLL - if ( timeout != 0 ) { - _timeout = timeout->tv_sec * 1000 + timeout->tv_nsec / 1000000; - } else { - _timeout = -1; - } -#endif -#ifdef __FIT_SELECT - if ( timeout != 0 ) { - _timeout.tv_sec = timeout->tv_sec; - _timeout.tv_usec = timeout->tv_nsec / 1000; - _timeout_ref = &_timeout; - } else { - _timeout_ref = 0; - } -#endif - if ( prot == sock_base::inet ) { - _fd = socket( PF_INET, type, 0 ); - if ( _fd == -1 ) { - throw std::runtime_error( "can't open socket" ); - } - _address.inet.sin_family = AF_INET; - // htons is a define at least in Linux 2.2.5-15, and it's expantion fail - // for gcc 2.95.3 -#if defined(linux) && defined(htons) && defined(__bswap_16) - _address.inet.sin_port = ((((port) >> 8) & 0xff) | (((port) & 0xff) << 8)); -#else - _address.inet.sin_port = htons( port ); -#endif // linux && htons - _address.inet.sin_addr = addr; - - // Generally, stream sockets may successfully connect() only once - if ( connect( _fd, &_address.any, sizeof( _address ) ) == -1 ) { - throw std::domain_error( "connect fail" ); - } - if ( type == sock_base::sock_stream ) { - _xwrite = &_Self_type::write; - _xread = &_Self_type::read; - } else if ( type == sock_base::sock_dgram ) { - _xwrite = &_Self_type::send; - _xread = &_Self_type::recv; - } - } else if ( prot == sock_base::local ) { - _fd = socket( PF_UNIX, type, 0 ); - if ( _fd == -1 ) { - throw std::runtime_error( "can't open socket" ); - } - } else { // other protocols not implemented yet - throw std::invalid_argument( "protocol not implemented" ); - } - if ( _bbuf == 0 ) - _M_allocate_block( type == sock_base::sock_stream ? 0xb00 : 0xffff ); // max 1460 (dec) [0x5b4] --- single segment - if ( _bbuf == 0 ) { - throw std::length_error( "can't allocate block" ); - } - -#ifdef __FIT_NONBLOCK_SOCKETS - if ( fcntl( _fd, F_SETFL, fcntl( _fd, F_GETFL ) | O_NONBLOCK ) != 0 ) { - throw std::runtime_error( "can't establish nonblock mode" ); - } -#endif -#ifdef __FIT_POLL - pfd.fd = _fd; - pfd.events = POLLIN | POLLHUP | POLLRDNORM; -#endif - setp( _bbuf, _bbuf + ((_ebuf - _bbuf)>>1) ); - setg( this->epptr(), this->epptr(), this->epptr() ); - - _errno = 0; // if any - } - catch ( std::domain_error& ) { -#ifdef WIN32 - _errno = WSAGetLastError(); - ::closesocket( _fd ); -#else - _errno = errno; - ::close( _fd ); -#endif - _fd = -1; - return 0; - } - catch ( std::length_error& ) { -#ifdef WIN32 - ::closesocket( _fd ); -#else - ::close( _fd ); -#endif - _fd = -1; - return 0; - } - catch ( std::runtime_error& ) { -#ifdef WIN32 - _errno = WSAGetLastError(); -#else - _errno = errno; -#endif - return 0; - } - catch ( std::invalid_argument& ) { - return 0; - } - - return this; -} -// -- - -template<class charT, class traits, class _Alloc> -basic_sockbuf<charT, traits, _Alloc> * -basic_sockbuf<charT, traits, _Alloc>::open( sock_base::socket_type s, - sock_base::stype t, - const timespec *timeout ) -{ - if ( is_open() || s == -1 ) { - return 0; - } - - sockaddr sa; - socklen_t sl = sizeof(sa); - getsockname( s, &sa, &sl ); - - return basic_sockbuf<charT, traits, _Alloc>::open( s, sa, t, timeout ); -} - -template<class charT, class traits, class _Alloc> -basic_sockbuf<charT, traits, _Alloc> * -basic_sockbuf<charT, traits, _Alloc>::open( sock_base::socket_type s, - const sockaddr& addr, - sock_base::stype t, - const timespec *timeout ) -{ - if ( is_open() || s == -1 ) { - return 0; - } - _fd = s; - memcpy( (void *)&_address.any, (const void *)&addr, sizeof(sockaddr) ); - _mode = ios_base::in | ios_base::out; - _errno = 0; - _type = t; -#ifdef WIN32 - WSASetLastError( 0 ); -#endif -#ifdef __FIT_POLL - if ( timeout != 0 ) { - _timeout = timeout->tv_sec * 1000 + timeout->tv_nsec / 1000000; - } else { - _timeout = -1; - } -#endif -#ifdef __FIT_SELECT - if ( timeout != 0 ) { - _timeout.tv_sec = timeout->tv_sec; - _timeout.tv_usec = timeout->tv_nsec / 1000; - _timeout_ref = &_timeout; - } else { - _timeout_ref = 0; - } -#endif - if ( t == sock_base::sock_stream ) { - _xwrite = &_Self_type::write; - _xread = &_Self_type::read; - } else if ( t == sock_base::sock_dgram ) { - _xwrite = &_Self_type::sendto; - _xread = &_Self_type::recvfrom; - } else { - _fd = -1; - return 0; // unsupported type - } - - if ( _bbuf == 0 ) { - _M_allocate_block( t == sock_base::sock_stream ? 0xb00 : 0x1ffff ); - } - - if ( _bbuf == 0 ) { -#ifdef WIN32 - ::closesocket( _fd ); -#else - ::close( _fd ); -#endif - _fd = -1; - return 0; - } - -#ifdef __FIT_NONBLOCK_SOCKETS - if ( fcntl( _fd, F_SETFL, fcntl( _fd, F_GETFL ) | O_NONBLOCK ) != 0 ) { - throw std::runtime_error( "can't establish nonblock mode" ); - } -#endif -#ifdef __FIT_POLL - pfd.fd = _fd; - pfd.events = POLLIN | POLLHUP | POLLRDNORM; -#endif - setp( _bbuf, _bbuf + ((_ebuf - _bbuf)>>1) ); - setg( this->epptr(), this->epptr(), this->epptr() ); - - _errno = 0; // if any - - return this; -} - -template<class charT, class traits, class _Alloc> -basic_sockbuf<charT, traits, _Alloc> * -basic_sockbuf<charT, traits, _Alloc>::attach( sock_base::socket_type s, - sock_base::stype t, - const timespec *timeout ) -{ - if ( is_open() || s == -1 ) { - return 0; - } - - sockaddr sa; - socklen_t sl = sizeof(sa); - getsockname( s, &sa, &sl ); - - return basic_sockbuf<charT, traits, _Alloc>::attach( s, sa, t, timeout ); -} - -template<class charT, class traits, class _Alloc> -basic_sockbuf<charT, traits, _Alloc> * -basic_sockbuf<charT, traits, _Alloc>::attach( sock_base::socket_type s, - const sockaddr& addr, - sock_base::stype t, - const timespec *timeout ) -{ - if ( is_open() || s == -1 ) { - return 0; - } - - // _doclose = false; - return basic_sockbuf<charT, traits, _Alloc>::open( dup(s), addr, t, timeout ); -} - -template<class charT, class traits, class _Alloc> -basic_sockbuf<charT, traits, _Alloc> * -basic_sockbuf<charT, traits, _Alloc>::close() -{ - if ( !is_open() ) - return 0; - - // if ( _doclose ) { -#ifdef WIN32 - ::closesocket( _fd ); -#else - ::close( _fd ); -#endif - // } - - // _STLP_ASSERT( _bbuf != 0 ); - // put area before get area - setp( _bbuf, _bbuf + ((_ebuf - _bbuf)>>1) ); - setg( this->epptr(), this->epptr(), this->epptr() ); - - _fd = -1; - - return this; -} - -template<class charT, class traits, class _Alloc> -void basic_sockbuf<charT, traits, _Alloc>::shutdown( sock_base::shutdownflg dir ) -{ - if ( is_open() ) { - if ( (dir & (sock_base::stop_in | sock_base::stop_out)) == - (sock_base::stop_in | sock_base::stop_out) ) { - ::shutdown( _fd, 2 ); - } else if ( dir & sock_base::stop_in ) { - ::shutdown( _fd, 0 ); - } else if ( dir & sock_base::stop_out ) { - ::shutdown( _fd, 1 ); - } - } -} - -template<class charT, class traits, class _Alloc> -__FIT_TYPENAME basic_sockbuf<charT, traits, _Alloc>::int_type -basic_sockbuf<charT, traits, _Alloc>::underflow() -{ - if( !is_open() ) - return traits::eof(); - - if ( this->gptr() < this->egptr() ) - return traits::to_int_type(*this->gptr()); - -#ifndef __FIT_NONBLOCK_SOCKETS -# ifdef __FIT_SELECT - FD_ZERO( &pfd ); - FD_SET( fd(), &pfd ); - - while ( select( fd() + 1, &pfd, 0, 0, _timeout_ref ) <= 0 ) { - if ( errno == EINTR ) { // may be interrupted, check and ignore - errno = 0; - continue; - } - return traits::eof(); - } -# endif // __FIT_SELECT -# ifdef __FIT_POLL - pfd.revents = 0; - - while ( poll( &pfd, 1, _timeout ) <= 0 ) { // wait infinite - if ( errno == EINTR ) { // may be interrupted, check and ignore - errno = 0; - continue; - } - return traits::eof(); - } - if ( (pfd.revents & POLLERR) != 0 ) { - // _state |= ios_base::failbit; - return traits::eof(); - } -# endif // __FIT_POLL -#endif // !__FIT_NONBLOCK_SOCKETS - long offset = (this->*_xread)( this->eback(), sizeof(char_type) * (_ebuf - this->eback()) ); -#ifdef __FIT_NONBLOCK_SOCKETS - if ( offset < 0 && errno == EAGAIN ) { - errno = 0; -# ifdef __FIT_SELECT - FD_ZERO( &pfd ); - FD_SET( fd(), &pfd ); - - while ( select( fd() + 1, &pfd, 0, 0, _timeout_ref ) <= 0 ) { - if ( errno == EINTR ) { // may be interrupted, check and ignore - errno = 0; - continue; - } - return traits::eof(); - } -# endif // __FIT_SELECT -# ifdef __FIT_POLL - pfd.revents = 0; - - while ( poll( &pfd, 1, _timeout ) <= 0 ) { // wait infinite - if ( errno == EINTR ) { // may be interrupted, check and ignore - errno = 0; - continue; - } - return traits::eof(); - } - if ( (pfd.revents & POLLERR) != 0 ) { - // _state |= ios_base::failbit; - return traits::eof(); - } -# endif // __FIT_POLL - offset = (this->*_xread)( this->eback(), sizeof(char_type) * (_ebuf - this->eback()) ); - } -#endif // __FIT_NONBLOCK_SOCKETS - // Without __FIT_NONBLOCK_SOCKETS: - // don't allow message of zero length: - // in conjunction with POLLIN in revent of poll above this designate that - // we receive FIN packet. - // With __FIT_NONBLOCK_SOCKETS: - // 0 is eof, < 0 --- second read also return < 0, but shouldn't - if ( offset <= 0 ) { - return traits::eof(); - } - - offset /= sizeof(charT); - - setg( this->eback(), this->eback(), this->eback() + offset ); - - return traits::to_int_type(*this->gptr()); -} - -template<class charT, class traits, class _Alloc> -__FIT_TYPENAME basic_sockbuf<charT, traits, _Alloc>::int_type -basic_sockbuf<charT, traits, _Alloc>::overflow( int_type c ) -{ - if ( !is_open() ) - return traits::eof(); - - if ( !traits::eq_int_type( c, traits::eof() ) && this->pptr() < this->epptr() ) { - sputc( traits::to_char_type(c) ); - return c; - } - - long count = this->pptr() - this->pbase(); - - if ( count ) { - count *= sizeof(charT); -#ifndef __FIT_NONBLOCK_SOCKETS - if ( (this->*_xwrite)( this->pbase(), count ) != count ) { - return traits::eof(); - } -#else - long offset = (this->*_xwrite)( this->pbase(), count ); - if ( offset < 0 ) { - if ( errno == EAGAIN ) { - pollfd wpfd; - wpfd.fd = _fd; - wpfd.events = POLLOUT | POLLHUP | POLLWRNORM; - wpfd.revents = 0; - while ( poll( &wpfd, 1, _timeout ) <= 0 ) { // wait infinite - if ( errno == EINTR ) { // may be interrupted, check and ignore - errno = 0; - continue; - } - return traits::eof(); - } - if ( (wpfd.revents & POLLERR) != 0 ) { - return traits::eof(); - } - offset = (this->*_xwrite)( this->pbase(), count ); - if ( offset < 0 ) { - return traits::eof(); - } - } else { - return traits::eof(); - } - } - if ( offset < count ) { - // MUST BE: (offset % sizeof(char_traits)) == 0 ! - offset /= sizeof(charT); - count /= sizeof(charT); - traits::move( this->pbase(), this->pbase() + offset, count - offset ); - // std::copy_backword( this->pbase() + offset, this->pbase() + count, this->pbase() ); - setp( this->pbase(), this->epptr() ); // require: set pptr - this->pbump( count - offset ); - if( !traits::eq_int_type(c,traits::eof()) ) { - sputc( traits::to_char_type(c) ); - } - - return traits::not_eof(c); - } -#endif - } - - setp( this->pbase(), this->epptr() ); // require: set pptr - if( !traits::eq_int_type(c,traits::eof()) ) { - sputc( traits::to_char_type(c) ); - } - - return traits::not_eof(c); -} - -template<class charT, class traits, class _Alloc> -int basic_sockbuf<charT, traits, _Alloc>::sync() -{ - if ( !is_open() ) { - return -1; - } - - long count = this->pptr() - this->pbase(); - if ( count ) { - // _STLP_ASSERT( this->pbase() != 0 ); - count *= sizeof(charT); -#ifndef __FIT_NONBLOCK_SOCKETS - if ( (this->*_xwrite)( this->pbase(), count ) != count ) { - return -1; - } -#else - long start = 0; - while ( count > 0 ) { - long offset = (this->*_xwrite)( this->pbase() + start, count ); - if ( offset < 0 ) { - ... [truncated message content] |
From: <com...@us...> - 2008-06-07 17:06:37
|
Revision: 1891 http://complement.svn.sourceforge.net/complement/?rev=1891&view=rev Author: complement Date: 2008-06-07 10:06:27 -0700 (Sat, 07 Jun 2008) Log Message: ----------- base64 encode/decode Added Paths: ----------- trunk/complement/explore/app/utils/base64/ trunk/complement/explore/app/utils/base64/Makefile trunk/complement/explore/app/utils/base64/Makefile.inc trunk/complement/explore/app/utils/base64/base64.cc Property changes on: trunk/complement/explore/app/utils/base64 ___________________________________________________________________ Name: svn:ignore + obj Added: trunk/complement/explore/app/utils/base64/Makefile =================================================================== --- trunk/complement/explore/app/utils/base64/Makefile (rev 0) +++ trunk/complement/explore/app/utils/base64/Makefile 2008-06-07 17:06:27 UTC (rev 1891) @@ -0,0 +1,10 @@ +# -*- Makefile -*- Time-stamp: <07/07/05 09:31:15 ptr> + +SRCROOT := ../../.. + +include Makefile.inc +include ${SRCROOT}/Makefiles/gmake/top.mak + +# INCLUDES += -I${BOOST_DIR} + +LDFLAGS += -Wl,-rpath=${STLPORT_LIB_DIR} Added: trunk/complement/explore/app/utils/base64/Makefile.inc =================================================================== --- trunk/complement/explore/app/utils/base64/Makefile.inc (rev 0) +++ trunk/complement/explore/app/utils/base64/Makefile.inc 2008-06-07 17:06:27 UTC (rev 1891) @@ -0,0 +1,4 @@ +# -*- makefile -*- Time-stamp: <02/07/14 14:03:13 ptr> + +PRGNAME = base64 +SRC_CC = base64.cc Added: trunk/complement/explore/app/utils/base64/base64.cc =================================================================== --- trunk/complement/explore/app/utils/base64/base64.cc (rev 0) +++ trunk/complement/explore/app/utils/base64/base64.cc 2008-06-07 17:06:27 UTC (rev 1891) @@ -0,0 +1,71 @@ + +#include <iostream> + +using namespace std; + +unsigned char a64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +const char cd64[]="|$$$}rstuvwxyz{$$$$$$$>?@ABCDEFGHIJKLMNOPQRSTUVW$$$$$$XYZ[\\]^_`abcdefghijklmnopq"; + +// void decode( istream ) +// { +// } + +void decodeblock( unsigned char in[4], unsigned char out[3] ) +{ + out[ 0 ] = (unsigned char ) (in[0] << 2 | in[1] >> 4); + out[ 1 ] = (unsigned char ) (in[1] << 4 | in[2] >> 2); + out[ 2 ] = (unsigned char ) (((in[2] << 6) & 0xc0) | in[3]); +} + +#if 1 +void decode( istream& is, ostream& os ) +{ + unsigned char in[4], out[3], v; + int len; + + while( !is.eof() ) { + len = 0; + for( int i = 0; i < 4 && !is.eof(); i++ ) { + v = 0; + while( !is.eof() && v == 0 ) { + is >> v; + v = (unsigned char) ((v < 43 || v > 122) ? 0 : cd64[ v - 43 ]); + if ( v ) { + v = (unsigned char) ((v == '$') ? 0 : v - 61); + } + } + if( !is.eof() ) { + len++; + if ( v ) { + in[ i ] = (unsigned char) (v - 1); + } + } else { + in[i] = 0; + } + } + if ( len ) { + decodeblock( in, out ); + for ( int i = 0; i < len - 1; i++ ) { + os << out[i]; + } + } + } +} +#else +void decode( istream& is, ostream& os ) +{ + unsigned char in[4], out[3], v; + while( !is.eof() ) { + is >> in[0] >> in[1] >> in[2] >> in[3]; + decodeblock( in, out ); + os << out[0] << out[1] << out[2]; + } +} +#endif + +int main() +{ + decode( cin, cout ); + + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2008-06-07 11:28:22
|
Revision: 1890 http://complement.svn.sourceforge.net/complement/?rev=1890&view=rev Author: complement Date: 2008-06-07 04:28:16 -0700 (Sat, 07 Jun 2008) Log Message: ----------- don't duplicate options in config.mak, that has default values in makefiles Modified Paths: -------------- trunk/complement/explore/Makefiles/ChangeLog trunk/complement/explore/configure Modified: trunk/complement/explore/Makefiles/ChangeLog =================================================================== --- trunk/complement/explore/Makefiles/ChangeLog 2008-06-06 17:27:03 UTC (rev 1889) +++ trunk/complement/explore/Makefiles/ChangeLog 2008-06-07 11:28:16 UTC (rev 1890) @@ -1,3 +1,8 @@ +2008-06-07 Petr Ovtchenkov <pt...@is...> + + * configure: don't duplicate options in config.mak, that + has default values in makefiles. + 2008-06-06 Petr Ovtchenkov <pt...@is...> * gmake/targetdirs.mak: use $(DESTDIR) as in common practice Modified: trunk/complement/explore/configure =================================================================== --- trunk/complement/explore/configure 2008-06-06 17:27:03 UTC (rev 1889) +++ trunk/complement/explore/configure 2008-06-07 11:28:16 UTC (rev 1890) @@ -1,6 +1,6 @@ #!/bin/sh -# Time-stamp: <08/06/06 17:44:52 yeti> +# Time-stamp: <08/06/07 15:22:06 yeti> base=`cd \`dirname $0\`; echo $PWD` @@ -86,27 +86,26 @@ # write_option "${PWD}/external/boost" BOOST_DIR # fi - if [ "$stlport_set" = "" ]; then - # write_option "${PWD}/external/STLport" STLPORT_DIR - write_option "1" WITHOUT_STLPORT - fi + # Set in Makefiles/gmake/extern.mak + # if [ -z "${stlport_set}" ]; then + # # write_option "${PWD}/external/STLport" STLPORT_DIR + # write_option "1" WITHOUT_STLPORT + # fi + # write_option "${PWD}/build/" BASE_INSTALL_DIR '${DESTDIR}' - if [ "$compiler_family_set" = "" ]; then - write_option gcc COMPILER_NAME - fi - # if [ "$prefix_set" = "" ]; then + + # Set in Makefiles/gmake/top.mak + # if [ -z "${compiler_family_set}" ]; then + # write_option gcc COMPILER_NAME + # fi + + # Set in Makefiles/gmake/targetdirs.mak + # if [ -z "${prefix_set}" ]; then # write_option "/usr/local" BASE_INSTALL_DIR '${DESTDIR}' # fi } -case $# in - 0) - if [ ! -f ${configmak} ]; then - default_settings - fi - exit 0 - ;; -esac +[ $# -eq 0 ] && { >${configmak}; default_settings; exit 0; } for a in $@ ; do case $a in @@ -121,8 +120,7 @@ esac done -rm -f ${configmak} -touch ${configmak} +>${configmak} while : do @@ -207,7 +205,7 @@ ;; --prefix=*) write_option "$option" BASE_INSTALL_DIR '${DESTDIR}' - # prefix_set=y + prefix_set=y ;; --bindir=*) write_option "$option" INSTALL_BIN_DIR '${DESTDIR}' @@ -221,46 +219,46 @@ esac done -if [ "$CXX" != "" ]; then - if [ "$cxx_set" != "" ]; then +if [ -n "${CXX}" ]; then + if [ -n "${cxx_set}" ]; then echo "Both --with-cxx and \$CXX set, using the first" - elif [ "$target_set" = "" ]; then - write_option "$CXX" _FORCE_CXX + elif [ -z "${target_set}" ]; then + write_option "${CXX}" _FORCE_CXX else echo "For cross-compilation with gcc use --target option only" fi - if [ "$CC" = "" ] && [ "$cc_set" = "" ]; then + if [ -z "${CC}" -a -z "${cc_set}" ]; then echo "\$CXX set, but I don't see \$CC!" fi fi -if [ "$CC" != "" ]; then - if [ "$cxx_set" != "" ]; then +if [ -n "${CC}" ]; then + if [ -n "${cxx_set}" ]; then echo "Both --with-cc and \$CC set, using the first" else - write_option "$CC" _FORCE_CC + write_option "${CC}" _FORCE_CC fi fi -if [ "$CXXFLAGS" != "" ]; then - if [ "$cxxflags_set" = "" ]; then - write_option "$CXXFLAGS" EXTRA_CXXFLAGS +if [ -n "${CXXFLAGS}" ]; then + if [ -z "${cxxflags_set}" ]; then + write_option "${CXXFLAGS}" EXTRA_CXXFLAGS else echo "Both --with-extra-cxxflags and \$CXXFLAGS set, using the first" fi fi -if [ "$CFLAGS" != "" ]; then - if [ "$cflags_set" = "" ]; then - write_option "$CFLAGS" EXTRA_CFLAGS +if [ -n "${CFLAGS}" ]; then + if [ -z "${cflags_set}" ]; then + write_option "${CFLAGS}" EXTRA_CFLAGS else echo "Both --with-extra-cflags and \$CFLAGS set, using the first" fi fi -if [ "$LDFLAGS" != "" ]; then - if [ "$ldflags_set" = "" ]; then - write_option "$LDFLAGS" EXTRA_LDFLAGS +if [ -n "${LDFLAGS}" ]; then + if [ -z "${ldflags_set}" ]; then + write_option "${LDFLAGS}" EXTRA_LDFLAGS else echo "Both --with-extra-ldflags and \$LDFLAGS set, using the first" fi This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2008-06-06 17:27:26
|
Revision: 1889 http://complement.svn.sourceforge.net/complement/?rev=1889&view=rev Author: complement Date: 2008-06-06 10:27:03 -0700 (Fri, 06 Jun 2008) Log Message: ----------- functions for generating UIDs; libxmt revision to 2.0.3 Modified Paths: -------------- trunk/complement/explore/include/mt/uid.h trunk/complement/explore/lib/mt/ChangeLog trunk/complement/explore/lib/mt/Makefile.inc trunk/complement/explore/lib/mt/uid.cc Modified: trunk/complement/explore/include/mt/uid.h =================================================================== --- trunk/complement/explore/include/mt/uid.h 2008-06-06 14:41:32 UTC (rev 1888) +++ trunk/complement/explore/include/mt/uid.h 2008-06-06 17:27:03 UTC (rev 1889) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/11/29 13:38:05 ptr> +// -*- C++ -*- Time-stamp: <08/06/06 21:21:30 yeti> /* * Copyright (c) 2006 @@ -65,6 +65,9 @@ const char *hostid_str(); const xmt::uuid_type& hostid(); +std::string uid_str(); +xmt::uuid_type uid(); + } // namespace xmt #endif // __mt_uid_h Modified: trunk/complement/explore/lib/mt/ChangeLog =================================================================== --- trunk/complement/explore/lib/mt/ChangeLog 2008-06-06 14:41:32 UTC (rev 1888) +++ trunk/complement/explore/lib/mt/ChangeLog 2008-06-06 17:27:03 UTC (rev 1889) @@ -1,3 +1,9 @@ +2008-06-06 Petr Ovtchenkov <pt...@is...> + + * uid.h, uid.cc: functions for generating UIDs; + + * libxmt: bump revision to 2.0.3. + 2008-04-23 Petr Ovtchenkov <pt...@is...> * mutex: remove STLport-specific macro STATIC_CAST; Modified: trunk/complement/explore/lib/mt/Makefile.inc =================================================================== --- trunk/complement/explore/lib/mt/Makefile.inc 2008-06-06 14:41:32 UTC (rev 1888) +++ trunk/complement/explore/lib/mt/Makefile.inc 2008-06-06 17:27:03 UTC (rev 1889) @@ -1,9 +1,9 @@ -# -*- Makefile -*- Time-stamp: <08/04/23 23:15:02 ptr> +# -*- Makefile -*- Time-stamp: <08/06/06 21:25:42 yeti> LIBNAME = xmt MAJOR = 2 MINOR = 0 -PATCH = 2 +PATCH = 3 SRC_CC = xmt.cc thr_mgr.cc time.cc uid.cc shm.cc callstack.cc system_error.cc thread.cc \ date_time.cc SRC_C = fl.c Modified: trunk/complement/explore/lib/mt/uid.cc =================================================================== --- trunk/complement/explore/lib/mt/uid.cc 2008-06-06 14:41:32 UTC (rev 1888) +++ trunk/complement/explore/lib/mt/uid.cc 2008-06-06 17:27:03 UTC (rev 1889) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/11/29 13:38:19 ptr> +// -*- C++ -*- Time-stamp: <08/06/06 21:23:34 yeti> /* * Copyright (c) 2006 @@ -34,6 +34,16 @@ uuid_type __uid_init::_host_id; char __uid_init::_host_id_str[48]; +class __uuid_init +{ + public: + __uuid_init(); + + static ifstream _uuid; +}; + +ifstream __uuid_init::_uuid; + __uid_init::__uid_init() { static mutex _lk; @@ -83,8 +93,21 @@ >> reinterpret_cast<unsigned&>(_host_id.u.b[15]); } +__uuid_init::__uuid_init() +{ + static mutex _lk; + + scoped_lock lock( _lk ); + + if ( !_uuid.is_open() ) { + _uuid.open( "/proc/sys/kernel/random/uuid" ); + } +} + } // namespace detail +using namespace std; + const char *hostid_str() { static detail::__uid_init _uid; @@ -97,4 +120,63 @@ return detail::__uid_init::_host_id; } +std::string uid_str() +{ + static detail::__uuid_init _uid; + + static mutex _lk; + + scoped_lock lock( _lk ); + + std::string tmp; + + getline( _uid._uuid, tmp ); + + return tmp; +} + +xmt::uuid_type uid() +{ + string tmp = uid_str(); + uuid_type id; + + stringstream s; + s << tmp[0] << tmp[1] << ' ' + << tmp[2] << tmp[3] << ' ' + << tmp[4] << tmp[5] << ' ' + << tmp[6] << tmp[7] << ' ' // - + << tmp[9] << tmp[10] << ' ' + << tmp[11] << tmp[12] << ' ' // - + << tmp[14] << tmp[15] << ' ' + << tmp[16] << tmp[17] << ' ' // - + << tmp[19] << tmp[20] << ' ' + << tmp[21] << tmp[22] << ' ' // - + << tmp[24] << tmp[25] << ' ' + << tmp[26] << tmp[27] << ' ' + << tmp[28] << tmp[29] << ' ' + << tmp[30] << tmp[31] << ' ' + << tmp[32] << tmp[33] << ' ' + << tmp[34] << tmp[35]; + + s >> hex + >> reinterpret_cast<unsigned&>(id.u.b[0]) + >> reinterpret_cast<unsigned&>(id.u.b[1]) + >> reinterpret_cast<unsigned&>(id.u.b[2]) + >> reinterpret_cast<unsigned&>(id.u.b[3]) + >> reinterpret_cast<unsigned&>(id.u.b[4]) + >> reinterpret_cast<unsigned&>(id.u.b[5]) + >> reinterpret_cast<unsigned&>(id.u.b[6]) + >> reinterpret_cast<unsigned&>(id.u.b[7]) + >> reinterpret_cast<unsigned&>(id.u.b[8]) + >> reinterpret_cast<unsigned&>(id.u.b[9]) + >> reinterpret_cast<unsigned&>(id.u.b[10]) + >> reinterpret_cast<unsigned&>(id.u.b[11]) + >> reinterpret_cast<unsigned&>(id.u.b[12]) + >> reinterpret_cast<unsigned&>(id.u.b[13]) + >> reinterpret_cast<unsigned&>(id.u.b[14]) + >> reinterpret_cast<unsigned&>(id.u.b[15]); + + return id; +} + } // namespace xmt This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2008-06-06 14:41:48
|
Revision: 1888 http://complement.svn.sourceforge.net/complement/?rev=1888&view=rev Author: complement Date: 2008-06-06 07:41:32 -0700 (Fri, 06 Jun 2008) Log Message: ----------- take into account extra CFLAGS and LDFLAGS; configurable via 'configure'; don't assume presence of STLport. Modified Paths: -------------- trunk/complement/explore/Makefiles/ChangeLog trunk/complement/explore/Makefiles/gmake/extern.mak trunk/complement/explore/Makefiles/gmake/gcc.mak trunk/complement/explore/Makefiles/gmake/top.mak trunk/complement/explore/configure Modified: trunk/complement/explore/Makefiles/ChangeLog =================================================================== --- trunk/complement/explore/Makefiles/ChangeLog 2008-06-06 12:29:52 UTC (rev 1887) +++ trunk/complement/explore/Makefiles/ChangeLog 2008-06-06 14:41:32 UTC (rev 1888) @@ -3,8 +3,13 @@ * gmake/targetdirs.mak: use $(DESTDIR) as in common practice (change root of installation, but don't change run paths); - * gmake/depend.mak: fix options for ctags/etags. + * gmake/depend.mak: fix options for ctags/etags; + * gmake/gcc.mak, gmake/top.mak, configure: take into account + extra CFLAGS and LDFLAGS; configurable via 'configure'; + + * gmake/extern.mak: don't assume presence of STLport. + 2008-02-27 Petr Ovtchenkov <pt...@is...> * gmake/lib/gcc.mak: 3.3 is normal compiler, just some Modified: trunk/complement/explore/Makefiles/gmake/extern.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/extern.mak 2008-06-06 12:29:52 UTC (rev 1887) +++ trunk/complement/explore/Makefiles/gmake/extern.mak 2008-06-06 14:41:32 UTC (rev 1888) @@ -1,6 +1,6 @@ -# Time-stamp: <07/03/08 22:41:26 ptr> +# Time-stamp: <08/06/06 17:06:16 yeti> # -# Copyright (c) 1997-1999, 2002, 2003, 2005, 2006 +# Copyright (c) 1997-1999, 2002, 2003, 2005, 2006, 2008 # Petr Ovtchenkov # # Portion Copyright (c) 1999-2001 @@ -30,9 +30,11 @@ # STLport library +ifndef STLPORT_DIR ifndef WITHOUT_STLPORT -STLPORT_DIR ?= ${HOME}/STLport.lab/STLport +WITHOUT_STLPORT = 1 endif +endif ifdef STLPORT_DIR STLPORT_LIB_DIR ?= $(STLPORT_DIR)/${TARGET_NAME}lib Modified: trunk/complement/explore/Makefiles/gmake/gcc.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/gcc.mak 2008-06-06 12:29:52 UTC (rev 1887) +++ trunk/complement/explore/Makefiles/gmake/gcc.mak 2008-06-06 14:41:32 UTC (rev 1888) @@ -1,4 +1,4 @@ -# Time-stamp: <08/02/26 13:46:36 ptr> +# Time-stamp: <08/06/06 17:38:26 yeti> # # Copyright (c) 1997-1999, 2002, 2003, 2005-2008 # Petr Ovtchenkov @@ -179,6 +179,10 @@ CXXFLAGS += ${EXTRA_CXXFLAGS} endif +ifdef EXTRA_CFLAGS +CFLAGS += ${EXTRA_CFLAGS} +endif + CDEPFLAGS = -E -M CCDEPFLAGS = -E -M Modified: trunk/complement/explore/Makefiles/gmake/top.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/top.mak 2008-06-06 12:29:52 UTC (rev 1887) +++ trunk/complement/explore/Makefiles/gmake/top.mak 2008-06-06 14:41:32 UTC (rev 1888) @@ -1,4 +1,4 @@ -# Time-stamp: <07/07/12 10:55:41 ptr> +# Time-stamp: <08/06/06 17:28:38 yeti> # # Copyright (c) 1997-1999, 2002, 2003, 2005-2007 # Petr Ovtchenkov @@ -25,6 +25,10 @@ COMPILER_NAME := gcc endif +ifndef LDFLAGS +LDFLAGS := +endif + ifndef ALL_TAGS ifndef _NO_SHARED_BUILD @@ -91,6 +95,8 @@ # os-specific local rules (or other project-specific definitions) -include specific.mak +LDFLAGS += ${EXTRA_LDFLAGS} + # derive common targets (*.o, *.d), # build rules (including output catalogs) include ${RULESBASE}/gmake/targets.mak Modified: trunk/complement/explore/configure =================================================================== --- trunk/complement/explore/configure 2008-06-06 12:29:52 UTC (rev 1887) +++ trunk/complement/explore/configure 2008-06-06 14:41:32 UTC (rev 1888) @@ -1,6 +1,6 @@ #!/bin/sh -# Time-stamp: <08/02/26 16:02:32 yeti> +# Time-stamp: <08/06/06 17:44:52 yeti> base=`cd \`dirname $0\`; echo $PWD` @@ -47,6 +47,10 @@ --with-mssdk=<dir> use MS SDK from this catalog --with-extra-cxxflags=<options> pass extra options to C++ compiler + --with-extra-cflags=<options> + pass extra options to C compiler + --with-extra-ldflags=<options> + pass extra options to linker (via C/C++) --use-static-gcc use static gcc libs instead of shared libgcc_s (useful for gcc compiler, that was builded with --enable-shared [default]; if compiler was builded with --disable-shared, static libraries will be used in any case) @@ -69,6 +73,8 @@ \$CXX C++ compiler name (use --target= for cross-compilation) \$CC C compiler name (use --target= for cross-compilation) \$CXXFLAGS pass extra options to C++ compiler + \$CFLAGS pass extra options to C compiler + \$LDFLAGS pass extra options to linker (via C/C++) Options has preference over environment variables. @@ -156,6 +162,14 @@ write_option "$option" EXTRA_CXXFLAGS cxxflags_set=y ;; + --with-extra-cflags=*) + write_option "$option" EXTRA_CFLAGS + cflags_set=y + ;; + --with-extra-ldflags=*) + write_option "$option" EXTRA_LDFLAGS + ldflags_set=y + ;; --use-static-gcc) write_option "1" USE_STATIC_LIBGCC ;; @@ -236,6 +250,22 @@ fi fi +if [ "$CFLAGS" != "" ]; then + if [ "$cflags_set" = "" ]; then + write_option "$CFLAGS" EXTRA_CFLAGS + else + echo "Both --with-extra-cflags and \$CFLAGS set, using the first" + fi +fi + +if [ "$LDFLAGS" != "" ]; then + if [ "$ldflags_set" = "" ]; then + write_option "$LDFLAGS" EXTRA_LDFLAGS + else + echo "Both --with-extra-ldflags and \$LDFLAGS set, using the first" + fi +fi + # default settings default_settings This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2008-06-06 12:29:57
|
Revision: 1887 http://complement.svn.sourceforge.net/complement/?rev=1887&view=rev Author: complement Date: 2008-06-06 05:29:52 -0700 (Fri, 06 Jun 2008) Log Message: ----------- use $(DESTDIR) as in common practice (change root of installation, but don't change run paths); fix options for ctags/etags. Modified Paths: -------------- trunk/complement/explore/Makefiles/ChangeLog trunk/complement/explore/Makefiles/gmake/depend.mak trunk/complement/explore/Makefiles/gmake/targetdirs.mak Modified: trunk/complement/explore/Makefiles/ChangeLog =================================================================== --- trunk/complement/explore/Makefiles/ChangeLog 2008-06-05 08:57:35 UTC (rev 1886) +++ trunk/complement/explore/Makefiles/ChangeLog 2008-06-06 12:29:52 UTC (rev 1887) @@ -1,3 +1,10 @@ +2008-06-06 Petr Ovtchenkov <pt...@is...> + + * gmake/targetdirs.mak: use $(DESTDIR) as in common practice + (change root of installation, but don't change run paths); + + * gmake/depend.mak: fix options for ctags/etags. + 2008-02-27 Petr Ovtchenkov <pt...@is...> * gmake/lib/gcc.mak: 3.3 is normal compiler, just some Modified: trunk/complement/explore/Makefiles/gmake/depend.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/depend.mak 2008-06-05 08:57:35 UTC (rev 1886) +++ trunk/complement/explore/Makefiles/gmake/depend.mak 2008-06-06 12:29:52 UTC (rev 1887) @@ -1,6 +1,6 @@ # Time-stamp: <07/02/05 12:57:11 ptr> # -# Copyright (c) 1997-1999, 2002, 2003, 2005, 2006 +# Copyright (c) 1997-1999, 2002, 2003, 2005, 2006, 2008 # Petr Ovtchenkov # # Portion Copyright (c) 1999-2001 @@ -35,9 +35,9 @@ @cat -s $(_ALL_DEP) /dev/null > $(DEPENDS_COLLECTION) TAGS: $(OUTPUT_DIRS) ${_DASH_DEP} - @cat -s $(_ALL_DEP) /dev/null | sed -e 's/^.*://;s/^ *//;s/\\$$//;s/ $$//;s/ /\n/g' | sort | uniq | xargs etags -i -m + @cat -s $(_ALL_DEP) /dev/null | sed -e 's/^.*://;s/^ *//;s/\\$$//;s/ $$//;s/ /\n/g' | sort | uniq | xargs etags -I --declarations tags: $(OUTPUT_DIRS) ${_DASH_DEP} - @cat -s $(_ALL_DEP) /dev/null | sed -e 's/^.*://;s/^ *//;s/\\$$//;s/ $$//;s/ /\n/g' | sort | uniq | ctags -d --globals --declarations -t -w + @cat -s $(_ALL_DEP) /dev/null | sed -e 's/^.*://;s/^ *//;s/\\$$//;s/ $$//;s/ /\n/g' | sort | uniq | xargs ctags -d --globals --declarations -t -T -include $(DEPENDS_COLLECTION) Modified: trunk/complement/explore/Makefiles/gmake/targetdirs.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/targetdirs.mak 2008-06-05 08:57:35 UTC (rev 1886) +++ trunk/complement/explore/Makefiles/gmake/targetdirs.mak 2008-06-06 12:29:52 UTC (rev 1887) @@ -36,12 +36,11 @@ OUTPUT_DIR_A_STLDBG := $(OUTPUT_DIR_STLDBG) endif -# BASE_INSTALL_DIR ?= ${SRCROOT}/build/$(TARGET_NAME) -BASE_INSTALL_DIR ?= $(DESTDIR)/usr/local +BASE_INSTALL_DIR ?= /usr/local -BASE_INSTALL_LIB_DIR ?= ${BASE_INSTALL_DIR} -BASE_INSTALL_BIN_DIR ?= ${BASE_INSTALL_DIR} -BASE_INSTALL_HDR_DIR ?= ${BASE_INSTALL_DIR} +BASE_INSTALL_LIB_DIR ?= $(DESTDIR)${BASE_INSTALL_DIR} +BASE_INSTALL_BIN_DIR ?= $(DESTDIR)${BASE_INSTALL_DIR} +BASE_INSTALL_HDR_DIR ?= $(DESTDIR)${BASE_INSTALL_DIR} INSTALL_LIB_DIR ?= ${BASE_INSTALL_LIB_DIR}/${TARGET_NAME}lib INSTALL_LIB_DIR_DBG ?= ${BASE_INSTALL_LIB_DIR}/${TARGET_NAME}lib This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2008-06-05 08:57:46
|
Revision: 1886 http://complement.svn.sourceforge.net/complement/?rev=1886&view=rev Author: complement Date: 2008-06-05 01:57:35 -0700 (Thu, 05 Jun 2008) Log Message: ----------- fix compilation; shouldn't work indeed, review required Modified Paths: -------------- branches/complement-sockios/explore/include/sockios/sockstream2 branches/complement-sockios/explore/include/sockios/sp.cc branches/complement-sockios/explore/include/sockios/sp.h branches/complement-sockios/explore/lib/sockios/ut/sockios2_test.cc Modified: branches/complement-sockios/explore/include/sockios/sockstream2 =================================================================== --- branches/complement-sockios/explore/include/sockios/sockstream2 2008-06-04 13:53:54 UTC (rev 1885) +++ branches/complement-sockios/explore/include/sockios/sockstream2 2008-06-05 08:57:35 UTC (rev 1886) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/04/09 13:02:18 yeti> +// -*- C++ -*- Time-stamp: <08/06/05 12:53:21 yeti> /* * Copyright (c) 1997-1999, 2002, 2003, 2005-2008 @@ -190,6 +190,9 @@ template <class charT, class traits, class _Alloc> class sockmgr; } // namespace detail +template <class charT, class traits, class _Alloc> +class sock_processor_base; + template<class charT, class traits, class _Alloc> class basic_socket { @@ -617,6 +620,7 @@ std::tr2::condition_variable ucnd; friend class detail::sockmgr<charT,traits,_Alloc>; + friend class sock_processor_base<charT,traits,_Alloc>; }; template <class charT, class traits, class _Alloc> @@ -768,7 +772,7 @@ typedef basic_sockbuf2<char,char_traits<char>,allocator<char> > sockbuf2; // typedef basic_sockbuf2<wchar_t,char_traits<wchar_t>,allocator<wchar_t> > wsockbuf; -typedef basic_sockstream2<char,char_traits<char>,allocator<char> > sockstream2; +typedef basic_sockstream2<char,std::char_traits<char>,std::allocator<char> > sockstream2; // typedef basic_sockstream<wchar_t,char_traits<wchar_t>,allocator<wchar_t> > wsockstream; #ifdef STLPORT Modified: branches/complement-sockios/explore/include/sockios/sp.cc =================================================================== --- branches/complement-sockios/explore/include/sockios/sp.cc 2008-06-04 13:53:54 UTC (rev 1885) +++ branches/complement-sockios/explore/include/sockios/sp.cc 2008-06-05 08:57:35 UTC (rev 1886) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/04/11 21:52:28 yeti> +// -*- C++ -*- Time-stamp: <08/06/05 12:55:59 yeti> /* * Copyright (c) 2008 @@ -199,19 +199,19 @@ } template <class Connect, class charT, class traits, class _Alloc, void (Connect::*C)( std::basic_sockstream2<charT,traits,_Alloc>& )> -void connect_processor<Connect, charT, traits, _Alloc, C>::operator ()( int fd, const typename connect_processor<Connect, charT, traits, _Alloc, C>::base_t::adopt_new_t& ) +void connect_processor<Connect, charT, traits, _Alloc, C>::operator ()( int fd, const sockaddr& addr ) { - typename base_t::sockstream_t* s = base_t::create_stream( fd ); + typename base_t::sockstream_t* s = base_t::create_stream( fd, addr ); - Connect* c = new Connect( s ); // bad point! I can't read from s in ctor indeed! + Connect* c = new Connect( *s ); // bad point! I can't read from s in ctor indeed! - if ( s.rdbuf()->in_avail() ) { + if ( s->rdbuf()->in_avail() ) { std::tr2::lock_guard<std::tr2::mutex> lk( rdlock ); - ready_pool.push_back( processor( c, &s ) ); + ready_pool.push_back( processor( c, s ) ); cnd.notify_one(); } else { std::tr2::lock_guard<std::tr2::mutex> lk( wklock ); - worker_pool.insert( std::make_pair( &s, c ) ); + worker_pool.insert( std::make_pair( fd, processor( c, s ) ) ); } } @@ -306,7 +306,7 @@ ready_pool.push_back( p ); } else { std::tr2::lock_guard<std::tr2::mutex> lk( wklock ); - worker_pool[p.s] = p.c; + worker_pool[p.s->rdbuf()->fd()] = p; } // std::cerr << "worker 3\n"; } @@ -497,7 +497,7 @@ try { std::cerr << __FILE__ << ":" << __LINE__ << " new sockstream_t" << std::endl; - (*info.p)( fd, typename socks_processor_t::adopt_new_t() ); + (*info.p)( fd, addr ); epoll_event ev_add; ev_add.events = EPOLLIN | EPOLLRDHUP | EPOLLERR | EPOLLHUP | EPOLLET | EPOLLONESHOT; @@ -591,7 +591,7 @@ } } if ( !is_closed ) { - (*info.p)( *info.s.s, typename socks_processor_t::adopt_data_t() ); + (*info.p)( ev.data.fd, typename socks_processor_t::adopt_data_t() ); } } break; @@ -652,7 +652,7 @@ } } if ( !is_closed ) { - (*info.p)( *info.s.s, typename socks_processor_t::adopt_data_t() ); + (*info.p)( ev.data.fd, typename socks_processor_t::adopt_data_t() ); } } } else { @@ -686,13 +686,13 @@ } if ( need_delete ) { std::cerr << __FILE__ << ":" << __LINE__ << " " << (void*)info.s.s << std::endl; - (*info.p)( *info.s.s, typename socks_processor_t::adopt_close_t() ); + (*info.p)( ifd->first, typename socks_processor_t::adopt_close_t() ); std::cerr << __FILE__ << ":" << __LINE__ << " " << (void*)info.s.s << std::endl; } } if ( (info.flags & fd_info::owner) != 0 && need_delete ) { std::cerr << __FILE__ << ":" << __LINE__ << " " << (void*)info.s.s << std::endl; - delete info.s.s; + delete info.s.s; // Ahtung! info.s.s = 0; } else { std::cerr << __FILE__ << ":" << __LINE__ << " " << (void*)info.s.s << std::endl; @@ -734,7 +734,7 @@ for ( typename fd_container_type::iterator ifd = descr.begin(); ifd != descr.end(); ) { if ( (ifd->second.flags & fd_info::owner) && (ifd->second.p == &p) ) { std::cerr << __FILE__ << ":" << __LINE__ << " " << (void*)&p << " " << (void*)ifd->second.s.s << std::endl; - p( /* *ifd->second.s.s */ /* *ifd->second.s.s.rdbuf()->fd() */, typename socks_processor_t::adopt_close_t() ); + p( ifd->first, typename socks_processor_t::adopt_close_t() ); std::cerr << __FILE__ << ":" << __LINE__ << " " << (void*)&p << " " << (void*)ifd->second.s.s << std::endl; delete ifd->second.s.s; if ( epoll_ctl( efd, EPOLL_CTL_DEL, ifd->first, 0 ) < 0 ) { Modified: branches/complement-sockios/explore/include/sockios/sp.h =================================================================== --- branches/complement-sockios/explore/include/sockios/sp.h 2008-06-04 13:53:54 UTC (rev 1885) +++ branches/complement-sockios/explore/include/sockios/sp.h 2008-06-05 08:57:35 UTC (rev 1886) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/04/11 22:14:39 yeti> +// -*- C++ -*- Time-stamp: <08/06/05 12:38:28 yeti> /* * Copyright (c) 2008 @@ -100,7 +100,7 @@ virtual void close(); - virtual void operator ()( int fd, const adopt_new_t& ) = 0; + virtual void operator ()( int fd, const sockaddr& ) = 0; virtual void operator ()( int fd, const adopt_close_t& ) = 0; virtual void operator ()( int fd, const adopt_data_t& ) = 0; @@ -110,10 +110,10 @@ protected: void setoptions_unsafe( sock_base2::so_t optname, bool on_off = true, int __v = 0 ); - sockstream_t* create_stream( int fd ) + sockstream_t* create_stream( int fd, const sockaddr& addr ) { sockstream_t* s = new sockstream_t(); - // s->rdbuf()->_open_sockmgr( fd, addr ); + s->rdbuf()->_open_sockmgr( fd, addr ); return s; } @@ -216,7 +216,7 @@ { if ( ploop.joinable() ) { ploop.join(); } } private: - virtual void operator ()( int fd, const typename base_t::adopt_new_t& ); + virtual void operator ()( int fd, const sockaddr& ); virtual void operator ()( int fd, const typename base_t::adopt_close_t& ); virtual void operator ()( int fd, const typename base_t::adopt_data_t& ); Modified: branches/complement-sockios/explore/lib/sockios/ut/sockios2_test.cc =================================================================== --- branches/complement-sockios/explore/lib/sockios/ut/sockios2_test.cc 2008-06-04 13:53:54 UTC (rev 1885) +++ branches/complement-sockios/explore/lib/sockios/ut/sockios2_test.cc 2008-06-05 08:57:35 UTC (rev 1886) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/04/09 21:18:52 yeti> +// -*- C++ -*- Time-stamp: <08/06/05 12:37:58 yeti> /* * @@ -46,7 +46,7 @@ { /* cerr << "In destructor\n"; */ } protected: - virtual void operator ()( int, const adopt_new_t& ) + virtual void operator ()( int, const sockaddr& ) { lock_guard<mutex> lk(lock); b.wait(); ++n_cnt; } virtual void operator ()( int, const adopt_close_t& ) { lock_guard<mutex> lk(lock); b.wait(); ++c_cnt; } @@ -80,7 +80,7 @@ { } protected: - virtual void operator ()( int, const adopt_new_t& ) + virtual void operator ()( int, const sockaddr& ) { lock_guard<mutex> lk(lock); b.wait(); ++n_cnt; } virtual void operator ()( int, const adopt_close_t& ) { lock_guard<mutex> lk(lock); b.wait(); ++c_cnt; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <oke...@us...> - 2008-06-04 13:54:00
|
Revision: 1885 http://complement.svn.sourceforge.net/complement/?rev=1885&view=rev Author: okechina Date: 2008-06-04 06:53:54 -0700 (Wed, 04 Jun 2008) Log Message: ----------- Modified Paths: -------------- branches/complement-sockios/explore/include/sockios/sp.cc branches/complement-sockios/explore/include/sockios/sp.h branches/complement-sockios/explore/lib/sockios/ut/sockios2_test.cc Modified: branches/complement-sockios/explore/include/sockios/sp.cc =================================================================== --- branches/complement-sockios/explore/include/sockios/sp.cc 2008-06-03 13:19:42 UTC (rev 1884) +++ branches/complement-sockios/explore/include/sockios/sp.cc 2008-06-04 13:53:54 UTC (rev 1885) @@ -502,7 +502,7 @@ epoll_event ev_add; ev_add.events = EPOLLIN | EPOLLRDHUP | EPOLLERR | EPOLLHUP | EPOLLET | EPOLLONESHOT; ev_add.data.fd = fd; -//undeclared s with some flags +//undeclared s // fd_info new_info = { fd_info::owner, s, info.p }; fd_info new_info = { fd_info::owner, 0, info.p }; descr[fd] = new_info; @@ -734,7 +734,7 @@ for ( typename fd_container_type::iterator ifd = descr.begin(); ifd != descr.end(); ) { if ( (ifd->second.flags & fd_info::owner) && (ifd->second.p == &p) ) { std::cerr << __FILE__ << ":" << __LINE__ << " " << (void*)&p << " " << (void*)ifd->second.s.s << std::endl; - p( *ifd->second.s.s, typename socks_processor_t::adopt_close_t() ); + p( /* *ifd->second.s.s */ /* *ifd->second.s.s.rdbuf()->fd() */, typename socks_processor_t::adopt_close_t() ); std::cerr << __FILE__ << ":" << __LINE__ << " " << (void*)&p << " " << (void*)ifd->second.s.s << std::endl; delete ifd->second.s.s; if ( epoll_ctl( efd, EPOLL_CTL_DEL, ifd->first, 0 ) < 0 ) { Modified: branches/complement-sockios/explore/include/sockios/sp.h =================================================================== --- branches/complement-sockios/explore/include/sockios/sp.h 2008-06-03 13:19:42 UTC (rev 1884) +++ branches/complement-sockios/explore/include/sockios/sp.h 2008-06-04 13:53:54 UTC (rev 1885) @@ -110,13 +110,13 @@ protected: void setoptions_unsafe( sock_base2::so_t optname, bool on_off = true, int __v = 0 ); -/* sockstream_t* create_stream( int fd ) + sockstream_t* create_stream( int fd ) { - typename base_t::sockstream_t* s = new typename base_t::sockstream_t(); - s->rdbuf()->_open_sockmgr( fd, addr ); + sockstream_t* s = new sockstream_t(); + // s->rdbuf()->_open_sockmgr( fd, addr ); return s; } -*/ + public: bool is_open() const { std::tr2::lock_guard<std::tr2::mutex> lk(_fd_lck); return basic_socket_t::is_open_unsafe(); } @@ -193,7 +193,9 @@ // { // std::tr2::lock_guard<std::tr2::mutex> lk( wklock ); for ( typename worker_pool_t::iterator i = worker_pool.begin(); i != worker_pool.end(); ++i ) { - delete i->second; + // delete i->second; + delete i->second.s; + delete i->second.c; } worker_pool.clear(); // } Modified: branches/complement-sockios/explore/lib/sockios/ut/sockios2_test.cc =================================================================== --- branches/complement-sockios/explore/lib/sockios/ut/sockios2_test.cc 2008-06-03 13:19:42 UTC (rev 1884) +++ branches/complement-sockios/explore/lib/sockios/ut/sockios2_test.cc 2008-06-04 13:53:54 UTC (rev 1885) @@ -46,11 +46,11 @@ { /* cerr << "In destructor\n"; */ } protected: - virtual void operator ()( sockstream_t& s, const adopt_new_t& ) + virtual void operator ()( int, const adopt_new_t& ) { lock_guard<mutex> lk(lock); b.wait(); ++n_cnt; } - virtual void operator ()( sockstream_t& s, const adopt_close_t& ) + virtual void operator ()( int, const adopt_close_t& ) { lock_guard<mutex> lk(lock); b.wait(); ++c_cnt; } - virtual void operator ()( sockstream_t& s, const adopt_data_t& ) + virtual void operator ()( int, const adopt_data_t& ) { lock_guard<mutex> lk(lock); ++d_cnt; } public: @@ -80,17 +80,17 @@ { } protected: - virtual void operator ()( sockstream_t& s, const adopt_new_t& ) + virtual void operator ()( int, const adopt_new_t& ) { lock_guard<mutex> lk(lock); b.wait(); ++n_cnt; } - virtual void operator ()( sockstream_t& s, const adopt_close_t& ) + virtual void operator ()( int, const adopt_close_t& ) { lock_guard<mutex> lk(lock); b.wait(); ++c_cnt; } - virtual void operator ()( sockstream_t& s, const adopt_data_t& ) + virtual void operator ()( int, const adopt_data_t& ) { lock_guard<mutex> lk(lock); b.wait(); ++d_cnt; string str; - getline( s, str ); + // getline( s, str ); // map fd -> s EXAM_CHECK_ASYNC( str == "Hello" ); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <oke...@us...> - 2008-06-03 13:20:05
|
Revision: 1884 http://complement.svn.sourceforge.net/complement/?rev=1884&view=rev Author: okechina Date: 2008-06-03 06:19:42 -0700 (Tue, 03 Jun 2008) Log Message: ----------- Changes made for successful project compilation Modified Paths: -------------- branches/complement-sockios/explore/include/mt/mutex branches/complement-sockios/explore/include/sockios/sp.cc branches/complement-sockios/explore/include/sockios/sp.h branches/complement-sockios/explore/lib/mt/date_time.cc Modified: branches/complement-sockios/explore/include/mt/mutex =================================================================== --- branches/complement-sockios/explore/include/mt/mutex 2008-05-26 09:20:46 UTC (rev 1883) +++ branches/complement-sockios/explore/include/mt/mutex 2008-06-03 13:19:42 UTC (rev 1884) @@ -379,7 +379,7 @@ { if ( --_count == 0 ) { # ifdef __FIT_PTHREADS - _id = __STATIC_CAST(pthread_t,-1); + _id = static_cast<pthread_t>(-1); pthread_spin_unlock( &this->_M_lock ); # endif } Modified: branches/complement-sockios/explore/include/sockios/sp.cc =================================================================== --- branches/complement-sockios/explore/include/sockios/sp.cc 2008-05-26 09:20:46 UTC (rev 1883) +++ branches/complement-sockios/explore/include/sockios/sp.cc 2008-06-03 13:19:42 UTC (rev 1884) @@ -241,7 +241,8 @@ } } if ( c != 0 ) { - (c->*C)( s ); +//using unknown variable s +// (c->*C)( s ); delete c; } } @@ -501,7 +502,9 @@ epoll_event ev_add; ev_add.events = EPOLLIN | EPOLLRDHUP | EPOLLERR | EPOLLHUP | EPOLLET | EPOLLONESHOT; ev_add.data.fd = fd; - fd_info new_info = { fd_info::owner, s, info.p }; +//undeclared s with some flags +// fd_info new_info = { fd_info::owner, s, info.p }; + fd_info new_info = { fd_info::owner, 0, info.p }; descr[fd] = new_info; if ( epoll_ctl( efd, EPOLL_CTL_ADD, fd, &ev_add ) < 0 ) { Modified: branches/complement-sockios/explore/include/sockios/sp.h =================================================================== --- branches/complement-sockios/explore/include/sockios/sp.h 2008-05-26 09:20:46 UTC (rev 1883) +++ branches/complement-sockios/explore/include/sockios/sp.h 2008-06-03 13:19:42 UTC (rev 1884) @@ -110,13 +110,13 @@ protected: void setoptions_unsafe( sock_base2::so_t optname, bool on_off = true, int __v = 0 ); - sockstream_t* create_stream( int fd ) +/* sockstream_t* create_stream( int fd ) { typename base_t::sockstream_t* s = new typename base_t::sockstream_t(); s->rdbuf()->_open_sockmgr( fd, addr ); return s; } - +*/ public: bool is_open() const { std::tr2::lock_guard<std::tr2::mutex> lk(_fd_lck); return basic_socket_t::is_open_unsafe(); } Modified: branches/complement-sockios/explore/lib/mt/date_time.cc =================================================================== --- branches/complement-sockios/explore/lib/mt/date_time.cc 2008-05-26 09:20:46 UTC (rev 1883) +++ branches/complement-sockios/explore/lib/mt/date_time.cc 2008-06-03 13:19:42 UTC (rev 1884) @@ -14,6 +14,7 @@ #include <mt/date_time> #include <ctime> +#include <sys/time.h> namespace std { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <oke...@us...> - 2008-05-26 09:20:48
|
Revision: 1883 http://complement.svn.sourceforge.net/complement/?rev=1883&view=rev Author: okechina Date: 2008-05-26 02:20:46 -0700 (Mon, 26 May 2008) Log Message: ----------- Multi-thread realization of TCP-server. A separate thread is created for each client. Modified Paths: -------------- trunk/complement/explore/app/SMTP-tools/smtp_server_ut/socket/ECHO_server.cc trunk/complement/explore/app/SMTP-tools/smtp_server_ut/socket/Makefile Modified: trunk/complement/explore/app/SMTP-tools/smtp_server_ut/socket/ECHO_server.cc =================================================================== --- trunk/complement/explore/app/SMTP-tools/smtp_server_ut/socket/ECHO_server.cc 2008-05-25 12:14:17 UTC (rev 1882) +++ trunk/complement/explore/app/SMTP-tools/smtp_server_ut/socket/ECHO_server.cc 2008-05-26 09:20:46 UTC (rev 1883) @@ -8,30 +8,42 @@ #include <stdio.h> #include <iostream> +#include <pthread.h> + #include "socket.h" const int bufsize = 4096; +char buf[bufsize]; +int TCPecho (int fd){ + int cc; + while ( cc = read( fd, buf, sizeof( buf ) ) ) { + write( fd, buf, cc ); + } + close(fd); + return 0; +} + int main() { struct sockaddr_in fsin; - + char *service = "3000"; // char *transport = "udp"; char *transport = "tcp"; int qlen = 0; - char buf[bufsize]; + unsigned int alen; + pthread_t th; + sct::sock s ( service, transport, qlen ); - unsigned int alen; + if (transport == "tcp") { - alen = sizeof( fsin ); - int sc = accept( s.getDescr(), (struct sockaddr *)&fsin, &alen); - while (1){ - int cc = read( sc, buf, sizeof( buf ) ); - write( sc, buf, cc ); + alen = sizeof( fsin ); + int sc = accept( s.getDescr(), (struct sockaddr *)&fsin, &alen); + pthread_create( &th, 0, ( void * (*)( void *))TCPecho, (void *)sc ); } } else { while (1){ Modified: trunk/complement/explore/app/SMTP-tools/smtp_server_ut/socket/Makefile =================================================================== --- trunk/complement/explore/app/SMTP-tools/smtp_server_ut/socket/Makefile 2008-05-25 12:14:17 UTC (rev 1882) +++ trunk/complement/explore/app/SMTP-tools/smtp_server_ut/socket/Makefile 2008-05-26 09:20:46 UTC (rev 1883) @@ -1,7 +1,7 @@ all: server client server: server.o socket.o - gcc -g -o server server.o socket.o -lstdc++ + gcc -g -o server server.o socket.o -lstdc++ -lpthread server.o: ECHO_server.cc socket.h gcc -g -c ECHO_server.cc -o server.o client: client.o socket.o This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dmi...@us...> - 2008-05-25 12:14:47
|
Revision: 1882 http://complement.svn.sourceforge.net/complement/?rev=1882&view=rev Author: dmitryosmakov Date: 2008-05-25 05:14:17 -0700 (Sun, 25 May 2008) Log Message: ----------- fixed lib Opts : loops in get functions are replaced by find and copy algorithms , help function is rewriten (using overloaded << operator for class Opt) Modified Paths: -------------- trunk/complement/explore/include/misc/opts.h trunk/complement/explore/lib/misc/opts.cpp trunk/complement/explore/lib/misc/ut/opts_test.cc Modified: trunk/complement/explore/include/misc/opts.h =================================================================== --- trunk/complement/explore/include/misc/opts.h 2008-05-24 10:09:48 UTC (rev 1881) +++ trunk/complement/explore/include/misc/opts.h 2008-05-25 12:14:17 UTC (rev 1882) @@ -12,28 +12,27 @@ #include <exception> #include <stdexcept> -const char* OPT_DEFAULT_DESCRIPTION = "(no description)"; -const char* OPT_DEFAULT_LONGNAME = "(no longname)"; +#define all(c) (c).begin() , (c).end() class Opt { public: - Opt() { cnt = 0 , shortname = ' '; } + Opt() : shortname(' ') + { } char shortname; std::string longname; std::string desc; std::string default_v; int token; - + std::vector< std::string > args; std::vector< int > pos; bool has_arg; - bool is_set; - int cnt; // number of times this option was encounterd in command line bool operator==( const std::string& _longname ) const { return longname == _longname; } bool operator==( char _shortname ) const { return shortname == _shortname; } bool operator==( int _token ) const { return token == _token; } + friend std::ostream& operator<<(std::ostream& t,const Opt& opt); }; class Opts @@ -50,14 +49,14 @@ // adding option / flag (option that doesn't need arguments) template <class T> - int add( const std::string& _longname,T _default_value,const std::string& _desc = OPT_DEFAULT_DESCRIPTION ); + int add( const std::string& _longname,T _default_value,const std::string& _desc = "(no decription)" ); template <class T> - int add( char _shortname,T _default_value,const std::string& _longname = OPT_DEFAULT_LONGNAME, const std::string& _desc = OPT_DEFAULT_DESCRIPTION ); + int add( char _shortname,T _default_value,const std::string& _longname = "(no longname)", const std::string& _desc = "(no decription)" ); - int addflag( const std::string& _longname,const std::string& desc = OPT_DEFAULT_DESCRIPTION); + int addflag( const std::string& _longname = "(no longname)",const std::string& desc = "(no decription)"); - int addflag( char _shortname,const std::string& _longname = OPT_DEFAULT_LONGNAME,const std::string& _desc = OPT_DEFAULT_DESCRIPTION ); + int addflag( char _shortname,const std::string& _longname = "(no longname)",const std::string& _desc = "(no decription)" ); // getting option @@ -151,54 +150,42 @@ template <class T> bool Opts::is_set(T field) const { - options_container_type::const_iterator i; - for (i = storage.begin();i != storage.end();++i) - if (*i == field) - return i->is_set; - return false; + options_container_type::const_iterator i = find(all(storage),field); + return ( (i == storage.end()) ? false : !i->pos.empty()); } template <class T> int Opts::get_cnt(T field) const { - options_container_type::const_iterator i; - for (i = storage.begin();i != storage.end();++i) - if (*i == field) - return i->cnt; - return 0; + options_container_type::const_iterator i = find(all(storage),field); + return ( (i == storage.end()) ? 0 : i->pos.size()); } template < class T , class V > T Opts::get( V field ) { - options_container_type::const_iterator i; + options_container_type::const_iterator i = find(all(storage),field); T res; - for ( i = storage.begin(); i != storage.end(); ++i ) + + if (i != storage.end()) { - if ( *i == field ) + if ( !i->has_arg ) { - if ( !i->has_arg ) - { - throw std::logic_error("using Opts::get for option without arguments"); - } - - std::stringstream ss; - ss << (i->args.empty() ? i->default_v : i->args[0]); - ss >> res; + throw std::logic_error("using Opts::get for option without arguments"); + } - if (ss.fail()) - { - std::stringstream ss1; - ss1 << field; - throw arg_typemismatch(ss1.str(),i->args[0]); - } - - break; + std::stringstream ss(i->args.empty() ? i->default_v : i->args[0]); + ss >> res; + + if (ss.fail()) + { + std::stringstream ss1; + ss1 << field; + throw arg_typemismatch(ss1.str(),i->args.empty() ? i->default_v : i->args[0]); } } - - if ( i == storage.end() ) - { + else + { std::stringstream ss1; ss1 << field; throw unknown_option( ss1.str() ); @@ -211,67 +198,60 @@ template <class T , class V> T Opts::get_default( V field ) { - options_container_type::const_iterator i; + options_container_type::const_iterator i = find(all(storage),field); T res; - for (i = storage.begin();i != storage.end();++i) - if (*i == field) - { - if (!i->has_arg) - throw std::logic_error("using Opts::get for option without arguments"); + + if (i != storage.end()) + { + if (!i->has_arg) + throw std::logic_error("using Opts::get for option without arguments"); - std::stringstream ss; - ss << i->default_v; + std::stringstream ss(i->default_v); + ss >> res; - ss >> res; - - if (ss.fail()) - { - std::stringstream ss1; - ss1 << field; - throw arg_typemismatch(ss1.str(),i->default_v); - } - - break; - } - - if (i == storage.end()) + if (ss.fail()) + { + std::stringstream ss1; + ss1 << field; + throw arg_typemismatch(ss1.str(),i->default_v); + } + } + else { std::stringstream ss1; ss1 << field; throw unknown_option( ss1.str() ); } + return res; } template <class V , class BackInsertIterator> void Opts::getemall( V field , BackInsertIterator bi) { - options_container_type::const_iterator i; - for (i = storage.begin();i != storage.end();++i) - if (*i == field) - { - if (!i->has_arg) - throw std::logic_error("using Opts::getemall for option without arguments"); + options_container_type::const_iterator i = find(all(storage),field); + if (i != storage.end()) + { + if (!i->has_arg) + throw std::logic_error("using Opts::getemall for option without arguments"); - if (!i->args.empty()) - for (int j = 0;j < i->args.size();j++) - { + if (!i->args.empty()) + { + for (int j = 0;j < i->args.size();++j) + { + std::stringstream ss(i->args[j]); + ss >> *bi++; - std::stringstream ss(i->args[j]); - ss >> *bi++; - - if (ss.fail()) - { - std::stringstream ss1; - ss1 << field; - throw arg_typemismatch(ss1.str(),i->args[j]); - } + if (ss.fail()) + { + std::stringstream ss1; + ss1 << field; + throw arg_typemismatch(ss1.str(),i->args[j]); } - - break; + } } - - if (i == storage.end()) + } + else { std::stringstream ss1; ss1 << field; @@ -282,27 +262,18 @@ template <class V , class BackInsertIterator> void Opts::get_pos( V field , BackInsertIterator bi) { - options_container_type::const_iterator i; - for (i = storage.begin();i != storage.end();++i) - if (*i == field) - { - if (i->is_set) - for (int j = 0;j < i->pos.size();j++) - { - *bi++ = i->pos[j]; - } - - break; - } + options_container_type::const_iterator i = find(all(storage),field); - if (i == storage.end()) + if (i != storage.end()) { + copy(all(i->pos),bi); + } + else + { std::stringstream ss1; ss1 << field; throw unknown_option(ss1.str()); } } - - #endif Modified: trunk/complement/explore/lib/misc/opts.cpp =================================================================== --- trunk/complement/explore/lib/misc/opts.cpp 2008-05-24 10:09:48 UTC (rev 1881) +++ trunk/complement/explore/lib/misc/opts.cpp 2008-05-25 12:14:17 UTC (rev 1882) @@ -10,10 +10,6 @@ string Opts::get_pname() const { return pname; } -bool Opts::isterm(const string& s) -{ - return (s == "--"); -} bool Opts::is_opt_name(const string& s) { @@ -81,6 +77,20 @@ return storage.end(); } +ostream& operator<<(ostream& out,const Opt& opt) +{ + if (opt.shortname == ' ') + { + out << "--" << opt.longname << '\t' << (opt.has_arg ? (string("[") + opt.default_v + "]\t") : "" ) << opt.desc; + } + else + { + out << '-' << opt.shortname << '\t' << (!opt.longname.empty() ? (string("[--") + opt.longname +"]\t") : "") << (opt.has_arg ? string("[") + opt.default_v + ("]\t") : "") << opt.desc; + } + + return out; +} + void Opts::help(ostream& out) { if (!brief.empty()) @@ -90,13 +100,11 @@ if (!copyright.empty()) out << copyright << endl; - out << "usage: " << endl; - out << pname << " [option ...] [optiongoup ...] [end operands ...]" << endl; - out << "available options:" << endl << "shortname:" << '\t' << "longname:" << '\t' << "default value" << '\t' << "description" << endl; + out << "Valid options:" << endl; options_container_type::const_iterator i; for (i = storage.begin();i != storage.end();++i) { - out << i->shortname << "\t[--" << i->longname << "] [" << i->default_v << "]\t-\t" << i->desc << endl; + out << *i << endl; } } @@ -107,7 +115,6 @@ opt.longname = _longname; opt.desc = _desc; opt.has_arg = false; - opt.is_set = false; opt.token = ++free_token; storage.push_back(opt); return opt.token; @@ -119,7 +126,6 @@ opt.longname = _longname; opt.desc = _desc; opt.has_arg = false; - opt.is_set = false; opt.token = ++free_token; storage.push_back(opt); return opt.token; @@ -132,7 +138,7 @@ int i = 1; int j = 1; int q = 0; - while (i < ac && !isterm(av[i])) + while ( (i < ac) && (string(av[i]) != "--") ) { if (is_opt_name(av[i])) { @@ -154,8 +160,6 @@ else { p->pos.push_back(++q); - p->is_set = true; - p->cnt++; if (p->has_arg) { if (!arg.empty()) @@ -184,8 +188,6 @@ } else { - p->is_set = true; - p->cnt++; p->pos.push_back(++q); if (p->has_arg) throw missing_arg( "-" + string(1,optgroup[j]) ); @@ -197,7 +199,7 @@ i++; } - i += (i < ac && isterm(av[i])); + i += ( i < ac ); while (i < ac) av[j++] = av[i++]; Modified: trunk/complement/explore/lib/misc/ut/opts_test.cc =================================================================== --- trunk/complement/explore/lib/misc/ut/opts_test.cc 2008-05-24 10:09:48 UTC (rev 1881) +++ trunk/complement/explore/lib/misc/ut/opts_test.cc 2008-05-25 12:14:17 UTC (rev 1882) @@ -15,12 +15,10 @@ #include <vector> #include <list> #include <fstream> + #include <iostream> -// #include <iostream> - using namespace std; - int EXAM_IMPL(opts_test::bool_option) { const char* argv[] = { "name", "-h" }; @@ -711,11 +709,11 @@ opts.addflag('h',"help","print this help message"); - opts.addflag('v',"verbose"); opts.addflag("flag","some program flag"); + opts.addflag('v',"version","view program version"); opts.add('I',"/usr/include","include","include paths" ); opts.add('p',80,"port","listen to tcp port"); - opts.add('t',"standart");; + opts.add("mode","standart","program mode"); opts.parse(argc,argv); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Dmi...@us...> - 2008-05-24 10:09:52
|
Revision: 1881 http://complement.svn.sourceforge.net/complement/?rev=1881&view=rev Author: DmitryOsmakov Date: 2008-05-24 03:09:48 -0700 (Sat, 24 May 2008) Log Message: ----------- fixed lib Opts : bad_usage is changed to logic_error everywhere , getting option by token is added , all get is summerized in on template , get option position is added , 2 ut to enforce program correctness and help ut is added (need to later modify help func) Modified Paths: -------------- trunk/complement/explore/include/misc/opts.h trunk/complement/explore/lib/misc/opts.cpp trunk/complement/explore/lib/misc/ut/misc_test_suite.cc trunk/complement/explore/lib/misc/ut/opts_test.cc trunk/complement/explore/lib/misc/ut/opts_test.h Modified: trunk/complement/explore/include/misc/opts.h =================================================================== --- trunk/complement/explore/include/misc/opts.h 2008-05-23 10:41:10 UTC (rev 1880) +++ trunk/complement/explore/include/misc/opts.h 2008-05-24 10:09:48 UTC (rev 1881) @@ -12,20 +12,28 @@ #include <exception> #include <stdexcept> +const char* OPT_DEFAULT_DESCRIPTION = "(no description)"; +const char* OPT_DEFAULT_LONGNAME = "(no longname)"; + class Opt { public: - Opt() { cnt = 0; } + Opt() { cnt = 0 , shortname = ' '; } char shortname; std::string longname; std::string desc; std::string default_v; + int token; std::vector< std::string > args; + std::vector< int > pos; bool has_arg; bool is_set; int cnt; // number of times this option was encounterd in command line + bool operator==( const std::string& _longname ) const { return longname == _longname; } + bool operator==( char _shortname ) const { return shortname == _shortname; } + bool operator==( int _token ) const { return token == _token; } }; class Opts @@ -37,48 +45,47 @@ Opts( const std::string& _brief = "", const std::string& _author = "", const std::string& _copyright = "") : brief(_brief), author(_author), - copyright(_copyright) - { } + copyright(_copyright) + { free_token = 0; } - // adding option / flag + // adding option / flag (option that doesn't need arguments) template <class T> - void add( char _shortname,T _default_value,const std::string& _longname = "", const std::string& _desc = "" ); - void addflag( char _shortname,const std::string& _longname = "",const std::string& _desc = "" ); + int add( const std::string& _longname,T _default_value,const std::string& _desc = OPT_DEFAULT_DESCRIPTION ); - // getting option template <class T> - T get( char _shortname ); + int add( char _shortname,T _default_value,const std::string& _longname = OPT_DEFAULT_LONGNAME, const std::string& _desc = OPT_DEFAULT_DESCRIPTION ); - template <class T> - T get( const std::string& _longname ); + int addflag( const std::string& _longname,const std::string& desc = OPT_DEFAULT_DESCRIPTION); - template <class T> - T get_default( char _shorname ); + int addflag( char _shortname,const std::string& _longname = OPT_DEFAULT_LONGNAME,const std::string& _desc = OPT_DEFAULT_DESCRIPTION ); + + // getting option + + template < class T ,class V > + T get( V field ); - template <class T> - T get_default( const std::string& _longname ); + template <class T , class V> + T get_default( V field ); - template <class BackInsertIterator> - void getemall(char _shortname,BackInsertIterator bi); + template < class V , class BackInsertIterator> + void getemall( V field , BackInsertIterator bi); - template <class BackInsertIterator> - void getemall(const std::string& _longname,BackInsertIterator bi); - bool is_set( char _shortname ); - bool is_set( const std::string& _longname ); + template < class T > + bool is_set( T field ) const; - int get_cnt( char _shortname ) const; - int get_cnt( const std::string& _longname ) const; + template < class T > + int get_cnt( T field ) const; + template < class V , class BackInsertIterator > + void get_pos( V field , BackInsertIterator bi); + // parse void parse(int& ac, const char** av); // stuff void help(std::ostream& out); std::string get_pname() const; - std::string get_brief() const; - std::string get_author() const; - std::string get_copyright() const; // error handling struct unknown_option : @@ -97,22 +104,15 @@ { } }; - struct invalid_arg : + struct arg_typemismatch : public std::invalid_argument { - invalid_arg( const std::string& _optname, const std::string& _argname) : - std::invalid_argument(std::string("invalid argument [").append(_argname).append("] for option ").append(_optname)) + arg_typemismatch( const std::string& _optname, const std::string& _argname) : + std::invalid_argument(std::string("argument [").append(_argname).append("] doesn't match by type for option ").append(_optname)) { } }; - struct bad_usage : - public std::invalid_argument - { - bad_usage( const std::string& descr ) : - std::invalid_argument( descr ) - { } - }; - + int free_token; private: std::string pname; std::string brief; @@ -127,55 +127,97 @@ }; template <class T> -void Opts::add(char _shortname,T _default_value,const std::string& _longname,const std::string& _desc) +int Opts::add(char _shortname,T _default_value,const std::string& _longname,const std::string& _desc) { addflag(_shortname,_longname,_desc); std::stringstream ss; ss << _default_value; storage[storage.size() - 1].default_v = ss.str(); storage[storage.size() - 1].has_arg = true; + return storage[storage.size() - 1].token; } template <class T> -T Opts::get( char _shortname ) +int Opts::add(const std::string& _longname,T _default_value,const std::string& _desc) { + addflag(_longname,_desc); + std::stringstream ss; + ss << _default_value; + storage[storage.size() - 1].default_v = ss.str(); + storage[storage.size() - 1].has_arg = true; + return storage[storage.size() - 1].token; +} + +template <class T> +bool Opts::is_set(T field) const +{ options_container_type::const_iterator i; + for (i = storage.begin();i != storage.end();++i) + if (*i == field) + return i->is_set; + return false; +} + +template <class T> +int Opts::get_cnt(T field) const +{ + options_container_type::const_iterator i; + for (i = storage.begin();i != storage.end();++i) + if (*i == field) + return i->cnt; + return 0; +} + +template < class T , class V > +T Opts::get( V field ) +{ + options_container_type::const_iterator i; T res; - for ( i = storage.begin(); i != storage.end(); ++i ) { - if ( i->shortname == _shortname ) { - if ( !i->has_arg ) { - throw bad_usage("using Opts::get for option without arguments"); + for ( i = storage.begin(); i != storage.end(); ++i ) + { + if ( *i == field ) + { + if ( !i->has_arg ) + { + throw std::logic_error("using Opts::get for option without arguments"); } std::stringstream ss; ss << (i->args.empty() ? i->default_v : i->args[0]); ss >> res; - if (ss.fail()) { - throw invalid_arg(std::string("-") + std::string(1,_shortname), i->args[0]); + if (ss.fail()) + { + std::stringstream ss1; + ss1 << field; + throw arg_typemismatch(ss1.str(),i->args[0]); } break; } } - if ( i == storage.end() ) { - throw unknown_option( std::string("-") + _shortname ); + if ( i == storage.end() ) + { + std::stringstream ss1; + ss1 << field; + throw unknown_option( ss1.str() ); } return res; } -template <class T> -T Opts::get_default( char _shortname ) + +template <class T , class V> +T Opts::get_default( V field ) { options_container_type::const_iterator i; T res; for (i = storage.begin();i != storage.end();++i) - if (i->shortname == _shortname) + if (*i == field) { if (!i->has_arg) - throw bad_usage("using Opts::get for option without arguments"); + throw std::logic_error("using Opts::get for option without arguments"); std::stringstream ss; ss << i->default_v; @@ -183,137 +225,84 @@ ss >> res; if (ss.fail()) - throw invalid_arg(std::string("-") + std::string(1,_shortname),i->default_v); + { + std::stringstream ss1; + ss1 << field; + throw arg_typemismatch(ss1.str(),i->default_v); + } break; } if (i == storage.end()) - throw unknown_option(std::string("-") + std::string(1,_shortname)); + { + std::stringstream ss1; + ss1 << field; + throw unknown_option( ss1.str() ); + } return res; } -template <class T> -T Opts::get( const std::string& _longname ) +template <class V , class BackInsertIterator> +void Opts::getemall( V field , BackInsertIterator bi) { options_container_type::const_iterator i; - T res; for (i = storage.begin();i != storage.end();++i) - if (i->longname == _longname) + if (*i == field) { if (!i->has_arg) - throw bad_usage("using Opts::get for option without arguments"); + throw std::logic_error("using Opts::getemall for option without arguments"); - std::stringstream ss; - ss << (i->args.empty() ? i->default_v : i->args[0]); - - ss >> res; - - if (ss.fail()) // need to recover stream? - throw invalid_arg(std::string("--") + _longname,i->args[0]); - - break; - } - - if (i == storage.end()) - throw unknown_option(std::string("--") + _longname); - return res; -} - -template <class T> -T Opts::get_default( const std::string& _longname ) -{ - options_container_type::const_iterator i; - T res; - for (i = storage.begin();i != storage.end();++i) - if (i->longname == _longname) - { - if (!i->has_arg) - throw bad_usage("using Opts::get for option without arguments"); - - std::stringstream ss(i->default_v); - - ss >> res; - - if (ss.fail()) // need to recover stream? - throw invalid_arg(std::string("--") + _longname,i->default_v); - - break; - } - - if (i == storage.end()) - throw unknown_option(std::string("--") + _longname); - return res; -} - -template <class BackInsertIterator> -void Opts::getemall( char _shortname , BackInsertIterator bi) -{ - options_container_type::const_iterator i; - for (i = storage.begin();i != storage.end();++i) - if (i->shortname == _shortname) - { - if (!i->has_arg) - throw bad_usage("using Opts::getemall for option without arguments"); - if (!i->args.empty()) for (int j = 0;j < i->args.size();j++) { std::stringstream ss(i->args[j]); - try - { - ss >> *bi++; - } - catch(...) - { - throw invalid_arg(std::string("-") + std::string(1,_shortname),i->args[j]); - } + ss >> *bi++; if (ss.fail()) - throw invalid_arg(std::string("-") + std::string(1,_shortname),i->args[j]); + { + std::stringstream ss1; + ss1 << field; + throw arg_typemismatch(ss1.str(),i->args[j]); + } } break; } if (i == storage.end()) - throw unknown_option(std::string("-") + std::string(1,_shortname)); + { + std::stringstream ss1; + ss1 << field; + throw unknown_option(ss1.str()); + } } -template <class BackInsertIterator> -void Opts::getemall( const std::string& _longname , BackInsertIterator bi) +template <class V , class BackInsertIterator> +void Opts::get_pos( V field , BackInsertIterator bi) { options_container_type::const_iterator i; for (i = storage.begin();i != storage.end();++i) - if (i->longname == _longname) + if (*i == field) { - if (!i->has_arg) - throw bad_usage("using Opts::getemall for option without arguments"); - - if (!i->args.empty()) - for (int j = 0;j < i->args.size();j++) + if (i->is_set) + for (int j = 0;j < i->pos.size();j++) { - - std::stringstream ss(i->args[j]); - try - { - ss >> *bi++; - } - catch(...) - { - throw invalid_arg(std::string("--") + _longname,i->args[j]); - } - - if (ss.fail()) - throw invalid_arg(std::string("-") + _longname,i->args[j]); + *bi++ = i->pos[j]; } break; } if (i == storage.end()) - throw unknown_option(std::string("-") + _longname); + { + std::stringstream ss1; + ss1 << field; + throw unknown_option(ss1.str()); + } } + + #endif Modified: trunk/complement/explore/lib/misc/opts.cpp =================================================================== --- trunk/complement/explore/lib/misc/opts.cpp 2008-05-23 10:41:10 UTC (rev 1880) +++ trunk/complement/explore/lib/misc/opts.cpp 2008-05-24 10:09:48 UTC (rev 1881) @@ -9,9 +9,6 @@ using namespace std; string Opts::get_pname() const { return pname; } -string Opts::get_brief() const { return brief; } -string Opts::get_author() const { return author; } -string Opts::get_copyright() const { return copyright; } bool Opts::isterm(const string& s) { @@ -95,13 +92,15 @@ out << "usage: " << endl; out << pname << " [option ...] [optiongoup ...] [end operands ...]" << endl; - out << "available options:" << endl; + out << "available options:" << endl << "shortname:" << '\t' << "longname:" << '\t' << "default value" << '\t' << "description" << endl; options_container_type::const_iterator i; for (i = storage.begin();i != storage.end();++i) - out << "-" << i->shortname << "\t[--" << i->longname << "] [" << i->default_v << "]\t-\t" << i->desc << endl; + { + out << i->shortname << "\t[--" << i->longname << "] [" << i->default_v << "]\t-\t" << i->desc << endl; + } } -void Opts::addflag(char _shortname,const string& _longname,const string& _desc) +int Opts::addflag(char _shortname,const string& _longname,const string& _desc) { Opt opt; opt.shortname = _shortname; @@ -109,52 +108,30 @@ opt.desc = _desc; opt.has_arg = false; opt.is_set = false; + opt.token = ++free_token; storage.push_back(opt); + return opt.token; } - -bool Opts::is_set(char _shortname) +int Opts::addflag(const string& _longname,const string& _desc) { - options_container_type::const_iterator i; - for (i = storage.begin();i != storage.end();++i) - if (i->shortname == _shortname) - return i->is_set; - return false; + Opt opt; + opt.longname = _longname; + opt.desc = _desc; + opt.has_arg = false; + opt.is_set = false; + opt.token = ++free_token; + storage.push_back(opt); + return opt.token; } -bool Opts::is_set(const string& _longname) -{ - options_container_type::const_iterator i; - for (i = storage.begin();i != storage.end();++i) - if (i->longname == _longname) - return i->is_set; - return false; -} - -int Opts::get_cnt(char _shortname) const -{ - options_container_type::const_iterator i; - for (i = storage.begin();i != storage.end();++i) - if (i->shortname == _shortname) - return i->cnt; - return 0; -} - -int Opts::get_cnt(const string& _longname) const -{ - options_container_type::const_iterator i; - for (i = storage.begin();i != storage.end();++i) - if (i->longname == _longname) - return i->cnt; - return 0; -} - void Opts::parse(int& ac,const char** av) { pname = av[0]; int i = 1; int j = 1; + int q = 0; while (i < ac && !isterm(av[i])) { if (is_opt_name(av[i])) @@ -171,11 +148,12 @@ } options_container_type::iterator p = get_opt_index(opt); - + if (p == storage.end()) throw unknown_option(opt); else { + p->pos.push_back(++q); p->is_set = true; p->cnt++; if (p->has_arg) @@ -189,8 +167,8 @@ throw missing_arg(opt); } else - if (!arg.empty()) //unexpected arg - throw invalid_arg(opt,arg); + if (!arg.empty()) //unexpected arg (not exactly mismatch) + throw arg_typemismatch(opt,arg); } } else @@ -201,11 +179,14 @@ { options_container_type::iterator p = get_opt_index(string("-") + optgroup[j]); if (p == storage.end()) + { throw unknown_option( "-" + string(1,optgroup[j]) ); + } else { p->is_set = true; p->cnt++; + p->pos.push_back(++q); if (p->has_arg) throw missing_arg( "-" + string(1,optgroup[j]) ); } Modified: trunk/complement/explore/lib/misc/ut/misc_test_suite.cc =================================================================== --- trunk/complement/explore/lib/misc/ut/misc_test_suite.cc 2008-05-23 10:41:10 UTC (rev 1880) +++ trunk/complement/explore/lib/misc/ut/misc_test_suite.cc 2008-05-24 10:09:48 UTC (rev 1881) @@ -65,14 +65,17 @@ opts_test opts; - t.add( &opts_test::bool_option_long, opts, "simple boolean option, long", + t.add( &opts_test::bool_option_long, opts, "simple boolean option, long" , t.add( &opts_test::bool_option, opts, "simple boolean option" ) ); - + t.add( &opts_test::int_option_long, opts, "option with int parameter, long", t.add( &opts_test::int_option, opts, "option with int parameter" ) ); + t.add( &opts_test::add_check_flag , opts , "add_check_flag"); + t.add( &opts_test::add_get_opt , opts , "add_get_opts"); + t.add( &opts_test::option_position,opts,"option position"); + t.add( &opts_test::defaults, opts, "defaults" ); - t.add( &opts_test::bad_option, opts, "bad option" ); t.add( &opts_test::bad_argument, opts, "bad argument" ); @@ -98,5 +101,7 @@ t.add( &opts_test::multiple_args, opts,"multiple_args"); + t.add( &opts_test::help, opts, "help"); + return t.girdle(); } Modified: trunk/complement/explore/lib/misc/ut/opts_test.cc =================================================================== --- trunk/complement/explore/lib/misc/ut/opts_test.cc 2008-05-23 10:41:10 UTC (rev 1880) +++ trunk/complement/explore/lib/misc/ut/opts_test.cc 2008-05-24 10:09:48 UTC (rev 1881) @@ -13,11 +13,14 @@ #include <misc/opts.h> #include <set> #include <vector> +#include <list> +#include <fstream> // #include <iostream> using namespace std; + int EXAM_IMPL(opts_test::bool_option) { const char* argv[] = { "name", "-h" }; @@ -34,7 +37,7 @@ } catch ( const Opts::unknown_option& e ) { } - catch ( const Opts::invalid_arg& e ) { + catch ( const Opts::arg_typemismatch& e ) { } return EXAM_RESULT; @@ -56,7 +59,7 @@ } catch ( const Opts::unknown_option& e ) { } - catch ( const Opts::invalid_arg& e ) { + catch ( const Opts::arg_typemismatch& e ) { } return EXAM_RESULT; @@ -80,7 +83,7 @@ } catch ( const Opts::unknown_option& e ) { } - catch ( const Opts::invalid_arg& e ) { + catch ( const Opts::arg_typemismatch& e ) { } return EXAM_RESULT; @@ -104,12 +107,183 @@ } catch ( const Opts::unknown_option& e ) { } - catch ( const Opts::invalid_arg& e ) { + catch ( const Opts::arg_typemismatch& e ) { } return EXAM_RESULT; } +int EXAM_IMPL(opts_test::add_check_flag) +{ + const char* argv[] = { "name", "-ht" , "--temp"}; + int argc = sizeof( argv ) / sizeof(argv[0]); + + Opts opts; + + int f_token = opts.addflag('f'); + opts.addflag('t',"tag"); + int foo_token = opts.addflag("foo"); + opts.addflag("temp","temp desc"); + int h_token = opts.addflag( 'h', "help", "print this help message" ); + bool exception_happens = false; + + try { + opts.parse( argc, argv ); + + EXAM_CHECK( opts.is_set( 'h' ) ); + } + catch ( const Opts::unknown_option& e ) { + } + catch ( const Opts::arg_typemismatch& e ) { + } + + EXAM_CHECK( !opts.is_set("foo") ); + EXAM_CHECK( !opts.is_set(foo_token) ); + EXAM_CHECK( opts.is_set('h') ); + EXAM_CHECK( opts.is_set(h_token) ); + EXAM_CHECK( opts.is_set("help")); + EXAM_CHECK( opts.is_set('t')); + EXAM_CHECK( opts.is_set("temp") ); + EXAM_CHECK( !opts.is_set("unknow option") ); + EXAM_CHECK( !opts.is_set(42) ); + + try + { + opts.get<int>('f'); + } + catch(const logic_error& e) + { + exception_happens = true; + } + + EXAM_CHECK( exception_happens ); + + exception_happens = false; + try + { + opts.get_default<int>("tag"); + } + catch(const logic_error& e) + { + exception_happens = true; + } + + EXAM_CHECK( exception_happens ); + + exception_happens = false; + + try + { + vector< string > vs; + opts.getemall(h_token,vs.begin()); + } + catch( const logic_error& e) + { + exception_happens = true; + } + + EXAM_CHECK( exception_happens ); + + return EXAM_RESULT; +} + +int EXAM_IMPL(opts_test::add_get_opt) +{ + const char* argv[] = { "name", "-t" , "20" , "--name=torwalds" }; + int argc = sizeof( argv ) / sizeof(argv[0]); + + Opts opts; + + int t_token = opts.add('t',10); + int name_token = opts.add("name","linus"); + int port_token = opts.add('p',80,"port"); + int num_token = opts.add("num",100,"number of elements"); + + + try { + opts.parse( argc, argv ); + } + catch ( const Opts::unknown_option& e ) { + } + catch ( const Opts::arg_typemismatch& e ) { + } + + EXAM_CHECK( opts.is_set('t') ); + EXAM_CHECK( opts.get_cnt(t_token) == 1 ); + EXAM_CHECK( opts.get<int>('t') == 20); + EXAM_CHECK( opts.get_default<int>(t_token) == 10 ); + EXAM_CHECK( opts.is_set(name_token) ); + EXAM_CHECK( opts.get_cnt("name") == 1 ); + EXAM_CHECK( opts.get<string>(name_token) == "torwalds"); + EXAM_CHECK( opts.get_default<string>("name") == "linus"); + EXAM_CHECK( !opts.is_set('p') ); + EXAM_CHECK( !opts.is_set("num") && opts.get<int>(num_token) == opts.get_default<int>("num") ) ; + + return EXAM_RESULT; +} + +int EXAM_IMPL(opts_test::option_position) +{ + const char* argv[] = { "name" , "--begin" , "--f1","--f2","--end","--f1","--port=10"}; + int argc = sizeof( argv ) / sizeof(argv[0]); + + Opts opts; + + opts.add( 'p', 0, "port", "listen tcp port"); + opts.addflag("begin"); + int f1_token = opts.addflag("f1"); + int f2_token = opts.addflag("f2"); + opts.addflag("end"); + + try { + opts.parse( argc, argv ); + + EXAM_CHECK(opts.get_cnt('p') == 1); + EXAM_CHECK(opts.get_cnt("begin") == 1); + EXAM_CHECK(opts.get_cnt(f1_token) == 2); + EXAM_CHECK(opts.get_cnt(f2_token) == 1); + EXAM_CHECK(opts.get_cnt("end") == 1); + EXAM_CHECK(opts.get_cnt("unknown") == 0); + EXAM_CHECK(opts.get_cnt('u') == 0); + EXAM_CHECK(opts.get_cnt(42) == 0); + + list<int> p_l(opts.get_cnt('p')); + vector<int> b_v(opts.get_cnt("begin")); + vector<int> f1_v(opts.get_cnt(f1_token)); + vector<int> f2_v(opts.get_cnt(f2_token)); + vector<int> e_v(opts.get_cnt("end")); + list<int> u_l(opts.get_cnt("unknown")); + bool exception_happens = false; + + opts.get_pos('p',p_l.begin()); + opts.get_pos("begin",b_v.begin()); + opts.get_pos("f1",f1_v.begin()); + opts.get_pos(f2_token,f2_v.begin()); + opts.get_pos("end",e_v.begin()); + + try + { + opts.get_pos("unknown",u_l.begin()); + } + catch(const Opts::unknown_option& e) + { + exception_happens = true; + } + + EXAM_CHECK( exception_happens ); + EXAM_CHECK( !b_v.empty() && !e_v.empty() && e_v[0] > b_v[0]); + EXAM_CHECK( f1_v.size() == 2 && f1_v[0] == 2 && f1_v[1] == 5); + EXAM_CHECK( !p_l.empty() && *p_l.begin() == 6); + EXAM_CHECK( u_l.empty() ); + } + catch ( const Opts::unknown_option& e ) { + } + catch ( const Opts::arg_typemismatch& e ) { + } + + return EXAM_RESULT; +} + int EXAM_IMPL(opts_test::defaults) { const char* argv[] = { "name" }; @@ -128,7 +302,7 @@ } catch ( const Opts::unknown_option& e ) { } - catch ( const Opts::invalid_arg& e ) { + catch ( const Opts::arg_typemismatch& e ) { } return EXAM_RESULT; @@ -153,7 +327,7 @@ catch ( const Opts::unknown_option& e ) { exception_happens = true; } - catch ( const Opts::invalid_arg& e ) { + catch ( const Opts::arg_typemismatch& e ) { } EXAM_CHECK( exception_happens ); @@ -178,7 +352,7 @@ { int t = opts.get<int>('p'); } - catch(const Opts::invalid_arg& e) + catch(const Opts::arg_typemismatch& e) { exception_happens = true; } @@ -204,7 +378,7 @@ { opts.parse( argc, argv ); } - catch(const Opts::invalid_arg& e) + catch(const Opts::arg_typemismatch& e) { exception_happens = true; } @@ -485,7 +659,7 @@ opts.add('t',string("standart"),"proc_type","process type"); bool exception_happens = false; - + try { opts.parse( argc, argv ); @@ -526,3 +700,33 @@ return EXAM_RESULT; } + +int EXAM_IMPL(opts_test::help) +{ + { + const char* argv[] = { "name" , "--help" }; + int argc = sizeof( argv ) / sizeof(argv[0]); + + Opts opts("what utility do","author","copyright"); + + + opts.addflag('h',"help","print this help message"); + opts.addflag('v',"verbose"); + opts.addflag("flag","some program flag"); + opts.add('I',"/usr/include","include","include paths" ); + opts.add('p',80,"port","listen to tcp port"); + opts.add('t',"standart");; + + opts.parse(argc,argv); + + EXAM_CHECK(opts.is_set('h')); + EXAM_CHECK( opts.get_pname() == "name" ); + + ofstream out("help.out"); + opts.help(out); + cout << "check file help.out" << endl; + out.close(); + } + + return EXAM_RESULT; +} Modified: trunk/complement/explore/lib/misc/ut/opts_test.h =================================================================== --- trunk/complement/explore/lib/misc/ut/opts_test.h 2008-05-23 10:41:10 UTC (rev 1880) +++ trunk/complement/explore/lib/misc/ut/opts_test.h 2008-05-24 10:09:48 UTC (rev 1881) @@ -23,6 +23,9 @@ int EXAM_DECL(bool_option_long); int EXAM_DECL(int_option); int EXAM_DECL(int_option_long); + int EXAM_DECL(add_check_flag); + int EXAM_DECL(add_get_opt); + int EXAM_DECL(option_position); int EXAM_DECL(defaults); int EXAM_DECL(bad_option); int EXAM_DECL(bad_argument); @@ -37,6 +40,7 @@ int EXAM_DECL(autocomplement); int EXAM_DECL(autocomplement_failure); int EXAM_DECL(multiple_args); + int EXAM_DECL(help); }; #endif // __MISC_TEST_H This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Dmi...@us...> - 2008-05-23 10:41:16
|
Revision: 1880 http://complement.svn.sourceforge.net/complement/?rev=1880&view=rev Author: DmitryOsmakov Date: 2008-05-23 03:41:10 -0700 (Fri, 23 May 2008) Log Message: ----------- fixed lib Opts : access to opts storage is modified everywhere (using options_container_type to make it more generic) Modified Paths: -------------- trunk/complement/explore/include/misc/opts.h trunk/complement/explore/lib/misc/opts.cpp trunk/complement/explore/lib/misc/ut/opts_test.cc Modified: trunk/complement/explore/include/misc/opts.h =================================================================== --- trunk/complement/explore/include/misc/opts.h 2008-05-22 14:26:19 UTC (rev 1879) +++ trunk/complement/explore/include/misc/opts.h 2008-05-23 10:41:10 UTC (rev 1880) @@ -19,9 +19,10 @@ char shortname; std::string longname; std::string desc; - std::vector< std::string > args; std::string default_v; + std::vector< std::string > args; + bool has_arg; bool is_set; int cnt; // number of times this option was encounterd in command line @@ -29,6 +30,9 @@ class Opts { + private: + typedef std::vector< Opt > options_container_type; + options_container_type storage; public: Opts( const std::string& _brief = "", const std::string& _author = "", const std::string& _copyright = "") : brief(_brief), @@ -109,12 +113,7 @@ { } }; - //std::vector< std::string > args; private: - // data - typedef std::vector< Opt > options_container_type; - options_container_type storage; - std::string pname; std::string brief; std::string author; @@ -124,7 +123,7 @@ bool is_opt_name( const std::string& s ); bool is_flag_group( const std::string& s ); bool is_substr(const std::string& small, const std::string& big ); - int get_opt_index( std::string s ); + options_container_type::iterator get_opt_index( std::string s ); }; template <class T> @@ -170,26 +169,26 @@ template <class T> T Opts::get_default( char _shortname ) { - int i; + options_container_type::const_iterator i; T res; - for (i = 0;i < storage.size();i++) - if (storage[i].shortname == _shortname) + for (i = storage.begin();i != storage.end();++i) + if (i->shortname == _shortname) { - if (!storage[i].has_arg) + if (!i->has_arg) throw bad_usage("using Opts::get for option without arguments"); std::stringstream ss; - ss << storage[i].default_v; + ss << i->default_v; ss >> res; if (ss.fail()) - throw invalid_arg(std::string("-") + std::string(1,_shortname),storage[i].default_v); + throw invalid_arg(std::string("-") + std::string(1,_shortname),i->default_v); break; } - if (i == storage.size()) + if (i == storage.end()) throw unknown_option(std::string("-") + std::string(1,_shortname)); return res; } @@ -197,29 +196,26 @@ template <class T> T Opts::get( const std::string& _longname ) { - int i; + options_container_type::const_iterator i; T res; - for (i = 0;i < storage.size();i++) - if (storage[i].longname == _longname) + for (i = storage.begin();i != storage.end();++i) + if (i->longname == _longname) { - if (!storage[i].has_arg) + if (!i->has_arg) throw bad_usage("using Opts::get for option without arguments"); std::stringstream ss; - if (!storage[i].args.empty()) - ss << storage[i].args[0]; - else - ss << storage[i].default_v; + ss << (i->args.empty() ? i->default_v : i->args[0]); ss >> res; if (ss.fail()) // need to recover stream? - throw invalid_arg(std::string("--") + _longname,storage[i].args[0]); + throw invalid_arg(std::string("--") + _longname,i->args[0]); break; } - if (i == storage.size()) + if (i == storage.end()) throw unknown_option(std::string("--") + _longname); return res; } @@ -227,25 +223,25 @@ template <class T> T Opts::get_default( const std::string& _longname ) { - int i; + options_container_type::const_iterator i; T res; - for (i = 0;i < storage.size();i++) - if (storage[i].longname == _longname) + for (i = storage.begin();i != storage.end();++i) + if (i->longname == _longname) { - if (!storage[i].has_arg) + if (!i->has_arg) throw bad_usage("using Opts::get for option without arguments"); - std::stringstream ss(storage[i].default_v); + std::stringstream ss(i->default_v); ss >> res; if (ss.fail()) // need to recover stream? - throw invalid_arg(std::string("--") + _longname,storage[i].default_v); + throw invalid_arg(std::string("--") + _longname,i->default_v); break; } - if (i == storage.size()) + if (i == storage.end()) throw unknown_option(std::string("--") + _longname); return res; } @@ -253,82 +249,70 @@ template <class BackInsertIterator> void Opts::getemall( char _shortname , BackInsertIterator bi) { - int i; - for (i = 0;i < storage.size();i++) - if (storage[i].shortname == _shortname) + options_container_type::const_iterator i; + for (i = storage.begin();i != storage.end();++i) + if (i->shortname == _shortname) { - if (!storage[i].has_arg) + if (!i->has_arg) throw bad_usage("using Opts::getemall for option without arguments"); - if (!storage[i].default_v.empty()) - { - std::stringstream ss(storage[i].default_v); - ss >> *bi++; - } - - if (!storage[i].args.empty()) - for (int j = 0;j < storage[i].args.size();j++) + if (!i->args.empty()) + for (int j = 0;j < i->args.size();j++) { - std::stringstream ss(storage[i].args[j]); + std::stringstream ss(i->args[j]); try { ss >> *bi++; } catch(...) { - throw invalid_arg(std::string("-") + std::string(1,_shortname),storage[i].args[j]); + throw invalid_arg(std::string("-") + std::string(1,_shortname),i->args[j]); } if (ss.fail()) - throw invalid_arg(std::string("-") + std::string(1,_shortname),storage[i].args[j]); + throw invalid_arg(std::string("-") + std::string(1,_shortname),i->args[j]); } break; } - if (i == storage.size()) + if (i == storage.end()) throw unknown_option(std::string("-") + std::string(1,_shortname)); } template <class BackInsertIterator> void Opts::getemall( const std::string& _longname , BackInsertIterator bi) { - int i; - for (i = 0;i < storage.size();i++) - if (storage[i].longname == _longname) + options_container_type::const_iterator i; + for (i = storage.begin();i != storage.end();++i) + if (i->longname == _longname) { - if (!storage[i].has_arg) + if (!i->has_arg) throw bad_usage("using Opts::getemall for option without arguments"); - if (!storage[i].default_v.empty()) - { - std::stringstream ss(storage[i].default_v); - ss >> *bi++; - } - - if (!storage[i].args.empty()) - for (int j = 0;j < storage[i].args.size();j++) + if (!i->args.empty()) + for (int j = 0;j < i->args.size();j++) { - std::stringstream ss(storage[i].args[j]); + std::stringstream ss(i->args[j]); try { ss >> *bi++; } catch(...) { - throw invalid_arg(std::string("--") + _longname,storage[i].args[j]); + throw invalid_arg(std::string("--") + _longname,i->args[j]); } if (ss.fail()) - throw invalid_arg(std::string("-") + _longname,storage[i].args[j]); + throw invalid_arg(std::string("-") + _longname,i->args[j]); } break; } - if (i == storage.size()) + if (i == storage.end()) throw unknown_option(std::string("-") + _longname); } Modified: trunk/complement/explore/lib/misc/opts.cpp =================================================================== --- trunk/complement/explore/lib/misc/opts.cpp 2008-05-22 14:26:19 UTC (rev 1879) +++ trunk/complement/explore/lib/misc/opts.cpp 2008-05-23 10:41:10 UTC (rev 1880) @@ -2,6 +2,7 @@ #include <string> #include <sstream> #include <typeinfo> +#include <cassert> #include <misc/opts.h> @@ -47,39 +48,40 @@ } // this function assumes that is_opt_name(s) = true; -int Opts::get_opt_index(string s) +Opts::options_container_type::iterator Opts::get_opt_index(string s) { + assert(is_opt_name(s)); if (s.size() == 2 && isalnum(s[1]) ) // is short name { - int i; - for (i = 0;i < storage.size();i++) - if (storage[i].shortname == s[1]) + options_container_type::iterator i; + for (i = storage.begin();i != storage.end();++i) + if (i->shortname == s[1]) break; return i; } if (s.size() > 2 && s[1] == '-') { - int i; + options_container_type::iterator i; s = s.substr(2); // exact match - for (i = 0;i < storage.size();i++) - if (storage[i].longname == s) + for (i = storage.begin();i != storage.end();++i) + if (i->longname == s) return i; - vector<int> matches; - for (i = 0;i < storage.size();i++) - if (is_substr(s,storage[i].longname)) + vector< options_container_type::iterator > matches; + for (i = storage.begin();i != storage.end();++i) + if (is_substr(s,i->longname)) matches.push_back(i); if (matches.size() == 1) return matches[0]; else - return storage.size(); + return storage.end(); } - return storage.size(); + return storage.end(); } void Opts::help(ostream& out) @@ -94,8 +96,9 @@ out << "usage: " << endl; out << pname << " [option ...] [optiongoup ...] [end operands ...]" << endl; out << "available options:" << endl; - for (int i = 0;i < storage.size();i++) - out << "-" << storage[i].shortname << "\t[--" << storage[i].longname << "] [" << storage[i].default_v << "]\t-\t" << storage[i].desc << endl; + options_container_type::const_iterator i; + for (i = storage.begin();i != storage.end();++i) + out << "-" << i->shortname << "\t[--" << i->longname << "] [" << i->default_v << "]\t-\t" << i->desc << endl; } void Opts::addflag(char _shortname,const string& _longname,const string& _desc) @@ -112,33 +115,37 @@ bool Opts::is_set(char _shortname) { - for (int i = 0;i < storage.size();i++) - if (storage[i].shortname == _shortname) - return storage[i].is_set; + options_container_type::const_iterator i; + for (i = storage.begin();i != storage.end();++i) + if (i->shortname == _shortname) + return i->is_set; return false; } bool Opts::is_set(const string& _longname) { - for (int i = 0;i < storage.size();i++) - if (storage[i].longname == _longname) - return storage[i].is_set; + options_container_type::const_iterator i; + for (i = storage.begin();i != storage.end();++i) + if (i->longname == _longname) + return i->is_set; return false; } int Opts::get_cnt(char _shortname) const { - for (int i = 0;i < storage.size();i++) - if (storage[i].shortname == _shortname) - return storage[i].cnt; + options_container_type::const_iterator i; + for (i = storage.begin();i != storage.end();++i) + if (i->shortname == _shortname) + return i->cnt; return 0; } int Opts::get_cnt(const string& _longname) const { - for (int i = 0;i < storage.size();i++) - if (storage[i].longname == _longname) - return storage[i].cnt; + options_container_type::const_iterator i; + for (i = storage.begin();i != storage.end();++i) + if (i->longname == _longname) + return i->cnt; return 0; } @@ -163,21 +170,21 @@ opt = opt.substr(0,k); } - int p = get_opt_index(opt); + options_container_type::iterator p = get_opt_index(opt); - if (p == storage.size()) + if (p == storage.end()) throw unknown_option(opt); else { - storage[p].is_set = true; - storage[p].cnt++; - if (storage[p].has_arg) + p->is_set = true; + p->cnt++; + if (p->has_arg) { if (!arg.empty()) - storage[p].args.push_back(arg); + p->args.push_back(arg); else if (i + 1 < ac) - storage[p].args.push_back(av[++i]); + p->args.push_back(av[++i]); else throw missing_arg(opt); } @@ -192,29 +199,26 @@ string optgroup = av[i]; for (int j = 1;j < optgroup.size();j++) { - int p = get_opt_index(string("-") + optgroup[j]); - if (p == storage.size()) + options_container_type::iterator p = get_opt_index(string("-") + optgroup[j]); + if (p == storage.end()) throw unknown_option( "-" + string(1,optgroup[j]) ); else { - storage[p].is_set = true; - storage[p].cnt++; - if (storage[p].has_arg) + p->is_set = true; + p->cnt++; + if (p->has_arg) throw missing_arg( "-" + string(1,optgroup[j]) ); } } } else - { av[j++] = av[i]; - //args.push_back(av[i]); - } i++; } i += (i < ac && isterm(av[i])); while (i < ac) - av[j++] = av[i++]; //args.push_back(av[i++]); + av[j++] = av[i++]; ac = j; } Modified: trunk/complement/explore/lib/misc/ut/opts_test.cc =================================================================== --- trunk/complement/explore/lib/misc/ut/opts_test.cc 2008-05-22 14:26:19 UTC (rev 1879) +++ trunk/complement/explore/lib/misc/ut/opts_test.cc 2008-05-23 10:41:10 UTC (rev 1880) @@ -308,7 +308,7 @@ int EXAM_IMPL(opts_test::multiple_compound) { { - const char* argv[] = { "name", "-xf","--flag", "-f", "-p=second" ,"--pa","third" }; + const char* argv[] = { "name", "-xf","--flag", "-f", "-p=first" ,"--pa","second" }; int argc = sizeof( argv ) / sizeof(argv[0]); Opts opts; @@ -316,7 +316,7 @@ opts.addflag( 'x', "x-option", "option x" ); opts.addflag( 'f', "flag", "option f" ); - opts.add('p',"first","path","some path"); + opts.add('p',"defaultpath","path","some path"); opts.parse( argc, argv ); @@ -324,12 +324,11 @@ EXAM_CHECK(opts.is_set("flag")); EXAM_CHECK(opts.is_set('p')); EXAM_CHECK(opts.get_cnt("flag") == 3 && opts.get_cnt('f') == 3); - vector<string> vs(3); + vector<string> vs(2); opts.getemall("path",vs.begin()); EXAM_CHECK( vs[0] == "first" ); EXAM_CHECK( vs[1] == "second" ); - EXAM_CHECK( vs[2] == "third" ); } @@ -518,10 +517,11 @@ opts.getemall('I',vs.begin()); - EXAM_CHECK( vs[0] == "/usr/include" ); - EXAM_CHECK( vs[1] == "first" ); - EXAM_CHECK( vs[2] == "second" ); - EXAM_CHECK( vs[3] == "third" ); + EXAM_CHECK( opts.get_default<string>("include") == "/usr/include"); + + EXAM_CHECK( vs[0] == "first" ); + EXAM_CHECK( vs[1] == "second" ); + EXAM_CHECK( vs[2] == "third" ); } return EXAM_RESULT; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <oke...@us...> - 2008-05-22 14:27:05
|
Revision: 1879 http://complement.svn.sourceforge.net/complement/?rev=1879&view=rev Author: okechina Date: 2008-05-22 07:26:19 -0700 (Thu, 22 May 2008) Log Message: ----------- Socket class is created, ECHO server and client use the class. Only one client can connect at once (server does not support parallel work) Added Paths: ----------- trunk/complement/explore/app/SMTP-tools/smtp_server_ut/socket/ trunk/complement/explore/app/SMTP-tools/smtp_server_ut/socket/ECHO_server.cc trunk/complement/explore/app/SMTP-tools/smtp_server_ut/socket/Makefile trunk/complement/explore/app/SMTP-tools/smtp_server_ut/socket/client.cc trunk/complement/explore/app/SMTP-tools/smtp_server_ut/socket/socket.cc trunk/complement/explore/app/SMTP-tools/smtp_server_ut/socket/socket.h Added: trunk/complement/explore/app/SMTP-tools/smtp_server_ut/socket/ECHO_server.cc =================================================================== --- trunk/complement/explore/app/SMTP-tools/smtp_server_ut/socket/ECHO_server.cc (rev 0) +++ trunk/complement/explore/app/SMTP-tools/smtp_server_ut/socket/ECHO_server.cc 2008-05-22 14:26:19 UTC (rev 1879) @@ -0,0 +1,44 @@ +#include <sys/types.h> +#include <sys/socket.h> + +#include <netinet/in.h> + +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <iostream> + +#include "socket.h" + +const int bufsize = 4096; + +int main() +{ + struct sockaddr_in fsin; + + char *service = "3000"; +// char *transport = "udp"; + char *transport = "tcp"; + int qlen = 0; + char buf[bufsize]; + + sct::sock s ( service, transport, qlen ); + unsigned int alen; + if (transport == "tcp") + { + alen = sizeof( fsin ); + int sc = accept( s.getDescr(), (struct sockaddr *)&fsin, &alen); + + while (1){ + int cc = read( sc, buf, sizeof( buf ) ); + write( sc, buf, cc ); + } + } else { + while (1){ + alen = sizeof( fsin ); + recvfrom( s.getDescr(), buf, sizeof( buf ), 0, (struct sockaddr *)&fsin, &alen ); + sendto( s.getDescr(), buf, sizeof( buf ), 0, (struct sockaddr *)&fsin, sizeof( fsin ) ); + } + } + return 0; +} Added: trunk/complement/explore/app/SMTP-tools/smtp_server_ut/socket/Makefile =================================================================== --- trunk/complement/explore/app/SMTP-tools/smtp_server_ut/socket/Makefile (rev 0) +++ trunk/complement/explore/app/SMTP-tools/smtp_server_ut/socket/Makefile 2008-05-22 14:26:19 UTC (rev 1879) @@ -0,0 +1,12 @@ +all: server client + +server: server.o socket.o + gcc -g -o server server.o socket.o -lstdc++ +server.o: ECHO_server.cc socket.h + gcc -g -c ECHO_server.cc -o server.o +client: client.o socket.o + gcc -g -o client client.o socket.o -lstdc++ +client.o: client.cc socket.h + gcc -g -c client.cc -o client.o +socket.o: socket.cc socket.h + gcc -g -c socket.cc -o socket.o Added: trunk/complement/explore/app/SMTP-tools/smtp_server_ut/socket/client.cc =================================================================== --- trunk/complement/explore/app/SMTP-tools/smtp_server_ut/socket/client.cc (rev 0) +++ trunk/complement/explore/app/SMTP-tools/smtp_server_ut/socket/client.cc 2008-05-22 14:26:19 UTC (rev 1879) @@ -0,0 +1,40 @@ +#include <unistd.h> +#include <stdio.h> +#include <iostream> + +#include <sys/types.h> +#include <sys/socket.h> + +#include <netinet/in.h> +#include <arpa/inet.h> + +#include <stdlib.h> +#include <string.h> +#include <netdb.h> + +#include "socket.h" + +int main(){ + const int linelen = 1000; + char *host = "localhost"; + char *service = "3000"; +// char *transport = "udp"; + char *transport = "tcp"; + char buf[linelen+1]; + int nchars; + + + sct::sock s( service, transport, host ); + + while ( fgets( buf, sizeof( buf ), stdin) ) { + buf[linelen] = '\0'; + + nchars = strlen( buf ); + write( s.getDescr(), buf, nchars ); + buf[0] = '\0'; + int n = read( s.getDescr(), buf, nchars ); + fputs( buf, stdout ); + } + + return 0; +} Added: trunk/complement/explore/app/SMTP-tools/smtp_server_ut/socket/socket.cc =================================================================== --- trunk/complement/explore/app/SMTP-tools/smtp_server_ut/socket/socket.cc (rev 0) +++ trunk/complement/explore/app/SMTP-tools/smtp_server_ut/socket/socket.cc 2008-05-22 14:26:19 UTC (rev 1879) @@ -0,0 +1,75 @@ +#include <sys/types.h> +#include <sys/socket.h> + +#include <netinet/in.h> +#include <arpa/inet.h> + +#include <stdlib.h> +#include <string.h> +#include <netdb.h> +#include <unistd.h> +#include <stdio.h> +#include <iostream> + +#include "socket.h" + +namespace sct +{ + +int sock::connectSock( const char *service, const char *transport, int qlen, char *host) +{ + int s; + memset (&sin, 0, sizeof(sin)); + sin.sin_family = AF_INET; + + if ( pse = getservbyname( service, transport ) ) + sin.sin_port = pse->s_port; + else if ( ( sin.sin_port = htons( (unsigned short)atoi( service ) ) ) == 0 ) + std::cerr << "error: can't get service entry"; + + ppe = getprotobyname(transport); + if (ppe == 0) + std::cerr << "error: can't get protocol entry"; + + if ( strcmp( transport, "udp" ) == 0 ) + type = SOCK_DGRAM; + else { + type = SOCK_STREAM; + } + + s = socket( PF_INET, type, ppe->p_proto ); + + if (s < 0) + std::cerr << "error: can't create socket"; + + if ( host == "" ) { //server socket is created + sin.sin_addr.s_addr = INADDR_ANY; + int t = bind( s, (struct sockaddr *)&sin, sizeof( sin ) ); +// std::cerr << t << std::endl; + if ( type == SOCK_STREAM ) { + listen(s,qlen); + } + } else { //client socket is created + if ( phe = gethostbyname( host ) ) + memcpy( &sin.sin_addr, phe->h_addr, phe->h_length ); + else sin.sin_addr.s_addr = inet_addr( host ); + int t = connect( s, (struct sockaddr *)&sin, sizeof( sin ) ); +// std::cerr << t << std::endl; + } + + return s; +} + +sock::sock( const char *service, const char *transport, int qlen) { //constructor for server socket + s = connectSock( service, transport, qlen, ""); +} + +sock::sock( const char *service, const char *transport, char *host) { //constructor for client socket + s = connectSock( service, transport, 0, host); +} + +int sock::getDescr() { + return s; +} + +} //namespace sct Added: trunk/complement/explore/app/SMTP-tools/smtp_server_ut/socket/socket.h =================================================================== --- trunk/complement/explore/app/SMTP-tools/smtp_server_ut/socket/socket.h (rev 0) +++ trunk/complement/explore/app/SMTP-tools/smtp_server_ut/socket/socket.h 2008-05-22 14:26:19 UTC (rev 1879) @@ -0,0 +1,35 @@ +#include <sys/types.h> +#include <sys/socket.h> + +#include <netinet/in.h> +#include <arpa/inet.h> + +#include <stdlib.h> +#include <string.h> +#include <netdb.h> +#include <unistd.h> +#include <stdio.h> + +namespace sct +{ + +class sock +{ + private: + struct hostent *phe; + struct servent *pse; + struct protoent *ppe; + struct sockaddr_in sin; + int s, type; + + int connectSock( const char *service, const char *transport, int qlen, char *host); + + public: + sock( const char *service, const char *transport, int qlen); //constructor for server socket + sock( const char *service, const char *transport, char *host); //constructor for client socket + ~sock() + {}; + int getDescr(); +}; + +} //namespace sct This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |