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

Diff of /imapfilter/tty.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by lefcha, Fri Jul 26 14:45:28 2002 UTC revision 1.5.2.2 by lefcha, Sun May 25 11:20:24 2003 UTC
# Line 1  Line 1 
1  #include <stdio.h>  #include <stdio.h>
2    #include <unistd.h>
3  #include <string.h>  #include <string.h>
4  #include <errno.h>  #include <errno.h>
5  #include <termios.h>  #include <termios.h>
# Line 17  static struct termios otio, ntio;      /* Ori Line 18  static struct termios otio, ntio;      /* Ori
18   */   */
19  int tty_store(void)  int tty_store(void)
20  {  {
21      if (tcgetattr(fileno(stdout), &otio)) {      if (isatty(fileno(stdin))) {
22          error("imapfilter: getting term attributes; %s\n", strerror(errno));          flags |= FLAG_TTY;
23          return ERROR_TERMIO;  
24            if (tcgetattr(fileno(stdin), &otio)) {
25                error("imapfilter: getting term attributes; %s\n", strerror(errno));
26                return ERROR_TERMIO;
27            }
28      }      }
29      return 0;      return 0;
30  }  }
# Line 30  int tty_store(void) Line 35  int tty_store(void)
35   */   */
36  int tty_disable_echo(void)  int tty_disable_echo(void)
37  {  {
38        if (!(flags & FLAG_TTY))
39            return 0;
40    
41      ntio = otio;      ntio = otio;
42      ntio.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL);      ntio.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL);
43    
44      flags |= FLAG_TTY_MODIFIED;      flags |= FLAG_TTY_MODIFIED;
45    
46      if (tcsetattr(fileno(stdout), TCSAFLUSH, &ntio)) {      if (tcsetattr(fileno(stdin), TCSAFLUSH, &ntio)) {
47          error("imapfilter: setting term attributes; %s\n", strerror(errno));          error("imapfilter: setting term attributes; %s\n", strerror(errno));
48          return ERROR_TERMIO;          return ERROR_TERMIO;
49      }      }
# Line 48  int tty_disable_echo(void) Line 56  int tty_disable_echo(void)
56   */   */
57  int tty_restore(void)  int tty_restore(void)
58  {  {
59      if (!(flags & FLAG_TTY_MODIFIED))      if (!(flags & FLAG_TTY) || !(flags & FLAG_TTY_MODIFIED))
60          return 0;          return 0;
61    
62      if (tcsetattr(fileno(stdout), TCSAFLUSH, &otio)) {      if (tcsetattr(fileno(stdin), TCSAFLUSH, &otio)) {
63          error("imapfilter: setting term attributes; %s\n", strerror(errno));          error("imapfilter: setting term attributes; %s\n", strerror(errno));
64          return ERROR_TERMIO;          return ERROR_TERMIO;
65      }      }

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.5.2.2

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26