sl@0: /* sl@0: * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved. sl@0: * sl@0: * Copyright (c) 1999 sl@0: * Silicon Graphics Computer Systems, Inc. sl@0: * sl@0: * Copyright (c) 1999 sl@0: * Boris Fomitchev sl@0: * sl@0: * This material is provided "as is", with absolutely no warranty expressed sl@0: * or implied. Any use is at your own risk. sl@0: * sl@0: * Permission to use or copy this software for any purpose is hereby granted sl@0: * without fee, provided the above notices are retained on all copies. sl@0: * Permission to modify the code and to distribute modified code is granted, sl@0: * provided the above notices are retained, and a notice that the code was sl@0: * modified is included with the above copyright notice. sl@0: * sl@0: */ sl@0: # include "stlport_prefix.h" sl@0: sl@0: #include sl@0: // #include sl@0: #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_) sl@0: # include "libstdcppwsd.h" sl@0: # endif sl@0: sl@0: #include sl@0: #include sl@0: #include "aligned_buffer.h" sl@0: sl@0: // boris : note this is repeated in sl@0: #ifndef _STLP_USE_NAMESPACES sl@0: // in case of SGI iostreams, we have to rename our streams not to clash with those sl@0: // provided in native lib sl@0: # define cin _STLP_cin sl@0: # define cout _STLP_cout sl@0: # define cerr _STLP_cerr sl@0: # define clog _STLP_clog sl@0: #endif sl@0: sl@0: _STLP_BEGIN_NAMESPACE sl@0: sl@0: #if defined (__BORLANDC__) && ! defined (_STLP_USE_GLIBC) sl@0: using _STLP_VENDOR_CSTD::_streams; sl@0: #endif sl@0: sl@0: // This file handles iostream initialization. It is inherently sl@0: // nonportable, since the C++ language definition provides no mechanism sl@0: // for controlling order of initialization of nonlocal objects. sl@0: // Initialization has three parts, which must be performed in the following sl@0: // order: sl@0: // (1) Initialize the locale system sl@0: // (2) Call the constructors for the eight global stream objects. sl@0: // (3) Create streambufs for the global stream objects, and initialize sl@0: // the stream objects by calling the init() member function. sl@0: sl@0: sl@0: #if defined (_STLP_MSVC) || defined(__MWERKS__) || defined (__ICL) || defined (__ISCPP__) || defined (__SYMBIAN32__) sl@0: // Definitions of the eight global I/O objects that are declared in sl@0: // . For VC++ we use the init_seg pragma to put the global I/O sl@0: // objects into an intitialization segement that will not sl@0: // be executed. We then explicitly invoke the constructors sl@0: // with placement new in ios_base::_S_initialize() sl@0: sl@0: #if defined(__MWERKS__) sl@0: # pragma suppress_init_code on sl@0: #else sl@0: # pragma init_seg("STLPORT_NO_INIT") sl@0: #endif sl@0: sl@0: # if !defined(__LIBSTD_CPP_SYMBIAN32_WSD__) && !defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_) sl@0: _STLP_EXP_DECLSPEC istream cin(0); sl@0: _STLP_EXP_DECLSPEC ostream cout(0); sl@0: _STLP_EXP_DECLSPEC ostream cerr(0); sl@0: _STLP_EXP_DECLSPEC ostream clog(0); sl@0: sl@0: #ifndef _STLP_NO_WCHAR_T sl@0: _STLP_EXP_DECLSPEC wistream wcin(0); sl@0: _STLP_EXP_DECLSPEC wostream wcout(0); sl@0: _STLP_EXP_DECLSPEC wostream wcerr(0); sl@0: _STLP_EXP_DECLSPEC wostream wclog(0); sl@0: #endif sl@0: # endif sl@0: sl@0: _STLP_EXP_DECLSPEC ostream& GetCErrStream() sl@0: { sl@0: return *getCErrStream(); sl@0: } sl@0: sl@0: _STLP_EXP_DECLSPEC ostream& GetCoutStream() sl@0: { sl@0: return *getCoutStream(); sl@0: } sl@0: sl@0: _STLP_EXP_DECLSPEC ostream& GetClogStream() sl@0: { sl@0: return *getClogStream(); sl@0: } sl@0: sl@0: _STLP_EXP_DECLSPEC istream& GetCinStream() sl@0: { sl@0: return *getCinStream(); sl@0: } sl@0: sl@0: #ifndef _STLP_NO_WCHAR_T sl@0: _STLP_EXP_DECLSPEC wostream& GetWCErrStream() sl@0: { sl@0: return *getWCErrStream(); sl@0: } sl@0: sl@0: _STLP_EXP_DECLSPEC wostream& GetWCoutStream() sl@0: { sl@0: return *getWCoutStream(); sl@0: } sl@0: sl@0: _STLP_EXP_DECLSPEC wostream& GetWClogStream() sl@0: { sl@0: return *getWClogStream(); sl@0: } sl@0: sl@0: _STLP_EXP_DECLSPEC wistream& GetWCinStream() sl@0: { sl@0: return *getWCinStream(); sl@0: } sl@0: #endif //_STLP_NO_WCHAR_T sl@0: sl@0: #if defined(__MWERKS__) sl@0: # pragma suppress_init_code off sl@0: #endif sl@0: sl@0: #else sl@0: sl@0: sl@0: // Definitions of the eight global I/O objects that are declared in sl@0: // . Disgusting hack: we deliberately define them with the sl@0: // wrong types so that the constructors don't get run automatically. sl@0: // We need special tricks to make sure that these objects are struct- sl@0: // aligned rather than byte-aligned. sl@0: sl@0: // This is not portable. Declaring a variable with different types in sl@0: // two translations units is "undefined", according to the C++ standard. sl@0: // Most compilers, however, silently accept this instead of diagnosing sl@0: // it as an error. sl@0: sl@0: #ifndef __DMC__ sl@0: _Stl_aligned_buffer cin; sl@0: _Stl_aligned_buffer cout; sl@0: _Stl_aligned_buffer cerr; sl@0: _Stl_aligned_buffer clog; sl@0: #else sl@0: _Stl_aligned_buffer cin; sl@0: _Stl_aligned_buffer cout; sl@0: _Stl_aligned_buffer cerr; sl@0: _Stl_aligned_buffer clog; sl@0: sl@0: #pragma alias("?cin@std@@3V?$basic_istream@std@DV?$char_traits@std@D@1@@1@A", "?cin@std@@3T?$_Stl_aligned_buffer@std@V?$basic_istream@std@DV?$char_traits@std@D@1@@1@@1@A") sl@0: #pragma alias("?cout@std@@3V?$basic_ostream@std@DV?$char_traits@std@D@1@@1@A", "?cout@std@@3T?$_Stl_aligned_buffer@std@V?$basic_ostream@std@DV?$char_traits@std@D@1@@1@@1@A") sl@0: #pragma alias("?cerr@std@@3V?$basic_ostream@std@DV?$char_traits@std@D@1@@1@A", "?cerr@std@@3T?$_Stl_aligned_buffer@std@V?$basic_ostream@std@DV?$char_traits@std@D@1@@1@@1@A") sl@0: #pragma alias("?clog@std@@3V?$basic_ostream@std@DV?$char_traits@std@D@1@@1@A", "?clog@std@@3T?$_Stl_aligned_buffer@std@V?$basic_ostream@std@DV?$char_traits@std@D@1@@1@@1@A") sl@0: #endif sl@0: sl@0: # ifndef _STLP_NO_WCHAR_T sl@0: sl@0: #ifndef __DMC__ sl@0: _Stl_aligned_buffer wcin; sl@0: _Stl_aligned_buffer wcout; sl@0: _Stl_aligned_buffer wcerr; sl@0: _Stl_aligned_buffer wclog; sl@0: #else sl@0: _Stl_aligned_buffer wcin; sl@0: _Stl_aligned_buffer wcout; sl@0: _Stl_aligned_buffer wcerr; sl@0: _Stl_aligned_buffer wclog; sl@0: sl@0: #pragma alias("?wcin@std@@3V?$basic_istream@std@_YV?$char_traits@std@_Y@1@@1@A", "?wcin@std@@3T?$_Stl_aligned_buffer@std@V?$basic_istream@std@_YV?$char_traits@std@_Y@1@@1@@1@A") sl@0: #pragma alias("?wcout@std@@3V?$basic_ostream@std@_YV?$char_traits@std@_Y@1@@1@A", "?wcout@std@@3T?$_Stl_aligned_buffer@std@V?$basic_ostream@std@_YV?$char_traits@std@_Y@1@@1@@1@A") sl@0: #pragma alias("?wcerr@std@@3V?$basic_ostream@std@_YV?$char_traits@std@_Y@1@@1@A", "?wcerr@std@@3T?$_Stl_aligned_buffer@std@V?$basic_ostream@std@_YV?$char_traits@std@_Y@1@@1@@1@A") sl@0: #pragma alias("?wclog@std@@3V?$basic_ostream@std@_YV?$char_traits@std@_Y@1@@1@A", "?wclog@std@@3T?$_Stl_aligned_buffer@std@V?$basic_ostream@std@_YV?$char_traits@std@_Y@1@@1@@1@A") sl@0: #endif sl@0: # endif sl@0: sl@0: #endif /* STL_MSVC || __MWERKS__ */ sl@0: sl@0: // Member functions from class ios_base and ios_base::Init sl@0: sl@0: #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_) sl@0: void ios_base_Init_S_count_init() sl@0: { sl@0: get_ios_base_Init_S_count() = 0; sl@0: } sl@0: void ios_base_S_was_synced_init() sl@0: { sl@0: get_ios_base_S_was_synced() = true; sl@0: } sl@0: # else sl@0: long ios_base::Init::_S_count = 0; sl@0: // by default, those are synced sl@0: bool ios_base::_S_was_synced = true; sl@0: # endif //__LIBSTD_CPP_SYMBIAN32_WSD__ sl@0: sl@0: sl@0: _STLP_DECLSPEC extern void LibStdCppInit(); sl@0: sl@0: sl@0: void CallIosInit() sl@0: { sl@0: ios_base::_S_initialize(); sl@0: } sl@0: sl@0: sl@0: _STLP_EXP_DECLSPEC ios_base::Init::Init() { sl@0: // if (_S_count == 0) sl@0: //ios_base::_S_initialize(); sl@0: LibStdCppInit(); sl@0: } sl@0: sl@0: _STLP_EXP_DECLSPEC ios_base::Init::~Init() { sl@0: // if (_S_count > 0) sl@0: ios_base::_S_uninitialize(); sl@0: } sl@0: sl@0: sl@0: filebuf* sl@0: _Stl_create_filebuf(FILE* f, ios_base::openmode mode ) sl@0: { sl@0: basic_filebuf >* result; sl@0: sl@0: result = new basic_filebuf >(); sl@0: sl@0: _STLP_TRY { sl@0: result->_M_open(_FILE_fd(f), mode); sl@0: } sl@0: _STLP_CATCH_ALL {} sl@0: sl@0: if (!result->is_open()) { sl@0: delete result; sl@0: result = 0; sl@0: } sl@0: return result; sl@0: } sl@0: sl@0: # ifndef _STLP_NO_WCHAR_T sl@0: sl@0: wfilebuf* sl@0: _Stl_create_wfilebuf(FILE* f, ios_base::openmode mode ) sl@0: { sl@0: basic_filebuf >* result; sl@0: sl@0: result = new basic_filebuf >(); sl@0: sl@0: _STLP_TRY { sl@0: result->_M_open(_FILE_fd(f), mode); sl@0: } sl@0: _STLP_CATCH_ALL {} sl@0: sl@0: if (!result->is_open()) { sl@0: delete result; sl@0: result = 0; sl@0: } sl@0: return result; sl@0: } sl@0: sl@0: # endif sl@0: sl@0: void _STLP_CALL ios_base::_S_initialize() sl@0: { sl@0: #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_) sl@0: if (get_ios_base_Init_S_count()++ > 0) sl@0: return ; sl@0: # else sl@0: if (ios_base::Init::_S_count++ > 0) sl@0: return ; sl@0: # endif //__LIBSTD_CPP_SYMBIAN32_WSD__ sl@0: sl@0: # if !defined(_STLP_HAS_NO_NAMESPACES) && !defined(_STLP_WINCE) sl@0: using _SgI::stdio_istreambuf; sl@0: using _SgI::stdio_ostreambuf; sl@0: # endif sl@0: _STLP_TRY { sl@0: // Run constructors for the four narrow stream objects. sl@0: // check with locale system sl@0: // if (_Loc_init::_S_count == 0) { sl@0: locale::_S_initialize(); sl@0: // } sl@0: #if !defined(_STLP_WINCE) sl@0: #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_) sl@0: istream* ptr_cin = new((void*)&GetCinStream()) istream(0); sl@0: ostream* ptr_cout = new((void*)&GetCoutStream()) ostream(0); sl@0: ostream* ptr_cerr = new((void*)&GetCErrStream()) ostream(0); sl@0: ostream* ptr_clog = new((void*)&GetClogStream()) ostream(0); sl@0: # else sl@0: istream* ptr_cin = new((void*)&cin) istream(0); sl@0: ostream* ptr_cout = new((void*)&cout) ostream(0); sl@0: ostream* ptr_cerr = new((void*)&cerr) ostream(0); sl@0: ostream* ptr_clog = new((void*)&clog) ostream(0); sl@0: # endif //__LIBSTD_CPP_SYMBIAN32_WSD__ sl@0: // Initialize the four narrow stream objects. sl@0: #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_) sl@0: if (get_ios_base_S_was_synced()) { sl@0: # else sl@0: if (_S_was_synced) { sl@0: # endif sl@0: ptr_cin->init(new stdio_istreambuf(stdin)); sl@0: ptr_cout->init(new stdio_ostreambuf(stdout)); sl@0: ptr_cerr->init(new stdio_ostreambuf(stderr)); sl@0: ptr_clog->init(new stdio_ostreambuf(stderr)); sl@0: } else { sl@0: ptr_cin->init(_Stl_create_filebuf(stdin, ios_base::in)); sl@0: ptr_cin->init(_Stl_create_filebuf(stdout, ios_base::out)); sl@0: ptr_cin->init(_Stl_create_filebuf(stderr, ios_base::out)); sl@0: ptr_cin->init(_Stl_create_filebuf(stderr, ios_base::out)); sl@0: } sl@0: ptr_cin->tie(ptr_cout); sl@0: ptr_cerr->setf(ios_base::unitbuf); sl@0: sl@0: # ifndef _STLP_NO_WCHAR_T sl@0: #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_) sl@0: // Run constructors for the four wide stream objects. sl@0: wistream* ptr_wcin = new(&GetWCinStream()) wistream(0); sl@0: wostream* ptr_wcout = new(&GetWCoutStream()) wostream(0); sl@0: wostream* ptr_wcerr = new(&GetWCErrStream()) wostream(0); sl@0: wostream* ptr_wclog = new(&GetWClogStream()) wostream(0); sl@0: # else sl@0: // Run constructors for the four wide stream objects. sl@0: wistream* ptr_wcin = new(&wcin) wistream(0); sl@0: wostream* ptr_wcout = new(&wcout) wostream(0); sl@0: wostream* ptr_wcerr = new(&wcerr) wostream(0); sl@0: wostream* ptr_wclog = new(&wclog) wostream(0); sl@0: # endif //__LIBSTD_CPP_SYMBIAN32_WSD__ sl@0: sl@0: wfilebuf* win = _Stl_create_wfilebuf(stdin, ios_base::in); sl@0: wfilebuf* wout = _Stl_create_wfilebuf(stdout, ios_base::out);; sl@0: wfilebuf* werr = _Stl_create_wfilebuf(stderr, ios_base::out); sl@0: wfilebuf* wlog = _Stl_create_wfilebuf(stderr, ios_base::out); sl@0: sl@0: ptr_wcin->init(win); sl@0: ptr_wcout->init(wout); sl@0: ptr_wcerr->init(werr); sl@0: ptr_wclog->init(wlog); sl@0: sl@0: ptr_wcin->tie(ptr_wcout); sl@0: ptr_wcerr->setf(ios_base::unitbuf); sl@0: sl@0: # endif /* _STLP_NO_WCHAR_T */ sl@0: #endif /* _STLP_WINCE */ sl@0: sl@0: // ++ios_base::Init::_S_count; sl@0: } sl@0: sl@0: _STLP_CATCH_ALL {} sl@0: } sl@0: sl@0: void _STLP_CALL ios_base::_S_uninitialize() sl@0: { sl@0: #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_) sl@0: if (--get_ios_base_Init_S_count() != 0) sl@0: return ; sl@0: # else sl@0: if (--ios_base::Init::_S_count != 0) sl@0: return ; sl@0: # endif //__LIBSTD_CPP_SYMBIAN32_WSD__ sl@0: sl@0: #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_) sl@0: // Note that destroying output streambufs flushes the buffers. sl@0: istream* ptr_cin = __REINTERPRET_CAST(istream*,&GetCinStream()); sl@0: ostream* ptr_cout = __REINTERPRET_CAST(ostream*,&GetCoutStream()); sl@0: ostream* ptr_cerr = __REINTERPRET_CAST(ostream*,&GetCErrStream()); sl@0: ostream* ptr_clog = __REINTERPRET_CAST(ostream*,&GetClogStream()); sl@0: sl@0: # ifndef _STLP_NO_WCHAR_T sl@0: wistream* ptr_wcin = __REINTERPRET_CAST(wistream*,&GetWCinStream()); sl@0: wostream* ptr_wcout = __REINTERPRET_CAST(wostream*,&GetWCoutStream()); sl@0: wostream* ptr_wcerr = __REINTERPRET_CAST(wostream*,&GetWCErrStream()); sl@0: wostream* ptr_wclog = __REINTERPRET_CAST(wostream*,&GetWClogStream()); sl@0: # endif //_STLP_NO_WCHAR_T sl@0: # else sl@0: // Note that destroying output streambufs flushes the buffers. sl@0: istream* ptr_cin = __REINTERPRET_CAST(istream*,&cin); sl@0: ostream* ptr_cout = __REINTERPRET_CAST(ostream*,&cout); sl@0: ostream* ptr_cerr = __REINTERPRET_CAST(ostream*,&cerr); sl@0: ostream* ptr_clog = __REINTERPRET_CAST(ostream*,&clog); sl@0: sl@0: # ifndef _STLP_NO_WCHAR_T sl@0: wistream* ptr_wcin = __REINTERPRET_CAST(wistream*,&wcin); sl@0: wostream* ptr_wcout = __REINTERPRET_CAST(wostream*,&wcout); sl@0: wostream* ptr_wcerr = __REINTERPRET_CAST(wostream*,&wcerr); sl@0: wostream* ptr_wclog = __REINTERPRET_CAST(wostream*,&wclog); sl@0: # endif sl@0: # endif //__LIBSTD_CPP_SYMBIAN32_WSD__ sl@0: sl@0: sl@0: // we don't want any exceptions being thrown here sl@0: ptr_cin->exceptions(0); sl@0: ptr_cout->exceptions(0); sl@0: ptr_cerr->exceptions(0); sl@0: ptr_clog->exceptions(0); sl@0: sl@0: delete ptr_cin->rdbuf(0); sl@0: delete ptr_cout->rdbuf(0); sl@0: delete ptr_cerr->rdbuf(0); sl@0: delete ptr_clog->rdbuf(0); sl@0: sl@0: _Destroy(ptr_cin); sl@0: _Destroy(ptr_cout); sl@0: _Destroy(ptr_cerr); sl@0: _Destroy(ptr_clog); sl@0: sl@0: # ifndef _STLP_NO_WCHAR_T sl@0: // we don't want any exceptions being thrown here sl@0: ptr_wcin->exceptions(0); sl@0: ptr_wcout->exceptions(0); sl@0: ptr_wcerr->exceptions(0); sl@0: ptr_wclog->exceptions(0); sl@0: sl@0: delete ptr_wcin->rdbuf(0); sl@0: delete ptr_wcout->rdbuf(0); sl@0: delete ptr_wcerr->rdbuf(0); sl@0: delete ptr_wclog->rdbuf(0); sl@0: sl@0: _Destroy(ptr_wcin); sl@0: _Destroy(ptr_wcout); sl@0: _Destroy(ptr_wcerr); sl@0: _Destroy(ptr_wclog); sl@0: sl@0: # endif sl@0: sl@0: #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_) sl@0: if (get_ios_base_Loc_init_S_count() > 0) { sl@0: # else sl@0: if (_Loc_init::_S_count > 0) { sl@0: # endif // __LIBSTD_CPP_SYMBIAN32_WSD__ sl@0: locale::_S_uninitialize(); sl@0: } sl@0: sl@0: #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_) sl@0: --get_ios_base_Init_S_count(); sl@0: # else sl@0: --ios_base::Init::_S_count; sl@0: # endif //__LIBSTD_CPP_SYMBIAN32_WSD__ sl@0: sl@0: } sl@0: sl@0: sl@0: _STLP_EXP_DECLSPEC bool _STLP_CALL ios_base::sync_with_stdio(bool sync) { sl@0: #if !defined(STLP_WINCE) sl@0: # ifndef _STLP_HAS_NO_NAMESPACES sl@0: using _SgI::stdio_istreambuf; sl@0: using _SgI::stdio_ostreambuf; sl@0: # endif sl@0: sl@0: #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_) sl@0: bool was_synced = get_ios_base_S_was_synced(); sl@0: # else sl@0: bool was_synced = _S_was_synced; sl@0: # endif //__LIBSTD_CPP_SYMBIAN32_WSD__ sl@0: sl@0: // if by any chance we got there before std streams initialization, sl@0: // just set the sync flag and exit sl@0: #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_) sl@0: if (get_ios_base_Init_S_count() == 0) { sl@0: get_ios_base_S_was_synced() = sync; sl@0: # else sl@0: if (Init::_S_count == 0) { sl@0: _S_was_synced = sync; sl@0: # endif //__LIBSTD_CPP_SYMBIAN32_WSD__ sl@0: return was_synced; sl@0: } sl@0: sl@0: #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_) sl@0: istream* ptr_cin = __REINTERPRET_CAST(istream*,&GetCinStream()); sl@0: ostream* ptr_cout = __REINTERPRET_CAST(ostream*,&GetCoutStream()); sl@0: ostream* ptr_cerr = __REINTERPRET_CAST(ostream*,&GetCErrStream()); sl@0: ostream* ptr_clog = __REINTERPRET_CAST(ostream*,&GetClogStream()); sl@0: # else sl@0: istream* ptr_cin = __REINTERPRET_CAST(istream*,&cin); sl@0: ostream* ptr_cout = __REINTERPRET_CAST(ostream*,&cout); sl@0: ostream* ptr_cerr = __REINTERPRET_CAST(ostream*,&cerr); sl@0: ostream* ptr_clog = __REINTERPRET_CAST(ostream*,&clog); sl@0: # endif //__LIBSTD_CPP_SYMBIAN32_WSD__ sl@0: sl@0: streambuf* old_cin = ptr_cin->rdbuf(); sl@0: streambuf* old_cout = ptr_cout->rdbuf(); sl@0: streambuf* old_cerr = ptr_cerr->rdbuf(); sl@0: streambuf* old_clog = ptr_clog->rdbuf(); sl@0: sl@0: streambuf* new_cin = 0; sl@0: streambuf* new_cout = 0; sl@0: streambuf* new_cerr = 0; sl@0: streambuf* new_clog = 0; sl@0: sl@0: _STLP_TRY { sl@0: if (sync && !was_synced) { sl@0: new_cin = new stdio_istreambuf(stdin); sl@0: new_cout = new stdio_ostreambuf(stdout); sl@0: new_cerr = new stdio_ostreambuf(stderr); sl@0: new_clog = new stdio_ostreambuf(stderr); sl@0: } sl@0: else if (!sync && was_synced) { sl@0: new_cin = _Stl_create_filebuf(stdin, ios_base::in); sl@0: new_cout = _Stl_create_filebuf(stdout, ios_base::out); sl@0: new_cerr = _Stl_create_filebuf(stderr, ios_base::out); sl@0: new_clog = _Stl_create_filebuf(stderr, ios_base::out); sl@0: } sl@0: } sl@0: _STLP_CATCH_ALL {} sl@0: sl@0: if (new_cin && new_cout && new_cerr && new_clog) { sl@0: ptr_cin->rdbuf(new_cin); sl@0: ptr_cout->rdbuf(new_cout); sl@0: ptr_cerr->rdbuf(new_cerr); sl@0: ptr_clog->rdbuf(new_clog); sl@0: sl@0: delete old_cin; sl@0: delete old_cout; sl@0: delete old_cerr; sl@0: delete old_clog; sl@0: } sl@0: else { sl@0: delete new_cin; sl@0: delete new_cout; sl@0: delete new_cerr; sl@0: delete new_clog; sl@0: } sl@0: sl@0: return was_synced; sl@0: #else sl@0: return false; sl@0: #endif /* _STLP_WINCE */ sl@0: } sl@0: sl@0: _STLP_END_NAMESPACE sl@0: sl@0: // Local Variables: sl@0: // mode:C++ sl@0: // End: