Commit | Line | Data |
---|---|---|
7c1f1e23 | 1 | /*- |
f1fd7d4e MK |
2 | * Copyright (c) 1989 The Regents of the University of California. |
3 | * All rights reserved. | |
4 | * | |
7c1f1e23 | 5 | * %sccs.include.redist.c% |
f1fd7d4e MK |
6 | */ |
7 | ||
8 | #if defined(LIBC_SCCS) && !defined(lint) | |
7c1f1e23 | 9 | static char sccsid[] = "@(#)termios.c 5.2 (Berkeley) %G%"; |
f1fd7d4e MK |
10 | #endif /* LIBC_SCCS and not lint */ |
11 | ||
816ee792 MT |
12 | #include <sys/types.h> |
13 | #include <sys/errno.h> | |
7c1f1e23 | 14 | #include <sys/ioctl.h> |
816ee792 | 15 | #include <sys/tty.h> |
7c1f1e23 | 16 | #include <sys/termios.h> |
816ee792 MT |
17 | #include <stdio.h> |
18 | ||
19 | tcgetattr(fd, t) | |
20 | int fd; | |
21 | struct termios *t; | |
22 | { | |
23 | extern errno; | |
24 | ||
25 | return(ioctl(fd, TIOCGETA, t)); | |
26 | } | |
27 | ||
28 | tcsetattr(fd, opt, t) | |
29 | int fd, opt; | |
30 | struct termios *t; | |
31 | { | |
7c1f1e23 | 32 | struct termios localterm; |
816ee792 | 33 | |
7c1f1e23 MT |
34 | if (opt & TCSASOFT) { |
35 | localterm = *t; | |
36 | localterm.c_cflag |= CIGNORE; | |
37 | t = &localterm; | |
38 | opt &= TCSASOFT; | |
816ee792 | 39 | } |
7c1f1e23 MT |
40 | if (opt == TCSANOW) |
41 | return (ioctl(fd, TIOCSETA, t)); | |
42 | else if (opt == TCSADRAIN) | |
43 | return (ioctl(fd, TIOCSETAW, t)); | |
44 | else | |
45 | return (ioctl(fd, TIOCSETAF, t)); | |
816ee792 MT |
46 | } |
47 | ||
48 | tcsetpgrp(fd, pgrp) | |
49 | { | |
50 | return(ioctl(fd, TIOCSPGRP, &pgrp)); | |
51 | } | |
52 | ||
53 | tcgetpgrp(fd) | |
54 | { | |
55 | int pgrp; | |
56 | ||
57 | if (ioctl(fd, TIOCGPGRP, &pgrp) < 0) | |
58 | return(-1); | |
59 | return(pgrp); | |
60 | } | |
61 | ||
62 | cfgetospeed(t) | |
63 | struct termios *t; | |
64 | { | |
65 | return(t->c_ospeed); | |
66 | } | |
67 | ||
68 | cfgetispeed(t) | |
69 | struct termios *t; | |
70 | { | |
71 | return(t->c_ispeed); | |
72 | } | |
73 | ||
74 | cfsetospeed(t, speed) | |
75 | struct termios *t; | |
76 | { | |
77 | t->c_ospeed = speed; | |
78 | } | |
79 | ||
80 | cfsetispeed(t, speed) | |
81 | struct termios *t; | |
82 | { | |
83 | t->c_ispeed = speed; | |
84 | } | |
85 | ||
86 | cfsetspeed(t, speed) | |
87 | struct termios *t; | |
88 | { | |
89 | t->c_ispeed = t->c_ospeed = speed; | |
90 | } | |
91 | ||
92 | cfmakeraw(t) | |
93 | struct termios *t; | |
94 | { | |
9de4492f | 95 | t->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|INLCR|IGNCR|ICRNL|IXON); |
816ee792 | 96 | t->c_oflag &= ~(ONLCR|OXTABS); |
9de4492f | 97 | t->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN); |
816ee792 MT |
98 | /* set MIN/TIME */ |
99 | } |