libutil: add O_NOCTTY back to old pty open code
[minix.git] / lib / libedit / sysunix.c
blob0bee530fe7c8527a8bd7bed4540998eeb34b7a7a
1 /*
2 ** Unix system-dependant routines for editline library.
3 */
4 #include "editline.h"
6 #if defined(HAVE_TCGETATTR)
7 #include <termios.h>
9 void
10 rl_ttyset(Reset)
11 int Reset;
13 static struct termios old;
14 struct termios new;
16 if (Reset == 0) {
17 (void)tcgetattr(0, &old);
18 rl_erase = old.c_cc[VERASE];
19 rl_kill = old.c_cc[VKILL];
20 rl_eof = old.c_cc[VEOF];
21 rl_intr = old.c_cc[VINTR];
22 rl_quit = old.c_cc[VQUIT];
24 new = old;
25 new.c_lflag &= ~(ECHO | ICANON | ISIG | IEXTEN);
26 new.c_iflag &= ~(ICRNL);
27 new.c_cc[VMIN] = 1;
28 new.c_cc[VTIME] = 0;
29 (void)tcsetattr(0, TCSADRAIN, &new);
31 else
32 (void)tcsetattr(0, TCSADRAIN, &old);
35 #else
36 #if defined(HAVE_TERMIO)
37 #include <termio.h>
39 void
40 rl_ttyset(Reset)
41 int Reset;
43 static struct termio old;
44 struct termio new;
46 if (Reset == 0) {
47 (void)ioctl(0, TCGETA, &old);
48 rl_erase = old.c_cc[VERASE];
49 rl_kill = old.c_cc[VKILL];
50 rl_eof = old.c_cc[VEOF];
51 rl_intr = old.c_cc[VINTR];
52 rl_quit = old.c_cc[VQUIT];
54 new = old;
55 new.c_cc[VINTR] = -1;
56 new.c_cc[VQUIT] = -1;
57 new.c_lflag &= ~(ECHO | ICANON);
58 new.c_cc[VMIN] = 1;
59 new.c_cc[VTIME] = 0;
60 (void)ioctl(0, TCSETAW, &new);
62 else
63 (void)ioctl(0, TCSETAW, &old);
66 #else
67 #include <sgtty.h>
69 void
70 rl_ttyset(Reset)
71 int Reset;
73 static struct sgttyb old_sgttyb;
74 static struct tchars old_tchars;
75 struct sgttyb new_sgttyb;
76 struct tchars new_tchars;
78 if (Reset == 0) {
79 (void)ioctl(0, TIOCGETP, &old_sgttyb);
80 rl_erase = old_sgttyb.sg_erase;
81 rl_kill = old_sgttyb.sg_kill;
83 (void)ioctl(0, TIOCGETC, &old_tchars);
84 rl_eof = old_tchars.t_eofc;
85 rl_intr = old_tchars.t_intrc;
86 rl_quit = old_tchars.t_quitc;
88 new_sgttyb = old_sgttyb;
89 new_sgttyb.sg_flags &= ~ECHO;
90 new_sgttyb.sg_flags |= RAW;
91 (void)ioctl(0, TIOCSETP, &new_sgttyb);
93 new_tchars = old_tchars;
94 new_tchars.t_intrc = -1;
95 new_tchars.t_quitc = -1;
96 (void)ioctl(0, TIOCSETC, &new_tchars);
98 else {
99 (void)ioctl(0, TIOCSETP, &old_sgttyb);
100 (void)ioctl(0, TIOCSETC, &old_tchars);
103 #endif /* defined(HAVE_TERMIO) */
104 #endif /* defined(HAVE_TCGETATTR) */
106 void
107 rl_add_slash(path, p)
108 char *path;
109 char *p;
111 struct stat Sb;
113 if (stat(path, &Sb) >= 0)
114 (void)strcat(p, S_ISDIR(Sb.st_mode) ? "/" : " ");
118 * $PchId: sysunix.c,v 1.4 1996/02/22 21:16:56 philip Exp $