tset.c (24360) | tset.c (28370) |
---|---|
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 --- 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, 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 --- 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 |
35static char copyright[] = | 35static const char copyright[] = |
36"@(#) Copyright (c) 1980, 1991, 1993\n\ 37 The Regents of the University of California. All rights reserved.\n"; 38#endif /* not lint */ 39 40#ifndef lint | 36"@(#) Copyright (c) 1980, 1991, 1993\n\ 37 The Regents of the University of California. All rights reserved.\n"; 38#endif /* not lint */ 39 40#ifndef lint |
41#if 0 |
|
41static char sccsid[] = "@(#)tset.c 8.1 (Berkeley) 6/9/93"; | 42static char sccsid[] = "@(#)tset.c 8.1 (Berkeley) 6/9/93"; |
43#endif 44static const char rcdif[] = 45 "$Id$"; |
|
42#endif /* not lint */ 43 44#include <sys/types.h> 45#include <sys/ioctl.h> | 46#endif /* not lint */ 47 48#include <sys/types.h> 49#include <sys/ioctl.h> |
46#include <termios.h> 47#include <errno.h> 48#include <unistd.h> 49#include <stdlib.h> 50#include <stdio.h> | |
51#include <ctype.h> | 50#include <ctype.h> |
51#include <err.h> 52#include <stdio.h> 53#include <stdlib.h> |
|
52#include <string.h> | 54#include <string.h> |
55#include <unistd.h> 56#include <termios.h> |
|
53#include "extern.h" 54 55void obsolete __P((char *[])); 56void report __P((char *, int, u_int)); 57void usage __P((void)); 58 59struct termios mode, oldmode; 60 --- 8 unchanged lines hidden (view full) --- 69main(argc, argv) 70 int argc; 71 char *argv[]; 72{ 73#ifdef TIOCGWINSZ 74 struct winsize win; 75#endif 76 int ch, noinit, noset, quiet, Sflag, sflag, showterm, usingupper; | 57#include "extern.h" 58 59void obsolete __P((char *[])); 60void report __P((char *, int, u_int)); 61void usage __P((void)); 62 63struct termios mode, oldmode; 64 --- 8 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; |
77 char savech, *p, *t, *tcapbuf, *ttype; | 81 char *p, *t, *tcapbuf, *ttype; |
78 79 if (tcgetattr(STDERR_FILENO, &mode) < 0) | 82 83 if (tcgetattr(STDERR_FILENO, &mode) < 0) |
80 err("standard error: %s", strerror(errno)); | 84 err(1, "standard error"); |
81 82 oldmode = mode; 83 Ospeed = cfgetospeed(&mode); 84 | 85 86 oldmode = mode; 87 Ospeed = cfgetospeed(&mode); 88 |
85 if (p = strrchr(*argv, '/')) | 89 if ((p = strrchr(*argv, '/'))) |
86 ++p; 87 else 88 p = *argv; 89 usingupper = isupper(*p); 90 if (!strcasecmp(p, "reset")) { 91 isreset = 1; 92 reset_mode(); 93 } --- 163 unchanged lines hidden (view full) --- 257 * Convert the obsolete argument form into something that getopt can handle. 258 * This means that -e, -i and -k get default arguments supplied for them. 259 */ 260void 261obsolete(argv) 262 char *argv[]; 263{ 264 for (; *argv; ++argv) { | 90 ++p; 91 else 92 p = *argv; 93 usingupper = isupper(*p); 94 if (!strcasecmp(p, "reset")) { 95 isreset = 1; 96 reset_mode(); 97 } --- 163 unchanged lines hidden (view full) --- 261 * Convert the obsolete argument form into something that getopt can handle. 262 * This means that -e, -i and -k get default arguments supplied for them. 263 */ 264void 265obsolete(argv) 266 char *argv[]; 267{ 268 for (; *argv; ++argv) { |
265 if (argv[0][0] != '-' || argv[1] && argv[1][0] != '-' || 266 argv[0][1] != 'e' && argv[0][1] != 'i' && 267 argv[0][1] != 'k' || argv[0][2] != '\0') | 269 if (argv[0][0] != '-' || (argv[1] && argv[1][0] != '-') || 270 (argv[0][1] != 'e' && argv[0][1] != 'i' && argv[0][1] != 'k') || 271 argv[0][2] != '\0') |
268 continue; 269 switch(argv[0][1]) { 270 case 'e': 271 argv[0] = "-e^H"; 272 break; 273 case 'i': 274 argv[0] = "-i^C"; 275 break; 276 case 'k': 277 argv[0] = "-k^U"; 278 break; 279 } 280 } 281} 282 283void 284usage() 285{ | 272 continue; 273 switch(argv[0][1]) { 274 case 'e': 275 argv[0] = "-e^H"; 276 break; 277 case 'i': 278 argv[0] = "-i^C"; 279 break; 280 case 'k': 281 argv[0] = "-k^U"; 282 break; 283 } 284 } 285} 286 287void 288usage() 289{ |
286 (void)fprintf(stderr, 287"usage: tset [-IQrSs] [-] [-e ch] [-i ch] [-k ch] [-m mapping] [terminal]\n"); | 290 (void)fprintf(stderr, "%s\n%s\n", 291"usage: tset [-IQrSs] [-] [-e ch] [-i ch] [-k ch] [-m mapping] [terminal]", 292" reset [-IQrSs] [-] [-e ch] [-i ch] [-k ch] [-m mapping] [terminal]"); |
288 exit(1); 289} | 293 exit(1); 294} |
295 |
|