Debian Codegraph @

Utilities/KWSys/testConsoleBufChild.cxx

raw
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
5 #include KWSYS_HEADER(ConsoleBuf.hxx)
6 #include KWSYS_HEADER(Encoding.hxx)
7
8 // Work-around CMake dependency scanning limitation. This must
9 // duplicate the above list of headers.
10 #if 0
11 # include "ConsoleBuf.hxx.in"
12 # include "Encoding.hxx.in"
13 #endif
14
15 #include <iostream>
16
17 #include "testConsoleBuf.hxx"
18
19 int main(int argc, const char* argv[])
20 {
21 #if defined(_WIN32)
22 kwsys::ConsoleBuf::Manager out(std::cout);
23 kwsys::ConsoleBuf::Manager err(std::cerr, true);
24 kwsys::ConsoleBuf::Manager in(std::cin);
25
26 if (argc > 1) {
27 std::cout << argv[1] << std::endl;
28 std::cerr << argv[1] << std::endl;
29 } else {
30 std::string str = kwsys::Encoding::ToNarrow(std::wstring(
31 UnicodeTestString, sizeof(UnicodeTestString) / sizeof(wchar_t) - 1));
32 std::cout << str << std::endl;
33 std::cerr << str << std::endl;
34 }
35
36 std::string input;
37 HANDLE event = OpenEventW(EVENT_MODIFY_STATE, FALSE, BeforeInputEventName);
38 if (event) {
39 SetEvent(event);
40 CloseHandle(event);
41 }
42
43 std::cin >> input;
44 std::cout << input << std::endl;
45 event = OpenEventW(EVENT_MODIFY_STATE, FALSE, AfterOutputEventName);
46 if (event) {
47 SetEvent(event);
48 CloseHandle(event);
49 }
50 #else
51 static_cast<void>(argc);
52 static_cast<void>(argv);
53 #endif
54 return 0;
55 }