@@ -36,7 +36,7 @@ fn main() -> io::Result<()> {
36
36
#[ cfg( all( not( windows) , feature = "stdio" ) ) ]
37
37
fn show < Fd : AsFd > ( fd : Fd ) -> io:: Result < ( ) > {
38
38
let fd = fd. as_fd ( ) ;
39
- println ! ( " - ready: {:?}" , rustix:: io:: ioctl_fionread( fd) ?) ;
39
+ println ! ( " - ready bytes : {:?}" , rustix:: io:: ioctl_fionread( fd) ?) ;
40
40
41
41
#[ cfg( feature = "termios" ) ]
42
42
if isatty ( fd) {
@@ -58,57 +58,53 @@ fn show<Fd: AsFd>(fd: Fd) -> io::Result<()> {
58
58
use rustix:: termios:: * ;
59
59
let term = tcgetattr ( fd) ?;
60
60
61
- if let Some ( speed) = speed_value ( cfgetispeed ( & term) ) {
62
- println ! ( " - ispeed: {}" , speed) ;
63
- }
64
- if let Some ( speed) = speed_value ( cfgetospeed ( & term) ) {
65
- println ! ( " - ospeed: {}" , speed) ;
66
- }
61
+ println ! ( " - input_speed: {}" , term. input_speed( ) ) ;
62
+ println ! ( " - output_speed: {}" , term. output_speed( ) ) ;
67
63
68
64
print ! ( " - in flags:" ) ;
69
- if ( term. c_iflag & IGNBRK ) != 0 {
65
+ if term. input_modes . contains ( InputModes :: IGNBRK ) {
70
66
print ! ( " IGNBRK" ) ;
71
67
}
72
- if ( term. c_iflag & BRKINT ) != 0 {
68
+ if term. input_modes . contains ( InputModes :: BRKINT ) {
73
69
print ! ( " BRKINT" ) ;
74
70
}
75
- if ( term. c_iflag & IGNPAR ) != 0 {
71
+ if term. input_modes . contains ( InputModes :: IGNPAR ) {
76
72
print ! ( " IGNPAR" ) ;
77
73
}
78
- if ( term. c_iflag & PARMRK ) != 0 {
74
+ if term. input_modes . contains ( InputModes :: PARMRK ) {
79
75
print ! ( " PARMRK" ) ;
80
76
}
81
- if ( term. c_iflag & INPCK ) != 0 {
77
+ if term. input_modes . contains ( InputModes :: INPCK ) {
82
78
print ! ( " INPCK" ) ;
83
79
}
84
- if ( term. c_iflag & ISTRIP ) != 0 {
80
+ if term. input_modes . contains ( InputModes :: ISTRIP ) {
85
81
print ! ( " ISTRIP" ) ;
86
82
}
87
- if ( term. c_iflag & INLCR ) != 0 {
83
+ if term. input_modes . contains ( InputModes :: INLCR ) {
88
84
print ! ( " INLCR" ) ;
89
85
}
90
- if ( term. c_iflag & IGNCR ) != 0 {
86
+ if term. input_modes . contains ( InputModes :: IGNCR ) {
91
87
print ! ( " IGNCR" ) ;
92
88
}
93
- if ( term. c_iflag & ICRNL ) != 0 {
89
+ if term. input_modes . contains ( InputModes :: ICRNL ) {
94
90
print ! ( " ICRNL" ) ;
95
91
}
96
- #[ cfg( any( linux_raw , all ( libc , any ( solarish, target_os = "haiku" ) ) ) ) ]
97
- if ( term. c_iflag & IUCLC ) != 0 {
92
+ #[ cfg( any( linux_kernel , solarish, target_os = "haiku" ) ) ]
93
+ if term. input_modes . contains ( InputModes :: IUCLC ) {
98
94
print ! ( " IUCLC" ) ;
99
95
}
100
- if ( term. c_iflag & IXON ) != 0 {
96
+ if term. input_modes . contains ( InputModes :: IXON ) {
101
97
print ! ( " IXON" ) ;
102
98
}
103
99
#[ cfg( not( target_os = "redox" ) ) ]
104
- if ( term. c_iflag & IXANY ) != 0 {
100
+ if term. input_modes . contains ( InputModes :: IXANY ) {
105
101
print ! ( " IXANY" ) ;
106
102
}
107
- if ( term. c_iflag & IXOFF ) != 0 {
103
+ if term. input_modes . contains ( InputModes :: IXOFF ) {
108
104
print ! ( " IXOFF" ) ;
109
105
}
110
106
#[ cfg( not( any( target_os = "haiku" , target_os = "redox" ) ) ) ]
111
- if ( term. c_iflag & IMAXBEL ) != 0 {
107
+ if term. input_modes . contains ( InputModes :: IMAXBEL ) {
112
108
print ! ( " IMAXBEL" ) ;
113
109
}
114
110
#[ cfg( not( any(
@@ -120,13 +116,13 @@ fn show<Fd: AsFd>(fd: Fd) -> io::Result<()> {
120
116
target_os = "haiku" ,
121
117
target_os = "redox" ,
122
118
) ) ) ]
123
- if ( term. c_iflag & IUTF8 ) != 0 {
119
+ if term. input_modes . contains ( InputModes :: IUTF8 ) {
124
120
print ! ( " IUTF8" ) ;
125
121
}
126
122
println ! ( ) ;
127
123
128
124
print ! ( " - out flags:" ) ;
129
- if ( term. c_oflag & OPOST ) != 0 {
125
+ if term. output_modes . contains ( OutputModes :: OPOST ) {
130
126
print ! ( " OPOST" ) ;
131
127
}
132
128
#[ cfg( not( any(
@@ -136,200 +132,180 @@ fn show<Fd: AsFd>(fd: Fd) -> io::Result<()> {
136
132
target_os = "netbsd" ,
137
133
target_os = "redox"
138
134
) ) ) ]
139
- if ( term. c_oflag & OLCUC ) != 0 {
135
+ if term. output_modes . contains ( OutputModes :: OLCUC ) {
140
136
print ! ( " OLCUC" ) ;
141
137
}
142
- if ( term. c_oflag & ONLCR ) != 0 {
138
+ if term. output_modes . contains ( OutputModes :: ONLCR ) {
143
139
print ! ( " ONLCR" ) ;
144
140
}
145
- if ( term. c_oflag & OCRNL ) != 0 {
141
+ if term. output_modes . contains ( OutputModes :: OCRNL ) {
146
142
print ! ( " OCRNL" ) ;
147
143
}
148
- if ( term. c_oflag & ONOCR ) != 0 {
144
+ if term. output_modes . contains ( OutputModes :: ONOCR ) {
149
145
print ! ( " ONOCR" ) ;
150
146
}
151
- if ( term. c_oflag & ONLRET ) != 0 {
147
+ if term. output_modes . contains ( OutputModes :: ONLRET ) {
152
148
print ! ( " ONLRET" ) ;
153
149
}
154
150
#[ cfg( not( bsd) ) ]
155
- if ( term. c_oflag & OFILL ) != 0 {
151
+ if term. output_modes . contains ( OutputModes :: OFILL ) {
156
152
print ! ( " OFILL" ) ;
157
153
}
158
154
#[ cfg( not( bsd) ) ]
159
- if ( term. c_oflag & OFDEL ) != 0 {
155
+ if term. output_modes . contains ( OutputModes :: OFDEL ) {
160
156
print ! ( " OFDEL" ) ;
161
157
}
162
158
#[ cfg( not( any( bsd, solarish, target_os = "redox" ) ) ) ]
163
- if ( term. c_oflag & NLDLY ) != 0 {
159
+ if term. output_modes . contains ( OutputModes :: NLDLY ) {
164
160
print ! ( " NLDLY" ) ;
165
161
}
166
162
#[ cfg( not( any( bsd, solarish, target_os = "aix" , target_os = "redox" ) ) ) ]
167
- if ( term. c_oflag & CRDLY ) != 0 {
163
+ if term. output_modes . contains ( OutputModes :: CRDLY ) {
168
164
print ! ( " CRDLY" ) ;
169
165
}
170
166
#[ cfg( not( any( netbsdlike, solarish, target_os = "dragonfly" , target_os = "redox" ) ) ) ]
171
- if ( term. c_oflag & TABDLY ) != 0 {
167
+ if term. output_modes . contains ( OutputModes :: TABDLY ) {
172
168
print ! ( " TABDLY" ) ;
173
169
}
174
170
#[ cfg( not( any( bsd, solarish, target_os = "redox" ) ) ) ]
175
- if ( term. c_oflag & BSDLY ) != 0 {
171
+ if term. output_modes . contains ( OutputModes :: BSDLY ) {
176
172
print ! ( " BSDLY" ) ;
177
173
}
178
- #[ cfg( not( any( all ( libc , target_env = "musl" ) , bsd, solarish, target_os = "redox" ) ) ) ]
179
- if ( term. c_oflag & VTDLY ) != 0 {
174
+ #[ cfg( not( any( bsd, solarish, target_os = "redox" ) ) ) ]
175
+ if term. output_modes . contains ( OutputModes :: VTDLY ) {
180
176
print ! ( " VTDLY" ) ;
181
177
}
182
- #[ cfg( not( any( all ( libc , target_env = "musl" ) , bsd, solarish, target_os = "redox" ) ) ) ]
183
- if ( term. c_oflag & FFDLY ) != 0 {
178
+ #[ cfg( not( any( bsd, solarish, target_os = "redox" ) ) ) ]
179
+ if term. output_modes . contains ( OutputModes :: FFDLY ) {
184
180
print ! ( " FFDLY" ) ;
185
181
}
186
182
println ! ( ) ;
187
183
188
184
print ! ( " - control flags:" ) ;
189
- #[ cfg( not( any( bsd, target_os = "haiku" , target_os = "redox" ) ) ) ]
190
- if ( term. c_cflag & CBAUD ) != 0 {
191
- print ! ( " CBAUD" ) ;
192
- }
193
- #[ cfg( not( any(
194
- bsd,
195
- solarish,
196
- target_os = "aix" ,
197
- target_os = "haiku" ,
198
- target_os = "redox"
199
- ) ) ) ]
200
- if ( term. c_cflag & CBAUDEX ) != 0 {
201
- print ! ( " CBAUDEX" ) ;
202
- }
203
- if ( term. c_cflag & CSIZE ) != 0 {
185
+ if term. control_modes . contains ( ControlModes :: CSIZE ) {
204
186
print ! ( " CSIZE" ) ;
205
187
}
206
- if ( term. c_cflag & CSTOPB ) != 0 {
188
+ if term. control_modes . contains ( ControlModes :: CSTOPB ) {
207
189
print ! ( " CSTOPB" ) ;
208
190
}
209
- if ( term. c_cflag & CREAD ) != 0 {
191
+ if term. control_modes . contains ( ControlModes :: CREAD ) {
210
192
print ! ( " CREAD" ) ;
211
193
}
212
- if ( term. c_cflag & PARENB ) != 0 {
194
+ if term. control_modes . contains ( ControlModes :: PARENB ) {
213
195
print ! ( " PARENB" ) ;
214
196
}
215
- if ( term. c_cflag & PARODD ) != 0 {
197
+ if term. control_modes . contains ( ControlModes :: PARODD ) {
216
198
print ! ( " PARODD" ) ;
217
199
}
218
- if ( term. c_cflag & HUPCL ) != 0 {
200
+ if term. control_modes . contains ( ControlModes :: HUPCL ) {
219
201
print ! ( " HUPCL" ) ;
220
202
}
221
- if ( term. c_cflag & CLOCAL ) != 0 {
203
+ if term. control_modes . contains ( ControlModes :: CLOCAL ) {
222
204
print ! ( " CLOCAL" ) ;
223
205
}
224
- #[ cfg( not( any(
225
- bsd,
226
- target_os = "emscripten" ,
227
- target_os = "haiku" ,
228
- target_os = "redox" ,
229
- ) ) ) ]
230
- if ( term. c_cflag & CIBAUD ) != 0 {
231
- print ! ( " CIBAUD" ) ;
232
- }
233
206
#[ cfg( not( any(
234
207
bsd,
235
208
solarish,
236
209
target_os = "emscripten" ,
237
210
target_os = "haiku" ,
238
211
target_os = "redox" ,
239
212
) ) ) ]
240
- if ( term. c_cflag & CMSPAR ) != 0 {
213
+ if term. control_modes . contains ( ControlModes :: CMSPAR ) {
241
214
print ! ( " CMSPAR" ) ;
242
215
}
243
216
#[ cfg( not( any( target_os = "aix" , target_os = "redox" ) ) ) ]
244
- if ( term. c_cflag & CRTSCTS ) != 0 {
217
+ if term. control_modes . contains ( ControlModes :: CRTSCTS ) {
245
218
print ! ( " CRTSCTS" ) ;
246
219
}
247
220
println ! ( ) ;
248
221
249
222
print ! ( " - local flags:" ) ;
250
- if ( term. c_lflag & ISIG ) != 0 {
223
+ if term. local_modes . contains ( LocalModes :: ISIG ) {
251
224
print ! ( " ISIG" ) ;
252
225
}
253
- if ( term. c_lflag & ICANON ) != 0 {
226
+ if term. local_modes . contains ( LocalModes :: ICANON ) {
254
227
print ! ( " ICANON" ) ;
255
228
}
256
- #[ cfg( any( linux_raw , all ( libc , any ( target_arch = "s390x" , target_os = "haiku" ) ) ) ) ]
257
- if ( term. c_lflag & XCASE ) != 0 {
229
+ #[ cfg( any( linux_kernel , target_arch = "s390x" , target_os = "haiku" ) ) ]
230
+ if term. local_modes . contains ( LocalModes :: XCASE ) {
258
231
print ! ( " XCASE" ) ;
259
232
}
260
- if ( term. c_lflag & ECHO ) != 0 {
233
+ if term. local_modes . contains ( LocalModes :: ECHO ) {
261
234
print ! ( " ECHO" ) ;
262
235
}
263
- if ( term. c_lflag & ECHOE ) != 0 {
236
+ if term. local_modes . contains ( LocalModes :: ECHOE ) {
264
237
print ! ( " ECHOE" ) ;
265
238
}
266
- if ( term. c_lflag & ECHOK ) != 0 {
239
+ if term. local_modes . contains ( LocalModes :: ECHOK ) {
267
240
print ! ( " ECHOK" ) ;
268
241
}
269
- if ( term. c_lflag & ECHONL ) != 0 {
242
+ if term. local_modes . contains ( LocalModes :: ECHONL ) {
270
243
print ! ( " ECHONL" ) ;
271
244
}
272
245
#[ cfg( not( any( target_os = "redox" ) ) ) ]
273
- if ( term. c_lflag & ECHOCTL ) != 0 {
246
+ if term. local_modes . contains ( LocalModes :: ECHOCTL ) {
274
247
print ! ( " ECHOCTL" ) ;
275
248
}
276
249
#[ cfg( not( any( target_os = "redox" ) ) ) ]
277
- if ( term. c_lflag & ECHOPRT ) != 0 {
250
+ if term. local_modes . contains ( LocalModes :: ECHOPRT ) {
278
251
print ! ( " ECHOPRT" ) ;
279
252
}
280
253
#[ cfg( not( any( target_os = "redox" ) ) ) ]
281
- if ( term. c_lflag & ECHOKE ) != 0 {
254
+ if term. local_modes . contains ( LocalModes :: ECHOKE ) {
282
255
print ! ( " ECHOKE" ) ;
283
256
}
284
257
#[ cfg( not( any( target_os = "redox" ) ) ) ]
285
- if ( term. c_lflag & FLUSHO ) != 0 {
258
+ if term. local_modes . contains ( LocalModes :: FLUSHO ) {
286
259
print ! ( " FLUSHO" ) ;
287
260
}
288
- if ( term. c_lflag & NOFLSH ) != 0 {
261
+ if term. local_modes . contains ( LocalModes :: NOFLSH ) {
289
262
print ! ( " NOFLSH" ) ;
290
263
}
291
- if ( term. c_lflag & TOSTOP ) != 0 {
264
+ if term. local_modes . contains ( LocalModes :: TOSTOP ) {
292
265
print ! ( " TOSTOP" ) ;
293
266
}
294
267
#[ cfg( not( any( target_os = "redox" ) ) ) ]
295
- if ( term. c_lflag & PENDIN ) != 0 {
268
+ if term. local_modes . contains ( LocalModes :: PENDIN ) {
296
269
print ! ( " PENDIN" ) ;
297
270
}
298
- if ( term. c_lflag & IEXTEN ) != 0 {
271
+ if term. local_modes . contains ( LocalModes :: IEXTEN ) {
299
272
print ! ( " IEXTEN" ) ;
300
273
}
301
274
println ! ( ) ;
302
275
303
276
println ! (
304
277
" - keys: INTR={} QUIT={} ERASE={} KILL={} EOF={} TIME={} MIN={} " ,
305
- key( term. c_cc [ VINTR ] ) ,
306
- key( term. c_cc [ VQUIT ] ) ,
307
- key( term. c_cc [ VERASE ] ) ,
308
- key( term. c_cc [ VKILL ] ) ,
309
- key( term. c_cc [ VEOF ] ) ,
310
- term. c_cc [ VTIME ] ,
311
- term. c_cc [ VMIN ]
278
+ key( term. special_codes [ SpecialCodeIndex :: VINTR ] ) ,
279
+ key( term. special_codes [ SpecialCodeIndex :: VQUIT ] ) ,
280
+ key( term. special_codes [ SpecialCodeIndex :: VERASE ] ) ,
281
+ key( term. special_codes [ SpecialCodeIndex :: VKILL ] ) ,
282
+ key( term. special_codes [ SpecialCodeIndex :: VEOF ] ) ,
283
+ term. special_codes [ SpecialCodeIndex :: VTIME ] ,
284
+ term. special_codes [ SpecialCodeIndex :: VMIN ]
312
285
) ;
313
286
println ! (
314
287
" START={} STOP={} SUSP={} EOL={}" ,
315
- key( term. c_cc [ VSTART ] ) ,
316
- key( term. c_cc [ VSTOP ] ) ,
317
- key( term. c_cc [ VSUSP ] ) ,
318
- key( term. c_cc [ VEOL ] ) ,
288
+ key( term. special_codes [ SpecialCodeIndex :: VSTART ] ) ,
289
+ key( term. special_codes [ SpecialCodeIndex :: VSTOP ] ) ,
290
+ key( term. special_codes [ SpecialCodeIndex :: VSUSP ] ) ,
291
+ key( term. special_codes [ SpecialCodeIndex :: VEOL ] ) ,
319
292
) ;
320
293
#[ cfg( not( target_os = "haiku" ) ) ]
321
294
println ! (
322
295
" REPRINT={} DISCARD={}" ,
323
- key( term. c_cc [ VREPRINT ] ) ,
324
- key( term. c_cc [ VDISCARD ] )
296
+ key( term. special_codes [ SpecialCodeIndex :: VREPRINT ] ) ,
297
+ key( term. special_codes [ SpecialCodeIndex :: VDISCARD ] )
325
298
) ;
326
299
#[ cfg( not( target_os = "haiku" ) ) ]
327
300
println ! (
328
301
" WERASE={} VLNEXT={}" ,
329
- key( term. c_cc[ VWERASE ] ) ,
330
- key( term. c_cc[ VLNEXT ] ) ,
302
+ key( term. special_codes[ SpecialCodeIndex :: VWERASE ] ) ,
303
+ key( term. special_codes[ SpecialCodeIndex :: VLNEXT ] ) ,
304
+ ) ;
305
+ println ! (
306
+ " EOL2={}" ,
307
+ key( term. special_codes[ SpecialCodeIndex :: VEOL2 ] )
331
308
) ;
332
- println ! ( " EOL2={}" , key( term. c_cc[ VEOL2 ] ) ) ;
333
309
}
334
310
} else {
335
311
println ! ( " - is not a tty" ) ;
0 commit comments