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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
// devela::sys::os::linux::io::term::flags
#[cfg(doc)]
use crate::LinuxTermios;
use crate::{
LINUX_TERMIOS_CFLAG as C, LINUX_TERMIOS_IFLAG as I, LINUX_TERMIOS_LFLAG as L,
LINUX_TERMIOS_OFLAG as O,
};
use crate::{c_uint, set};
set! {
#[doc = crate::_tags!(linux term set)]
/// [`LinuxTermios`] input flags.
#[doc = crate::_doc_meta!{
location("sys/os/term/session"),
test_size_of(LinuxTermiosInputFlags = 2|16),
}]
///
pub struct LinuxTermiosInputFlags(u16) {
/// Ignore BREAK condition on input.
IGNBRK = 0;
/// Signal interrupt on BREAK.
BRKINT = 1;
/// Ignore framing errors and parity errors.
IGNPAR = 2;
/// Mark parity and framing errors.
PARMRK = 3;
/// Enable input parity checking.
INPCK = 4;
/// Strip off eighth bit.
ISTRIP = 5;
/// Translate `NL` to `CR` on input.
INLCR = 6;
/// Ignore `CR` on input.
IGNCR = 7;
/// Translate `CR` to `NL` on input.
ICRNL = 8;
/// Map uppercase characters to lowercase on input.
IUCLC = 9;
/// Enable XON/XOFF flow control on output.
IXON = 10;
/// Any character restarts stopped output.
IXANY = 11;
/// Enable XON/XOFF flow control on input.
IXOFF = 12;
/// Ring bell when input queue is full.
IMAXBEL = 13;
/// Input is UTF-8.
IUTF8 = 14;
}
impl {
/// Returns flags from the raw Linux `c_iflag` word.
#[must_use]
pub const fn from_c_uint(bits: c_uint) -> Self {
Self::from_bits(bits as u16)
}
/// Returns flags as a raw Linux `c_iflag` word.
#[must_use]
pub const fn as_c_uint(self) -> c_uint {
self.bits() as c_uint
}
const _ASSERT_RAW_VALUES: () = {
assert!(Self::IGNBRK.as_c_uint() == I::IGNBRK);
assert!(Self::BRKINT.as_c_uint() == I::BRKINT);
assert!(Self::IGNPAR.as_c_uint() == I::IGNPAR);
assert!(Self::PARMRK.as_c_uint() == I::PARMRK);
assert!(Self::INPCK.as_c_uint() == I::INPCK);
assert!(Self::ISTRIP.as_c_uint() == I::ISTRIP);
assert!(Self::INLCR.as_c_uint() == I::INLCR);
assert!(Self::IGNCR.as_c_uint() == I::IGNCR);
assert!(Self::ICRNL.as_c_uint() == I::ICRNL);
assert!(Self::IUCLC.as_c_uint() == I::IUCLC);
assert!(Self::IXON.as_c_uint() == I::IXON);
assert!(Self::IXANY.as_c_uint() == I::IXANY);
assert!(Self::IXOFF.as_c_uint() == I::IXOFF);
assert!(Self::IMAXBEL.as_c_uint() == I::IMAXBEL);
assert!(Self::IUTF8.as_c_uint() == I::IUTF8);
};
}
}
set! {
#[doc = crate::_tags!(linux term set)]
/// [`LinuxTermios`] output flags.
#[doc = crate::_doc_meta!{
location("sys/os/term/session"),
test_size_of(LinuxTermiosOutputFlags = 4|32),
}]
///
/// NOTE: Some constants in this group are masked delay fields,
/// not independent boolean flags. Prefer field-specific helpers
/// when they exist instead of combining delay values manually.
pub struct LinuxTermiosOutputFlags(u32) {
/// Enable implementation-defined output processing.
OPOST = 0;
/// Map lowercase characters to uppercase on output.
OLCUC = 1;
/// Map `NL` to `CR-NL` on output.
ONLCR = 2;
/// Map `CR` to `NL` on output.
OCRNL = 3;
/// Don't output `CR` at column 0.
ONOCR = 4;
/// `NL` performs carriage-return.
ONLRET = 5;
/// Send fill characters for a delay.
OFILL = 6;
/// Fill character is ASCII `DEL`.
OFDEL = 7;
/// Newline delay mask.
NLDLY = 8;
/// Newline delay type 1.
NL1 = 8;
/// Carriage-return delay mask.
CRDLY = 9..=10;
/// Carriage-return delay type 1.
CR1 = 9;
/// Carriage-return delay type 2.
CR2 = 10;
/// Carriage-return delay type 3.
CR3 = 9..=10;
/// Horizontal-tab delay mask.
TABDLY = 11..=12;
/// Horizontal-tab delay type 1.
TAB1 = 11;
/// Horizontal-tab delay type 2.
TAB2 = 12;
/// Horizontal-tab delay type 3.
TAB3 = 11..=12;
/// Backspace delay mask.
BSDLY = 13;
/// Backspace delay type 1.
BS1 = 13;
/// Vertical-tab delay mask.
VTDLY = 14;
/// Vertical-tab delay type 1.
VT1 = 14;
/// Form-feed delay mask.
FFDLY = 15;
/// Form-feed delay type 1.
FF1 = 15;
/// Expands tabs to spaces. Same value as [`TAB3`](Self::TAB3).
XTABS = 11..=12;
}
impl {
/// Newline delay type 0.
pub const NL0: Self = Self::new();
/// Carriage-return delay type 0.
pub const CR0: Self = Self::new();
/// Horizontal-tab delay type 0.
pub const TAB0: Self = Self::new();
/// Backspace delay type 0.
pub const BS0: Self = Self::new();
/// Vertical-tab delay type 0.
pub const VT0: Self = Self::new();
/// Form-feed delay type 0.
pub const FF0: Self = Self::new();
/// Returns flags from the raw Linux `c_oflag` word.
#[must_use]
pub const fn from_c_uint(bits: c_uint) -> Self {
Self::from_bits(bits)
}
/// Returns flags as a raw Linux `c_oflag` word.
#[must_use]
pub const fn as_c_uint(self) -> c_uint {
self.bits()
}
const _ASSERT_RAW_VALUES: () = {
assert!(Self::OPOST.as_c_uint() == O::OPOST);
assert!(Self::OLCUC.as_c_uint() == O::OLCUC);
assert!(Self::ONLCR.as_c_uint() == O::ONLCR);
assert!(Self::OCRNL.as_c_uint() == O::OCRNL);
assert!(Self::ONOCR.as_c_uint() == O::ONOCR);
assert!(Self::ONLRET.as_c_uint() == O::ONLRET);
assert!(Self::OFILL.as_c_uint() == O::OFILL);
assert!(Self::OFDEL.as_c_uint() == O::OFDEL);
assert!(Self::NLDLY.as_c_uint() == O::NLDLY);
assert!(Self::NL0.as_c_uint() == O::NL0);
assert!(Self::NL1.as_c_uint() == O::NL1);
assert!(Self::CRDLY.as_c_uint() == O::CRDLY);
assert!(Self::CR0.as_c_uint() == O::CR0);
assert!(Self::CR1.as_c_uint() == O::CR1);
assert!(Self::CR2.as_c_uint() == O::CR2);
assert!(Self::CR3.as_c_uint() == O::CR3);
assert!(Self::TABDLY.as_c_uint() == O::TABDLY);
assert!(Self::TAB0.as_c_uint() == O::TAB0);
assert!(Self::TAB1.as_c_uint() == O::TAB1);
assert!(Self::TAB2.as_c_uint() == O::TAB2);
assert!(Self::TAB3.as_c_uint() == O::TAB3);
assert!(Self::XTABS.as_c_uint() == O::XTABS);
assert!(Self::BSDLY.as_c_uint() == O::BSDLY);
assert!(Self::BS0.as_c_uint() == O::BS0);
assert!(Self::BS1.as_c_uint() == O::BS1);
assert!(Self::VTDLY.as_c_uint() == O::VTDLY);
assert!(Self::VT0.as_c_uint() == O::VT0);
assert!(Self::VT1.as_c_uint() == O::VT1);
assert!(Self::FFDLY.as_c_uint() == O::FFDLY);
assert!(Self::FF0.as_c_uint() == O::FF0);
assert!(Self::FF1.as_c_uint() == O::FF1);
};
}
}
set! {
#[doc = crate::_tags!(linux term set)]
/// [`LinuxTermios`] control flags.
#[doc = crate::_doc_meta!{
location("sys/os/linux/io/term"),
test_size_of(LinuxTermiosControlFlags = 2|16),
}]
/// NOTE: `CSIZE`/`CS5`/`CS6`/`CS7`/`CS8` are a masked character-size field,
/// not independent flags. Prefer [`LinuxTermios::set_char_size`] when changing it.
pub struct LinuxTermiosControlFlags(u16) {
/// Character size mask.
CSIZE = 4..=5;
/// Character size 6 bits.
CS6 = 4;
/// Character size 7 bits.
CS7 = 5;
/// Character size 8 bits.
CS8 = 4..=5;
/// Set two stop bits, rather than one.
CSTOPB = 6;
/// Enable receiver.
CREAD = 7;
/// Enable parity generation and checking.
PARENB = 8;
/// Odd parity instead of even parity.
PARODD = 9;
/// Hang up on last close.
HUPCL = 10;
/// Ignore modem control lines.
CLOCAL = 11;
}
impl {
/// Character size 5 bits.
pub const CS5: Self = Self::new();
/// Returns flags from the raw Linux `c_cflag` word.
#[must_use]
pub const fn from_c_uint(bits: c_uint) -> Self {
Self::from_bits(bits as u16)
}
/// Returns flags as a raw Linux `c_cflag` word.
#[must_use]
pub const fn as_c_uint(self) -> c_uint {
self.bits() as c_uint
}
const _ASSERT_RAW_VALUES: () = {
assert!(Self::CSIZE.as_c_uint() == C::CSIZE);
assert!(Self::CS5.as_c_uint() == C::CS5);
assert!(Self::CS6.as_c_uint() == C::CS6);
assert!(Self::CS7.as_c_uint() == C::CS7);
assert!(Self::CS8.as_c_uint() == C::CS8);
assert!(Self::CSTOPB.as_c_uint() == C::CSTOPB);
assert!(Self::CREAD.as_c_uint() == C::CREAD);
assert!(Self::PARENB.as_c_uint() == C::PARENB);
assert!(Self::PARODD.as_c_uint() == C::PARODD);
assert!(Self::HUPCL.as_c_uint() == C::HUPCL);
assert!(Self::CLOCAL.as_c_uint() == C::CLOCAL);
};
}
}
set! {
#[doc = crate::_tags!(linux term set)]
/// [`LinuxTermios`] local flags.
#[doc = crate::_doc_meta!{
location("sys/os/linux/io/term"),
test_size_of(LinuxTermiosLocalFlags = 4|32),
}]
pub struct LinuxTermiosLocalFlags(u32) {
/// Enable signals.
ISIG = 0;
/// Enable canonical mode.
ICANON = 1;
/// Uppercase-only terminal compatibility mode.
XCASE = 2;
/// Echo input characters.
ECHO = 3;
/// Echo erase processing.
ECHOE = 4;
/// Echo kill processing.
ECHOK = 5;
/// Echo newline.
ECHONL = 6;
/// Disable flushing when generating signals.
NOFLSH = 7;
/// Send `SIGTTOU` for background output.
TOSTOP = 8;
/// Echo control characters as `^X`.
ECHOCTL = 9;
/// Visual erase mode.
ECHOPRT = 10;
/// Echo line kill by erasing each character.
ECHOKE = 11;
/// Output is being flushed.
FLUSHO = 12;
/// Pending input reprint.
PENDING = 14;
/// Enable implementation-defined input processing.
IEXTEN = 15;
/// External processing.
EXTPROC = 16;
}
impl {
/// Returns flags from the raw Linux `c_lflag` word.
#[must_use]
pub const fn from_c_uint(bits: c_uint) -> Self {
Self::from_bits(bits)
}
/// Returns flags as a raw Linux `c_lflag` word.
#[must_use]
pub const fn as_c_uint(self) -> c_uint {
self.bits()
}
const _ASSERT_RAW_VALUES: () = {
assert!(Self::ISIG.as_c_uint() == L::ISIG);
assert!(Self::ICANON.as_c_uint() == L::ICANON);
assert!(Self::XCASE.as_c_uint() == L::XCASE);
assert!(Self::ECHO.as_c_uint() == L::ECHO);
assert!(Self::ECHOE.as_c_uint() == L::ECHOE);
assert!(Self::ECHOK.as_c_uint() == L::ECHOK);
assert!(Self::ECHONL.as_c_uint() == L::ECHONL);
assert!(Self::NOFLSH.as_c_uint() == L::NOFLSH);
assert!(Self::TOSTOP.as_c_uint() == L::TOSTOP);
assert!(Self::ECHOCTL.as_c_uint() == L::ECHOCTL);
assert!(Self::ECHOPRT.as_c_uint() == L::ECHOPRT);
assert!(Self::ECHOKE.as_c_uint() == L::ECHOKE);
assert!(Self::FLUSHO.as_c_uint() == L::FLUSHO);
assert!(Self::PENDING.as_c_uint() == L::PENDING);
assert!(Self::IEXTEN.as_c_uint() == L::IEXTEN);
assert!(Self::EXTPROC.as_c_uint() == L::EXTPROC);
};
}
}