summaryrefslogtreecommitdiff
path: root/net/tnftp/files/libedit/tty.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/tnftp/files/libedit/tty.c')
-rw-r--r--net/tnftp/files/libedit/tty.c157
1 files changed, 146 insertions, 11 deletions
diff --git a/net/tnftp/files/libedit/tty.c b/net/tnftp/files/libedit/tty.c
index 719e129f6d3..a60929980a0 100644
--- a/net/tnftp/files/libedit/tty.c
+++ b/net/tnftp/files/libedit/tty.c
@@ -1,4 +1,5 @@
-/* $NetBSD: tty.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */
+/* NetBSD: tty.c,v 1.4 2005/05/11 01:17:39 lukem Exp */
+/* from NetBSD: tty.c,v 1.21 2004/08/13 12:10:39 mycroft Exp */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -39,9 +36,21 @@
#include "tnftp.h"
#include "sys.h"
+#if 0
+#include "config.h"
+#if !defined(lint) && !defined(SCCSID)
+#if 0
+static char sccsid[] = "@(#)tty.c 8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("NetBSD: tty.c,v 1.4 2005/05/11 01:17:39 lukem Exp");
+#endif
+#endif /* not lint && not SCCSID */
+#endif
+
/*
* tty.c: tty interface stuff
*/
+#include <assert.h>
#include "tty.h"
#include "el.h"
@@ -118,11 +127,11 @@ private const ttychar_t ttychar = {
private const ttymap_t tty_map[] = {
#ifdef VERASE
{C_ERASE, VERASE,
- {ED_DELETE_PREV_CHAR, VI_DELETE_PREV_CHAR, ED_PREV_CHAR}},
+ {EM_DELETE_PREV_CHAR, VI_DELETE_PREV_CHAR, ED_PREV_CHAR}},
#endif /* VERASE */
#ifdef VERASE2
{C_ERASE2, VERASE2,
- {ED_DELETE_PREV_CHAR, VI_DELETE_PREV_CHAR, ED_PREV_CHAR}},
+ {EM_DELETE_PREV_CHAR, VI_DELETE_PREV_CHAR, ED_PREV_CHAR}},
#endif /* VERASE2 */
#ifdef VKILL
{C_KILL, VKILL,
@@ -449,6 +458,7 @@ private const ttymodes_t ttymodes[] = {
#define tty__geteightbit(td) (((td)->c_cflag & CSIZE) == CS8)
#define tty__cooked_mode(td) ((td)->c_lflag & ICANON)
+private int tty__getcharindex(int);
private void tty__getchar(struct termios *, unsigned char *);
private void tty__setchar(struct termios *, unsigned char *);
private speed_t tty__getspeed(struct termios *);
@@ -562,7 +572,7 @@ tty_init(EditLine *el)
*/
protected void
/*ARGSUSED*/
-tty_end(EditLine *el)
+tty_end(EditLine *el __attribute__((__unused__)))
{
/* XXX: Maybe reset to an initial state? */
@@ -582,6 +592,113 @@ tty__getspeed(struct termios *td)
return (spd);
}
+/* tty__getspeed():
+ * Return the index of the asked char in the c_cc array
+ */
+private int
+tty__getcharindex(int i)
+{
+ switch (i) {
+#ifdef VINTR
+ case C_INTR:
+ return VINTR;
+#endif /* VINTR */
+#ifdef VQUIT
+ case C_QUIT:
+ return VQUIT;
+#endif /* VQUIT */
+#ifdef VERASE
+ case C_ERASE:
+ return VERASE;
+#endif /* VERASE */
+#ifdef VKILL
+ case C_KILL:
+ return VKILL;
+#endif /* VKILL */
+#ifdef VEOF
+ case C_EOF:
+ return VEOF;
+#endif /* VEOF */
+#ifdef VEOL
+ case C_EOL:
+ return VEOL;
+#endif /* VEOL */
+#ifdef VEOL2
+ case C_EOL2:
+ return VEOL2;
+#endif /* VEOL2 */
+#ifdef VSWTCH
+ case C_SWTCH:
+ return VSWTCH;
+#endif /* VSWTCH */
+#ifdef VDSWTCH
+ case C_DSWTCH:
+ return VDSWTCH;
+#endif /* VDSWTCH */
+#ifdef VERASE2
+ case C_ERASE2:
+ return VERASE2;
+#endif /* VERASE2 */
+#ifdef VSTART
+ case C_START:
+ return VSTART;
+#endif /* VSTART */
+#ifdef VSTOP
+ case C_STOP:
+ return VSTOP;
+#endif /* VSTOP */
+#ifdef VWERASE
+ case C_WERASE:
+ return VWERASE;
+#endif /* VWERASE */
+#ifdef VSUSP
+ case C_SUSP:
+ return VSUSP;
+#endif /* VSUSP */
+#ifdef VDSUSP
+ case C_DSUSP:
+ return VDSUSP;
+#endif /* VDSUSP */
+#ifdef VREPRINT
+ case C_REPRINT:
+ return VREPRINT;
+#endif /* VREPRINT */
+#ifdef VDISCARD
+ case C_DISCARD:
+ return VDISCARD;
+#endif /* VDISCARD */
+#ifdef VLNEXT
+ case C_LNEXT:
+ return VLNEXT;
+#endif /* VLNEXT */
+#ifdef VSTATUS
+ case C_STATUS:
+ return VSTATUS;
+#endif /* VSTATUS */
+#ifdef VPAGE
+ case C_PAGE:
+ return VPAGE;
+#endif /* VPAGE */
+#ifdef VPGOFF
+ case C_PGOFF:
+ return VPGOFF;
+#endif /* VPGOFF */
+#ifdef VKILL2
+ case C_KILL2:
+ return VKILL2;
+#endif /* KILL2 */
+#ifdef VMIN
+ case C_MIN:
+ return VMIN;
+#endif /* VMIN */
+#ifdef VTIME
+ case C_TIME:
+ return VTIME;
+#endif /* VTIME */
+ default:
+ return -1;
+ }
+}
/* tty__getchar():
* Get the tty characters
@@ -1035,13 +1152,14 @@ tty_noquotemode(EditLine *el)
*/
protected int
/*ARGSUSED*/
-tty_stty(EditLine *el, int argc, const char **argv)
+tty_stty(EditLine *el, int argc __attribute__((__unused__)), const char **argv)
{
const ttymodes_t *m;
char x;
int aflag = 0;
const char *s, *d;
const char *name;
+ struct termios *tios = &el->el_tty.t_ex;
int z = EX_IO;
if (argv == NULL)
@@ -1056,14 +1174,17 @@ tty_stty(EditLine *el, int argc, const char **argv)
break;
case 'd':
argv++;
+ tios = &el->el_tty.t_ed;
z = ED_IO;
break;
case 'x':
argv++;
+ tios = &el->el_tty.t_ex;
z = EX_IO;
break;
case 'q':
argv++;
+ tios = &el->el_tty.t_ts;
z = QU_IO;
break;
default:
@@ -1113,6 +1234,7 @@ tty_stty(EditLine *el, int argc, const char **argv)
return (0);
}
while (argv && (s = *argv++)) {
+ char *p;
switch (*s) {
case '+':
case '-':
@@ -1123,8 +1245,11 @@ tty_stty(EditLine *el, int argc, const char **argv)
break;
}
d = s;
+ if ((p = strchr(s, '=')) != NULL)
+ *p++ = '\0';
for (m = ttymodes; m->m_name; m++)
- if (strcmp(m->m_name, d) == 0)
+ if (strcmp(m->m_name, d) == 0 &&
+ (p == NULL || m->m_type == MD_CHAR))
break;
if (!m->m_name) {
@@ -1132,6 +1257,16 @@ tty_stty(EditLine *el, int argc, const char **argv)
"%s: Invalid argument `%s'.\n", name, d);
return (-1);
}
+ if (p) {
+ int c = ffs((int)m->m_value);
+ int v = *p ? parse__escape((const char **const) &p) :
+ el->el_tty.t_vdisable;
+ assert(c-- != 0);
+ c = tty__getcharindex(c);
+ assert(c != -1);
+ tios->c_cc[c] = v;
+ continue;
+ }
switch (x) {
case '+':
el->el_tty.t_t[z][m->m_type].t_setmask |= m->m_value;