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

Diff of /imapfilter/tty.c

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

revision 1.2 by lefcha, Mon Jan 14 18:15:23 2002 UTC revision 1.3 by lefcha, Wed Jan 30 19:19:00 2002 UTC
# Line 7  Line 7 
7  #include "imapfilter.h"  #include "imapfilter.h"
8    
9    
10  static struct termios otio, ntio;  static struct termios otio, ntio;       /* Original and new tty settings. */
11    static int ttymod = 0;                  /* Flag set if tty setting modified. */
12    
13    
14  /*  /*
# Line 19  int tty_store(void) Line 20  int tty_store(void)
20          error("imapfilter: getting term attributes; %s\n", strerror(errno));          error("imapfilter: getting term attributes; %s\n", strerror(errno));
21          return ERROR_TERMIO;          return ERROR_TERMIO;
22      }      }
23        
24      return 0;      return 0;
25  }  }
26    
# Line 30  int tty_disable_echo(void) Line 32  int tty_disable_echo(void)
32  {  {
33      ntio = otio;      ntio = otio;
34      ntio.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL);      ntio.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL);
35        
36        ttymod = 1;
37    
38      if (tcsetattr(fileno(stdout), TCSAFLUSH, &ntio)) {      if (tcsetattr(fileno(stdout), TCSAFLUSH, &ntio)) {
39          error("imapfilter: setting term attributes; %s\n", strerror(errno));          error("imapfilter: setting term attributes; %s\n", strerror(errno));
# Line 44  int tty_disable_echo(void) Line 48  int tty_disable_echo(void)
48   */   */
49  int tty_restore(void)  int tty_restore(void)
50  {  {
51        if (!ttymod)
52            return 0;
53        
54      if (tcsetattr(fileno(stdout), TCSAFLUSH, &otio)) {      if (tcsetattr(fileno(stdout), TCSAFLUSH, &otio)) {
55          error("imapfilter: setting term attributes; %s\n", strerror(errno));          error("imapfilter: setting term attributes; %s\n", strerror(errno));
56          return ERROR_TERMIO;          return ERROR_TERMIO;
57      }      }
58        
59        ttymod = 0;
60        
61      return 0;      return 0;
62  }  }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26