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.

62 lines
1.5 KiB

  1. // wiostream -- initialize standard wide streams
  2. #include <locale>
  3. #include <fstream>
  4. #include <iostream>
  5. #include <new>
  6. _STD_BEGIN
  7. // OBJECT DECLARATIONS
  8. int _Winit::_Init_cnt = -1;
  9. static wfilebuf wfin(_Noinit);
  10. static wfilebuf wfout(_Noinit);
  11. static wfilebuf wferr(_Noinit);
  12. _CRTIMP2 wistream wcin(_Noinit);
  13. _CRTIMP2 wostream wcout(_Noinit);
  14. _CRTIMP2 wostream wcerr(_Noinit);
  15. _CRTIMP2 wostream wclog(_Noinit);
  16. _CRTIMP2 _Winit::_Winit()
  17. { // initialize standard wide 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 wide streams
  26. new (&wfin) wfilebuf(stdin);
  27. new (&wfout) wfilebuf(stdout);
  28. new (&wferr) wfilebuf(stderr);
  29. new (&wcin) wistream(&wfin, true);
  30. new (&wcout) wostream(&wfout, true);
  31. wcin.tie(&wcout);
  32. new (&wcerr) wostream(&wferr, true);
  33. wcerr.tie(&wcout);
  34. wcerr.setf(ios_base::unitbuf);
  35. new (&wclog) wostream(&wferr, true);
  36. wclog.tie(&wcout);
  37. }
  38. }
  39. _CRTIMP2 _Winit::~_Winit()
  40. { // flush standard wide 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 wide streams
  49. wcout.flush();
  50. wcerr.flush();
  51. wclog.flush();
  52. }
  53. _STD_END
  54. }
  55. /*
  56. * Copyright (c) 1994 by P.J. Plauger. ALL RIGHTS RESERVED.
  57. * Consult your license regarding permissions and restrictions.
  58. */