/[imapfilter]/imapfilter/tty.c
ViewVC logotype

Contents of /imapfilter/tty.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Sat Dec 8 14:46:27 2001 UTC (22 years, 3 months ago) by lefcha
Branch: MAIN
File MIME type: text/plain
File for term related functions.

1 #include <stdio.h>
2 #include <string.h>
3 #include <errno.h>
4 #include <termios.h>
5
6 #include "imapfilter.h"
7
8
9 static struct termios otio, ntio;
10
11
12 /*
13 * Store original term attributes.
14 */
15 int tty_store(void)
16 {
17 if (tcgetattr(fileno(stdout), &otio)) {
18 error("imapfilter: getting term attributes; %s\n", strerror(errno));
19 return ERROR_TERMIO;
20 }
21
22 return 0;
23 }
24
25
26 /*
27 * Disable echo.
28 */
29 int tty_disable_echo(void)
30 {
31 ntio = otio;
32 ntio.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL);
33
34 if (tcsetattr(fileno(stdout), TCSAFLUSH, &ntio)) {
35 error("imapfilter: setting term attributes; %s\n", strerror(errno));
36 return ERROR_TERMIO;
37 }
38
39 return 0;
40 }
41
42
43 /*
44 * Restore original term attributes.
45 */
46 int tty_restore(void)
47 {
48 if (tcsetattr(fileno(stdout), TCSAFLUSH, &otio)) {
49 error("imapfilter: setting term attributes; %s\n", strerror(errno));
50 return ERROR_TERMIO;
51 }
52 return 0;
53 }
54
55

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26