Annotation of researchv10no/cmd/cfront/libC/oiostream/cstreams.c, revision 1.1

1.1     ! root        1: /*ident        "@(#)ctrans:lib/stream/cstreams.c       1.1.4.1" */
        !             2: /**************************************************************************
        !             3:                         Copyright (c) 1984 AT&T
        !             4:                           All Rights Reserved   
        !             5: 
        !             6:         THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T
        !             7:         
        !             8:         The copyright notice above does not evidence any        
        !             9:         actual or intended publication of such source code.
        !            10: 
        !            11: cstreams.c:
        !            12: 
        !            13: *****************************************************************************/
        !            14: 
        !            15: #include <iostream.h>
        !            16: #include <fstream.h>
        !            17: #include <new.h>
        !            18: #include "streamdefs.h"
        !            19: 
        !            20: int Iostream_init::stdstatus = 0 ;
        !            21: int Iostream_init::initcount = 0 ;
        !            22: 
        !            23: static char cinbuf[STREAMBUFSIZE];
        !            24: static char coutbuf[STREAMBUFSIZE];
        !            25: 
        !            26: istream_withassign cin ;
        !            27: ostream_withassign cout ;
        !            28: ostream_withassign cerr ;
        !            29: ostream_withassign clog ;
        !            30: 
        !            31:        // The value of Iostream_init::stdstatus describes the
        !            32:        // The std stream variables
        !            33: 
        !            34:        // 0 means istream::stdin, ostream::stdout, ostream::stderr, and
        !            35:        //      ostream::stdlog are unitialized
        !            36:        // 1 means they are initialized to filebufs
        !            37:        // 2 means they are initialized to stdiobufs
        !            38: 
        !            39: Iostream_init::Iostream_init() 
        !            40: {
        !            41:        ++initcount ;
        !            42:        if ( initcount > 1 ) return ;
        !            43: 
        !            44:        // Be careful.  Initialization occurs before constructors
        !            45:        // of the standard streams are called.
        !            46:        new (&cin) istream_withassign ;
        !            47:        new (&cout) ostream_withassign ;
        !            48:        new (&cerr) ostream_withassign ;
        !            49:        new (&clog) ostream_withassign ;
        !            50:        cin = new filebuf(0,cinbuf,sizeof(cinbuf)) ;
        !            51:        cout = new filebuf(1,coutbuf,sizeof(coutbuf)) ;
        !            52:        cerr = new filebuf(2,0,0) ;
        !            53:        clog = new filebuf(2) ;
        !            54: 
        !            55:        cin.setf(ios::skipws,ios::skipws) ;
        !            56:        cin.tie(&cout) ;
        !            57:        cerr.tie(&cout) ;
        !            58:        clog.tie(&cout) ;
        !            59:        stdstatus = 1 ;
        !            60:        }
        !            61: 
        !            62: Iostream_init::~Iostream_init()
        !            63: {
        !            64:        --initcount ;
        !            65:        if ( initcount > 0 ) return ;
        !            66:        cout.flush() ;
        !            67:        cerr.flush() ;
        !            68:        clog.flush() ;
        !            69:        }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.