aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2001-12-25 21:12:07 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2001-12-25 21:12:07 +0000
commit2ec0e7173627c60082309f3b4bed31a4d4350bf2 (patch)
tree478308e9771ec6ebdffba099906fc57c0b9bae7a /io.c
parentf3a2afa02ecccbf4300c74b832248630a761df6a (diff)
Version 0.1.10 from FTP
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@396 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'io.c')
-rwxr-xr-xio.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/io.c b/io.c
index aef361c64..91aec690b 100755
--- a/io.c
+++ b/io.c
@@ -15,6 +15,7 @@
#include <sys/poll.h>
#include <unistd.h>
#include <stdlib.h>
+#include <termios.h>
#include <asterisk/io.h>
#include <asterisk/logger.h>
@@ -257,3 +258,42 @@ void ast_io_dump(struct io_context *ioc)
}
ast_log(LOG_DEBUG, "================================================\n");
}
+
+/* Unrelated I/O functions */
+
+int ast_hide_password(int fd)
+{
+ struct termios tios;
+ int res;
+ int old;
+ if (!isatty(fd))
+ return -1;
+ res = tcgetattr(fd, &tios);
+ if (res < 0)
+ return -1;
+ old = tios.c_lflag & (ECHO | ECHONL);
+ tios.c_lflag &= ~ECHO;
+ tios.c_lflag |= ECHONL;
+ res = tcsetattr(fd, TCSAFLUSH, &tios);
+ if (res < 0)
+ return -1;
+ return old;
+}
+
+int ast_restore_tty(int fd, int oldstate)
+{
+ int res;
+ struct termios tios;
+ if (oldstate < 0)
+ return 0;
+ res = tcgetattr(fd, &tios);
+ if (res < 0)
+ return -1;
+ tios.c_lflag &= ~(ECHO | ECHONL);
+ tios.c_lflag |= oldstate;
+ res = tcsetattr(fd, TCSAFLUSH, &tios);
+ if (res < 0)
+ return -1;
+ return 0;
+}
+