4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
32 #include <sys/types.h>
34 #include <sys/stermio.h>
35 #include <sys/termiox.h>
38 extern char *getenv();
42 static char *STTY
= "stty: ";
43 static char *USAGE
= "usage: stty [-agh] [modes]\n";
45 static struct termios cb
;
46 static struct termio ocb
; /* for non-streams devices */
47 static struct stio stio
;
48 static struct termiox termiox
;
49 static struct winsize winsize
, owinsize
;
56 void pit(unsigned char, char *, char *);
57 void delay(int, char *s
);
58 void prspeed(char *, int);
65 main(int argc
, char *argv
[])
69 char *s_arg
, *sttyparse(); /* s_arg: ptr to mode to be set */
70 extern const struct speeds speeds
[];
74 * "stty size", "stty speed" and "stty -g" are intended for
75 * use within backquotes; thus, they do the "fetch" "ioctl"
76 * from "/dev/tty" and always print their result on the
78 * Since their standard output is likely to be a pipe, they
79 * should not try to read the modes from the standard output.
81 if (strcmp(argv
[1], "size") == 0) {
82 if ((i
= open("/dev/tty", 0)) < 0) {
83 perror("stty: Cannot open /dev/tty");
86 if (ioctl(i
, TIOCGWINSZ
, &winsize
) < 0) {
87 perror("stty: TIOCGWINSZ");
90 (void) printf("%d %d\n",
91 winsize
.ws_row
, winsize
.ws_col
);
93 } else if (strcmp(argv
[1], "speed") == 0) {
94 if ((i
= open("/dev/tty", 0)) < 0) {
95 perror("stty: Cannot open /dev/tty");
98 if ((term
= get_ttymode(i
,
99 &ocb
, &cb
, &stio
, &termiox
, &winsize
)) < 0) {
103 if (term
& TERMIOS
) {
104 for (i
= 0; speeds
[i
].string
; i
++)
105 if (cfgetospeed(&cb
) ==
107 (void) printf("%s\n",
112 for (i
= 0; speeds
[i
].string
; i
++)
113 if ((cb
.c_cflag
&CBAUD
) ==
115 (void) printf("%s\n",
120 (void) printf("unknown\n");
122 } else if (strcmp(argv
[1], "-g") == 0) {
123 if ((i
= open("/dev/tty", 0)) < 0) {
124 perror("stty: Cannot open /dev/tty");
127 if ((term
= get_ttymode(i
,
128 &ocb
, &cb
, &stio
, &termiox
, &winsize
)) < 0) {
137 if ((term
= get_ttymode(ioctl_desc
,
138 &ocb
, &cb
, &stio
, &termiox
, &winsize
)) < 0) {
147 if ((argc
== 2) && strcmp(argv
[1], "all") == 0) {
151 if ((argc
== 2) && strcmp(argv
[1], "everything") == 0) {
155 if ((argc
== 2) && (argv
[1][0] == '-') && (argv
[1][2] == '\0'))
156 switch (argv
[1][1]) {
164 (void) fprintf(stderr
, "%s", USAGE
);
167 if (s_arg
= sttyparse(argc
, argv
,
168 term
, &ocb
, &cb
, &termiox
, &winsize
)) {
169 (void) fprintf(stderr
, "unknown mode: %s\n", s_arg
);
173 if (set_ttymode(ioctl_desc
,
174 term
, &ocb
, &cb
, &stio
, &termiox
, &winsize
, &owinsize
) == -1) {
178 return (0); /*NOTREACHED*/
182 prmodes(int moremodes
)
183 /* print modes, no options, argc is 1 */
187 if (!(term
& ASYNC
)) {
190 (void) fprintf(output
, "iuclc ");
192 (void) fprintf(output
, "-iuclc ");
195 (void) fprintf(output
, "olcuc ");
197 (void) fprintf(output
, "-olcuc ");
199 (void) fprintf(output
, "tab3 ");
202 (void) fprintf(output
, "xcase ");
204 (void) fprintf(output
, "-xcase ");
206 (void) fprintf(output
, "stflush ");
208 (void) fprintf(output
, "-stflush ");
210 (void) fprintf(output
, "stwrap ");
212 (void) fprintf(output
, "-stwrap ");
214 (void) fprintf(output
, "stappl ");
216 (void) fprintf(output
, "-stappl ");
217 (void) fprintf(output
, "\n");
221 if ((term
& TERMIOS
) && cfgetispeed(&cb
) != 0 &&
222 cfgetispeed(&cb
) != cfgetospeed(&cb
)) {
223 prspeed("ispeed ", cfgetispeed(&cb
));
224 prspeed("ospeed ", cfgetospeed(&cb
));
226 prspeed("speed ", cfgetospeed(&cb
));
228 if ((m
& PAREXT
) && (term
& TERMIOS
)) {
230 (void) fprintf(output
, "markp ");
232 (void) fprintf(output
, "spacep ");
235 (void) fprintf(output
, "oddp ");
237 (void) fprintf(output
, "evenp ");
240 (void) fprintf(output
, "-parity ");
241 if (((m
& PARENB
) && !(m
& CS7
)) ||
242 (!(m
& PARENB
) && !(m
& CS8
)))
243 (void) fprintf(output
, "cs%c ", '5' + (m
& CSIZE
)/CS6
);
245 (void) fprintf(output
, "cstopb ");
247 (void) fprintf(output
, "hupcl ");
249 (void) fprintf(output
, "-cread ");
251 (void) fprintf(output
, "clocal ");
253 (void) fprintf(output
, "loblk ");
254 (void) fprintf(output
, "\n");
256 (void) fprintf(output
, "line = %d; ", ocb
.c_line
);
258 (void) fprintf(output
, "rows = %d; columns = %d;",
259 winsize
.ws_row
, winsize
.ws_col
);
260 (void) fprintf(output
, " ypixels = %d; xpixels = %d;\n",
261 winsize
.ws_ypixel
, winsize
.ws_xpixel
);
263 if ((cb
.c_lflag
& ICANON
) == 0)
264 (void) fprintf(output
, "min = %d; time = %d;\n",
265 cb
.c_cc
[VMIN
], cb
.c_cc
[VTIME
]);
267 if (cb
.c_cc
[VINTR
] != CINTR
)
268 pit(cb
.c_cc
[VINTR
], "intr", "; ");
269 if (cb
.c_cc
[VQUIT
] != CQUIT
)
270 pit(cb
.c_cc
[VQUIT
], "quit", "; ");
271 if (cb
.c_cc
[VERASE
] != CERASE
)
272 pit(cb
.c_cc
[VERASE
], "erase", "; ");
273 if (cb
.c_cc
[VKILL
] != CKILL
)
274 pit(cb
.c_cc
[VKILL
], "kill", "; ");
275 if (cb
.c_cc
[VEOF
] != CEOF
)
276 pit(cb
.c_cc
[VEOF
], "eof", "; ");
277 if (cb
.c_cc
[VEOL
] != CNUL
)
278 pit(cb
.c_cc
[VEOL
], "eol", "; ");
279 if (cb
.c_cc
[VEOL2
] != CNUL
)
280 pit(cb
.c_cc
[VEOL2
], "eol2", "; ");
281 if (cb
.c_cc
[VSWTCH
] != CSWTCH
)
282 pit(cb
.c_cc
[VSWTCH
], "swtch", "; ");
283 if (term
& TERMIOS
) {
284 if (cb
.c_cc
[VSTART
] != CSTART
)
285 pit(cb
.c_cc
[VSTART
], "start", "; ");
286 if (cb
.c_cc
[VSTOP
] != CSTOP
)
287 pit(cb
.c_cc
[VSTOP
], "stop", "; ");
288 if (cb
.c_cc
[VSUSP
] != CSUSP
)
289 pit(cb
.c_cc
[VSUSP
], "susp", "; ");
290 if (cb
.c_cc
[VDSUSP
] != CDSUSP
)
291 pit(cb
.c_cc
[VDSUSP
], "dsusp", "; ");
292 if (cb
.c_cc
[VREPRINT
] != CRPRNT
)
293 pit(cb
.c_cc
[VREPRINT
], "rprnt", "; ");
294 if (cb
.c_cc
[VDISCARD
] != CFLUSH
)
295 pit(cb
.c_cc
[VDISCARD
], "flush", "; ");
296 if (cb
.c_cc
[VWERASE
] != CWERASE
)
297 pit(cb
.c_cc
[VWERASE
], "werase", "; ");
298 if (cb
.c_cc
[VLNEXT
] != CLNEXT
)
299 pit(cb
.c_cc
[VLNEXT
], "lnext", "; ");
303 (void) fprintf(output
, "\n");
306 (void) fprintf(output
, "ignbrk ");
307 else if (!(m
& BRKINT
))
308 (void) fprintf(output
, "-brkint ");
310 (void) fprintf(output
, "-inpck ");
311 else if (!(m
& IGNPAR
))
312 (void) fprintf(output
, "-ignpar ");
314 (void) fprintf(output
, "parmrk ");
316 (void) fprintf(output
, "-istrip ");
318 (void) fprintf(output
, "inlcr ");
320 (void) fprintf(output
, "igncr ");
322 (void) fprintf(output
, "-icrnl ");
324 (void) fprintf(output
, "iuclc ");
326 (void) fprintf(output
, "-ixon ");
328 (void) fprintf(output
, "ixany ");
330 (void) fprintf(output
, "ixoff ");
331 if ((term
& TERMIOS
) && (m
& IMAXBEL
))
332 (void) fprintf(output
, "imaxbel ");
335 (void) fprintf(output
, "-opost ");
338 (void) fprintf(output
, "olcuc ");
340 (void) fprintf(output
, "-onlcr ");
342 (void) fprintf(output
, "ocrnl ");
344 (void) fprintf(output
, "onocr ");
346 (void) fprintf(output
, "onlret ");
349 (void) fprintf(output
, "del-fill ");
351 (void) fprintf(output
, "nul-fill ");
352 delay((m
& CRDLY
)/CR1
, "cr");
353 delay((m
& NLDLY
)/NL1
, "nl");
354 if ((m
& TABDLY
) == XTABS
)
355 (void) fprintf(output
, "-tabs ");
357 delay((m
& TABDLY
)/TAB1
, "tab");
358 delay((m
& BSDLY
)/BS1
, "bs");
359 delay((m
& VTDLY
)/VT1
, "vt");
360 delay((m
& FFDLY
)/FF1
, "ff");
362 (void) fprintf(output
, "\n");
365 (void) fprintf(output
, "-isig ");
367 (void) fprintf(output
, "-icanon ");
369 (void) fprintf(output
, "xcase ");
371 (void) fprintf(output
, "-echo ");
374 (void) fprintf(output
, "crt ");
376 (void) fprintf(output
, "echoe -echoke ");
379 (void) fprintf(output
, "-echoprt ");
382 (void) fprintf(output
, "-echok ");
384 (void) fprintf(output
, "echonl ");
386 (void) fprintf(output
, "noflsh ");
388 (void) fprintf(output
, "tostop ");
390 (void) fprintf(output
, "-echoctl ");
392 (void) fprintf(output
, "defecho ");
394 (void) fprintf(output
, "flusho ");
396 (void) fprintf(output
, "pendin ");
398 (void) fprintf(output
, "iexten ");
399 (void) fprintf(output
, "\n");
404 (void) fprintf(output
, "rtsxoff ");
406 (void) fprintf(output
, "ctsxon ");
408 (void) fprintf(output
, "dterxoff ");
410 (void) fprintf(output
, "rlsdxon ");
412 (void) fprintf(output
, "isxoff ");
414 switch (m
& XMTCLK
) {
416 (void) fprintf(output
, "xcibrg ");
419 (void) fprintf(output
, "xctset ");
422 (void) fprintf(output
, "xcrset ");
426 switch (m
& RCVCLK
) {
428 (void) fprintf(output
, "rcibrg ");
431 (void) fprintf(output
, "rctset ");
434 (void) fprintf(output
, "rcrset ");
438 switch (m
& TSETCLK
) {
440 (void) fprintf(output
, "tsetcoff ");
443 (void) fprintf(output
, "tsetcrc ");
446 (void) fprintf(output
, "tsetcxc ");
450 switch (m
& RSETCLK
) {
452 (void) fprintf(output
, "rsetcoff ");
455 (void) fprintf(output
, "rsetcrc ");
458 (void) fprintf(output
, "rsetcxc ");
460 (void) fprintf(output
, "\n");
467 pramodes(int tabform
)
468 /* print all modes, -a option */
474 if ((term
& TERMIOS
) && cfgetispeed(&cb
) != 0 &&
475 cfgetispeed(&cb
) != cfgetospeed(&cb
)) {
476 prspeed("ispeed ", cfgetispeed(&cb
));
477 prspeed("ospeed ", cfgetospeed(&cb
));
479 prspeed("speed ", cfgetospeed(&cb
));
480 if (!(term
& TERMIOS
))
481 (void) fprintf(output
, "line = %d; ", ocb
.c_line
);
482 (void) fprintf(output
, "\n");
484 (void) fprintf(output
, "rows = %d columns = %d; ",
485 winsize
.ws_row
, winsize
.ws_col
);
486 (void) fprintf(output
, "ypixels = %d xpixels = %d\n",
487 winsize
.ws_ypixel
, winsize
.ws_xpixel
);
489 if ((cb
.c_lflag
& ICANON
) == 0)
490 (void) fprintf(output
, "min = %d; time = %d;\n",
491 cb
.c_cc
[VMIN
], cb
.c_cc
[VTIME
]);
493 pit(cb
.c_cc
[VINTR
], "intr", "; ");
494 pit(cb
.c_cc
[VQUIT
], "quit", "; ");
495 pit(cb
.c_cc
[VERASE
], "erase", "; ");
496 pit(cb
.c_cc
[VKILL
], "kill", ";\n");
497 pit(cb
.c_cc
[VEOF
], "eof", "; ");
498 pit(cb
.c_cc
[VEOL
], "eol", "; ");
499 pit(cb
.c_cc
[VEOL2
], "eol2", "; ");
500 pit(cb
.c_cc
[VSWTCH
], "swtch", ";\n");
501 if (term
& TERMIOS
) {
502 pit(cb
.c_cc
[VSTART
], "start", "; ");
503 pit(cb
.c_cc
[VSTOP
], "stop", "; ");
504 pit(cb
.c_cc
[VSUSP
], "susp", "; ");
505 pit(cb
.c_cc
[VDSUSP
], "dsusp", ";\n");
506 pit(cb
.c_cc
[VREPRINT
], "rprnt", "; ");
507 pit(cb
.c_cc
[VDISCARD
], "flush", "; ");
508 pit(cb
.c_cc
[VWERASE
], "werase", "; ");
509 pit(cb
.c_cc
[VLNEXT
], "lnext", ";\n");
513 pit((unsigned)stio
.tab
, "ctab", "\n");
515 (void) fprintf(output
, "-parenb " + ((m
& PARENB
) != 0));
516 (void) fprintf(output
, "-parodd " + ((m
& PARODD
) != 0));
517 (void) fprintf(output
, "cs%c ", '5'+ (m
& CSIZE
)/CS6
);
518 (void) fprintf(output
, "-cstopb " + ((m
& CSTOPB
) != 0));
519 (void) fprintf(output
, "-hupcl " + ((m
& HUPCL
) != 0));
520 (void) fprintf(output
, "-cread " + ((m
& CREAD
) != 0));
521 (void) fprintf(output
, "-clocal " + ((m
& CLOCAL
) != 0));
523 (void) fprintf(output
, "-loblk " + ((m
& LOBLK
) != 0));
525 (void) fprintf(output
, "-parext " + ((m
& PAREXT
) != 0));
527 (void) fprintf(output
, "\n");
529 (void) fprintf(output
, "-ignbrk " + ((m
& IGNBRK
) != 0));
530 (void) fprintf(output
, "-brkint " + ((m
& BRKINT
) != 0));
531 (void) fprintf(output
, "-ignpar " + ((m
& IGNPAR
) != 0));
532 (void) fprintf(output
, "-parmrk " + ((m
& PARMRK
) != 0));
533 (void) fprintf(output
, "-inpck " + ((m
& INPCK
) != 0));
534 (void) fprintf(output
, "-istrip " + ((m
& ISTRIP
) != 0));
535 (void) fprintf(output
, "-inlcr " + ((m
& INLCR
) != 0));
536 (void) fprintf(output
, "-igncr " + ((m
& IGNCR
) != 0));
537 (void) fprintf(output
, "-icrnl " + ((m
& ICRNL
) != 0));
538 (void) fprintf(output
, "-iuclc " + ((m
& IUCLC
) != 0));
539 (void) fprintf(output
, "\n");
540 (void) fprintf(output
, "-ixon " + ((m
& IXON
) != 0));
541 (void) fprintf(output
, "-ixany " + ((m
& IXANY
) != 0));
542 (void) fprintf(output
, "-ixoff " + ((m
& IXOFF
) != 0));
544 (void) fprintf(output
, "-imaxbel " + ((m
& IMAXBEL
) != 0));
545 (void) fprintf(output
, "\n");
547 (void) fprintf(output
, "-isig " + ((m
& ISIG
) != 0));
548 (void) fprintf(output
, "-icanon " + ((m
& ICANON
) != 0));
549 (void) fprintf(output
, "-xcase " + ((m
& XCASE
) != 0));
550 (void) fprintf(output
, "-echo " + ((m
& ECHO
) != 0));
551 (void) fprintf(output
, "-echoe " + ((m
& ECHOE
) != 0));
552 (void) fprintf(output
, "-echok " + ((m
& ECHOK
) != 0));
553 (void) fprintf(output
, "-echonl " + ((m
& ECHONL
) != 0));
554 (void) fprintf(output
, "-noflsh " + ((m
& NOFLSH
) != 0));
555 if (term
& TERMIOS
) {
556 (void) fprintf(output
, "\n");
557 (void) fprintf(output
, "-tostop " + ((m
& TOSTOP
) != 0));
558 (void) fprintf(output
, "-echoctl " + ((m
& ECHOCTL
) != 0));
559 (void) fprintf(output
, "-echoprt " + ((m
& ECHOPRT
) != 0));
560 (void) fprintf(output
, "-echoke " + ((m
& ECHOKE
) != 0));
561 (void) fprintf(output
, "-defecho " + ((m
& DEFECHO
) != 0));
562 (void) fprintf(output
, "-flusho " + ((m
& FLUSHO
) != 0));
563 (void) fprintf(output
, "-pendin " + ((m
& PENDIN
) != 0));
564 (void) fprintf(output
, "-iexten " + ((m
& IEXTEN
) != 0));
566 if (!(term
& ASYNC
)) {
567 (void) fprintf(output
, "-stflush " + ((m
& STFLUSH
) != 0));
568 (void) fprintf(output
, "-stwrap " + ((m
& STWRAP
) != 0));
569 (void) fprintf(output
, "-stappl " + ((m
& STAPPL
) != 0));
571 (void) fprintf(output
, "\n");
573 (void) fprintf(output
, "-opost " + ((m
& OPOST
) != 0));
574 (void) fprintf(output
, "-olcuc " + ((m
& OLCUC
) != 0));
575 (void) fprintf(output
, "-onlcr " + ((m
& ONLCR
) != 0));
576 (void) fprintf(output
, "-ocrnl " + ((m
& OCRNL
) != 0));
577 (void) fprintf(output
, "-onocr " + ((m
& ONOCR
) != 0));
578 (void) fprintf(output
, "-onlret " + ((m
& ONLRET
) != 0));
579 (void) fprintf(output
, "-ofill " + ((m
& OFILL
) != 0));
580 (void) fprintf(output
, "-ofdel " + ((m
& OFDEL
) != 0));
581 delay((m
& CRDLY
)/CR1
, "cr");
582 delay((m
& NLDLY
)/NL1
, "nl");
583 if ((m
& TABDLY
) == XTABS
)
584 (void) fprintf(output
, "-tabs ");
586 delay((m
& TABDLY
)/TAB1
, "tab");
587 delay((m
& BSDLY
)/BS1
, "bs");
588 delay((m
& VTDLY
)/VT1
, "vt");
589 delay((m
& FFDLY
)/FF1
, "ff");
590 (void) fprintf(output
, "\n");
593 (void) fprintf(output
, "-rtsxoff " + ((m
& RTSXOFF
) != 0));
594 (void) fprintf(output
, "-ctsxon " + ((m
& CTSXON
) != 0));
595 (void) fprintf(output
, "-dterxoff " + ((m
& DTRXOFF
) != 0));
596 (void) fprintf(output
, "-rlsdxon " + ((m
& CDXON
) != 0));
597 (void) fprintf(output
, "-isxoff " + ((m
& ISXOFF
) != 0));
599 switch (m
& XMTCLK
) {
601 (void) fprintf(output
, "xcibrg ");
604 (void) fprintf(output
, "xctset ");
607 (void) fprintf(output
, "xcrset ");
611 switch (m
& RCVCLK
) {
613 (void) fprintf(output
, "rcibrg ");
616 (void) fprintf(output
, "rctset ");
619 (void) fprintf(output
, "rcrset ");
623 switch (m
& TSETCLK
) {
625 (void) fprintf(output
, "tsetcoff ");
628 (void) fprintf(output
, "tsetcrc ");
631 (void) fprintf(output
, "tsetcxc ");
635 switch (m
& RSETCLK
) {
637 (void) fprintf(output
, "rsetcoff ");
640 (void) fprintf(output
, "rsetcrc ");
643 (void) fprintf(output
, "rsetcxc ");
646 (void) fprintf(output
, "\n");
655 if ((cb
.c_lflag
& ICANON
) == 0)
656 (void) fprintf(output
, "min %d, time %d\n", cb
.c_cc
[VMIN
],
658 (void) fprintf(output
, "\
659 erase kill werase rprnt flush lnext susp intr quit stop eof\
661 pcol(cb
.c_cc
[VERASE
], 0);
662 pcol(cb
.c_cc
[VKILL
], 0);
663 pcol(cb
.c_cc
[VWERASE
], 0);
664 pcol(cb
.c_cc
[VREPRINT
], 0);
665 pcol(cb
.c_cc
[VDISCARD
], 0);
666 pcol(cb
.c_cc
[VLNEXT
], 0);
667 pcol(cb
.c_cc
[VSUSP
], cb
.c_cc
[VDSUSP
]);
668 pcol(cb
.c_cc
[VINTR
], 0);
669 pcol(cb
.c_cc
[VQUIT
], 0);
670 pcol(cb
.c_cc
[VSTOP
], cb
.c_cc
[VSTART
]);
671 if (cb
.c_lflag
&ICANON
)
672 pcol(cb
.c_cc
[VEOF
], cb
.c_cc
[VEOL
]);
673 (void) fprintf(output
, "\n");
674 if (cb
.c_cc
[VEOL2
] != 0 || cb
.c_cc
[VSWTCH
] != 0) {
675 (void) fprintf(output
, "\
678 pcol(cb
.c_cc
[VEOL2
], 0);
679 pcol(cb
.c_cc
[VSWTCH
], 0);
680 (void) fprintf(output
, "\n");
685 pcol(int ch1
, int ch2
)
693 for (; ch1
!= 0 || ch2
!= 0; ch1
= ch2
, ch2
= 0) {
696 if (ch1
& 0200 && !isprint(ch1
)) {
697 (void) fprintf(output
, "M-");
702 (void) fprintf(output
, "^");
705 } else if (ch1
< ' ') {
706 (void) fprintf(output
, "^");
710 (void) fprintf(output
, "%c", ch1
);
713 (void) fprintf(output
, "/");
718 (void) fprintf(output
, " ");
724 pit(unsigned char what
, char *itsname
, char *sep
)
725 /* print function for prmodes() and pramodes() */
729 (void) fprintf(output
, "%s", itsname
);
730 if ((term
& TERMIOS
) && what
== _POSIX_VDISABLE
||
731 !(term
& TERMIOS
) && what
== 0200) {
732 (void) fprintf(output
, " = <undef>%s", sep
);
735 (void) fprintf(output
, " = ");
736 if (what
& 0200 && !isprint(what
)) {
737 (void) fprintf(output
, "-");
741 (void) fprintf(output
, "^?%s", sep
);
743 } else if (what
< ' ') {
744 (void) fprintf(output
, "^");
747 (void) fprintf(output
, "%c%s", what
, sep
);
751 delay(int m
, char *s
)
754 (void) fprintf(output
, "%s%d ", s
, m
);
758 0, 50, 75, 110, 134, 150, 200, 300,
759 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400,
760 57600, 76800, 115200, 153600, 230400, 307200, 460800, 921600
764 prspeed(char *c
, int s
)
766 (void) fprintf(output
, "%s%d baud; ", c
, speed
[s
]);
770 * print current settings for use with
771 * another stty cmd, used for -g option
778 /* Since the -g option is mostly used for redirecting to a file */
779 /* We must print to stdout here, not stderr */
781 (void) printf("%x:%x:%x:%x:", cb
.c_iflag
, cb
.c_oflag
,
782 cb
.c_cflag
, cb
.c_lflag
);
785 /* last control slot is unused */
789 for (i
= 0; i
< last
; i
++)
790 (void) printf("%x:", cb
.c_cc
[i
]);
791 (void) printf("%x\n", cb
.c_cc
[last
]);