tty.c (17678) | tty.c (74769) |
---|---|
1/* 2 * Copyright (c) 1980, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 18 unchanged lines hidden (view full) --- 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 34#ifndef lint | 1/* 2 * Copyright (c) 1980, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 18 unchanged lines hidden (view full) --- 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 34#ifndef lint |
35#if 0 |
|
35static char sccsid[] = "@(#)tty.c 8.1 (Berkeley) 6/6/93"; | 36static char sccsid[] = "@(#)tty.c 8.1 (Berkeley) 6/6/93"; |
37#endif 38static const char rcsid[] = 39 "$FreeBSD: head/usr.bin/mail/tty.c 74769 2001-03-25 04:57:05Z mikeh $"; |
|
36#endif /* not lint */ 37 38/* 39 * Mail -- a mail program 40 * 41 * Generally useful tty stuff. 42 */ 43 --- 31 unchanged lines hidden (view full) --- 75 savetstp = signal(SIGTSTP, SIG_DFL); 76 savettou = signal(SIGTTOU, SIG_DFL); 77 savettin = signal(SIGTTIN, SIG_DFL); 78 errs = 0; 79#ifndef TIOCSTI 80 ttyset = 0; 81#endif 82 if (tcgetattr(fileno(stdin), &tio) < 0) { | 40#endif /* not lint */ 41 42/* 43 * Mail -- a mail program 44 * 45 * Generally useful tty stuff. 46 */ 47 --- 31 unchanged lines hidden (view full) --- 79 savetstp = signal(SIGTSTP, SIG_DFL); 80 savettou = signal(SIGTTOU, SIG_DFL); 81 savettin = signal(SIGTTIN, SIG_DFL); 82 errs = 0; 83#ifndef TIOCSTI 84 ttyset = 0; 85#endif 86 if (tcgetattr(fileno(stdin), &tio) < 0) { |
83 perror("tcgetattr(stdin)"); | 87 warn("tcgetattr(stdin)"); |
84 return(-1); 85 } 86 c_erase = tio.c_cc[VERASE]; 87 c_kill = tio.c_cc[VKILL]; 88#ifndef TIOCSTI 89 tio.c_cc[VERASE] = 0; 90 tio.c_cc[VKILL] = 0; 91 if ((saveint = signal(SIGINT, SIG_IGN)) == SIG_DFL) --- 70 unchanged lines hidden (view full) --- 162 fputs(pr, stdout); 163 fflush(stdout); 164 if (src != NOSTR && strlen(src) > BUFSIZ - 2) { 165 printf("too long to edit\n"); 166 return(src); 167 } 168#ifndef TIOCSTI 169 if (src != NOSTR) | 88 return(-1); 89 } 90 c_erase = tio.c_cc[VERASE]; 91 c_kill = tio.c_cc[VKILL]; 92#ifndef TIOCSTI 93 tio.c_cc[VERASE] = 0; 94 tio.c_cc[VKILL] = 0; 95 if ((saveint = signal(SIGINT, SIG_IGN)) == SIG_DFL) --- 70 unchanged lines hidden (view full) --- 166 fputs(pr, stdout); 167 fflush(stdout); 168 if (src != NOSTR && strlen(src) > BUFSIZ - 2) { 169 printf("too long to edit\n"); 170 return(src); 171 } 172#ifndef TIOCSTI 173 if (src != NOSTR) |
170 cp = copy(src, canonb); | 174 strlcpy(canonb, src, sizeof(canonb)); |
171 else | 175 else |
172 cp = copy("", canonb); | 176 *canonb = '\0'; |
173 fputs(canonb, stdout); 174 fflush(stdout); 175#else 176 cp = src == NOSTR ? "" : src; 177 while (c = *cp++) { 178 if (c == c_erase || c == c_kill) { 179 ch = '\\'; 180 ioctl(0, TIOCSTI, &ch); 181 } 182 ch = c; 183 ioctl(0, TIOCSTI, &ch); 184 } 185 cp = canonb; | 177 fputs(canonb, stdout); 178 fflush(stdout); 179#else 180 cp = src == NOSTR ? "" : src; 181 while (c = *cp++) { 182 if (c == c_erase || c == c_kill) { 183 ch = '\\'; 184 ioctl(0, TIOCSTI, &ch); 185 } 186 ch = c; 187 ioctl(0, TIOCSTI, &ch); 188 } 189 cp = canonb; |
186 *cp = 0; | 190 *cp = '\0'; |
187#endif 188 cp2 = cp; 189 while (cp2 < canonb + BUFSIZ) | 191#endif 192 cp2 = cp; 193 while (cp2 < canonb + BUFSIZ) |
190 *cp2++ = 0; | 194 *cp2++ = '\0'; |
191 cp2 = cp; 192 if (setjmp(rewrite)) 193 goto redo; 194 signal(SIGTSTP, ttystop); 195 signal(SIGTTOU, ttystop); 196 signal(SIGTTIN, ttystop); 197 clearerr(stdin); 198 while (cp2 < canonb + BUFSIZ) { --- 75 unchanged lines hidden --- | 195 cp2 = cp; 196 if (setjmp(rewrite)) 197 goto redo; 198 signal(SIGTSTP, ttystop); 199 signal(SIGTTOU, ttystop); 200 signal(SIGTTIN, ttystop); 201 clearerr(stdin); 202 while (cp2 < canonb + BUFSIZ) { --- 75 unchanged lines hidden --- |