123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- #include <iostream>
- #include <fstream> // debug
- #include <string>
- #include <thread>
- #include <chrono>
-
- int
- main(int argc, char *argv[]) {
-
- std::ofstream log("childProgram.log");
-
- // Output for read test.
- if (argc == 2) {
-
- // Write a single line and exit.
- if (std::string(argv[1]) == "write") {
- log << "Command is \"write\". Returning \"This is a test\"" << std::endl;
- std::cout << "This is a test";
- std::cout.flush();
-
- goto exit;
-
- }
-
- // Exit without writing anything.
- if (std::string(argv[1]) == "quit") {
- log << "Command is \"quit\". Exiting" << std::endl;
-
- goto exit;
-
- }
-
- }
-
- char ch;
- log << "Received \"";
- while (std::cin >> ch) {
-
- // Exit?
- if ('q' == ch) {
- log << (char) ch << "\"" << std::endl;
- break;
-
- }
-
- std::cout << (char) std::toupper(ch);
- std::cout.flush();
- log << (char) ch;
- log.flush();
-
- }
-
- exit:
- log.close();
- return 25;
-
- }
|