testConsoleBufChild.cxx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
  3. #include "kwsysPrivate.h"
  4. #include KWSYS_HEADER(ConsoleBuf.hxx)
  5. #include KWSYS_HEADER(Encoding.hxx)
  6. // Work-around CMake dependency scanning limitation. This must
  7. // duplicate the above list of headers.
  8. #if 0
  9. #include "ConsoleBuf.hxx.in"
  10. #include "Encoding.hxx.in"
  11. #endif
  12. #include <iostream>
  13. #include "testConsoleBuf.hxx"
  14. int main(int argc, const char* argv[])
  15. {
  16. #if defined(_WIN32)
  17. kwsys::ConsoleBuf::Manager out(std::cout);
  18. kwsys::ConsoleBuf::Manager err(std::cerr, true);
  19. kwsys::ConsoleBuf::Manager in(std::cin);
  20. if (argc > 1) {
  21. std::cout << argv[1] << std::endl;
  22. std::cerr << argv[1] << std::endl;
  23. } else {
  24. std::string str = kwsys::Encoding::ToNarrow(std::wstring(
  25. UnicodeTestString, sizeof(UnicodeTestString) / sizeof(wchar_t) - 1));
  26. std::cout << str << std::endl;
  27. std::cerr << str << std::endl;
  28. }
  29. std::string input;
  30. HANDLE event = OpenEventW(EVENT_MODIFY_STATE, FALSE, BeforeInputEventName);
  31. if (event) {
  32. SetEvent(event);
  33. CloseHandle(event);
  34. }
  35. std::cin >> input;
  36. std::cout << input << std::endl;
  37. event = OpenEventW(EVENT_MODIFY_STATE, FALSE, AfterOutputEventName);
  38. if (event) {
  39. SetEvent(event);
  40. CloseHandle(event);
  41. }
  42. #else
  43. static_cast<void>(argc);
  44. static_cast<void>(argv);
  45. #endif
  46. return 0;
  47. }