testConsoleBufChild.cxx 1.41 KB
Newer Older
1 2
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
   file Copyright.txt or https://cmake.org/licensing#kwsys for details.  */
3 4 5 6 7 8 9 10
#include "kwsysPrivate.h"

#include KWSYS_HEADER(ConsoleBuf.hxx)
#include KWSYS_HEADER(Encoding.hxx)

// Work-around CMake dependency scanning limitation.  This must
// duplicate the above list of headers.
#if 0
11 12
#include "ConsoleBuf.hxx.in"
#include "Encoding.hxx.in"
13 14 15
#endif

#include <iostream>
16

17 18 19 20 21 22 23 24 25 26 27 28 29
#include "testConsoleBuf.hxx"

int main(int argc, const char* argv[])
{
#if defined(_WIN32)
  kwsys::ConsoleBuf::Manager out(std::cout);
  kwsys::ConsoleBuf::Manager err(std::cerr, true);
  kwsys::ConsoleBuf::Manager in(std::cin);

  if (argc > 1) {
    std::cout << argv[1] << std::endl;
    std::cerr << argv[1] << std::endl;
  } else {
30 31
    std::string str = kwsys::Encoding::ToNarrow(std::wstring(
      UnicodeTestString, sizeof(UnicodeTestString) / sizeof(wchar_t) - 1));
32 33 34 35 36
    std::cout << str << std::endl;
    std::cerr << str << std::endl;
  }

  std::string input;
37 38 39 40
  HANDLE event = OpenEventW(EVENT_MODIFY_STATE, FALSE, BeforeInputEventName);
  if (event) {
    SetEvent(event);
    CloseHandle(event);
41 42 43 44
  }

  std::cin >> input;
  std::cout << input << std::endl;
45 46 47 48
  event = OpenEventW(EVENT_MODIFY_STATE, FALSE, AfterOutputEventName);
  if (event) {
    SetEvent(event);
    CloseHandle(event);
49 50 51 52 53 54 55
  }
#else
  static_cast<void>(argc);
  static_cast<void>(argv);
#endif
  return 0;
}