No empty .Rs/.Re
[netbsd-mini2440.git] / crypto / dist / heimdal / lib / editline / sysunix.c
blob66e1f4dda583deec4cb383d7f4545e7f415b3db5
1 /* Copyright 1992 Simmule Turner and Rich Salz. All rights reserved.
3 * This software is not subject to any license of the American Telephone
4 * and Telegraph Company or of the Regents of the University of California.
6 * Permission is granted to anyone to use this software for any purpose on
7 * any computer system, and to alter it and redistribute it freely, subject
8 * to the following restrictions:
9 * 1. The authors are not responsible for the consequences of use of this
10 * software, no matter how awful, even if they arise from flaws in it.
11 * 2. The origin of this software must not be misrepresented, either by
12 * explicit claim or by omission. Since few users ever read sources,
13 * credits must appear in the documentation.
14 * 3. Altered versions must be plainly marked as such, and must not be
15 * misrepresented as being the original software. Since few users
16 * ever read sources, credits must appear in the documentation.
17 * 4. This notice may not be removed or altered.
21 ** Unix system-dependant routines for editline library.
23 #include <config.h>
24 #include "edit_locl.h"
26 #ifdef HAVE_TERMIOS_H
27 #include <termios.h>
28 #else
29 #include <sgtty.h>
30 #endif
32 __RCSID("$Heimdal: sysunix.c 14926 2005-04-24 18:57:16Z lha $"
33 "$NetBSD$");
35 #ifdef HAVE_TERMIOS_H
37 void
38 rl_ttyset(int Reset)
40 static struct termios old;
41 struct termios new;
43 if (Reset == 0) {
44 tcgetattr(0, &old);
45 rl_erase = old.c_cc[VERASE];
46 rl_kill = old.c_cc[VKILL];
47 rl_eof = old.c_cc[VEOF];
48 rl_intr = old.c_cc[VINTR];
49 rl_quit = old.c_cc[VQUIT];
51 new = old;
52 new.c_cc[VINTR] = -1;
53 new.c_cc[VQUIT] = -1;
54 new.c_lflag &= ~(ECHO | ICANON);
55 new.c_iflag &= ~(ISTRIP | INPCK);
56 new.c_cc[VMIN] = 1;
57 new.c_cc[VTIME] = 0;
58 tcsetattr(0, TCSANOW, &new);
60 else
61 tcsetattr(0, TCSANOW, &old);
64 #else /* !HAVE_TERMIOS_H */
66 void
67 rl_ttyset(int Reset)
69 static struct sgttyb old;
70 struct sgttyb new;
72 if (Reset == 0) {
73 ioctl(0, TIOCGETP, &old);
74 rl_erase = old.sg_erase;
75 rl_kill = old.sg_kill;
76 new = old;
77 new.sg_flags &= ~(ECHO | ICANON);
78 new.sg_flags &= ~(ISTRIP | INPCK);
79 ioctl(0, TIOCSETP, &new);
80 } else {
81 ioctl(0, TIOCSETP, &old);
84 #endif /* HAVE_TERMIOS_H */
86 void
87 rl_add_slash(char *path, char *p, size_t len)
89 struct stat Sb;
91 if (stat(path, &Sb) >= 0)
92 strlcat(p, S_ISDIR(Sb.st_mode) ? "/" : " ", len);