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

Annotation of /imapfilter/tty.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Mon Jan 14 18:15:23 2002 UTC (22 years, 2 months ago) by lefcha
Branch: MAIN
Changes since 1.1: +2 -5 lines
File MIME type: text/plain
Small changes.

1 lefcha 1.1 #include <stdio.h>
2     #include <string.h>
3     #include <errno.h>
4     #include <termios.h>
5    
6 lefcha 1.2 #include "config.h"
7 lefcha 1.1 #include "imapfilter.h"
8    
9    
10     static struct termios otio, ntio;
11    
12    
13     /*
14     * Store original term attributes.
15     */
16     int tty_store(void)
17     {
18     if (tcgetattr(fileno(stdout), &otio)) {
19     error("imapfilter: getting term attributes; %s\n", strerror(errno));
20     return ERROR_TERMIO;
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 lefcha 1.2
34 lefcha 1.1 if (tcsetattr(fileno(stdout), TCSAFLUSH, &ntio)) {
35     error("imapfilter: setting term attributes; %s\n", strerror(errno));
36     return ERROR_TERMIO;
37     }
38     return 0;
39     }
40    
41    
42     /*
43     * Restore original term attributes.
44     */
45     int tty_restore(void)
46     {
47     if (tcsetattr(fileno(stdout), TCSAFLUSH, &otio)) {
48     error("imapfilter: setting term attributes; %s\n", strerror(errno));
49     return ERROR_TERMIO;
50     }
51     return 0;
52     }

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26