diff -urN tmp/commoncpp2/include/cc++/Makefile.am src/cvs/commoncpp2/include/cc++/Makefile.am --- tmp/commoncpp2/include/cc++/Makefile.am 2002-06-27 14:39:00.000000000 -0500 +++ src/cvs/commoncpp2/include/cc++/Makefile.am 2002-07-01 00:33:54.000000000 -0500 @@ -22,12 +22,14 @@ ccxxinclude_HEADERS = \ cmdoptns.h common.h config.h digest.h exception.h export.h file.h \ ftp.h groups.h misc.h numbers.h persist.h serial.h slog.h \ - socket.h strchar.h thread.h unix.h url.h xml.h process.h ftp.h + socket.h strchar.h thread.h unix.h url.h xml.h process.h \ + postream postream.tcc pistream piostream pios piosfwd kdoc_headers = \ cmdoptns.h common.h config.h digest.h exception.h export.h file.h \ ftp.h groups.h misc.h numbers.h persist.h serial.h slog.h \ - socket.h strchar.h thread.h unix.h url.h xml.h process.h + socket.h strchar.h thread.h unix.h url.h xml.h process.h \ + postream postream.tcc pistream piostream pios piosfwd kdoc: kdoc -f html -d $(KDOC_DIR) -L $(KDOC_DIR) -n CommonC++ $(kdoc_headers) --cppcmd ../../doc/kdoc_cpp --cpp -I ../../doc diff -urN tmp/commoncpp2/include/cc++/pfstream src/cvs/commoncpp2/include/cc++/pfstream --- tmp/commoncpp2/include/cc++/pfstream 1969-12-31 18:00:00.000000000 -0600 +++ src/cvs/commoncpp2/include/cc++/pfstream 2002-08-10 11:28:30.000000000 -0500 @@ -0,0 +1,74 @@ +// Copyright (C) 2002 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// As a special exception to the GNU General Public License, permission is +// granted for additional uses of the text contained in its release +// of Common C++. +// +// The exception is that, if you link the Common C++ library with other +// files to produce an executable, this does not by itself cause the +// resulting executable to be covered by the GNU General Public License. +// Your use of that executable is in no way restricted on account of +// linking the Common C++ library code into it. +// +// This exception does not however invalidate any other reasons why +// the executable file might be covered by the GNU General Public License. +// +// This exception applies only to the code released under the +// name Common C++. If you copy code from other releases into a copy of +// Common C++, as the General Public License permits, the exception does +// not apply to the code that you add in this way. To avoid misleading +// anyone as to the status of such modified files, you must delete +// this exception notice from them. +// +// If you write modifications of your own for Common C++, it is your choice +// whether to permit this exception to apply to your modifications. +// If you do not wish that, delete this exception notice. + +#ifndef CCXX_BASIC_PFSTREAM +#define CCXX_BASIC_PFSTREAM + +#ifndef CCXX_CONFIG_H_ +#include +#endif + +// put headers here + +#ifdef CCXX_NAMESPACES +using namespace std; + +namespace ost +{ +#endif + + template + class basic_pfilebuf: public basic_filebuf + { + + +#ifdef CCXX_NAMESPACES +} // namespace ost +#endif + +//#include + +#endif /* CCXX_BASIC_PFSTREAM */ +/** EMACS ** + * Local variables: + * mode: c++ + * c-basic-offset: 2 + * End: + */ diff -urN tmp/commoncpp2/include/cc++/piomanip src/cvs/commoncpp2/include/cc++/piomanip --- tmp/commoncpp2/include/cc++/piomanip 1969-12-31 18:00:00.000000000 -0600 +++ src/cvs/commoncpp2/include/cc++/piomanip 2002-08-13 20:09:10.000000000 -0500 @@ -0,0 +1,68 @@ +// Copyright (C) 2002 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// As a special exception to the GNU General Public License, permission is +// granted for additional uses of the text contained in its release +// of Common C++. +// +// The exception is that, if you link the Common C++ library with other +// files to produce an executable, this does not by itself cause the +// resulting executable to be covered by the GNU General Public License. +// Your use of that executable is in no way restricted on account of +// linking the Common C++ library code into it. +// +// This exception does not however invalidate any other reasons why +// the executable file might be covered by the GNU General Public License. +// +// This exception applies only to the code released under the +// name Common C++. If you copy code from other releases into a copy of +// Common C++, as the General Public License permits, the exception does +// not apply to the code that you add in this way. To avoid misleading +// anyone as to the status of such modified files, you must delete +// this exception notice from them. +// +// If you write modifications of your own for Common C++, it is your choice +// whether to permit this exception to apply to your modifications. +// If you do not wish that, delete this exception notice. + +#ifndef CCXX_PIOMANIP +#define CCXX_PIOMANIP 1 + +#ifndef CCXX_CONFIG_H_ +#include +#endif + +#include +#include + +#ifdef CCXX_NAMESPACES +using namespace std; + +namespace ost +{ +#endif + +#ifdef CCXX_NAMESPACES +} // namespace ost +#endif + +#endif /* CCXX_PIOMANIP */ +/** EMACS ** + * Local variables: + * mode: c++ + * c-basic-offset: 2 + * End: + */ diff -urN tmp/commoncpp2/include/cc++/pios src/cvs/commoncpp2/include/cc++/pios --- tmp/commoncpp2/include/cc++/pios 1969-12-31 18:00:00.000000000 -0600 +++ src/cvs/commoncpp2/include/cc++/pios 2002-08-11 23:26:52.000000000 -0500 @@ -0,0 +1,101 @@ +// Copyright (C) 2002 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// As a special exception to the GNU General Public License, permission is +// granted for additional uses of the text contained in its release +// of Common C++. +// +// The exception is that, if you link the Common C++ library with other +// files to produce an executable, this does not by itself cause the +// resulting executable to be covered by the GNU General Public License. +// Your use of that executable is in no way restricted on account of +// linking the Common C++ library code into it. +// +// This exception does not however invalidate any other reasons why +// the executable file might be covered by the GNU General Public License. +// +// This exception applies only to the code released under the +// name Common C++. If you copy code from other releases into a copy of +// Common C++, as the General Public License permits, the exception does +// not apply to the code that you add in this way. To avoid misleading +// anyone as to the status of such modified files, you must delete +// this exception notice from them. +// +// If you write modifications of your own for Common C++, it is your choice +// whether to permit this exception to apply to your modifications. +// If you do not wish that, delete this exception notice. + +// Copyright (C) 2002 Open Source Telecom Corporation. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// As a special exception to the GNU General Public License, permission is +// granted for additional uses of the text contained in its release +// of Common C++. +// +// The exception is that, if you link the Common C++ library with other +// files to produce an executable, this does not by itself cause the +// resulting executable to be covered by the GNU General Public License. +// Your use of that executable is in no way restricted on account of +// linking the Common C++ library code into it. +// +// This exception does not however invalidate any other reasons why +// the executable file might be covered by the GNU General Public License. +// +// This exception applies only to the code released under the +// name Common C++. If you copy code from other releases into a copy of +// Common C++, as the General Public License permits, the exception does +// not apply to the code that you add in this way. To avoid misleading +// anyone as to the status of such modified files, you must delete +// this exception notice from them. +// +// If you write modifications of your own for Common C++, it is your choice +// whether to permit this exception to apply to your modifications. +// If you do not wish that, delete this exception notice. + +#ifndef CCXX_PIOS +#define CCXX_PIOS 1 + +#include +#include // For ios_base::failure +#include // For char_traits, streamoff, streamsize, fpos +#include // For SEEK_SET, SEEK_CUR, SEEK_END +#include // For class locale +#include // For ios_base declarations. +//#include +#include +#include +#include + +#endif /* CCXX_PIOS */ +/** EMACS ** + * Local variables: + * mode: c++ + * c-basic-offset: 2 + * End: + */ diff -urN tmp/commoncpp2/include/cc++/pios_init.h src/cvs/commoncpp2/include/cc++/pios_init.h --- tmp/commoncpp2/include/cc++/pios_init.h 1969-12-31 18:00:00.000000000 -0600 +++ src/cvs/commoncpp2/include/cc++/pios_init.h 2002-08-10 13:14:55.000000000 -0500 @@ -0,0 +1,87 @@ +// Copyright (C) 2002 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// As a special exception to the GNU General Public License, permission is +// granted for additional uses of the text contained in its release +// of Common C++. +// +// The exception is that, if you link the Common C++ library with other +// files to produce an executable, this does not by itself cause the +// resulting executable to be covered by the GNU General Public License. +// Your use of that executable is in no way restricted on account of +// linking the Common C++ library code into it. +// +// This exception does not however invalidate any other reasons why +// the executable file might be covered by the GNU General Public License. +// +// This exception applies only to the code released under the +// name Common C++. If you copy code from other releases into a copy of +// Common C++, as the General Public License permits, the exception does +// not apply to the code that you add in this way. To avoid misleading +// anyone as to the status of such modified files, you must delete +// this exception notice from them. +// +// If you write modifications of your own for Common C++, it is your choice +// whether to permit this exception to apply to your modifications. +// If you do not wish that, delete this exception notice. + +#ifndef CCXX_PIOS_INIT_H +#define CCXX_PIOS_INIT_H + +#ifndef CCXX_CONFIG_H_ +#include +#endif + +#ifdef CCXX_NAMESPACES +using namespace std; + +namespace ost +{ +#endif + + // Class Init + // Used to initialize standard streams. In theory, g++ could use + // -finit-priority to order this stuff correctly without going + // through these machinations. + class Init + { + // friend class ios_base; + public: + Init(); + ~Init(); + + static void + pios_create(bool syncf); + + static void + pios_destroy(); + + private: + static int pios_init; + static bool synced_with_stdio; + }; + +#ifdef CCXX_NAMESPACES +} // namespace ost +#endif + +#endif /* CCXX_PIOS_INIT_H +/** EMACS ** + * Local variables: + * mode: c++ + * c-basic-offset: 2 + * End: + */ diff -urN tmp/commoncpp2/include/cc++/piosfwd src/cvs/commoncpp2/include/cc++/piosfwd --- tmp/commoncpp2/include/cc++/piosfwd 1969-12-31 18:00:00.000000000 -0600 +++ src/cvs/commoncpp2/include/cc++/piosfwd 2002-08-11 22:25:06.000000000 -0500 @@ -0,0 +1,144 @@ +// Copyright (C) 2002 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// As a special exception to the GNU General Public License, permission is +// granted for additional uses of the text contained in its release +// of Common C++. +// +// The exception is that, if you link the Common C++ library with other +// files to produce an executable, this does not by itself cause the +// resulting executable to be covered by the GNU General Public License. +// Your use of that executable is in no way restricted on account of +// linking the Common C++ library code into it. +// +// This exception does not however invalidate any other reasons why +// the executable file might be covered by the GNU General Public License. +// +// This exception applies only to the code released under the +// name Common C++. If you copy code from other releases into a copy of +// Common C++, as the General Public License permits, the exception does +// not apply to the code that you add in this way. To avoid misleading +// anyone as to the status of such modified files, you must delete +// this exception notice from them. +// +// If you write modifications of your own for Common C++, it is your choice +// whether to permit this exception to apply to your modifications. +// If you do not wish that, delete this exception notice. + +#ifndef CCXX_PIOSFWD +#define CCXX_PIOSFWD + +#ifdef CCXX_NAMESPACES + +using namespace std; + +namespace ost +{ +#endif + + //template > + //class basic_pstreambuf; + + template > + class basic_pistream; + + template > + class basic_postream; + + template > + class basic_piostream; + /* + template, + typename _Alloc = allocator > + class basic_stringbuf; + + template, + typename _Alloc = allocator > + class basic_istringstream; + + template, + typename _Alloc = allocator > + class basic_ostringstream; + + template, + typename _Alloc = allocator > + class basic_stringstream; + + template > + class basic_filebuf; + + template > + class basic_ifstream; + + template > + class basic_ofstream; + + template > + class basic_fstream; + + template > + class istreambuf_iterator; + + template > + class ostreambuf_iterator; + */ + +/* +#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS + // Not included. (??? Apparently no LWG number?) + class ios_base; +#endif +*/ + + //typedef basic_ios ios; + //typedef basic_pstreambuf pstreambuf; + typedef basic_pistream pistream; + typedef basic_postream postream; + typedef basic_piostream piostream; + //typedef basic_stringbuf stringbuf; + //typedef basic_istringstream istringstream; + //typedef basic_ostringstream ostringstream; + //typedef basic_stringstream stringstream; + //typedef basic_filebuf filebuf; + //typedef basic_ifstream ifstream; + //typedef basic_ofstream ofstream; + //typedef basic_fstream fstream; + + //typedef basic_ios wios; + //typedef basic_pstreambuf wpstreambuf; + typedef basic_pistream wpistream; + typedef basic_postream wpostream; + typedef basic_piostream wpiostream; + //typedef basic_stringbuf wstringbuf; + //typedef basic_istringstream wistringstream; + //typedef basic_ostringstream wostringstream; + //typedef basic_stringstream wstringstream; + //typedef basic_filebuf wfilebuf; + //typedef basic_ifstream wifstream; + //typedef basic_ofstream wofstream; + //typedef basic_fstream wfstream; + +#ifdef CCXX_NAMESPACES +} // namespace ost +#endif + +#endif /* CCXX_PIOSFWD */ +/** EMACS ** + * Local variables: + * mode: c++ + * c-basic-offset: 2 + * End: + */ diff -urN tmp/commoncpp2/include/cc++/piostream src/cvs/commoncpp2/include/cc++/piostream --- tmp/commoncpp2/include/cc++/piostream 1969-12-31 18:00:00.000000000 -0600 +++ src/cvs/commoncpp2/include/cc++/piostream 2002-08-10 14:32:57.000000000 -0500 @@ -0,0 +1,78 @@ +// Copyright (C) 2002 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// As a special exception to the GNU General Public License, permission is +// granted for additional uses of the text contained in its release +// of Common C++. +// +// The exception is that, if you link the Common C++ library with other +// files to produce an executable, this does not by itself cause the +// resulting executable to be covered by the GNU General Public License. +// Your use of that executable is in no way restricted on account of +// linking the Common C++ library code into it. +// +// This exception does not however invalidate any other reasons why +// the executable file might be covered by the GNU General Public License. +// +// This exception applies only to the code released under the +// name Common C++. If you copy code from other releases into a copy of +// Common C++, as the General Public License permits, the exception does +// not apply to the code that you add in this way. To avoid misleading +// anyone as to the status of such modified files, you must delete +// this exception notice from them. +// +// If you write modifications of your own for Common C++, it is your choice +// whether to permit this exception to apply to your modifications. +// If you do not wish that, delete this exception notice. + +#ifndef CCXX_PIOSTREAM +#define CCXX_PIOSTREAM + +#include +#include + +#ifdef CCXX_NAMESPACES +namespace ost +{ +#endif + + extern pistream pin; + extern postream pout; + extern postream perr; + extern postream plog; + /* +#ifdef _GLIBCPP_USE_WCHAR_T + extern wpistream wpin; + extern wpostream wpout; + extern wpostream wperr; + extern wpostream wplog; +#endif + */ + + // For construction of filebuffers for pout, pin, perr, clog et. al. + static ost::Init pioinit; + +#ifdef CCXX_NAMESPACES +} // namespace ost +#endif + +#endif /* CCXX_PIOSTREAM */ +/** EMACS ** + * Local variables: + * mode: c++ + * c-basic-offset: 2 + * End: + */ diff -urN tmp/commoncpp2/include/cc++/pistream src/cvs/commoncpp2/include/cc++/pistream --- tmp/commoncpp2/include/cc++/pistream 1969-12-31 18:00:00.000000000 -0600 +++ src/cvs/commoncpp2/include/cc++/pistream 2002-08-10 13:41:58.000000000 -0500 @@ -0,0 +1,304 @@ +// Copyright (C) 2002 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// As a special exception to the GNU General Public License, permission is +// granted for additional uses of the text contained in its release +// of Common C++. +// +// The exception is that, if you link the Common C++ library with other +// files to produce an executable, this does not by itself cause the +// resulting executable to be covered by the GNU General Public License. +// Your use of that executable is in no way restricted on account of +// linking the Common C++ library code into it. +// +// This exception does not however invalidate any other reasons why +// the executable file might be covered by the GNU General Public License. +// +// This exception applies only to the code released under the +// name Common C++. If you copy code from other releases into a copy of +// Common C++, as the General Public License permits, the exception does +// not apply to the code that you add in this way. To avoid misleading +// anyone as to the status of such modified files, you must delete +// this exception notice from them. +// +// If you write modifications of your own for Common C++, it is your choice +// whether to permit this exception to apply to your modifications. +// If you do not wish that, delete this exception notice. + +#ifndef CCXX_BASIC_PISTREAM +#define CCXX_BASIC_PISTREAM + +#ifndef CCXX_CONFIG_H_ +#include +#endif + +#include +#include +#include + +#ifdef CCXX_NAMESPACES +using namespace std; + +namespace ost +{ +#endif + + // Template class basic_pistream + template + class basic_pistream : public basic_istream + { + public: + // Types + 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; + + // Non-standard Types: + typedef basic_streambuf streambuf_type; + typedef basic_ios ios_type; + typedef basic_istream istream_type; + typedef basic_pistream pistream_type; + typedef istreambuf_iterator istreambuf_iter; + typedef num_get numget_type; + typedef ctype ctype_type; + + public: + explicit + basic_pistream(streambuf_type* sb) + : basic_istream(sb) { } + + virtual + ~basic_pistream() + { } + + // Prefix/suffix: + class psentry; + friend class psentry; + + // Formatted input: + // basic_pistream::operator>> + pistream_type& + operator>>(pistream_type& (*pf)(pistream_type&)); + + pistream_type& + operator>>(istream_type& (*pf)(istream_type&)); + + pistream_type& + operator>>(ios_type& (*pf)(ios_type&)); + + pistream_type& + operator>>(ios_base& (*pf)(ios_base&)); + + // Arithmetic Extractors + pistream_type& + operator>>(bool& n); + + pistream_type& + operator>>(short& n); + + pistream_type& + operator>>(unsigned short& n); + + pistream_type& + operator>>(int& n); + + pistream_type& + operator>>(unsigned int& n); + + pistream_type& + operator>>(long& n); + + pistream_type& + operator>>(unsigned long& n); + + //#ifdef _GLIBCPP_USE_LONG_LONG + pistream_type& + operator>>(long long& n); + + pistream_type& + operator>>(unsigned long long& n); + //#endif + + pistream_type& + operator>>(float& f); + + pistream_type& + operator>>(double& f); + + pistream_type& + operator>>(long double& f); + + pistream_type& + operator>>(void*& p); + + pistream_type& + operator>>(streambuf_type* sb); + + // Unformatted input: + inline streamsize + gcount(void) const + { istream_type::gcount(); } + + int_type + get(void); + + pistream_type& + get(char_type& c); + + istream_type& + get(char_type* s, streamsize n, char_type delim); + + inline pistream_type& + get(char_type* s, streamsize n) + { istream_type::get(s, n); } + + pistream_type& + get(streambuf_type& sb, char_type delim); + + inline pistream_type& + get(streambuf_type& sb) + { istream_type::get(sb); } + + pistream_type& + getline(char_type* s, streamsize n, char_type delim); + + inline pistream_type& + getline(char_type* s, streamsize n) + { istream_type::getline(s, n); } + + pistream_type& + ignore(streamsize n = 1, int_type delim = traits_type::eof()); + + int_type + peek(void); + + istream_type& + read(char_type* s, streamsize n); + + streamsize + readsome(char_type* s, streamsize n); + + pistream_type& + putback(char_type c); + + pistream_type& + unget(void); + + int + sync(void); + + pos_type + tellg(void); + + pistream_type& + seekg(pos_type); + + pistream_type& + seekg(off_type, ios_base::seekdir); + }; + + template + class basic_pistream::psentry + { + public: + typedef Traits traits_type; + typedef basic_streambuf streambuf_type; + typedef basic_pistream pistream_type; + typedef typename istream_type::ctype_type ctype_type; + typedef typename Traits::int_type int_type; + + explicit + psentry(basic_pistream& pis, bool noskipws = false); + + ~psentry() + { } + + operator bool() + { return ok; } + + private: + bool ok; + }; + + // Character extraction templates + template + basic_pistream& + operator>>(basic_pistream& pin, charT& c); + + template + basic_pistream& + operator>>(basic_pistream& pin, unsigned char& c) + { return (pin >> reinterpret_cast(c)); } + + template + basic_pistream& + operator>>(basic_pistream& pin, signed char& c) + { return (pin >> reinterpret_cast(c)); } + + template + basic_pistream& + operator>>(basic_pistream& pin, charT* s); + + template + basic_pistream& + operator>>(basic_pistream& pin, unsigned char* s) + { return (pin >> reinterpret_cast(s)); } + + template + basic_pistream& + operator>>(basic_pistream& pin, signed char* s) + { return (pin >> reinterpret_cast(s)); } + + // Template class basic_piostream + template + class basic_piostream + : public basic_pistream, + public basic_postream + { + public: + // Non-standard Types: + typedef basic_pistream pistream_type; + typedef basic_postream postream_type; + + explicit + basic_piostream(basic_streambuf* sb) + : istream_type(sb), ostream_type(sb) + { } + + virtual + ~basic_piostream() { } + }; + + // Standard basic_pistream manipulators + template + basic_pistream& + ws(basic_pistream& is); + +#ifdef CCXX_NAMESPACES +} +#endif + +#include + +#endif /* CCXX_BASIC_PISTREAM */ +/** EMACS ** + * Local variables: + * mode: c++ + * c-basic-offset: 2 + * End: + */ diff -urN tmp/commoncpp2/include/cc++/pistream.tcc src/cvs/commoncpp2/include/cc++/pistream.tcc --- tmp/commoncpp2/include/cc++/pistream.tcc 1969-12-31 18:00:00.000000000 -0600 +++ src/cvs/commoncpp2/include/cc++/pistream.tcc 2002-07-02 21:54:36.000000000 -0500 @@ -0,0 +1,59 @@ +// Copyright (C) 2002 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// As a special exception to the GNU General Public License, permission is +// granted for additional uses of the text contained in its release +// of Common C++. +// +// The exception is that, if you link the Common C++ library with other +// files to produce an executable, this does not by itself cause the +// resulting executable to be covered by the GNU General Public License. +// Your use of that executable is in no way restricted on account of +// linking the Common C++ library code into it. +// +// This exception does not however invalidate any other reasons why +// the executable file might be covered by the GNU General Public License. +// +// This exception applies only to the code released under the +// name Common C++. If you copy code from other releases into a copy of +// Common C++, as the General Public License permits, the exception does +// not apply to the code that you add in this way. To avoid misleading +// anyone as to the status of such modified files, you must delete +// this exception notice from them. +// +// If you write modifications of your own for Common C++, it is your choice +// whether to permit this exception to apply to your modifications. +// If you do not wish that, delete this exception notice. + +#include +#include // For flush() + +#ifdef CCXX_NAMESPACES +using namespace std; + +namespace ost +{ +#endif + +#ifdef CCXX_NAMESPACES +} // namespace ost +#endif +/** EMACS ** + * Local variables: + * mode: c++ + * c-basic-offset: 2 + * End: + */ diff -urN tmp/commoncpp2/include/cc++/postream src/cvs/commoncpp2/include/cc++/postream --- tmp/commoncpp2/include/cc++/postream 1969-12-31 18:00:00.000000000 -0600 +++ src/cvs/commoncpp2/include/cc++/postream 2002-08-24 21:03:41.000000000 -0500 @@ -0,0 +1,408 @@ +// Copyright (C) 2002 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// As a special exception to the GNU General Public License, permission is +// granted for additional uses of the text contained in its release +// of Common C++. +// +// The exception is that, if you link the Common C++ library with other +// files to produce an executable, this does not by itself cause the +// resulting executable to be covered by the GNU General Public License. +// Your use of that executable is in no way restricted on account of +// linking the Common C++ library code into it. +// +// This exception does not however invalidate any other reasons why +// the executable file might be covered by the GNU General Public License. +// +// This exception applies only to the code released under the +// name Common C++. If you copy code from other releases into a copy of +// Common C++, as the General Public License permits, the exception does +// not apply to the code that you add in this way. To avoid misleading +// anyone as to the status of such modified files, you must delete +// this exception notice from them. +// +// If you write modifications of your own for Common C++, it is your choice +// whether to permit this exception to apply to your modifications. +// If you do not wish that, delete this exception notice. + +#ifndef CCXX_BASIC_POSTREAM +#define CCXX_BASIC_POSTREAM + +#ifndef CCXX_CONFIG_H_ +#include +#endif + +#include +#include +#include +#include +#include + +#ifdef CCXX_NAMESPACES +using namespace std; + +namespace ost +{ +#endif + + template + class basic_postream: public basic_ostream + { + public: + + // Types + 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; + + // Non-standard Types: + typedef basic_streambuf streambuf_type; + //typedef basic_pstreambuf pstreambuf_type; + typedef basic_ios ios_type; + typedef basic_ostream ostream_type; + typedef basic_postream postream_type; + typedef ostreambuf_iterator ostreambuf_iter; + typedef num_put numput_type; + typedef ctype ctype_type; + + // Constructor/destructor: + explicit + basic_postream(streambuf_type* sb) + : ostream_type(sb), currth(NULL), pid(0), tid(0), lockcnt(0), + owned(false), header(false) + { } + + virtual + ~basic_postream() { } + + class psentry; + friend class psentry; + + // Formatted output: + // basic_postream::operator<< + postream_type& + operator<<(postream_type& (*pf)(postream_type&)); + + //postream_type& + //operator<<(ostream_type& (*pf)(ostream_type&)); + + postream_type& + operator<<(ios_type& (*pf)(ios_type&)); + + postream_type& + operator<<(ios_base& (*pf)(ios_base&)); + + // Arithmetic Inserters + postream_type& + operator<<(long n); + + postream_type& + operator<<(unsigned long n); + + postream_type& + operator<<(bool n); + + postream_type& + operator<<(short n) + { + ios_base::fmtflags fmt = this->flags() & ios_base::basefield; + if (fmt & ios_base::oct || fmt & ios_base::hex) + return this->operator<<(static_cast + (static_cast(n))); + else + return this->operator<<(static_cast(n)); + } + + postream_type& + operator<<(unsigned short n) + { return this->operator<<(static_cast(n)); } + + postream_type& + operator<<(int n) + { + ios_base::fmtflags fmt = this->flags() & ios_base::basefield; + if (fmt & ios_base::oct || fmt & ios_base::hex) + return this->operator<<(static_cast + (static_cast(n))); + else + return this->operator<<(static_cast(n)); + } + + postream_type& + operator<<(unsigned int n) + { return this->operator<<(static_cast(n)); } + + //#ifdef _GLIBCPP_USE_LONG_LONG + postream_type& + operator<<(long long n); + + postream_type& + operator<<(unsigned long long n); + //#endif + + postream_type& + operator<<(double f); + + postream_type& + operator<<(float f) + { return this->operator<<(static_cast(f)); } + + postream_type& + operator<<(long double f); + + postream_type& + operator<<(const void* p); + + postream_type& + operator<<(streambuf_type* sb); + + // Unformatted output: + postream_type& + put(char_type c); + + postream_type& + write(const char_type* s, streamsize n); + + postream_type& + flush(); + + // Seeks: + pos_type + tellp(); + + postream_type& + seekp(pos_type); + + postream_type& + seekp(off_type, ios_base::seekdir); + + // std::ios_base methods + + // Format flags state + inline ios_base::fmtflags + flags() const + { + MutexLock mlock(lock); + basic_ostream::flags(); + } + + inline ios_base::fmtflags + flags(ios_base::fmtflags fmtfl) + { + MutexLock mlock(lock); + basic_ostream::flags(fmtfl); + } + + inline ios_base::fmtflags + setf(ios_base::fmtflags fmtfl) + { + MutexLock mlock(lock); + basic_ostream::setf(fmtfl); + } + + inline ios_base::fmtflags + setf(ios_base::fmtflags fmtfl, ios_base::fmtflags mask) + { + MutexLock mlock(lock); + basic_ostream::setf(fmtfl, mask); + } + + inline void + unsetf(ios_base::fmtflags mask) + { + MutexLock mlock(lock); + basic_ostream::unsetf(mask); + } + + inline streamsize + precision() const + { + MutexLock mlock(lock); + basic_ostream::precision(); + } + + inline streamsize + precision(streamsize prec) + { + MutexLock mlock(lock); + basic_ostream::precision(prec); + } + + inline streamsize + width() const + { + MutexLock mlock(lock); + basic_ostream::width(); + } + + inline streamsize + width(streamsize wide) + { + MutexLock mlock(lock); + basic_ostream::width(wide); + } + + static bool + sync_with_stdio(bool sync = true); + + // Locales: + locale + imbue(const locale& loc); + + inline locale + getloc() const + { + MutexLock mlock(lock); + basic_ostream::getloc(); + } + + // Storage: + static int + xalloc() throw(); + + inline long& + iword(int ix) + { + MutexLock mlock(lock); + basic_ostream::iword(ix); + } + + inline void*& + pword(int ix) + { + MutexLock mlock(lock); + basic_ostream::pword(ix); + } + + Thread* currth; + int pid; + int tid; + unsigned int lockcnt; + bool owned; + bool header; + + void lockStream(); + void unlockStream(); + void outputHeader(); + protected: + mutable Mutex lock; + mutable Mutex lockbuf; + //mutable Mutex mtx; + }; + + // Class basic_postream::psentry + template + class basic_postream::psentry + { + // Data Members: + bool ok; + postream_type& pos; + typename ostream_type::sentry* msentry; + + public: + explicit + psentry(basic_postream& os); + + ~psentry() + { + pos.lockbuf.leaveMutex(); // unlock the buffer + pos.lock.leaveMutex(); // unlock the stream + } + + operator bool() + { return ok; } + }; + + template + basic_postream& + operator<<(basic_postream& out, charT c); + + template + basic_postream& + operator<<(basic_postream& out, char c) + { return (out << out.widen(c)); } + + // Specialization + template + basic_postream& + operator<<(basic_postream& out, char c); + + // Signed and unsigned + template + basic_postream& + operator<<(basic_postream& out, signed char c) + { return (out << static_cast(c)); } + + template + basic_postream& + operator<<(basic_postream& out, unsigned char c) + { return (out << static_cast(c)); } + + template + basic_postream& + operator<<(basic_postream& out, const charT* s); + + template + basic_postream & + operator<<(basic_postream& out, const char* s); + + // Partial specializationss + template + basic_postream& + operator<<(basic_postream& out, const char* s); + + // Signed and unsigned + template + basic_postream& + operator<<(basic_postream& out, const signed char* s) + { return (out << reinterpret_cast(s)); } + + template + basic_postream & + operator<<(basic_postream& out, const unsigned char* s) + { return (out << reinterpret_cast(s)); } + + // Standard basic_postream manipulators + template + basic_postream& + endl(basic_postream& os) + { return flush(os.put(os.widen('\n'))); } + + template + basic_postream& + ends(basic_postream& os) + { return os.put(charT()); } + + template + basic_postream& + flush(basic_postream& os) + { return os.flush(); } + +#ifdef CCXX_NAMESPACES +} // namespace ost +#endif + +#include + +#endif /* CCXX_BASIC_POSTREAM */ +/** EMACS ** + * Local variables: + * mode: c++ + * c-basic-offset: 2 + * End: + */ diff -urN tmp/commoncpp2/include/cc++/postream.tcc src/cvs/commoncpp2/include/cc++/postream.tcc --- tmp/commoncpp2/include/cc++/postream.tcc 1969-12-31 18:00:00.000000000 -0600 +++ src/cvs/commoncpp2/include/cc++/postream.tcc 2002-08-24 20:28:46.000000000 -0500 @@ -0,0 +1,504 @@ +// Copyright (C) 2002 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// As a special exception to the GNU General Public License, permission is +// granted for additional uses of the text contained in its release +// of Common C++. +// +// The exception is that, if you link the Common C++ library with other +// files to produce an executable, this does not by itself cause the +// resulting executable to be covered by the GNU General Public License. +// Your use of that executable is in no way restricted on account of +// linking the Common C++ library code into it. +// +// This exception does not however invalidate any other reasons why +// the executable file might be covered by the GNU General Public License. +// +// This exception applies only to the code released under the +// name Common C++. If you copy code from other releases into a copy of +// Common C++, as the General Public License permits, the exception does +// not apply to the code that you add in this way. To avoid misleading +// anyone as to the status of such modified files, you must delete +// this exception notice from them. +// +// If you write modifications of your own for Common C++, it is your choice +// whether to permit this exception to apply to your modifications. +// If you do not wish that, delete this exception notice. + +#include +#include +#include +#include + +#include + +#ifdef CCXX_NAMESPACES +using namespace std; + +namespace ost +{ +#endif + template + basic_postream::psentry:: + psentry(basic_postream& os) + : pos(os) + { + pos.lock.enterMutex(); // lock the stream + pos.lockbuf.enterMutex(); // lock the buffer + //pos.lockStream(); + msentry = new typename postream_type::sentry(os); + if(msentry) + ok = true; + } + + template + basic_postream& + basic_postream:: + operator<<(postream_type& (*pf)(postream_type&)) + { + typedef basic_postream postream_type; + + try + { + // Create a psentry object (may set error bits or throw failure) + typename postream_type::psentry opfx(*this); + + if(opfx) + { pf(*this); } + } + catch(...) + { + bool flag = false; + try + { + this->setstate(std::ios_base::failbit); + } + catch(std::ios_base::failure) + { + flag = true; + } + if(flag) + throw; + } + + return *this; + } + /* + template + basic_postream& + basic_postream:: + operator<<(ostream_type& (*pf)(ostream_type&)) + { + // Create a psentry object (may set error bits or throw failure) + typedef basic_postream postream_type; + typename postream_type::psentry opfx(*this); + + ostream_type::operator<<(pf); + + return *this; + } + */ + template + basic_postream& + basic_postream:: + operator<<(ios_type& (*pf)(ios_type&)) + { + // Create a psentry object (may set error bits or throw failure) + typedef basic_postream postream_type; + typename postream_type::psentry opfx(*this); + + ostream_type::operator<<(pf); + + return this; + } + + template + basic_postream& + basic_postream:: + operator<<(ios_base& (*pf)(ios_base&)) + { + // Create a psentry object (may set error bits or throw failure) + typedef basic_postream postream_type; + typename postream_type::psentry opfx(*this); + + ostream_type::operator<<(pf); + + return *this; + } + + template + basic_postream& + basic_postream::operator<<(streambuf_type* sbin) + { + // Create a psentry object (may set error bits or throw failure) + typedef basic_postream postream_type; + typename postream_type::psentry opfx(*this); + + ostream_type::operator<<(sbin); + + return *this; + } + + template + basic_postream& + basic_postream::operator<<(bool n) + { + // Create a psentry object (may set error bits or throw failure) + typedef basic_postream postream_type; + typename postream_type::psentry opfx(*this); + + ostream_type::operator<<(n); + + return *this; + } + + template + basic_postream& + basic_postream::operator<<(long n) + { + // Create a psentry object (may set error bits or throw failure) + typedef basic_postream postream_type; + typename postream_type::psentry opfx(*this); + + ostream_type::operator<<(n); + + return *this; + } + + template + basic_postream& + basic_postream::operator<<(unsigned long n) + { + // Create a psentry object (may set error bits or throw failure) + typedef basic_postream postream_type; + typename postream_type::psentry opfx(*this); + + ostream_type::operator<<(n); + + return *this; + } + + // TODO: #ifdef USE_LONG_LONG + template + basic_postream& + basic_postream::operator<<(long long n) + { + // Create a psentry object (may set error bits or throw failure) + typedef basic_postream postream_type; + typename postream_type::psentry opfx(*this); + + ostream_type::operator<<(n); + + return *this; + } + + template + basic_postream& + basic_postream::operator<<(unsigned long long n) + { + // Create a psentry object (may set error bits or throw failure) + typedef basic_postream postream_type; + typename postream_type::psentry opfx(*this); + + ostream_type::operator<<(n); + + return *this; + } + //#endif + + template + basic_postream& + basic_postream::operator<<(double n) + { + // Create a psentry object (may set error bits or throw failure) + typedef basic_postream postream_type; + typename postream_type::psentry opfx(*this); + + ostream_type::operator<<(n); + + return *this; + } + + template + basic_postream& + basic_postream::operator<<(long double n) + { + // Create a psentry object (may set error bits or throw failure) + typedef basic_postream postream_type; + typename postream_type::psentry opfx(*this); + + ostream_type::operator<<(n); + + return *this; + } + + template + basic_postream& + basic_postream::operator<<(const void* n) + { + // Create a psentry object (may set error bits or throw failure) + typedef basic_postream postream_type; + typename postream_type::psentry opfx(*this); + + ostream_type::operator<<(n); + + return *this; + } + + template + basic_postream& + basic_postream::put(char_type c) + { + // Create a psentry object (may set error bits or throw failure) + typedef basic_postream postream_type; + typename postream_type::psentry opfx(*this); + + ostream_type::put(c); + + return *this; + } + + template + basic_postream& + basic_postream::write(const charT* s, streamsize n) + { + // Create a psentry object (may set error bits or throw failure) + typedef basic_postream postream_type; + typename postream_type::psentry opfx(*this); + + ostream_type::write(s, n); + + retrn *this; + } + + template + basic_postream& + basic_postream::flush() + { + // Create a psentry object (may set error bits or throw failure) + typedef basic_postream postream_type; + typename postream_type::psentry opfx(*this); + + ostream_type::flush(); + + //this->unlockStream(); + } + + + template + typename basic_postream::pos_type + basic_postream::tellp() + { + // TODO: make this operation thread-safe? + ostream_type::tellp(); + + return *this; + } + + template + basic_postream& + basic_postream::seekp(pos_type pos) + { + // TODO: make this operation thread-safe? + ostream_type::seekp(pos); + + return this; + } + + template + basic_postream& + basic_postream:: + seekp(off_type off, ios_base::seekdir d) + { + // TODO: make this operation thread-safe? + ostream_type::seekp(d); + + return *this; + } + + template + void + basic_postream::lockStream() + { + if(!owned) + { + currth = ost::getThread(); + owned = true; + pid = getpid(); + tid = currth->getThreadID(); + if(!header) + { + outputHeader(); + header = true; + } + } + lock.enterMutex(); + lockcnt++; + } + + template + void + basic_postream::unlockStream() + { + mtx.enterMutex(); + if(owned) + { + currth = NULL; + owned = false; + pid = 0; + tid = 0; + header = false; + } + while(lockcnt != 0) + { + lock.leaveMutex(); + lockcnt--; + } + mtx.leaveMutex(); + printf("fully unlocked\n"); + } + + template + void + basic_postream::outputHeader() + { + *this << "PID: " << pid << ", TID: " << tid << "> "; + } + + // Character inserters. + template + basic_postream& + operator<<(basic_postream& out, charT c) + { + typedef basic_postream postream_type; + typename postream_type::psentry opfx(out); + + std::operator<<(out, c); + + return out; + //~psentry + } + + // Specializations + template + basic_postream& + operator<<(basic_postream& out, char c) + { + typedef basic_postream postream_type; + typename postream_type::psentry opfx(out); + + std::operator<<(out, c); + + return out; + //~psentry + } + + template + basic_postream& + operator<<(basic_postream& out, const charT* s) + { + typedef basic_postream postream_type; + typename postream_type::psentry opfx(out); + + std::operator<<(out, s); + + return out; + //~psentry + } + + template + basic_postream& + operator<<(basic_postream& out, const char* s) + { + typedef basic_postream postream_type; + typename postream_type::psentry opfx(out); + + out.currth = ost::getThread(); + + std::operator<<(out, s); + + return out; + //~psentry + } + + // Partial specializations. + template + basic_postream& + operator<<(basic_postream& out, const char* s) + { + typedef basic_postream postream_type; + typename postream_type::psentry opfx(out); + + out.currth = ost::getThread(); + int tid = static_cast(out.currth->getThreadID()); + //out.operator<<(tid); + + std::operator<<(out, s); + + return out; + // ~psentry + } + + // basic_string::operator<< + template + basic_postream& + operator<<(basic_postream& out, + const basic_string& str) + { + typedef basic_postream postream_type; + typename postream_type::psentry opfx(out); + + out.currth = ost::getThread(); + int tid = (int)out.currth->getThreadID(); + //printf("PID: %d\n", getpid()); + //printf("TID: %d\n", tid); + + std::operator<<(out, str); + + return out; + //~psentry + } + + /* + extern template class basic_postream; + extern template postream& endl(postream&); + extern template postream& ends(postream&); + extern template postream& flush(postream&); + extern template postream& operator<<(postream&, char); + extern template postream& operator<<(postream&, unsigned char); + extern template postream& operator<<(postream&, signed char); + extern template postream& operator<<(postream&, const char*); + extern template postream& operator<<(postream&, const unsigned char*); + extern template postream& operator<<(postream&, const signed char*); + + extern template class basic_postream; + extern template wpostream& endl(wpostream&); + extern template wpostream& ends(wpostream&); + extern template wpostream& flush(wpostream&); + extern template wpostream& operator<<(wpostream&, wchar_t); + extern template wpostream& operator<<(wpostream&, char); + extern template wpostream& operator<<(wpostream&, const wchar_t*); + extern template wpostream& operator<<(wpostream&, const char*); + */ +#ifdef CCXX_NAMESPACES +} // namespace ost +#endif +/** EMACS ** + * Local variables: + * mode: c++ + * c-basic-offset: 2 + * End: + */ diff -urN tmp/commoncpp2/include/cc++/thread.h src/cvs/commoncpp2/include/cc++/thread.h --- tmp/commoncpp2/include/cc++/thread.h 2002-08-15 09:25:57.000000000 -0500 +++ src/cvs/commoncpp2/include/cc++/thread.h 2002-08-24 12:41:36.000000000 -0500 @@ -1051,6 +1051,9 @@ #endif /** @internal */ friend class DummyThread; + + pthread_t getThreadID(void) const; + private: friend class Slog; diff -urN tmp/commoncpp2/src/Makefile.am src/cvs/commoncpp2/src/Makefile.am --- tmp/commoncpp2/src/Makefile.am 2002-08-19 14:53:57.000000000 -0500 +++ src/cvs/commoncpp2/src/Makefile.am 2002-08-24 12:41:36.000000000 -0500 @@ -34,6 +34,7 @@ libccext2_la_LIBADD = @BASE_LIB@ @LIBGETOPTOBJS@ @THREAD_LIBS@ libccext2_la_SOURCES = buffer.cpp fifo.cpp pipe.cpp numbers.cpp \ cmdoptns.cpp url.cpp xml.cpp persist.cpp engine.cpp digest.cpp \ - date.cpp groups.cpp md5.cpp unix.cpp ftp.cpp + date.cpp groups.cpp md5.cpp unix.cpp ftp.cpp pio_globals.cpp \ + pios.cpp # private.h are internal headers diff -urN tmp/commoncpp2/src/pio_globals.cpp src/cvs/commoncpp2/src/pio_globals.cpp --- tmp/commoncpp2/src/pio_globals.cpp 1969-12-31 18:00:00.000000000 -0600 +++ src/cvs/commoncpp2/src/pio_globals.cpp 2002-08-11 23:14:29.000000000 -0500 @@ -0,0 +1,90 @@ +// Copyright (C) 1999-2002 Open Source Telecom Corporation. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// As a special exception to the GNU General Public License, permission is +// granted for additional uses of the text contained in its release +// of Common C++. +// +// The exception is that, if you link the Common C++ library with other +// files to produce an executable, this does not by itself cause the +// resulting executable to be covered by the GNU General Public License. +// Your use of that executable is in no way restricted on account of +// linking the Common C++ library code into it. +// +// This exception does not however invalidate any other reasons why +// the executable file might be covered by the GNU General Public License. +// +// This exception applies only to the code released under the +// name Common C++. If you copy code from other releases into a copy of +// Common C++, as the General Public License permits, the exception does +// not apply to the code that you add in this way. To avoid misleading +// anyone as to the status of such modified files, you must delete +// this exception notice from them. +// +// If you write modifications of your own for Common C++, it is your choice +// whether to permit this exception to apply to your modifications. +// If you do not wish that, delete this exception notice. + +#include +#include +#include +#include + +#ifdef CCXX_NAMESPACES +using namespace std; + +namespace ost +{ +#endif + + // Standard stream objects. + typedef char fake_pistream[sizeof(pistream)] + __attribute__ ((aligned(__alignof__(pistream)))); + typedef char fake_postream[sizeof(postream)] + __attribute__ ((aligned(__alignof__(postream)))); + fake_pistream pin; + fake_postream pout; + fake_postream perr; + fake_postream plog; + + typedef char fake_filebuf[sizeof(__gnu_cxx::stdio_filebuf)] + __attribute__ ((aligned(__alignof__(__gnu_cxx::stdio_filebuf)))); + fake_filebuf buf_pout; + fake_filebuf buf_pin; + fake_filebuf buf_perr; + +/* +#ifdef _GLIBCPP_USE_WCHAR_T + typedef char fake_wistream[sizeof(wistream)] + __attribute__ ((aligned(__alignof__(wistream)))); + typedef char fake_wostream[sizeof(wostream)] + __attribute__ ((aligned(__alignof__(wostream)))); + fake_wistream wcin; + fake_wostream wcout; + fake_wostream wcerr; + fake_wostream wclog; + + typedef char fake_wfilebuf[sizeof(__gnu_cxx::stdio_filebuf)] + __attribute__ ((aligned(__alignof__(__gnu_cxx::stdio_filebuf)))); + fake_wfilebuf buf_wcout; + fake_wfilebuf buf_wcin; + fake_wfilebuf buf_wcerr; +#endif +*/ + +#ifdef CCXX_NAMESPACES +} +#endif diff -urN tmp/commoncpp2/src/pios.cpp src/cvs/commoncpp2/src/pios.cpp --- tmp/commoncpp2/src/pios.cpp 1969-12-31 18:00:00.000000000 -0600 +++ src/cvs/commoncpp2/src/pios.cpp 2002-08-11 23:24:25.000000000 -0500 @@ -0,0 +1,161 @@ +// Copyright (C) 1999-2002 Open Source Telecom Corporation. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// As a special exception to the GNU General Public License, permission is +// granted for additional uses of the text contained in its release +// of Common C++. +// +// The exception is that, if you link the Common C++ library with other +// files to produce an executable, this does not by itself cause the +// resulting executable to be covered by the GNU General Public License. +// Your use of that executable is in no way restricted on account of +// linking the Common C++ library code into it. +// +// This exception does not however invalidate any other reasons why +// the executable file might be covered by the GNU General Public License. +// +// This exception applies only to the code released under the +// name Common C++. If you copy code from other releases into a copy of +// Common C++, as the General Public License permits, the exception does +// not apply to the code that you add in this way. To avoid misleading +// anyone as to the status of such modified files, you must delete +// this exception notice from them. +// +// If you write modifications of your own for Common C++, it is your choice +// whether to permit this exception to apply to your modifications. +// If you do not wish that, delete this exception notice. + + +//#include +#include +#include +#include +#include + + +#ifdef CCXX_NAMESPACES +using namespace std; + +namespace ost +{ +#endif + + // Extern declarations for global objects in src/pio_globals.cpp. + extern pistream pin; + extern postream pout; + extern postream perr; + extern postream plog; + + using __gnu_cxx::stdio_filebuf; + extern stdio_filebuf buf_pout; + extern stdio_filebuf buf_pin; + extern stdio_filebuf buf_perr; + +/* +#ifdef _GLIBCPP_USE_WCHAR_T + extern wpistream wpin; + extern wpostream wpout; + extern wpostream wperr; + extern wpostream wplog; + + extern stdio_filebuf buf_wpout; + extern stdio_filebuf buf_wpin; + extern stdio_filebuf buf_wperr; +#endif +*/ + + int ost::Init::pios_init = 0; + bool ost::Init::synced_with_stdio = true; + + void + ost::Init::pios_create(bool syncf) + { + int out_size = syncf ? 0 : static_cast(BUFSIZ); + int in_size = syncf ? 1 : static_cast(BUFSIZ); + + // The file pios_globals.cpp creates the four standard files + // with NULL buffers. At this point, we swap out the dummy NULL + // p[io]stream objects and buffers with the real deal. + new (&buf_pout) stdio_filebuf(stdout, ios_base::out, out_size); + new (&buf_pin) stdio_filebuf(stdin, ios_base::in, in_size); + new (&buf_perr) stdio_filebuf(stderr, ios_base::out, out_size); + new (&pout) postream(&buf_pout); + new (&pin) pistream(&buf_pin); + new (&perr) postream(&buf_perr); + new (&plog) postream(&buf_perr); + pin.tie(&pout); + perr.flags(ios_base::unitbuf); + +/* +#ifdef _GLIBCPP_USE_WCHAR_T + new (&buf_wpout) stdio_filebuf(stdout, ios_base::out, out_size); + new (&buf_wpin) stdio_filebuf(stdin, ios_base::in, in_size); + new (&buf_wperr) stdio_filebuf(stderr, ios_base::out, out_size); + new (&wpout) wpostream(&buf_wpout); + new (&wpin) wpistream(&buf_wpin); + new (&wperr) wpostream(&buf_wperr); + new (&wplog) wpostream(&buf_wperr); + wpin.tie(&wpout); + wperr.flags(ios_base::unitbuf); +#endif +*/ + } + + void + ost::Init::pios_destroy() + { + // Explicitly call dtors to free any memory that is dynamically + // allocated by filebuf ctor or member functions, but don't + // deallocate all memory by calling operator delete. + pout.flush(); + perr.flush(); + plog.flush(); + buf_pout.~stdio_filebuf(); + buf_pin.~stdio_filebuf(); + buf_perr.~stdio_filebuf(); + +/* +#ifdef _GLIBCPP_USE_WCHAR_T + wpout.flush(); + wperr.flush(); + wplog.flush(); + buf_wpout.~wfilebuf(); + buf_wpin.~wfilebuf(); + buf_wperr.~wfilebuf(); +#endif +*/ + } + + ost::Init::Init() + { + if (pios_init == 0) + { + // Standard streams default to synced with "C" operations. + ost::Init::synced_with_stdio = true; + pios_create(ost::Init::synced_with_stdio); + } + ++pios_init; + } + + ost::Init::~Init() + { + if (--pios_init == 0) + pios_destroy(); + } + +#ifdef CCXX_NAMESPACES +} +#endif diff -urN tmp/commoncpp2/src/thread.cpp src/cvs/commoncpp2/src/thread.cpp --- tmp/commoncpp2/src/thread.cpp 2002-08-12 09:22:20.000000000 -0500 +++ src/cvs/commoncpp2/src/thread.cpp 2002-08-24 12:41:37.000000000 -0500 @@ -647,6 +647,11 @@ #endif // WIN32 } +pthread_t Thread::getThreadID(void) const +{ + return priv->_tid; +} + int Thread::start(Semaphore *start) { if(!priv) diff -urN tmp/commoncpp2/tests/Makefile.am src/cvs/commoncpp2/tests/Makefile.am --- tmp/commoncpp2/tests/Makefile.am 2002-05-08 18:18:30.000000000 -0500 +++ src/cvs/commoncpp2/tests/Makefile.am 2002-08-10 15:06:08.000000000 -0500 @@ -11,12 +11,12 @@ MAINTAINERCLEANFILES = Makefile.in Makefile EXTRA_DIST = README dotests.sh test.sh output.txt vc6.mak -CXXFLAGS = @CXXFLAGS@ $(THREAD_FLAGS) +CXXFLAGS = @CXXFLAGS@ $(THREAD_FLAGS) -g INCLUDES = -I$(top_srcdir)/include LDADD = ../src/libccgnu2.la $(THREAD_LIBS) $(DYN_LOADER) Z_LIBS = -lz -noinst_PROGRAMS = bug1 bug2 thread1 thread2 digest tcpstr1 url1 +noinst_PROGRAMS = bug1 bug2 thread1 thread2 digest tcpstr1 url1 pio bug1_SOURCES = bug1.cpp @@ -35,3 +35,5 @@ url1_SOURCES = url1.cpp url1_LDADD = ../src/libccext2.la $(XML_LIBS) $(Z_LIBS) $(LDADD) +pio_SOURCES = pio.cpp +pio_LDADD = ../src/libccext2.la $(XML_LIBS) $(Z_LIBS) $(LDADD) diff -urN tmp/commoncpp2/tests/pio.cpp src/cvs/commoncpp2/tests/pio.cpp --- tmp/commoncpp2/tests/pio.cpp 1969-12-31 18:00:00.000000000 -0600 +++ src/cvs/commoncpp2/tests/pio.cpp 2002-08-24 20:35:59.000000000 -0500 @@ -0,0 +1,102 @@ +#include +#include +#include + +#ifdef CCXX_NAMESPACES +using namespace std; +using namespace ost; +#endif + +class Thread1: public Thread +{ +public: + Thread1(); + void run(); +}; + +class Thread2: public Thread +{ +public: + Thread2(); + void run(); +}; + +class Thread3: public Thread +{ +public: + Thread3(); + void run(); +}; + +Thread1::Thread1() +{ +} + +Thread2::Thread2() +{ +} + +Thread3::Thread3() +{ +} + +void Thread1::run() +{ + string test("string test."); + int i = 0; + + while(i != 100) + { + pout << "a really long string to try and see if it will preempt in the middle of it because if it does it will really suck a lot, but recursive locking is a PITA!!!" << endl; + pout << i << " " << "Test." << endl; + pout << i << " " << test << endl; + pout << i << " " << "Hello World!" << endl; + + i++; + } + //pout.seekp(0, ios_base::cur); +} + +void Thread2::run() +{ + int i = 0; + + while(i != 100) + { + pout << i << " " << "thread2 outputting some stuff" << endl; + pout << i << " " << "check, check, check" << endl; + pout << i << " " << "waaaaazzzzzzaaaaaapaaneeeeen!!!!" << endl; + + i++; + } +} + +void Thread3::run() +{ + int i = 0; + + while(i != 100) + { + pout << i << " " << "thread 3 is in da hiiiiizzoooooouuuuseee!" << endl; + pout << i << " " << "test some stuff and stuff" << endl; + pout << i << " " << "chillywilly is so weird." << endl; + + i++; + } +} + +int main(int argc, char* argv[]) +{ + Thread1 thread1; + Thread2 thread2; + Thread3 thread3; + + thread1.start(); + thread2.start(); + thread3.start(); + + pout << "Hit ctrl-c to end" << endl; + + for(;;) + { } +}