-
Notifications
You must be signed in to change notification settings - Fork 362
/
termios.c
200 lines (178 loc) · 6.58 KB
/
termios.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#if defined(SCALANATIVE_COMPILE_ALWAYS) || defined(__SCALANATIVE_POSIX_TERMIOS)
#if defined(__unix__) || defined(__unix) || defined(unix) || \
(defined(__APPLE__) && defined(__MACH__))
#include <termios.h>
#if defined(__FreeBSD__)
#define COMPAT_43TTY
#include <sys/ioctl_compat.h>
#define NLDLY NLDELAY
#define CRDLY CRDELAY
#define BSDLY BSDELAY
#define VTDLY VTDELAY
#endif
#if defined(__OpenBSD__) || defined(__NetBSD__)
// OpenBSD and NetBSD has missed some constatn, use 0 instead
#define NLDLY 0
#define CRDLY 0
#define BSDLY 0
#define VTDLY 0
#define BS0 0
#define BS1 0
#define CR0 0
#define CR1 0
#define CR2 0
#define CR3 0
#define FF0 0
#define FF1 0
#define NL0 0
#define NL1 0
#define TAB1 0
#define TAB2 0
// NetBSD requires a few more
#ifdef __NetBSD__
#define TABDLY 0
#define TAB0 0
#define TAB3 0
#endif // NetBSD
#endif // OpenBSD || NetBSD
// symbolic constants for use as subscripts for the array c_cc
int scalanative_termios_veof() { return VEOF; }
int scalanative_termios_veol() { return VEOL; }
int scalanative_termios_verase() { return VERASE; }
int scalanative_termios_vintr() { return VINTR; }
int scalanative_termios_vkill() { return VKILL; }
int scalanative_termios_vmin() { return VMIN; }
int scalanative_termios_vquit() { return VQUIT; }
int scalanative_termios_vstart() { return VSTART; }
int scalanative_termios_vstop() { return VSTOP; }
int scalanative_termios_vsusp() { return VSUSP; }
int scalanative_termios_vtime() { return VTIME; }
// Input Modes - symbolic constants for use as flags in the c_iflag field
int scalanative_termios_brkint() { return BRKINT; }
int scalanative_termios_icrnl() { return ICRNL; }
int scalanative_termios_ignbrk() { return IGNBRK; }
int scalanative_termios_igncr() { return IGNCR; }
int scalanative_termios_ignpar() { return IGNPAR; }
int scalanative_termios_inlcr() { return INLCR; }
int scalanative_termios_inpck() { return INPCK; }
int scalanative_termios_istrip() { return ISTRIP; }
int scalanative_termios_ixany() { return IXANY; }
int scalanative_termios_ixoff() { return IXOFF; }
int scalanative_termios_ixon() { return IXON; }
int scalanative_termios_parmrk() { return PARMRK; }
// Output Modes - symbolic constants for use as flags in the c_oflag field
int scalanative_termios_opost() { return OPOST; }
// [XSI] follows
int scalanative_termios_onlcr() { return ONLCR; }
int scalanative_termios_ocrnl() { return OCRNL; }
int scalanative_termios_onocr() { return ONOCR; }
int scalanative_termios_onlret() { return ONLRET; }
int scalanative_termios_ofdel() {
#ifdef OFDEL
return OFDEL;
#else
return 0;
#endif
}
int scalanative_termios_ofill() {
#ifdef OFILL
return OFILL;
#else
return 0;
#endif
}
// Masks - Linux [requires _BSD_SOURCE or _SVID_SOURCE or _XOPEN_SOURCE]
int scalanative_termios_nldly() { return NLDLY; }
int scalanative_termios_nl0() { return NL0; }
int scalanative_termios_nl1() { return NL1; }
int scalanative_termios_crdly() { return CRDLY; }
int scalanative_termios_cr0() { return CR0; }
int scalanative_termios_cr1() { return CR1; }
int scalanative_termios_cr2() { return CR2; }
int scalanative_termios_cr3() { return CR3; }
int scalanative_termios_tabdly() { return TABDLY; }
int scalanative_termios_tab0() { return TAB0; }
int scalanative_termios_tab1() { return TAB1; }
int scalanative_termios_tab2() { return TAB2; }
int scalanative_termios_tab3() { return TAB3; }
int scalanative_termios_bsdly() { return BSDLY; }
int scalanative_termios_bs0() { return BS0; }
int scalanative_termios_bs1() { return BS1; }
int scalanative_termios_vtdly() { return VTDLY; }
int scalanative_termios_vt0() {
#ifdef VT0
return VT0;
#else
return 0;
#endif
}
int scalanative_termios_vt1() {
#ifdef VT1
return VT1;
#else
return 0;
#endif
}
int scalanative_termios_ffdly() {
#ifdef FFDLY
return FFDLY;
#else
return 0;
#endif
}
int scalanative_termios_ff0() { return FF0; }
int scalanative_termios_ff1() { return FF1; }
// Baud Rate Selection - valid values for objects of type speed_t
int scalanative_termios_b0() { return B0; }
int scalanative_termios_b50() { return B50; }
int scalanative_termios_b75() { return B75; }
int scalanative_termios_b110() { return B110; }
int scalanative_termios_b134() { return B134; }
int scalanative_termios_b150() { return B150; }
int scalanative_termios_b200() { return B200; }
int scalanative_termios_b300() { return B300; }
int scalanative_termios_b600() { return B600; }
int scalanative_termios_b1200() { return B1200; }
int scalanative_termios_b1800() { return B1800; }
int scalanative_termios_b2400() { return B2400; }
int scalanative_termios_b4800() { return B4800; }
int scalanative_termios_b9600() { return B9600; }
int scalanative_termios_b19200() { return B19200; }
int scalanative_termios_b38400() { return B38400; }
// Control Modes - symbolic constants for use as flags in the c_cflag field
int scalanative_termios_csize() { return CSIZE; }
int scalanative_termios_cs5() { return CS5; }
int scalanative_termios_cs6() { return CS6; }
int scalanative_termios_cs7() { return CS7; }
int scalanative_termios_cs8() { return CS8; }
int scalanative_termios_cstopb() { return CSTOPB; }
int scalanative_termios_cread() { return CREAD; }
int scalanative_termios_parenb() { return PARENB; }
int scalanative_termios_parodd() { return PARODD; }
int scalanative_termios_hupcl() { return HUPCL; }
int scalanative_termios_clocal() { return CLOCAL; }
// Local Modes - symbolic constants for use as flags in the c_lflag field
int scalanative_termios_echo() { return ECHO; }
int scalanative_termios_echoe() { return ECHOE; }
int scalanative_termios_echok() { return ECHOK; }
int scalanative_termios_echonl() { return ECHONL; }
int scalanative_termios_icanon() { return ICANON; }
int scalanative_termios_iexten() { return IEXTEN; }
int scalanative_termios_isig() { return ISIG; }
int scalanative_termios_noflsh() { return NOFLSH; }
int scalanative_termios_tostop() { return TOSTOP; }
// Attribute Selection - symbolic constants for use with tcsetattr()
int scalanative_termios_tcsanow() { return TCSANOW; }
int scalanative_termios_tcsadrain() { return TCSADRAIN; }
int scalanative_termios_tcsaflush() { return TCSAFLUSH; }
// Line Control - symbolic constants for use with tcflush()
int scalanative_termios_tciflush() { return TCIFLUSH; }
int scalanative_termios_tcioflush() { return TCIOFLUSH; }
int scalanative_termios_tcoflush() { return TCOFLUSH; }
// Line Control cont. - symbolic constants for use with tcflow()
int scalanative_termios_tcioff() { return TCIOFF; }
int scalanative_termios_tcion() { return TCION; }
int scalanative_termios_tcooff() { return TCOOFF; }
int scalanative_termios_tcoon() { return TCOON; }
#endif // Unix or Mac OS
#endif