/[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.2.2 by lefcha, Sun May 25 11:20:24 2003 UTC revision 1.12 by lefcha, Fri Feb 13 13:18:38 2004 UTC
# Line 16  static struct termios otio, ntio;      /* Ori Line 16  static struct termios otio, ntio;      /* Ori
16  /*  /*
17   * Store original term attributes.   * Store original term attributes.
18   */   */
19  int tty_store(void)  int
20    tty_store(void)
21  {  {
     if (isatty(fileno(stdin))) {  
         flags |= FLAG_TTY;  
22    
23          if (tcgetattr(fileno(stdin), &otio)) {          if (isatty(fileno(stdin))) {
24              error("imapfilter: getting term attributes; %s\n", strerror(errno));                  flags |= FLAG_TTY;
25              return ERROR_TERMIO;  
26                    if (tcgetattr(fileno(stdin), &otio)) {
27                            error("getting term attributes; %s\n", strerror(errno));
28                            return ERROR_TERMIO;
29                    }
30          }          }
31      }          return 0;
     return 0;  
32  }  }
33    
34    
35  /*  /*
36   * Disable echo.   * Disable echo.
37   */   */
38  int tty_disable_echo(void)  int
39    tty_noecho(void)
40  {  {
     if (!(flags & FLAG_TTY))  
         return 0;  
41    
42      ntio = otio;          if (!(flags & FLAG_TTY))
43      ntio.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL);                  return 0;
44    
45      flags |= FLAG_TTY_MODIFIED;          ntio = otio;
46            ntio.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL);
47    
48      if (tcsetattr(fileno(stdin), TCSAFLUSH, &ntio)) {          flags |= FLAG_TTYMOD;
49          error("imapfilter: setting term attributes; %s\n", strerror(errno));  
50          return ERROR_TERMIO;          if (tcsetattr(fileno(stdin), TCSAFLUSH, &ntio)) {
51      }                  error("setting term attributes; %s\n", strerror(errno));
52      return 0;                  return ERROR_TERMIO;
53            }
54            return 0;
55  }  }
56    
57    
58  /*  /*
59   * Restore original term attributes.   * Restore original term attributes.
60   */   */
61  int tty_restore(void)  int
62    tty_restore(void)
63  {  {
     if (!(flags & FLAG_TTY) || !(flags & FLAG_TTY_MODIFIED))  
         return 0;  
64    
65      if (tcsetattr(fileno(stdin), TCSAFLUSH, &otio)) {          if (!(flags & FLAG_TTY) || !(flags & FLAG_TTYMOD))
66          error("imapfilter: setting term attributes; %s\n", strerror(errno));                  return 0;
         return ERROR_TERMIO;  
     }  
     flags &= ~(FLAG_TTY_MODIFIED);  
67    
68      return 0;          if (tcsetattr(fileno(stdin), TCSAFLUSH, &otio)) {
69                    error("setting term attributes; %s\n", strerror(errno));
70                    return ERROR_TERMIO;
71            }
72            flags &= ~(FLAG_TTYMOD);
73    
74            return 0;
75  }  }

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

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26