Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.7 KiB

  1. // iostream -- ios::Init members, initialize standard streams
  2. #include <locale>
  3. #include <fstream>
  4. #include <istream> /* NOT <iostream> */
  5. #include <new>
  6. _STD_BEGIN
  7. // OBJECT DECLARATIONS
  8. int ios_base::Init::_Init_cnt = -1;
  9. static filebuf fin(_Noinit);
  10. static filebuf fout(_Noinit);
  11. _CRTIMP2 istream cin(_Noinit);
  12. _CRTIMP2 ostream cout(_Noinit);
  13. static filebuf ferr(_Noinit);
  14. _CRTIMP2 ostream cerr(_Noinit);
  15. _CRTIMP2 ostream clog(_Noinit);
  16. _CRTIMP2 ios_base::Init::Init()
  17. { // initialize standard streams first time
  18. bool doinit;
  19. {_Lockit _Lk;
  20. if (0 <= _Init_cnt)
  21. ++_Init_cnt, doinit = false;
  22. else
  23. _Init_cnt = 1, doinit = true; }
  24. if (doinit)
  25. { // initialize standard streams
  26. new (&fin) filebuf(stdin);
  27. new (&fout) filebuf(stdout);
  28. new (&cin) istream(&fin, true);
  29. new (&cout) ostream(&fout, true);
  30. cin.tie(&cout);
  31. new (&ferr) filebuf(stderr);
  32. new (&cerr) ostream(&ferr, true);
  33. cerr.tie(&cout);
  34. cerr.setf(ios_base::unitbuf);
  35. new (&clog) ostream(&ferr, true);
  36. clog.tie(&cout);
  37. }
  38. }
  39. _CRTIMP2 ios_base::Init::~Init()
  40. { // flush standard streams last time
  41. bool doflush;
  42. {_Lockit _Lk;
  43. if (--_Init_cnt == 0)
  44. doflush = true;
  45. else
  46. doflush = false; }
  47. if (doflush)
  48. { // flush standard streams
  49. cout.flush();
  50. cerr.flush();
  51. clog.flush();
  52. }
  53. _STD_END
  54. }
  55. const char _PJP_CPP_Copyright[] =
  56. "Portions of this work are derived"
  57. " from 'The Draft Standard C++ Library',\n"
  58. "copyright (c) 1994-1995 by P.J. Plauger,"
  59. " published by Prentice-Hall,\n"
  60. "and are used with permission.";
  61. /*
  62. * Copyright (c) 1994 by P.J. Plauger. ALL RIGHTS RESERVED.
  63. * Consult your license regarding permissions and restrictions.
  64. */