Deleted Added
full compact
stty.c (59715) stty.c (59788)
1/*-
2 * Copyright (c) 1989, 1991, 1993, 1994
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

--- 28 unchanged lines hidden (view full) ---

37 The Regents of the University of California. All rights reserved.\n";
38#endif /* not lint */
39
40#ifndef lint
41#if 0
42static char sccsid[] = "@(#)stty.c 8.3 (Berkeley) 4/2/94";
43#endif
44static const char rcsid[] =
1/*-
2 * Copyright (c) 1989, 1991, 1993, 1994
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

--- 28 unchanged lines hidden (view full) ---

37 The Regents of the University of California. All rights reserved.\n";
38#endif /* not lint */
39
40#ifndef lint
41#if 0
42static char sccsid[] = "@(#)stty.c 8.3 (Berkeley) 4/2/94";
43#endif
44static const char rcsid[] =
45 "$FreeBSD: head/bin/stty/stty.c 59715 2000-04-27 21:45:41Z ache $";
45 "$FreeBSD: head/bin/stty/stty.c 59788 2000-04-30 17:04:26Z ache $";
46#endif /* not lint */
47
48#include <sys/types.h>
49
50#include <ctype.h>
51#include <err.h>
52#include <errno.h>
53#include <fcntl.h>

--- 44 unchanged lines hidden (view full) ---

98 argv += optind;
99
100 if (tcgetattr(i.fd, &i.t) < 0)
101 errx(1, "stdin isn't a terminal");
102 if (ioctl(i.fd, TIOCGETD, &i.ldisc) < 0)
103 err(1, "TIOCGETD");
104 if (ioctl(i.fd, TIOCGWINSZ, &i.win) < 0)
105 warn("TIOCGWINSZ: %s\n", strerror(errno));
46#endif /* not lint */
47
48#include <sys/types.h>
49
50#include <ctype.h>
51#include <err.h>
52#include <errno.h>
53#include <fcntl.h>

--- 44 unchanged lines hidden (view full) ---

98 argv += optind;
99
100 if (tcgetattr(i.fd, &i.t) < 0)
101 errx(1, "stdin isn't a terminal");
102 if (ioctl(i.fd, TIOCGETD, &i.ldisc) < 0)
103 err(1, "TIOCGETD");
104 if (ioctl(i.fd, TIOCGWINSZ, &i.win) < 0)
105 warn("TIOCGWINSZ: %s\n", strerror(errno));
106 if (ioctl(i.fd, TIOCGDRAINWAIT, &i.timeout) < 0)
107 warn("TIOCGDRAINWAIT: %s\n", strerror(errno));
108
109 checkredirect(); /* conversion aid */
110
111 switch(fmt) {
112 case NOTSET:
113 if (*argv)
114 break;
115 /* FALLTHROUGH */
116 case BSD:
117 case POSIX:
106
107 checkredirect(); /* conversion aid */
108
109 switch(fmt) {
110 case NOTSET:
111 if (*argv)
112 break;
113 /* FALLTHROUGH */
114 case BSD:
115 case POSIX:
118 print(&i.t, &i.win, i.ldisc, i.timeout, fmt);
116 print(&i.t, &i.win, i.ldisc, fmt);
119 break;
120 case GFLAG:
117 break;
118 case GFLAG:
121 gprint(&i.t, &i.win, i.ldisc, i.timeout);
119 gprint(&i.t, &i.win, i.ldisc);
122 break;
123 }
124
120 break;
121 }
122
125 for (i.set = i.wset = i.tset = 0; *argv; ++argv) {
123 for (i.set = i.wset = 0; *argv; ++argv) {
126 if (ksearch(&argv, &i))
127 continue;
128
129 if (csearch(&argv, &i))
130 continue;
131
132 if (msearch(&argv, &i))
133 continue;

--- 4 unchanged lines hidden (view full) ---

138 speed = atoi(*argv);
139 cfsetospeed(&i.t, speed);
140 cfsetispeed(&i.t, speed);
141 i.set = 1;
142 continue;
143 }
144
145 if (!strncmp(*argv, "gfmt1", sizeof("gfmt1") - 1)) {
124 if (ksearch(&argv, &i))
125 continue;
126
127 if (csearch(&argv, &i))
128 continue;
129
130 if (msearch(&argv, &i))
131 continue;

--- 4 unchanged lines hidden (view full) ---

136 speed = atoi(*argv);
137 cfsetospeed(&i.t, speed);
138 cfsetispeed(&i.t, speed);
139 i.set = 1;
140 continue;
141 }
142
143 if (!strncmp(*argv, "gfmt1", sizeof("gfmt1") - 1)) {
146 gread(&i, *argv + sizeof("gfmt1") - 1);
144 gread(&i.t, *argv + sizeof("gfmt1") - 1);
145 i.set = 1;
147 continue;
148 }
149
150 warnx("illegal option -- %s", *argv);
151 usage();
152 }
153
154 if (i.set && tcsetattr(i.fd, 0, &i.t) < 0)
155 err(1, "tcsetattr");
156 if (i.wset && ioctl(i.fd, TIOCSWINSZ, &i.win) < 0)
157 warn("TIOCSWINSZ");
146 continue;
147 }
148
149 warnx("illegal option -- %s", *argv);
150 usage();
151 }
152
153 if (i.set && tcsetattr(i.fd, 0, &i.t) < 0)
154 err(1, "tcsetattr");
155 if (i.wset && ioctl(i.fd, TIOCSWINSZ, &i.win) < 0)
156 warn("TIOCSWINSZ");
158 if (i.tset && ioctl(i.fd, TIOCSDRAINWAIT, &i.timeout) < 0)
159 warn("TIOCSDRAINWAIT");
160 exit(0);
161}
162
163void
164usage()
165{
166
167 (void)fprintf(stderr, "usage: stty [-a|-e|-g] [-f file] [options]\n");
168 exit (1);
169}
157 exit(0);
158}
159
160void
161usage()
162{
163
164 (void)fprintf(stderr, "usage: stty [-a|-e|-g] [-f file] [options]\n");
165 exit (1);
166}