version 1.2, 1996/06/11 12:53:52 |
version 1.3, 1997/07/13 21:21:17 |
|
|
/* $OpenBSD$ */ |
/* $OpenBSD$ */ |
/* $NetBSD: tty.c,v 1.5 1996/06/08 19:48:43 christos Exp $ */ |
/* $NetBSD: tty.c,v 1.7 1997/07/09 05:25:46 mikel Exp $ */ |
|
|
/* |
/* |
* Copyright (c) 1980, 1993 |
* Copyright (c) 1980, 1993 |
|
|
|
|
#ifndef lint |
#ifndef lint |
#if 0 |
#if 0 |
static char sccsid[] = "@(#)tty.c 8.1 (Berkeley) 6/6/93"; |
static char sccsid[] = "@(#)tty.c 8.2 (Berkeley) 4/20/95"; |
#else |
#else |
static char rcsid[] = "$OpenBSD$"; |
static char rcsid[] = "$OpenBSD$"; |
#endif |
#endif |
|
|
sig_t saveint; |
sig_t saveint; |
#ifndef TIOCSTI |
#ifndef TIOCSTI |
sig_t savequit; |
sig_t savequit; |
|
#else |
|
int extproc, flag; |
#endif |
#endif |
sig_t savetstp; |
sig_t savetstp; |
sig_t savettou; |
sig_t savettou; |
|
|
int errs; |
int errs; |
#ifdef __GNUC__ |
#ifdef __GNUC__ |
/* Avoid longjmp clobbering */ |
/* Avoid longjmp clobbering */ |
|
#ifdef TIOCSTI |
|
(void) &extproc; |
|
#endif |
(void) &saveint; |
(void) &saveint; |
#endif |
#endif |
|
|
|
|
ttyset = 0; |
ttyset = 0; |
#endif |
#endif |
if (tcgetattr(fileno(stdin), &ttybuf) < 0) { |
if (tcgetattr(fileno(stdin), &ttybuf) < 0) { |
perror("tcgetattr"); |
warn("tcgetattr"); |
return(-1); |
return(-1); |
} |
} |
c_erase = ttybuf.c_cc[VERASE]; |
c_erase = ttybuf.c_cc[VERASE]; |
|
|
if ((savequit = signal(SIGQUIT, SIG_IGN)) == SIG_DFL) |
if ((savequit = signal(SIGQUIT, SIG_IGN)) == SIG_DFL) |
signal(SIGQUIT, SIG_DFL); |
signal(SIGQUIT, SIG_DFL); |
#else |
#else |
|
# ifdef TIOCEXT |
|
extproc = ((ttybuf.c_lflag & EXTPROC) ? 1 : 0); |
|
if (extproc) { |
|
flag = 0; |
|
if (ioctl(fileno(stdin), TIOCEXT, &flag) < 0) |
|
warn("TIOCEXT: off"); |
|
} |
|
# endif /* TIOCEXT */ |
if (setjmp(intjmp)) |
if (setjmp(intjmp)) |
goto out; |
goto out; |
saveint = signal(SIGINT, ttyint); |
saveint = signal(SIGINT, ttyint); |
|
|
if (ttyset) |
if (ttyset) |
tcsetattr(fileno(stdin), TCSADRAIN, &ttybuf); |
tcsetattr(fileno(stdin), TCSADRAIN, &ttybuf); |
signal(SIGQUIT, savequit); |
signal(SIGQUIT, savequit); |
|
#else |
|
# ifdef TIOCEXT |
|
if (extproc) { |
|
flag = 1; |
|
if (ioctl(fileno(stdin), TIOCEXT, &flag) < 0) |
|
warn("TIOCEXT: on"); |
|
} |
|
# endif /* TIOCEXT */ |
#endif |
#endif |
signal(SIGINT, saveint); |
signal(SIGINT, saveint); |
return(errs); |
return(errs); |
|
|
fputs(pr, stdout); |
fputs(pr, stdout); |
fflush(stdout); |
fflush(stdout); |
if (src != NOSTR && strlen(src) > BUFSIZ - 2) { |
if (src != NOSTR && strlen(src) > BUFSIZ - 2) { |
printf("too long to edit\n"); |
puts("too long to edit"); |
return(src); |
return(src); |
} |
} |
#ifndef TIOCSTI |
#ifndef TIOCSTI |