1 /**
2  * D header file for POSIX.
3  *
4  * Copyright: Copyright Sean Kelly 2005 - 2009.
5  * License:   $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
6  * Authors:   Sean Kelly, Alex Rønne Petersen
7  * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
8  */
9 
10 /*          Copyright Sean Kelly 2005 - 2009.
11  * Distributed under the Boost Software License, Version 1.0.
12  *    (See accompanying file LICENSE or copy at
13  *          http://www.boost.org/LICENSE_1_0.txt)
14  */
15 module core.sys.posix.termios;
16 
17 import core.sys.posix.config;
18 public import core.sys.posix.sys.types; // for pid_t
19 
20 version (OSX)
21     version = Darwin;
22 else version (iOS)
23     version = Darwin;
24 else version (TVOS)
25     version = Darwin;
26 else version (WatchOS)
27     version = Darwin;
28 
29 version (Posix):
30 extern (C):
31 
32 nothrow:
33 @nogc:
34 
35 //
36 // Required
37 //
38 /*
39 cc_t
40 speed_t
41 tcflag_t
42 
43 NCCS
44 
45 struct termios
46 {
47     tcflag_t   c_iflag;
48     tcflag_t   c_oflag;
49     tcflag_t   c_cflag;
50     tcflag_t   c_lflag;
51     cc_t[NCCS] c_cc;
52 }
53 
54 VEOF
55 VEOL
56 VERASE
57 VINTR
58 VKILL
59 VMIN
60 VQUIT
61 VSTART
62 VSTOP
63 VSUSP
64 VTIME
65 
66 BRKINT
67 ICRNL
68 IGNBRK
69 IGNCR
70 IGNPAR
71 INLCR
72 INPCK
73 ISTRIP
74 IXOFF
75 IXON
76 PARMRK
77 
78 OPOST
79 
80 B0
81 B50
82 B75
83 B110
84 B134
85 B150
86 B200
87 B300
88 B600
89 B1200
90 B1800
91 B2400
92 B4800
93 B9600
94 B19200
95 B38400
96 
97 CSIZE
98     CS5
99     CS6
100     CS7
101     CS8
102 CSTOPB
103 CREAD
104 PARENB
105 PARODD
106 HUPCL
107 CLOCAL
108 
109 ECHO
110 ECHOE
111 ECHOK
112 ECHONL
113 ICANON
114 IEXTEN
115 ISIG
116 NOFLSH
117 TOSTOP
118 
119 TCSANOW
120 TCSADRAIN
121 TCSAFLUSH
122 
123 TCIFLUSH
124 TCIOFLUSH
125 TCOFLUSH
126 
127 TCIOFF
128 TCION
129 TCOOFF
130 TCOON
131 */
132 
133 version (linux)
134 {
135     alias ubyte cc_t;
136     alias uint  speed_t;
137     alias uint  tcflag_t;
138 
139     enum NCCS   = 32;
140 
141     struct termios
142     {
143         tcflag_t   c_iflag;
144         tcflag_t   c_oflag;
145         tcflag_t   c_cflag;
146         tcflag_t   c_lflag;
147         cc_t       c_line;
148         cc_t[NCCS] c_cc;
149         speed_t    c_ispeed;
150         speed_t    c_ospeed;
151     }
152 
153     enum VEOF       = 4;
154     enum VEOL       = 11;
155     enum VERASE     = 2;
156     enum VINTR      = 0;
157     enum VKILL      = 3;
158     enum VMIN       = 6;
159     enum VQUIT      = 1;
160     enum VSTART     = 8;
161     enum VSTOP      = 9;
162     enum VSUSP      = 10;
163     enum VTIME      = 5;
164 
165     enum BRKINT     = 0x0000002; // 0000002
166     enum ICRNL      = 0x0000100; // 0000400
167     enum IGNBRK     = 0x0000001; // 0000001
168     enum IGNCR      = 0x0000080; // 0000200
169     enum IGNPAR     = 0x0000004; // 0000004
170     enum INLCR      = 0x0000040; // 0000100
171     enum INPCK      = 0x0000010; // 0000020
172     enum ISTRIP     = 0x0000020; // 0000040
173     enum IXOFF      = 0x0001000; // 0010000
174     enum IXON       = 0x0000400; // 0002000
175     enum PARMRK     = 0x0000008; // 0000010
176 
177     enum OPOST      = 0x0000001; // 0000001
178 
179     enum B0         = 0x0000000; // 0000000
180     enum B50        = 0x0000001; // 0000001
181     enum B75        = 0x0000002; // 0000002
182     enum B110       = 0x0000003; // 0000003
183     enum B134       = 0x0000004; // 0000004
184     enum B150       = 0x0000005; // 0000005
185     enum B200       = 0x0000006; // 0000006
186     enum B300       = 0x0000007; // 0000007
187     enum B600       = 0x0000008; // 0000010
188     enum B1200      = 0x0000009; // 0000011
189     enum B1800      = 0x000000A; // 0000012
190     enum B2400      = 0x000000B; // 0000013
191     enum B4800      = 0x000000C; // 0000014
192     enum B9600      = 0x000000D; // 0000015
193     enum B19200     = 0x000000E; // 0000016
194     enum B38400     = 0x000000F; // 0000017
195 
196     enum CSIZE      = 0x0000030; // 0000060
197     enum   CS5      = 0x0000000; // 0000000
198     enum   CS6      = 0x0000010; // 0000020
199     enum   CS7      = 0x0000020; // 0000040
200     enum   CS8      = 0x0000030; // 0000060
201     enum CSTOPB     = 0x0000040; // 0000100
202     enum CREAD      = 0x0000080; // 0000200
203     enum PARENB     = 0x0000100; // 0000400
204     enum PARODD     = 0x0000200; // 0001000
205     enum HUPCL      = 0x0000400; // 0002000
206     enum CLOCAL     = 0x0000800; // 0004000
207 
208     enum ECHO       = 0x0000008; // 0000010
209     enum ECHOE      = 0x0000010; // 0000020
210     enum ECHOK      = 0x0000020; // 0000040
211     enum ECHONL     = 0x0000040; // 0000100
212     enum ICANON     = 0x0000002; // 0000002
213     enum IEXTEN     = 0x0008000; // 0100000
214     enum ISIG       = 0x0000001; // 0000001
215     enum NOFLSH     = 0x0000080; // 0000200
216     enum TOSTOP     = 0x0000100; // 0000400
217 
218     enum TCSANOW    = 0;
219     enum TCSADRAIN  = 1;
220     enum TCSAFLUSH  = 2;
221 
222     enum TCIFLUSH   = 0;
223     enum TCOFLUSH   = 1;
224     enum TCIOFLUSH  = 2;
225 
226     enum TCIOFF     = 2;
227     enum TCION      = 3;
228     enum TCOOFF     = 0;
229     enum TCOON      = 1;
230 }
231 else version (Darwin)
232 {
233     alias ubyte cc_t;
234     alias c_ulong  speed_t;
235     alias c_ulong  tcflag_t;
236 
237     enum NCCS   = 20;
238 
239     struct termios
240     {
241         tcflag_t   c_iflag;
242         tcflag_t   c_oflag;
243         tcflag_t   c_cflag;
244         tcflag_t   c_lflag;
245         cc_t[NCCS] c_cc;
246         speed_t    c_ispeed;
247         speed_t    c_ospeed;
248     }
249 
250     enum VEOF       = 0;
251     enum VEOL       = 1;
252     enum VERASE     = 3;
253     enum VINTR      = 8;
254     enum VKILL      = 5;
255     enum VMIN       = 16;
256     enum VQUIT      = 9;
257     enum VSTART     = 12;
258     enum VSTOP      = 13;
259     enum VSUSP      = 10;
260     enum VTIME      = 17;
261 
262     enum BRKINT     = 0x0000002;
263     enum ICRNL      = 0x0000100;
264     enum IGNBRK     = 0x0000001;
265     enum IGNCR      = 0x0000080;
266     enum IGNPAR     = 0x0000004;
267     enum INLCR      = 0x0000040;
268     enum INPCK      = 0x0000010;
269     enum ISTRIP     = 0x0000020;
270     enum IXOFF      = 0x0000400;
271     enum IXON       = 0x0000200;
272     enum PARMRK     = 0x0000008;
273 
274     enum OPOST      = 0x0000001;
275 
276     enum B0         = 0;
277     enum B50        = 50;
278     enum B75        = 75;
279     enum B110       = 110;
280     enum B134       = 134;
281     enum B150       = 150;
282     enum B200       = 200;
283     enum B300       = 300;
284     enum B600       = 600;
285     enum B1200      = 1200;
286     enum B1800      = 1800;
287     enum B2400      = 2400;
288     enum B4800      = 4800;
289     enum B9600      = 9600;
290     enum B19200     = 19200;
291     enum B38400     = 38400;
292 
293     enum CSIZE      = 0x0000300;
294     enum   CS5      = 0x0000000;
295     enum   CS6      = 0x0000100;
296     enum   CS7      = 0x0000200;
297     enum   CS8      = 0x0000300;
298     enum CSTOPB     = 0x0000400;
299     enum CREAD      = 0x0000800;
300     enum PARENB     = 0x0001000;
301     enum PARODD     = 0x0002000;
302     enum HUPCL      = 0x0004000;
303     enum CLOCAL     = 0x0008000;
304 
305     enum ECHO       = 0x00000008;
306     enum ECHOE      = 0x00000002;
307     enum ECHOK      = 0x00000004;
308     enum ECHONL     = 0x00000010;
309     enum ICANON     = 0x00000100;
310     enum IEXTEN     = 0x00000400;
311     enum ISIG       = 0x00000080;
312     enum NOFLSH     = 0x80000000;
313     enum TOSTOP     = 0x00400000;
314 
315     enum TCSANOW    = 0;
316     enum TCSADRAIN  = 1;
317     enum TCSAFLUSH  = 2;
318 
319     enum TCIFLUSH   = 1;
320     enum TCOFLUSH   = 2;
321     enum TCIOFLUSH  = 3;
322 
323     enum TCIOFF     = 3;
324     enum TCION      = 4;
325     enum TCOOFF     = 1;
326     enum TCOON      = 2;
327 }
328 else version (FreeBSD)
329 {
330     alias ubyte cc_t;
331     alias uint  speed_t;
332     alias uint  tcflag_t;
333 
334     enum NCCS   = 20;
335 
336     struct termios
337     {
338         tcflag_t   c_iflag;
339         tcflag_t   c_oflag;
340         tcflag_t   c_cflag;
341         tcflag_t   c_lflag;
342         cc_t[NCCS] c_cc;
343         speed_t    c_ispeed;
344         speed_t    c_ospeed;
345     }
346 
347     enum VEOF       = 0;
348     enum VEOL       = 1;
349     enum VERASE     = 3;
350     enum VINTR      = 8;
351     enum VKILL      = 5;
352     enum VMIN       = 16;
353     enum VQUIT      = 9;
354     enum VSTART     = 12;
355     enum VSTOP      = 13;
356     enum VSUSP      = 10;
357     enum VTIME      = 17;
358 
359     enum BRKINT     = 0x0000002;
360     enum ICRNL      = 0x0000100;
361     enum IGNBRK     = 0x0000001;
362     enum IGNCR      = 0x0000080;
363     enum IGNPAR     = 0x0000004;
364     enum INLCR      = 0x0000040;
365     enum INPCK      = 0x0000010;
366     enum ISTRIP     = 0x0000020;
367     enum IXOFF      = 0x0000400;
368     enum IXON       = 0x0000200;
369     enum PARMRK     = 0x0000008;
370 
371     enum OPOST      = 0x0000001;
372 
373     enum B0         = 0;
374     enum B50        = 50;
375     enum B75        = 75;
376     enum B110       = 110;
377     enum B134       = 134;
378     enum B150       = 150;
379     enum B200       = 200;
380     enum B300       = 300;
381     enum B600       = 600;
382     enum B1200      = 1200;
383     enum B1800      = 1800;
384     enum B2400      = 2400;
385     enum B4800      = 4800;
386     enum B9600      = 9600;
387     enum B19200     = 19200;
388     enum B38400     = 38400;
389 
390     enum CSIZE      = 0x0000300;
391     enum   CS5      = 0x0000000;
392     enum   CS6      = 0x0000100;
393     enum   CS7      = 0x0000200;
394     enum   CS8      = 0x0000300;
395     enum CSTOPB     = 0x0000400;
396     enum CREAD      = 0x0000800;
397     enum PARENB     = 0x0001000;
398     enum PARODD     = 0x0002000;
399     enum HUPCL      = 0x0004000;
400     enum CLOCAL     = 0x0008000;
401 
402     enum ECHO       = 0x00000008;
403     enum ECHOE      = 0x00000002;
404     enum ECHOK      = 0x00000004;
405     enum ECHONL     = 0x00000010;
406     enum ICANON     = 0x00000100;
407     enum IEXTEN     = 0x00000400;
408     enum ISIG       = 0x00000080;
409     enum NOFLSH     = 0x80000000;
410     enum TOSTOP     = 0x00400000;
411 
412     enum TCSANOW    = 0;
413     enum TCSADRAIN  = 1;
414     enum TCSAFLUSH  = 2;
415 
416     enum TCIFLUSH   = 1;
417     enum TCOFLUSH   = 2;
418     enum TCIOFLUSH  = 3;
419 
420     enum TCIOFF     = 3;
421     enum TCION      = 4;
422     enum TCOOFF     = 1;
423     enum TCOON      = 2;
424 }
425 else version (DragonFlyBSD)
426 {
427     alias ubyte cc_t;
428     alias uint  speed_t;
429     alias uint  tcflag_t;
430 
431     enum NCCS   = 20;
432 
433     struct termios
434     {
435         tcflag_t   c_iflag;
436         tcflag_t   c_oflag;
437         tcflag_t   c_cflag;
438         tcflag_t   c_lflag;
439         cc_t[NCCS] c_cc;
440         speed_t    c_ispeed;
441         speed_t    c_ospeed;
442     }
443 
444     enum VEOF       = 0;
445     enum VEOL       = 1;
446     enum VERASE     = 3;
447     enum VINTR      = 8;
448     enum VKILL      = 5;
449     enum VMIN       = 16;
450     enum VQUIT      = 9;
451     enum VSTART     = 12;
452     enum VSTOP      = 13;
453     enum VSUSP      = 10;
454     enum VTIME      = 17;
455 
456     enum BRKINT     = 0x0000002;
457     enum ICRNL      = 0x0000100;
458     enum IGNBRK     = 0x0000001;
459     enum IGNCR      = 0x0000080;
460     enum IGNPAR     = 0x0000004;
461     enum INLCR      = 0x0000040;
462     enum INPCK      = 0x0000010;
463     enum ISTRIP     = 0x0000020;
464     enum IXOFF      = 0x0000400;
465     enum IXON       = 0x0000200;
466     enum PARMRK     = 0x0000008;
467 
468     enum OPOST      = 0x0000001;
469 
470     enum B0         = 0;
471     enum B50        = 50;
472     enum B75        = 75;
473     enum B110       = 110;
474     enum B134       = 134;
475     enum B150       = 150;
476     enum B200       = 200;
477     enum B300       = 300;
478     enum B600       = 600;
479     enum B1200      = 1200;
480     enum B1800      = 1800;
481     enum B2400      = 2400;
482     enum B4800      = 4800;
483     enum B9600      = 9600;
484     enum B19200     = 19200;
485     enum B38400     = 38400;
486 
487     enum CSIZE      = 0x0000300;
488     enum   CS5      = 0x0000000;
489     enum   CS6      = 0x0000100;
490     enum   CS7      = 0x0000200;
491     enum   CS8      = 0x0000300;
492     enum CSTOPB     = 0x0000400;
493     enum CREAD      = 0x0000800;
494     enum PARENB     = 0x0001000;
495     enum PARODD     = 0x0002000;
496     enum HUPCL      = 0x0004000;
497     enum CLOCAL     = 0x0008000;
498 
499     enum ECHO       = 0x00000008;
500     enum ECHOE      = 0x00000002;
501     enum ECHOK      = 0x00000004;
502     enum ECHONL     = 0x00000010;
503     enum ICANON     = 0x00000100;
504     enum IEXTEN     = 0x00000400;
505     enum ISIG       = 0x00000080;
506     enum NOFLSH     = 0x80000000;
507     enum TOSTOP     = 0x00400000;
508 
509     enum TCSANOW    = 0;
510     enum TCSADRAIN  = 1;
511     enum TCSAFLUSH  = 2;
512 
513     enum TCIFLUSH   = 1;
514     enum TCOFLUSH   = 2;
515     enum TCIOFLUSH  = 3;
516 
517     enum TCIOFF     = 3;
518     enum TCION      = 4;
519     enum TCOOFF     = 1;
520     enum TCOON      = 2;
521 }
522 else version (NetBSD)
523 {
524     alias ubyte cc_t;
525     alias uint  speed_t;
526     alias uint  tcflag_t;
527 
528     enum NCCS   = 20;
529 
530     struct termios
531     {
532         tcflag_t   c_iflag;
533         tcflag_t   c_oflag;
534         tcflag_t   c_cflag;
535         tcflag_t   c_lflag;
536         cc_t[NCCS] c_cc;
537         speed_t    c_ispeed;
538         speed_t    c_ospeed;
539     }
540 
541     enum VEOF       = 0;
542     enum VEOL       = 1;
543     enum VERASE     = 3;
544     enum VINTR      = 8;
545     enum VKILL      = 5;
546     enum VMIN       = 16;
547     enum VQUIT      = 9;
548     enum VSTART     = 12;
549     enum VSTOP      = 13;
550     enum VSUSP      = 10;
551     enum VTIME      = 17;
552 
553     enum BRKINT     = 0x0000002;
554     enum ICRNL      = 0x0000100;
555     enum IGNBRK     = 0x0000001;
556     enum IGNCR      = 0x0000080;
557     enum IGNPAR     = 0x0000004;
558     enum INLCR      = 0x0000040;
559     enum INPCK      = 0x0000010;
560     enum ISTRIP     = 0x0000020;
561     enum IXOFF      = 0x0000400;
562     enum IXON       = 0x0000200;
563     enum PARMRK     = 0x0000008;
564 
565     enum OPOST      = 0x0000001;
566 
567     enum B0         = 0;
568     enum B50        = 50;
569     enum B75        = 75;
570     enum B110       = 110;
571     enum B134       = 134;
572     enum B150       = 150;
573     enum B200       = 200;
574     enum B300       = 300;
575     enum B600       = 600;
576     enum B1200      = 1200;
577     enum B1800      = 1800;
578     enum B2400      = 2400;
579     enum B4800      = 4800;
580     enum B9600      = 9600;
581     enum B19200     = 19200;
582     enum B38400     = 38400;
583 
584     enum CSIZE      = 0x0000300;
585     enum   CS5      = 0x0000000;
586     enum   CS6      = 0x0000100;
587     enum   CS7      = 0x0000200;
588     enum   CS8      = 0x0000300;
589     enum CSTOPB     = 0x0000400;
590     enum CREAD      = 0x0000800;
591     enum PARENB     = 0x0001000;
592     enum PARODD     = 0x0002000;
593     enum HUPCL      = 0x0004000;
594     enum CLOCAL     = 0x0008000;
595 
596     enum ECHO       = 0x00000008;
597     enum ECHOE      = 0x00000002;
598     enum ECHOK      = 0x00000004;
599     enum ECHONL     = 0x00000010;
600     enum ICANON     = 0x00000100;
601     enum IEXTEN     = 0x00000400;
602     enum ISIG       = 0x00000080;
603     enum NOFLSH     = 0x80000000;
604     enum TOSTOP     = 0x00400000;
605 
606     enum TCSANOW    = 0;
607     enum TCSADRAIN  = 1;
608     enum TCSAFLUSH  = 2;
609 
610     enum TCIFLUSH   = 1;
611     enum TCOFLUSH   = 2;
612     enum TCIOFLUSH  = 3;
613 
614     enum TCIOFF     = 3;
615     enum TCION      = 4;
616     enum TCOOFF     = 1;
617     enum TCOON      = 2;
618 }
619 else version (OpenBSD)
620 {
621     alias uint  tcflag_t;
622     alias ubyte cc_t;
623     alias uint  speed_t;
624 
625     enum NCCS   = 20;
626 
627     struct termios
628     {
629         tcflag_t   c_iflag;
630         tcflag_t   c_oflag;
631         tcflag_t   c_cflag;
632         tcflag_t   c_lflag;
633         cc_t[NCCS] c_cc;
634         int        c_ispeed;
635         int        c_ospeed;
636     }
637 
638     enum VEOF       = 0;
639     enum VEOL       = 1;
640     enum VERASE     = 3;
641     enum VINTR      = 8;
642     enum VKILL      = 5;
643     enum VMIN       = 16;
644     enum VQUIT      = 9;
645     enum VSTART     = 12;
646     enum VSTOP      = 13;
647     enum VSUSP      = 10;
648     enum VTIME      = 17;
649 
650     enum BRKINT     = 0x0000002;
651     enum ICRNL      = 0x0000100;
652     enum IGNBRK     = 0x0000001;
653     enum IGNCR      = 0x0000080;
654     enum IGNPAR     = 0x0000004;
655     enum INLCR      = 0x0000040;
656     enum INPCK      = 0x0000010;
657     enum ISTRIP     = 0x0000020;
658     enum IXOFF      = 0x0000400;
659     enum IXON       = 0x0000200;
660     enum PARMRK     = 0x0000008;
661 
662     enum OPOST      = 0x0000001;
663 
664     enum B0         = 0;
665     enum B50        = 50;
666     enum B75        = 75;
667     enum B110       = 110;
668     enum B134       = 134;
669     enum B150       = 150;
670     enum B200       = 200;
671     enum B300       = 300;
672     enum B600       = 600;
673     enum B1200      = 1200;
674     enum B1800      = 1800;
675     enum B2400      = 2400;
676     enum B4800      = 4800;
677     enum B9600      = 9600;
678     enum B19200     = 19200;
679     enum B38400     = 38400;
680 
681     enum CSIZE      = 0x0000300;
682     enum   CS5      = 0x0000000;
683     enum   CS6      = 0x0000100;
684     enum   CS7      = 0x0000200;
685     enum   CS8      = 0x0000300;
686     enum CSTOPB     = 0x0000400;
687     enum CREAD      = 0x0000800;
688     enum PARENB     = 0x0001000;
689     enum PARODD     = 0x0002000;
690     enum HUPCL      = 0x0004000;
691     enum CLOCAL     = 0x0008000;
692 
693     enum ECHO       = 0x00000008;
694     enum ECHOE      = 0x00000002;
695     enum ECHOK      = 0x00000004;
696     enum ECHONL     = 0x00000010;
697     enum ICANON     = 0x00000100;
698     enum IEXTEN     = 0x00000400;
699     enum ISIG       = 0x00000080;
700     enum NOFLSH     = 0x80000000;
701     enum TOSTOP     = 0x00400000;
702 
703     enum TCSANOW    = 0;
704     enum TCSADRAIN  = 1;
705     enum TCSAFLUSH  = 2;
706 
707     enum TCIFLUSH   = 1;
708     enum TCOFLUSH   = 2;
709     enum TCIOFLUSH  = 3;
710 
711     enum TCIOFF     = 3;
712     enum TCION      = 4;
713     enum TCOOFF     = 1;
714     enum TCOON      = 2;
715 }
716 else version (Solaris)
717 {
718     alias tcflag_t = uint;
719     alias cc_t = ubyte;
720     alias speed_t = uint;
721 
722     enum NCCS   = 19;
723 
724     struct termios
725     {
726         tcflag_t   c_iflag;    /* input modes */
727         tcflag_t   c_oflag;    /* output modes */
728         tcflag_t   c_cflag;    /* control modes */
729         tcflag_t   c_lflag;    /* line discipline modes */
730         cc_t[NCCS] c_cc;       /* control chars */
731     }
732 
733     /* control characters */
734     enum VINTR  = 0;
735     enum VQUIT  = 1;
736     enum VERASE = 2;
737     enum VKILL  = 3;
738     enum VEOF   = 4;
739     enum VEOL   = 5;
740     enum VMIN   = 4;
741     enum VTIME  = 5;
742     enum VSTART = 8;
743     enum VSTOP  = 9;
744     enum VSUSP  = 10;
745 
746     /* input modes */
747     enum IGNBRK = 0x000001;
748     enum BRKINT = 0x000002;
749     enum IGNPAR = 0x000004;
750     enum PARMRK = 0x000008;
751     enum INPCK  = 0x000010;
752     enum ISTRIP = 0x000020;
753     enum INLCR  = 0x000040;
754     enum IGNCR  = 0x000080;
755     enum ICRNL  = 0x000100;
756     enum IXON   = 0x000400;
757     enum IXOFF  = 0x001000;
758 
759     /* output modes */
760     enum OPOST  = 0x000001;
761 
762     /* control modes */
763     enum CSIZE  = 0x000030;
764     enum CS5    = 0x000000;
765     enum CS6    = 0x000010;
766     enum CS7    = 0x000020;
767     enum CS8    = 0x000030;
768     enum CSTOPB = 0x000040;
769     enum CREAD  = 0x000080;
770     enum PARENB = 0x000100;
771     enum PARODD = 0x000200;
772     enum HUPCL  = 0x000400;
773     enum CLOCAL = 0x000800;
774 
775     enum CRTSCTS = 0x10000000;
776 
777     /* line discipline 0 modes */
778     enum ISIG   = 0x000001;
779     enum ICANON = 0x000002;
780     enum ECHO   = 0x000008;
781     enum ECHOE  = 0x000010;
782     enum ECHOK  = 0x000020;
783     enum ECHONL = 0x000040;
784     enum NOFLSH = 0x000080;
785     enum TOSTOP = 0x000100;
786 
787     enum ECHOCTL = 0x000200;
788     enum ECHOPRT = 0x000400;
789     enum ECHOKE  = 0x000800;
790 
791     enum IEXTEN = 0x008000;  /* POSIX flag - enable POSIX extensions */
792 
793     enum _TIOC      = ('T'<<8);
794     enum TCSANOW    = (_TIOC|14);
795     enum TCSADRAIN  = (_TIOC|15);
796     enum TCSAFLUSH  = (_TIOC|16);
797 
798     /* termios option flags */
799     enum TCIFLUSH   = 0;  /* flush data received but not read */
800     enum TCOFLUSH   = 1;  /* flush data written but not transmitted */
801     enum TCIOFLUSH  = 2;  /* flush both data both input and output queues */
802 
803     enum TCOOFF     = 0;  /* suspend output */
804     enum TCOON      = 1;  /* restart suspended output */
805     enum TCIOFF     = 2;  /* suspend input */
806     enum TCION      = 3;  /* restart suspended input */
807 
808     /* Speeds */
809     enum B0      = 0;
810     enum B50     = 1;
811     enum B75     = 2;
812     enum B110    = 3;
813     enum B134    = 4;
814     enum B150    = 5;
815     enum B200    = 6;
816     enum B300    = 7;
817     enum B600    = 8;
818     enum B1200   = 9;
819     enum B1800   = 10;
820     enum B2400   = 11;
821     enum B4800   = 12;
822     enum B9600   = 13;
823     enum B19200  = 14;
824     enum B38400  = 15;
825     enum B57600  = 16;
826     enum B76800  = 17;
827     enum B115200 = 18;
828     enum B153600 = 19;
829     enum B230400 = 20;
830     enum B307200 = 21;
831     enum B460800 = 22;
832     enum B921600 = 23;
833 }
834 
835 /*
836 speed_t cfgetispeed(const scope termios*);
837 speed_t cfgetospeed(const scope termios*);
838 int     cfsetispeed(termios*, speed_t);
839 int     cfsetospeed(termios*, speed_t);
840 int     tcdrain(int);
841 int     tcflow(int, int);
842 int     tcflush(int, int);
843 int     tcgetattr(int, termios*);
844 int     tcsendbreak(int, int);
845 int     tcsetattr(int, int, const scope termios*);
846 */
847 
848 version (CRuntime_Glibc)
849 {
850     speed_t cfgetispeed(const scope termios*);
851     speed_t cfgetospeed(const scope termios*);
852     int     cfsetispeed(termios*, speed_t);
853     int     cfsetospeed(termios*, speed_t);
854     int     tcdrain(int);
855     int     tcflow(int, int);
856     int     tcflush(int, int);
857     int     tcgetattr(int, termios*);
858     int     tcsendbreak(int, int);
859     int     tcsetattr(int, int, const scope termios*);
860 }
861 else version (Darwin)
862 {
863     speed_t cfgetispeed(const scope termios*);
864     speed_t cfgetospeed(const scope termios*);
865     int     cfsetispeed(termios*, speed_t);
866     int     cfsetospeed(termios*, speed_t);
867     int     tcdrain(int);
868     int     tcflow(int, int);
869     int     tcflush(int, int);
870     int     tcgetattr(int, termios*);
871     int     tcsendbreak(int, int);
872     int     tcsetattr(int, int, const scope termios*);
873 
874 }
875 else version (FreeBSD)
876 {
877     speed_t cfgetispeed(const scope termios*);
878     speed_t cfgetospeed(const scope termios*);
879     int     cfsetispeed(termios*, speed_t);
880     int     cfsetospeed(termios*, speed_t);
881     int     tcdrain(int);
882     int     tcflow(int, int);
883     int     tcflush(int, int);
884     int     tcgetattr(int, termios*);
885     int     tcsendbreak(int, int);
886     int     tcsetattr(int, int, const scope termios*);
887 }
888 else version (DragonFlyBSD)
889 {
890     speed_t cfgetispeed(const scope termios*);
891     speed_t cfgetospeed(const scope termios*);
892     int     cfsetispeed(termios*, speed_t);
893     int     cfsetospeed(termios*, speed_t);
894     int     tcdrain(int);
895     int     tcflow(int, int);
896     int     tcflush(int, int);
897     int     tcgetattr(int, termios*);
898     int     tcsendbreak(int, int);
899     int     tcsetattr(int, int, const scope termios*);
900 }
901 else version (NetBSD)
902 {
903     speed_t cfgetispeed(const scope termios*);
904     speed_t cfgetospeed(const scope termios*);
905     int     cfsetispeed(termios*, speed_t);
906     int     cfsetospeed(termios*, speed_t);
907     int     tcdrain(int);
908     int     tcflow(int, int);
909     int     tcflush(int, int);
910     int     tcgetattr(int, termios*);
911     int     tcsendbreak(int, int);
912     int     tcsetattr(int, int, const scope termios*);
913 }
914 else version (OpenBSD)
915 {
916     speed_t cfgetispeed(const scope termios*);
917     speed_t cfgetospeed(const scope termios*);
918     int     cfsetispeed(termios*, speed_t);
919     int     cfsetospeed(termios*, speed_t);
920     int     tcdrain(int);
921     int     tcflow(int, int);
922     int     tcflush(int, int);
923     int     tcgetattr(int, termios*);
924     int     tcsendbreak(int, int);
925     int     tcsetattr(int, int, const scope termios*);
926 }
927 else version (Solaris)
928 {
929     speed_t cfgetospeed(const scope termios*);
930     int     cfsetospeed(termios*, speed_t);
931     speed_t cfgetispeed(const scope termios*);
932     int     cfsetispeed(termios*, speed_t);
933     int     tcgetattr(int, termios*);
934     int     tcsetattr(int, int, const scope termios*);
935     int     tcsendbreak(int, int);
936     int     tcdrain(int);
937     int     tcflush(int, int);
938     int     tcflow(int, int);
939 }
940 else version (CRuntime_UClibc)
941 {
942     speed_t cfgetispeed(const scope termios*);
943     speed_t cfgetospeed(const scope termios*);
944     int     cfsetispeed(termios*, speed_t);
945     int     cfsetospeed(termios*, speed_t);
946     int     tcdrain(int);
947     int     tcflow(int, int);
948     int     tcflush(int, int);
949     int     tcgetattr(int, termios*);
950     int     tcsendbreak(int, int);
951     int     tcsetattr(int, int, const scope termios*);
952 }
953 
954 //
955 // XOpen (XSI)
956 //
957 /*
958 IXANY
959 
960 ONLCR
961 OCRNL
962 ONOCR
963 ONLRET
964 OFILL
965 NLDLY
966     NL0
967     NL1
968 CRDLY
969     CR0
970     CR1
971     CR2
972     CR3
973 TABDLY
974     TAB0
975     TAB1
976     TAB2
977     TAB3
978 BSDLY
979     BS0
980     BS1
981 VTDLY
982     VT0
983     VT1
984 FFDLY
985     FF0
986     FF1
987 
988 pid_t   tcgetsid(int);
989 */
990 
991 version (CRuntime_Glibc)
992 {
993     enum IXANY      = 0x0000800; // 0004000
994 
995     enum ONLCR      = 0x0000004; // 0000004
996     enum OCRNL      = 0x0000008; // 0000010
997     enum ONOCR      = 0x0000010; // 0000020
998     enum ONLRET     = 0x0000020; // 0000040
999     enum OFILL      = 0x0000040; // 0000100
1000     enum NLDLY      = 0x0000100; // 0000400
1001     enum   NL0      = 0x0000000; // 0000000
1002     enum   NL1      = 0x0000100; // 0000400
1003     enum CRDLY      = 0x0000600; // 0003000
1004     enum   CR0      = 0x0000000; // 0000000
1005     enum   CR1      = 0x0000200; // 0001000
1006     enum   CR2      = 0x0000400; // 0002000
1007     enum   CR3      = 0x0000600; // 0003000
1008     enum TABDLY     = 0x0001800; // 0014000
1009     enum   TAB0     = 0x0000000; // 0000000
1010     enum   TAB1     = 0x0000800; // 0004000
1011     enum   TAB2     = 0x0001000; // 0010000
1012     enum   TAB3     = 0x0001800; // 0014000
1013     enum BSDLY      = 0x0002000; // 0020000
1014     enum   BS0      = 0x0000000; // 0000000
1015     enum   BS1      = 0x0002000; // 0020000
1016     enum VTDLY      = 0x0004000; // 0040000
1017     enum   VT0      = 0x0000000; // 0000000
1018     enum   VT1      = 0x0004000; // 0040000
1019     enum FFDLY      = 0x0008000; // 0100000
1020     enum   FF0      = 0x0000000; // 0000000
1021     enum   FF1      = 0x0008000; // 0100000
1022 
1023     pid_t   tcgetsid(int);
1024 }
1025 
1026 else version (Darwin)
1027 {
1028     enum IXANY      = 0x00000800;
1029 
1030     enum ONLCR      = 0x00000002;
1031     enum OCRNL      = 0x00000010;
1032     enum ONOCR      = 0x00000020;
1033     enum ONLRET     = 0x00000040;
1034     enum OFILL      = 0x00000080;
1035     enum NLDLY      = 0x00000300;
1036     enum   NL0      = 0x00000000;
1037     enum   NL1      = 0x00000100;
1038     enum CRDLY      = 0x00003000;
1039     enum   CR0      = 0x00000000;
1040     enum   CR1      = 0x00001000;
1041     enum   CR2      = 0x00002000;
1042     enum   CR3      = 0x00003000;
1043     enum TABDLY     = 0x00000c04;
1044     enum   TAB0     = 0x00000000;
1045     enum   TAB1     = 0x00000400;
1046     enum   TAB2     = 0x00000800;
1047     enum   TAB3     = 0x00000004;
1048     enum BSDLY      = 0x00008000;
1049     enum   BS0      = 0x00000000;
1050     enum   BS1      = 0x00008000;
1051     enum VTDLY      = 0x00010000;
1052     enum   VT0      = 0x00000000;
1053     enum   VT1      = 0x00010000;
1054     enum FFDLY      = 0x00004000;
1055     enum   FF0      = 0x00000000;
1056     enum   FF1      = 0x00004000;
1057 
1058     pid_t tcgetsid (int);
1059 }
1060 
1061 else version (FreeBSD)
1062 {
1063     enum IXANY      = 0x00000800;
1064 
1065     enum ONLCR      = 0x00000002;
1066     enum OCRNL      = 0x00000010;
1067     enum ONOCR      = 0x00000020;
1068     enum ONLRET     = 0x00000040;
1069     //enum OFILL
1070     //enum NLDLY
1071     //enum     NL0
1072     //enum     NL1
1073     //enum CRDLY
1074     //enum     CR0
1075     //enum     CR1
1076     //enum     CR2
1077     //enum     CR3
1078     enum TABDLY     = 0x00000004;
1079     enum     TAB0   = 0x00000000;
1080     //enum     TAB1
1081     //enum     TAB2
1082     enum     TAB3   = 0x00000004;
1083     //enum BSDLY
1084     //enum     BS0
1085     //enum     BS1
1086     //enum VTDLY
1087     //enum     VT0
1088     //enum     VT1
1089     //enum FFDLY
1090     //enum     FF0
1091     //enum     FF1
1092 
1093     pid_t   tcgetsid(int);
1094 }
1095 else version (DragonFlyBSD)
1096 {
1097     enum IXANY      = 0x00000800;
1098 
1099     enum ONLCR      = 0x00000002;
1100     enum OCRNL      = 0x00000010;
1101     enum ONOCR      = 0x00000020;
1102     enum ONLRET     = 0x00000040;
1103     //enum OFILL
1104     //enum NLDLY
1105     //enum     NL0
1106     //enum     NL1
1107     //enum CRDLY
1108     //enum     CR0
1109     //enum     CR1
1110     //enum     CR2
1111     //enum     CR3
1112     enum TABDLY     = 0x00000004;
1113     enum     TAB0   = 0x00000000;
1114     //enum     TAB1
1115     //enum     TAB2
1116     enum     TAB3   = 0x00000004;
1117     //enum BSDLY
1118     //enum     BS0
1119     //enum     BS1
1120     //enum VTDLY
1121     //enum     VT0
1122     //enum     VT1
1123     //enum FFDLY
1124     //enum     FF0
1125     //enum     FF1
1126 
1127     pid_t   tcgetsid(int);
1128 }
1129 else version (NetBSD)
1130 {
1131     enum IXANY      = 0x00000800;
1132 
1133     enum ONLCR      = 0x00000002;
1134     enum OCRNL      = 0x00000010;
1135     enum ONOCR      = 0x00000020;
1136     enum ONLRET     = 0x00000040;
1137     //enum OFILL
1138     //enum NLDLY
1139     //enum     NL0
1140     //enum     NL1
1141     //enum CRDLY
1142     //enum     CR0
1143     //enum     CR1
1144     //enum     CR2
1145     //enum     CR3
1146     enum TABDLY     = 0x00000004;
1147     enum     TAB0   = 0x00000000;
1148     //enum     TAB1
1149     //enum     TAB2
1150     enum     TAB3   = 0x00000004;
1151     //enum BSDLY
1152     //enum     BS0
1153     //enum     BS1
1154     //enum VTDLY
1155     //enum     VT0
1156     //enum     VT1
1157     //enum FFDLY
1158     //enum     FF0
1159     //enum     FF1
1160 
1161     pid_t   tcgetsid(int);
1162 }
1163 else version (OpenBSD)
1164 {
1165     enum IXANY      = 0x00000800;
1166 
1167     enum ONLCR      = 0x00000002;
1168     enum OCRNL      = 0x00000010;
1169     enum ONOCR      = 0x00000040;
1170     enum ONLRET     = 0x00000080;
1171     //enum OFILL
1172     //enum NLDLY
1173     //enum   NL0
1174     //enum   NL1
1175     //enum CRDLY
1176     //enum   CR0
1177     //enum   CR1
1178     //enum   CR2
1179     //enum   CR3
1180     //enum TABDLY
1181     //enum   TAB0
1182     //enum   TAB1
1183     //enum   TAB2
1184     //enum   TAB3
1185     //enum BSDLY
1186     //enum   BS0
1187     //enum   BS1
1188     //enum VTDLY
1189     //enum   VT0
1190     //enum   VT1
1191     //enum FFDLY
1192     //enum   FF0
1193     //enum   FF1
1194 
1195     pid_t   tcgetsid(int);
1196 }
1197 else version (Solaris)
1198 {
1199     enum IXANY      = 0x0000800;
1200 
1201     enum ONLCR      = 0x0000004;
1202     enum OCRNL      = 0x0000008;
1203     enum ONOCR      = 0x0000010;
1204     enum ONLRET     = 0x0000020;
1205     enum OFILL      = 0x0000040;
1206     enum OFDEL      = 0x0000080;
1207     enum NLDLY      = 0x0000100;
1208     enum NL0        = 0x0000000;
1209     enum NL1        = 0x0000100;
1210     enum CRDLY      = 0x0000600;
1211     enum CR0        = 0x0000000;
1212     enum CR1        = 0x0000200;
1213     enum CR2        = 0x0000400;
1214     enum CR3        = 0x0000600;
1215     enum TABDLY     = 0x0001800;
1216     enum TAB0       = 0x0000000;
1217     enum TAB1       = 0x0000800;
1218     enum TAB2       = 0x0001000;
1219     enum TAB3       = 0x0001800;
1220     enum BSDLY      = 0x0002000;
1221     enum BS0        = 0x0000000;
1222     enum BS1        = 0x0002000;
1223     enum VTDLY      = 0x0004000;
1224     enum VT0        = 0x0000000;
1225     enum VT1        = 0x0004000;
1226     enum FFDLY      = 0x0008000;
1227     enum FF0        = 0x0000000;
1228     enum FF1        = 0x0008000;
1229     enum XCASE      = 0x0000004;
1230 
1231     pid_t   tcgetsid(int);
1232 }
1233 else version (CRuntime_UClibc)
1234 {
1235     enum IXANY      = 0x0000800; // 0004000
1236 
1237     enum ONLCR      = 0x0000004; // 0000004
1238     enum OCRNL      = 0x0000008; // 0000010
1239     enum ONOCR      = 0x0000010; // 0000020
1240     enum ONLRET     = 0x0000020; // 0000040
1241     enum OFILL      = 0x0000040; // 0000100
1242     enum NLDLY      = 0x0000100; // 0000400
1243     enum   NL0      = 0x0000000; // 0000000
1244     enum   NL1      = 0x0000100; // 0000400
1245     enum CRDLY      = 0x0000600; // 0003000
1246     enum   CR0      = 0x0000000; // 0000000
1247     enum   CR1      = 0x0000200; // 0001000
1248     enum   CR2      = 0x0000400; // 0002000
1249     enum   CR3      = 0x0000600; // 0003000
1250     enum TABDLY     = 0x0001800; // 0014000
1251     enum   TAB0     = 0x0000000; // 0000000
1252     enum   TAB1     = 0x0000800; // 0004000
1253     enum   TAB2     = 0x0001000; // 0010000
1254     enum   TAB3     = 0x0001800; // 0014000
1255     enum BSDLY      = 0x0002000; // 0020000
1256     enum   BS0      = 0x0000000; // 0000000
1257     enum   BS1      = 0x0002000; // 0020000
1258     enum VTDLY      = 0x0004000; // 0040000
1259     enum   VT0      = 0x0000000; // 0000000
1260     enum   VT1      = 0x0004000; // 0040000
1261     enum FFDLY      = 0x0008000; // 0100000
1262     enum   FF0      = 0x0000000; // 0000000
1263     enum   FF1      = 0x0008000; // 0100000
1264 
1265     pid_t   tcgetsid(int);
1266 }