summaryrefslogtreecommitdiff
path: root/sys/src/ape/lib/v/plan9/tty.c
diff options
context:
space:
mode:
authorTaru Karttunen <taruti@taruti.net>2011-03-30 15:46:40 +0300
committerTaru Karttunen <taruti@taruti.net>2011-03-30 15:46:40 +0300
commite5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch)
treed8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/ape/lib/v/plan9/tty.c
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/ape/lib/v/plan9/tty.c')
-rwxr-xr-xsys/src/ape/lib/v/plan9/tty.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/sys/src/ape/lib/v/plan9/tty.c b/sys/src/ape/lib/v/plan9/tty.c
new file mode 100755
index 000000000..dae26d48f
--- /dev/null
+++ b/sys/src/ape/lib/v/plan9/tty.c
@@ -0,0 +1,37 @@
+/*
+ * turn raw (no echo, etc.) on and off.
+ * ptyfs is gone, so don't even try tcsetattr, etc.
+ */
+#define _POSIX_SOURCE
+#define _RESEARCH_SOURCE
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <libv.h>
+
+static int ctlfd = -1;
+
+/* fd is ignored */
+
+tty_echooff(int fd)
+{
+ if(ctlfd >= 0)
+ return 0;
+ ctlfd = open("/dev/consctl", O_WRONLY);
+ if(ctlfd < 0)
+ return -1;
+ write(ctlfd, "rawon", 5);
+ return 0;
+}
+
+tty_echoon(int fd)
+{
+ if(ctlfd >= 0){
+ write(ctlfd, "rawoff", 6);
+ close(ctlfd);
+ ctlfd = -1;
+ return 0;
+ }
+ return -1;
+}