Version 0.1.10 from FTP

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Spencer
2001-12-25 21:12:07 +00:00
parent 54e1f06913
commit eb97d576eb
12 changed files with 1877 additions and 29 deletions

40
io.c
View File

@@ -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;
}