Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Unified Diff: cloud_print/gcp20/prototype/conio_posix.cc

Issue 19468002: Added confirmation for printer registration. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@new-api-availability-check
Patch Set: kbhit to _kbhit Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cloud_print/gcp20/prototype/conio_posix.h ('k') | cloud_print/gcp20/prototype/dns_sd_server.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cloud_print/gcp20/prototype/conio_posix.cc
diff --git a/cloud_print/gcp20/prototype/conio_posix.cc b/cloud_print/gcp20/prototype/conio_posix.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0a955c1ef58856e99c0296ca940da48fb946162a
--- /dev/null
+++ b/cloud_print/gcp20/prototype/conio_posix.cc
@@ -0,0 +1,49 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cloud_print/gcp20/prototype/conio_posix.h"
+
+#include <stdio.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <termios.h>
+#include <unistd.h>
+
+void SetTemporaryTermiosSettings(bool temporary) {
+ static termios oldt, newt;
+
+ if (temporary) {
+ tcgetattr(STDIN_FILENO, &oldt);
+ newt = oldt;
+ newt.c_lflag &= ~ICANON; // Disable buffered IO.
+ tcsetattr(STDIN_FILENO, TCSANOW, &newt);
+ } else {
+ tcsetattr(STDIN_FILENO, TCSANOW, &oldt); // Restore default settings.
+ }
+}
+
+int _kbhit() {
+ SetTemporaryTermiosSettings(true);
+
+ timeval tv;
+ fd_set rdfs;
+
+ tv.tv_sec = 0;
+ tv.tv_usec = 0;
+
+ FD_ZERO(&rdfs);
+ FD_SET(STDIN_FILENO, &rdfs);
+ select(STDIN_FILENO + 1, &rdfs, NULL, NULL, &tv);
+ SetTemporaryTermiosSettings(false);
+
+ return FD_ISSET(STDIN_FILENO, &rdfs);
+}
+
+int _getche() {
+ SetTemporaryTermiosSettings(true);
+ int c = getchar();
+ SetTemporaryTermiosSettings(false);
+ return c;
+}
+
« no previous file with comments | « cloud_print/gcp20/prototype/conio_posix.h ('k') | cloud_print/gcp20/prototype/dns_sd_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698