source: trunk/minix/lib/editline/sysunix.c@ 10

Last change on this file since 10 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 2.3 KB
Line 
1/* $Revision: 1.1.1.1 $
2**
3** Unix system-dependant routines for editline library.
4*/
5#include "editline.h"
6
7#if defined(HAVE_TCGETATTR)
8#include <termios.h>
9
10void
11rl_ttyset(Reset)
12 int Reset;
13{
14 static struct termios old;
15 struct termios new;
16
17 if (Reset == 0) {
18 (void)tcgetattr(0, &old);
19 rl_erase = old.c_cc[VERASE];
20 rl_kill = old.c_cc[VKILL];
21 rl_eof = old.c_cc[VEOF];
22 rl_intr = old.c_cc[VINTR];
23 rl_quit = old.c_cc[VQUIT];
24
25 new = old;
26 new.c_lflag &= ~(ECHO | ICANON | ISIG | IEXTEN);
27 new.c_iflag &= ~(ICRNL);
28 new.c_cc[VMIN] = 1;
29 new.c_cc[VTIME] = 0;
30 (void)tcsetattr(0, TCSADRAIN, &new);
31 }
32 else
33 (void)tcsetattr(0, TCSADRAIN, &old);
34}
35
36#else
37#if defined(HAVE_TERMIO)
38#include <termio.h>
39
40void
41rl_ttyset(Reset)
42 int Reset;
43{
44 static struct termio old;
45 struct termio new;
46
47 if (Reset == 0) {
48 (void)ioctl(0, TCGETA, &old);
49 rl_erase = old.c_cc[VERASE];
50 rl_kill = old.c_cc[VKILL];
51 rl_eof = old.c_cc[VEOF];
52 rl_intr = old.c_cc[VINTR];
53 rl_quit = old.c_cc[VQUIT];
54
55 new = old;
56 new.c_cc[VINTR] = -1;
57 new.c_cc[VQUIT] = -1;
58 new.c_lflag &= ~(ECHO | ICANON);
59 new.c_cc[VMIN] = 1;
60 new.c_cc[VTIME] = 0;
61 (void)ioctl(0, TCSETAW, &new);
62 }
63 else
64 (void)ioctl(0, TCSETAW, &old);
65}
66
67#else
68#include <sgtty.h>
69
70void
71rl_ttyset(Reset)
72 int Reset;
73{
74 static struct sgttyb old_sgttyb;
75 static struct tchars old_tchars;
76 struct sgttyb new_sgttyb;
77 struct tchars new_tchars;
78
79 if (Reset == 0) {
80 (void)ioctl(0, TIOCGETP, &old_sgttyb);
81 rl_erase = old_sgttyb.sg_erase;
82 rl_kill = old_sgttyb.sg_kill;
83
84 (void)ioctl(0, TIOCGETC, &old_tchars);
85 rl_eof = old_tchars.t_eofc;
86 rl_intr = old_tchars.t_intrc;
87 rl_quit = old_tchars.t_quitc;
88
89 new_sgttyb = old_sgttyb;
90 new_sgttyb.sg_flags &= ~ECHO;
91 new_sgttyb.sg_flags |= RAW;
92 (void)ioctl(0, TIOCSETP, &new_sgttyb);
93
94 new_tchars = old_tchars;
95 new_tchars.t_intrc = -1;
96 new_tchars.t_quitc = -1;
97 (void)ioctl(0, TIOCSETC, &new_tchars);
98 }
99 else {
100 (void)ioctl(0, TIOCSETP, &old_sgttyb);
101 (void)ioctl(0, TIOCSETC, &old_tchars);
102 }
103}
104#endif /* defined(HAVE_TERMIO) */
105#endif /* defined(HAVE_TCGETATTR) */
106
107void
108rl_add_slash(path, p)
109 char *path;
110 char *p;
111{
112 struct stat Sb;
113
114 if (stat(path, &Sb) >= 0)
115 (void)strcat(p, S_ISDIR(Sb.st_mode) ? "/" : " ");
116}
117
118/*
119 * $PchId: sysunix.c,v 1.4 1996/02/22 21:16:56 philip Exp $
120 */
Note: See TracBrowser for help on using the repository browser.