1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "cloud_print/gcp20/prototype/conio_posix.h"
13 void SetTemporaryTermiosSettings(bool temporary) {
14 static termios oldt, newt;
17 tcgetattr(STDIN_FILENO, &oldt);
19 newt.c_lflag &= ~ICANON; // Disable buffered IO.
20 tcsetattr(STDIN_FILENO, TCSANOW, &newt);
22 tcsetattr(STDIN_FILENO, TCSANOW, &oldt); // Restore default settings.
27 SetTemporaryTermiosSettings(true);
36 FD_SET(STDIN_FILENO, &rdfs);
37 select(STDIN_FILENO + 1, &rdfs, NULL, NULL, &tv);
38 SetTemporaryTermiosSettings(false);
40 return FD_ISSET(STDIN_FILENO, &rdfs);
44 SetTemporaryTermiosSettings(true);
46 SetTemporaryTermiosSettings(false);