tset.c (78737) | tset.c (87701) |
---|---|
1/*- 2 * Copyright (c) 1980, 1991, 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 --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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 | 1/*- 2 * Copyright (c) 1980, 1991, 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 --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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#include <sys/cdefs.h> 35 36__FBSDID("$FreeBSD: head/usr.bin/tset/tset.c 87701 2001-12-11 23:29:45Z markm $"); 37 |
|
34#ifndef lint 35static const char copyright[] = 36"@(#) Copyright (c) 1980, 1991, 1993\n\ 37 The Regents of the University of California. All rights reserved.\n"; | 38#ifndef lint 39static const char copyright[] = 40"@(#) Copyright (c) 1980, 1991, 1993\n\ 41 The Regents of the University of California. All rights reserved.\n"; |
38#endif /* not lint */ | 42#endif |
39 40#ifndef lint | 43 44#ifndef lint |
41#if 0 42static char sccsid[] = "@(#)tset.c 8.1 (Berkeley) 6/9/93"; | 45static const char sccsid[] = "@(#)tset.c 8.1 (Berkeley) 6/9/93"; |
43#endif | 46#endif |
44static const char rcdif[] = 45 "$FreeBSD: head/usr.bin/tset/tset.c 78737 2001-06-24 23:41:57Z dd $"; 46#endif /* not lint */ | |
47 48#include <sys/types.h> 49#include <sys/ioctl.h> | 47 48#include <sys/types.h> 49#include <sys/ioctl.h> |
50 |
|
50#include <ctype.h> 51#include <err.h> 52#include <stdio.h> 53#include <stdlib.h> 54#include <string.h> | 51#include <ctype.h> 52#include <err.h> 53#include <stdio.h> 54#include <stdlib.h> 55#include <string.h> |
55#include <unistd.h> | |
56#include <termios.h> | 56#include <termios.h> |
57#include <unistd.h> 58 |
|
57#include "extern.h" 58 59void obsolete __P((char *[])); | 59#include "extern.h" 60 61void obsolete __P((char *[])); |
60void report __P((char *, int, u_int)); | 62void report __P((const char *, int, u_int)); |
61void usage __P((void)); 62 63struct termios mode, oldmode; 64 65int erasech; /* new erase character */ 66int intrchar; /* new interrupt character */ 67int isreset; /* invoked as reset */ 68int killch; /* new kill character */ --- 4 unchanged lines hidden (view full) --- 73main(argc, argv) 74 int argc; 75 char *argv[]; 76{ 77#ifdef TIOCGWINSZ 78 struct winsize win; 79#endif 80 int ch, noinit, noset, quiet, Sflag, sflag, showterm, usingupper; | 63void usage __P((void)); 64 65struct termios mode, oldmode; 66 67int erasech; /* new erase character */ 68int intrchar; /* new interrupt character */ 69int isreset; /* invoked as reset */ 70int killch; /* new kill character */ --- 4 unchanged lines hidden (view full) --- 75main(argc, argv) 76 int argc; 77 char *argv[]; 78{ 79#ifdef TIOCGWINSZ 80 struct winsize win; 81#endif 82 int ch, noinit, noset, quiet, Sflag, sflag, showterm, usingupper; |
81 char *p, *tcapbuf, *ttype; | 83 char *p, *tcapbuf; 84 const char *ttype; |
82 83 if (tcgetattr(STDERR_FILENO, &mode) < 0) 84 err(1, "standard error"); 85 86 oldmode = mode; 87 Ospeed = cfgetospeed(&mode); 88 89 if ((p = strrchr(*argv, '/'))) --- 145 unchanged lines hidden (view full) --- 235 exit(0); 236} 237 238/* 239 * Tell the user if a control key has been changed from the default value. 240 */ 241void 242report(name, which, def) | 85 86 if (tcgetattr(STDERR_FILENO, &mode) < 0) 87 err(1, "standard error"); 88 89 oldmode = mode; 90 Ospeed = cfgetospeed(&mode); 91 92 if ((p = strrchr(*argv, '/'))) --- 145 unchanged lines hidden (view full) --- 238 exit(0); 239} 240 241/* 242 * Tell the user if a control key has been changed from the default value. 243 */ 244void 245report(name, which, def) |
243 char *name; | 246 const char *name; |
244 int which; 245 u_int def; 246{ 247 u_int old, new; 248 249 new = mode.c_cc[which]; 250 old = oldmode.c_cc[which]; 251 --- 23 unchanged lines hidden (view full) --- 275{ 276 for (; *argv; ++argv) { 277 if (argv[0][0] != '-' || (argv[1] && argv[1][0] != '-') || 278 (argv[0][1] != 'e' && argv[0][1] != 'i' && argv[0][1] != 'k') || 279 argv[0][2] != '\0') 280 continue; 281 switch(argv[0][1]) { 282 case 'e': | 247 int which; 248 u_int def; 249{ 250 u_int old, new; 251 252 new = mode.c_cc[which]; 253 old = oldmode.c_cc[which]; 254 --- 23 unchanged lines hidden (view full) --- 278{ 279 for (; *argv; ++argv) { 280 if (argv[0][0] != '-' || (argv[1] && argv[1][0] != '-') || 281 (argv[0][1] != 'e' && argv[0][1] != 'i' && argv[0][1] != 'k') || 282 argv[0][2] != '\0') 283 continue; 284 switch(argv[0][1]) { 285 case 'e': |
283 argv[0] = "-e^H"; | 286 argv[0] = strdup("-e^H"); |
284 break; 285 case 'i': | 287 break; 288 case 'i': |
286 argv[0] = "-i^C"; | 289 argv[0] = strdup("-i^C"); |
287 break; 288 case 'k': | 290 break; 291 case 'k': |
289 argv[0] = "-k^U"; | 292 argv[0] = strdup("-k^U"); |
290 break; 291 } 292 } 293} 294 295void 296usage() 297{ 298 (void)fprintf(stderr, "%s\n%s\n", 299"usage: tset [-IQrSs] [-] [-e ch] [-i ch] [-k ch] [-m mapping] [terminal]", 300" reset [-IQrSs] [-] [-e ch] [-i ch] [-k ch] [-m mapping] [terminal]"); 301 exit(1); 302} 303 | 293 break; 294 } 295 } 296} 297 298void 299usage() 300{ 301 (void)fprintf(stderr, "%s\n%s\n", 302"usage: tset [-IQrSs] [-] [-e ch] [-i ch] [-k ch] [-m mapping] [terminal]", 303" reset [-IQrSs] [-] [-e ch] [-i ch] [-k ch] [-m mapping] [terminal]"); 304 exit(1); 305} 306 |