d: Merge upstream dmd, druntime f8bae04558, phobos ba2ade9dec
[official-gcc.git] / libgm2 / libm2pim / termios.cc
blob6176a5b15c14405d3005d9353d0ed88536dc9d0f
1 /* termios.cc provide access to the terminal.
3 Copyright (C) 2010-2022 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6 This file is part of GNU Modula-2.
8 GNU Modula-2 is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
13 GNU Modula-2 is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. */
27 #include <config.h>
28 #include <m2rts.h>
30 #define EXPORT(FUNC) m2pim ## _termios_ ## FUNC
31 #define M2EXPORT(FUNC) m2pim ## _M2_termios_ ## FUNC
32 #define M2LIBNAME "m2pim"
34 #if defined(HAVE_STDIO_H)
35 #include <stdio.h>
36 #endif
37 #if defined(HAVE_STDARG_H)
38 #include <stdarg.h>
39 #endif
40 #if defined(HAVE_STDLIB_H)
41 #include <stdlib.h>
42 #endif
43 #if defined(HAVE_STRING_H)
44 #include <string.h>
45 #endif
46 #if defined(HAVE_STRINGS_H)
47 #include <strings.h>
48 #endif
50 #ifdef TERMIOS_NEEDS_XOPEN_SOURCE
51 #define _XOPEN_SOURCE
52 #endif
54 #if defined(HAVE_SYS_TYPES_H)
55 #include <sys/types.h>
56 #endif
58 #if defined(HAVE_TERMIOS_H)
59 #include <termios.h>
60 #endif
62 void _M2_termios_init (void);
63 void _M2_termios_finish (void);
65 #if defined(HAVE_TERMIOS_H)
67 typedef enum {
68 vintr,
69 vquit,
70 verase,
71 vkill,
72 veof,
73 vtime,
74 vmin,
75 vswtc,
76 vstart,
77 vstop,
78 vsusp,
79 veol,
80 vreprint,
81 vdiscard,
82 vwerase,
83 vlnext,
84 veol2
85 } ControlChar;
87 typedef enum {
88 /* Input flag bits. */
89 ignbrk,
90 ibrkint,
91 ignpar,
92 iparmrk,
93 inpck,
94 istrip,
95 inlcr,
96 igncr,
97 icrnl,
98 iuclc,
99 ixon,
100 ixany,
101 ixoff,
102 imaxbel,
103 /* Output flag bits. */
104 opost,
105 olcuc,
106 onlcr,
107 ocrnl,
108 onocr,
109 onlret,
110 ofill,
111 ofdel,
112 onl0,
113 onl1,
114 ocr0,
115 ocr1,
116 ocr2,
117 ocr3,
118 otab0,
119 otab1,
120 otab2,
121 otab3,
122 obs0,
123 obs1,
124 off0,
125 off1,
126 ovt0,
127 ovt1,
128 /* Baud rate. */
130 b50,
131 b75,
132 b110,
133 b135,
134 b150,
135 b200,
136 b300,
137 b600,
138 b1200,
139 b1800,
140 b2400,
141 b4800,
142 b9600,
143 b19200,
144 b38400,
145 b57600,
146 b115200,
147 b240400,
148 b460800,
149 b500000,
150 b576000,
151 b921600,
152 b1000000,
153 b1152000,
154 b1500000,
155 b2000000,
156 b2500000,
157 b3000000,
158 b3500000,
159 b4000000,
160 maxbaud,
161 crtscts,
162 /* Character size. */
163 cs5,
164 cs6,
165 cs7,
166 cs8,
167 cstopb,
168 cread,
169 parenb,
170 parodd,
171 hupcl,
172 clocal,
173 /* Local flags. */
174 lisig,
175 licanon,
176 lxcase,
177 lecho,
178 lechoe,
179 lechok,
180 lechonl,
181 lnoflsh,
182 ltopstop,
183 lechoctl,
184 lechoprt,
185 lechoke,
186 lflusho,
187 lpendin,
188 liexten
189 } Flag;
191 /* Prototypes. */
192 extern "C" void *EXPORT (InitTermios) (void);
193 extern "C" void *EXPORT (KillTermios) (struct termios *p);
194 extern "C" int EXPORT (cfgetospeed) (struct termios *t);
195 extern "C" int EXPORT (cfgetispeed) (struct termios *t);
196 extern "C" int EXPORT (cfsetospeed) (struct termios *t, unsigned int b);
197 extern "C" int EXPORT (cfsetispeed) (struct termios *t, unsigned int b);
198 extern "C" int EXPORT (cfsetspeed) (struct termios *t, unsigned int b);
199 extern "C" int EXPORT (tcgetattr) (int fd, struct termios *t);
200 extern "C" int EXPORT (tcsetattr) (int fd, int option, struct termios *t);
201 extern "C" void EXPORT (cfmakeraw) (struct termios *t);
202 extern "C" int EXPORT (tcsendbreak) (int fd, int duration);
203 extern "C" int EXPORT (tcdrain) (int fd);
204 extern "C" int EXPORT (tcflushi) (int fd);
205 extern "C" int EXPORT (tcflusho) (int fd);
206 extern "C" int EXPORT (tcflushio) (int fd);
207 extern "C" int EXPORT (tcflowoni) (int fd);
208 extern "C" int EXPORT (tcflowoffi) (int fd);
209 extern "C" int EXPORT (tcflowono) (int fd);
210 extern "C" int EXPORT (tcflowoffo) (int fd);
211 extern "C" bool EXPORT (GetFlag) (struct termios *t, Flag f, bool *b);
212 extern "C" bool EXPORT (SetFlag) (struct termios *t, Flag f, bool b);
213 extern "C" bool EXPORT (GetChar) (struct termios *t, ControlChar c, char *ch);
214 extern "C" bool EXPORT (SetChar) (struct termios *t, ControlChar c, char ch);
215 extern "C" int EXPORT (tcsnow) (void);
216 extern "C" int EXPORT (tcsflush) (void);
217 extern "C" int EXPORT (tcsdrain) (void);
218 extern "C" bool doSetUnset (tcflag_t *bitset, unsigned int mask, bool value);
220 /* InitTermios new data structure. */
222 extern "C" void
223 *EXPORT (InitTermios) (void)
225 struct termios *p = (struct termios *)malloc (sizeof (struct termios));
227 memset (p, 0, sizeof (struct termios));
228 return p;
231 /* KillTermios delete data structure. */
233 extern "C" void*
234 EXPORT (KillTermios) (struct termios *p)
236 free (p);
237 return NULL;
240 /* tcsnow return the value of TCSANOW. */
242 extern "C" int
243 EXPORT (tcsnow) (void) { return TCSANOW; }
245 /* tcsdrain return the value of TCSADRAIN. */
247 extern "C" int
248 EXPORT (tcsdrain) (void) { return TCSADRAIN; }
250 /* tcsflush return the value of TCSAFLUSH. */
252 extern "C" int
253 EXPORT (tcsflush) (void) { return TCSAFLUSH; }
255 /* cfgetospeed return output baud rate. */
257 extern "C" int
258 EXPORT (cfgetospeed) (struct termios *t) { return cfgetospeed (t); }
260 /* cfgetispeed return input baud rate. */
262 extern "C" int
263 EXPORT (cfgetispeed) (struct termios *t) { return cfgetispeed (t); }
265 /* cfsetospeed set output baud rate. */
267 extern "C" int
268 EXPORT (cfsetospeed) (struct termios *t, unsigned int b)
270 return cfsetospeed (t, b);
273 /* cfsetispeed set input baud rate. */
275 extern "C" int
276 EXPORT (cfsetispeed) (struct termios *t, unsigned int b)
278 return cfsetispeed (t, b);
281 /* cfsetspeed set input and output baud rate. */
283 extern "C" int
284 EXPORT (cfsetspeed) (struct termios *t, unsigned int b)
286 int val = cfsetispeed (t, b);
287 if (val == 0)
288 return cfsetospeed (t, b);
289 cfsetospeed (t, b);
290 return val;
293 /* tcgetattr get state of, fd, into, t. */
295 extern "C" int
296 EXPORT (tcgetattr) (int fd, struct termios *t)
298 return tcgetattr (fd, t);
301 /* tcsetattr set state of, fd, to, t, using option. */
303 int EXPORT (tcsetattr) (int fd, int option, struct termios *t)
305 return tcsetattr (fd, option, t);
308 /* cfmakeraw sets the terminal to raw mode. */
310 extern "C" void
311 EXPORT (cfmakeraw) (struct termios *t)
313 #if defined(HAVE_CFMAKERAW)
314 return cfmakeraw (t);
315 #endif
318 /* tcsendbreak send zero bits for duration. */
320 extern "C" int
321 EXPORT (tcsendbreak) (int fd, int duration)
323 return tcsendbreak (fd, duration);
326 /* tcdrain waits for pending output to be written on, fd. */
328 extern "C" int
329 EXPORT (tcdrain) (int fd) { return tcdrain (fd); }
331 /* tcflushi flush input. */
333 extern "C" int
334 EXPORT (tcflushi) (int fd)
336 #if defined(TCIFLUSH)
337 return tcflush (fd, TCIFLUSH);
338 #else
339 return 1;
340 #endif
343 /* tcflusho flush output. */
345 extern "C" int
346 EXPORT (tcflusho) (int fd)
348 #if defined(TCOFLUSH)
349 return tcflush (fd, TCOFLUSH);
350 #else
351 return 1;
352 #endif
355 /* tcflushio flush input and output. */
357 extern "C" int
358 EXPORT (tcflushio) (int fd)
360 #if defined(TCIOFLUSH)
361 return tcflush (fd, TCIOFLUSH);
362 #else
363 return 1;
364 #endif
367 /* tcflowoni restart input on, fd. */
369 extern "C" int
370 EXPORT (tcflowoni) (int fd)
372 #if defined(TCION)
373 return tcflow (fd, TCION);
374 #else
375 return 1;
376 #endif
379 /* tcflowoffi stop input on, fd. */
381 extern "C" int
382 EXPORT (tcflowoffi) (int fd)
384 #if defined(TCIOFF)
385 return tcflow (fd, TCIOFF);
386 #else
387 return 1;
388 #endif
391 /* tcflowono restart output on, fd. */
393 extern "C" int
394 EXPORT (tcflowono) (int fd)
396 #if defined(TCOON)
397 return tcflow (fd, TCOON);
398 #else
399 return 1;
400 #endif
403 /* tcflowoffo stop output on, fd. */
405 extern "C" int
406 EXPORT (tcflowoffo) (int fd)
408 #if defined(TCOOFF)
409 return tcflow (fd, TCOOFF);
410 #else
411 return 1;
412 #endif
415 /* doSetUnset applies mask or undoes mask depending upon value and returns true. */
417 extern "C" bool
418 doSetUnset (tcflag_t *bitset, unsigned int mask, bool value)
420 if (value)
421 (*bitset) |= mask;
422 else
423 (*bitset) &= (~mask);
424 return true;
427 /* GetFlag sets a flag value from t in b and returns true if t supports f. */
429 extern "C" bool
430 EXPORT (GetFlag) (struct termios *t, Flag f, bool *b)
432 switch (f)
435 case ignbrk:
436 #if defined(IGNBRK)
437 *b = ((t->c_iflag & IGNBRK) == IGNBRK);
438 return true;
439 #else
440 return false;
441 #endif
442 case ibrkint:
443 #if defined(BRKINT)
444 *b = ((t->c_iflag & BRKINT) == BRKINT);
445 return true;
446 #else
447 return false;
448 #endif
449 case ignpar:
450 #if defined(IGNPAR)
451 *b = ((t->c_iflag & IGNPAR) == IGNPAR);
452 return true;
453 #else
454 return false;
455 #endif
456 case iparmrk:
457 #if defined(PARMRK)
458 *b = ((t->c_iflag & PARMRK) == PARMRK);
459 return true;
460 #else
461 return false;
462 #endif
463 case inpck:
464 #if defined(INPCK)
465 *b = ((t->c_iflag & INPCK) == INPCK);
466 return true;
467 #else
468 return false;
469 #endif
470 case istrip:
471 #if defined(ISTRIP)
472 *b = ((t->c_iflag & ISTRIP) == ISTRIP);
473 return true;
474 #else
475 return false;
476 #endif
477 case inlcr:
478 #if defined(INLCR)
479 *b = ((t->c_iflag & INLCR) == INLCR);
480 return true;
481 #else
482 return false;
483 #endif
484 case igncr:
485 #if defined(IGNCR)
486 *b = ((t->c_iflag & IGNCR) == IGNCR);
487 return true;
488 #else
489 return false;
490 #endif
491 case icrnl:
492 #if defined(ICRNL)
493 *b = ((t->c_iflag & ICRNL) == ICRNL);
494 return true;
495 #else
496 return false;
497 #endif
498 case iuclc:
499 #if defined(IUCLC)
500 *b = ((t->c_iflag & IUCLC) == IUCLC);
501 return true;
502 #else
503 return false;
504 #endif
505 case ixon:
506 #if defined(IXON)
507 *b = ((t->c_iflag & IXON) == IXON);
508 return true;
509 #else
510 return false;
511 #endif
512 case ixany:
513 #if defined(IXANY)
514 *b = ((t->c_iflag & IXANY) == IXANY);
515 return true;
516 #else
517 return false;
518 #endif
519 case ixoff:
520 #if defined(IXOFF)
521 *b = ((t->c_iflag & IXOFF) == IXOFF);
522 return true;
523 #else
524 return false;
525 #endif
526 case imaxbel:
527 #if defined(IMAXBEL)
528 *b = ((t->c_iflag & IMAXBEL) == IMAXBEL);
529 return true;
530 #else
531 return false;
532 #endif
533 case opost:
534 #if defined(OPOST)
535 *b = ((t->c_oflag & OPOST) == OPOST);
536 return true;
537 #else
538 return false;
539 #endif
540 case olcuc:
541 #if defined(OLCUC)
542 *b = ((t->c_oflag & OLCUC) == OLCUC);
543 return true;
544 #else
545 return false;
546 #endif
547 case onlcr:
548 #if defined(ONLCR)
549 *b = ((t->c_oflag & ONLCR) == ONLCR);
550 return true;
551 #else
552 return false;
553 #endif
554 case ocrnl:
555 #if defined(OCRNL)
556 *b = ((t->c_oflag & OCRNL) == OCRNL);
557 return true;
558 #else
559 return false;
560 #endif
561 case onocr:
562 #if defined(ONOCR)
563 *b = ((t->c_oflag & ONOCR) == ONOCR);
564 return true;
565 #else
566 return false;
567 #endif
568 case onlret:
569 #if defined(ONLRET)
570 *b = ((t->c_oflag & ONLRET) == ONLRET);
571 return true;
572 #else
573 return false;
574 #endif
575 case ofill:
576 #if defined(OFILL)
577 *b = ((t->c_oflag & OFILL) == OFILL);
578 return true;
579 #else
580 return false;
581 #endif
582 case ofdel:
583 #if defined(OFDEL)
584 *b = ((t->c_oflag & OFDEL) == OFDEL);
585 return true;
586 #else
587 return false;
588 #endif
589 case onl0:
590 #if defined(NL0)
591 *b = ((t->c_oflag & NL0) == NL0);
592 return true;
593 #else
594 return false;
595 #endif
596 case onl1:
597 #if defined(NL1)
598 *b = ((t->c_oflag & NL1) == NL1);
599 return true;
600 #else
601 return false;
602 #endif
603 case ocr0:
604 #if defined(CR0)
605 *b = ((t->c_oflag & CR0) == CR0);
606 return true;
607 #else
608 return false;
609 #endif
610 case ocr1:
611 #if defined(CR1)
612 *b = ((t->c_oflag & CR1) == CR1);
613 return true;
614 #else
615 return false;
616 #endif
617 case ocr2:
618 #if defined(CR2)
619 *b = ((t->c_oflag & CR2) == CR2);
620 return true;
621 #else
622 return false;
623 #endif
624 case ocr3:
625 #if defined(CR3)
626 *b = ((t->c_oflag & CR3) == CR3);
627 return true;
628 #else
629 return false;
630 #endif
631 case otab0:
632 #if defined(TAB0)
633 *b = ((t->c_oflag & TAB0) == TAB0);
634 return true;
635 #else
636 return false;
637 #endif
638 case otab1:
639 #if defined(TAB1)
640 *b = ((t->c_oflag & TAB1) == TAB1);
641 return true;
642 #else
643 return false;
644 #endif
645 case otab2:
646 #if defined(TAB2)
647 *b = ((t->c_oflag & TAB2) == TAB2);
648 return true;
649 #else
650 return false;
651 #endif
652 case otab3:
653 #if defined(TAB3)
654 *b = ((t->c_oflag & TAB3) == TAB3);
655 return true;
656 #else
657 return false;
658 #endif
659 case obs0:
660 #if defined(BS0)
661 *b = ((t->c_oflag & BS0) == BS0);
662 return true;
663 #else
664 return false;
665 #endif
666 case obs1:
667 #if defined(BS1)
668 *b = ((t->c_oflag & BS1) == BS1);
669 return true;
670 #else
671 return false;
672 #endif
673 case off0:
674 #if defined(FF0)
675 *b = ((t->c_oflag & FF0) == FF0);
676 return true;
677 #else
678 return false;
679 #endif
680 case off1:
681 #if defined(FF1)
682 *b = ((t->c_oflag & FF1) == FF1);
683 return true;
684 #else
685 return false;
686 #endif
687 case ovt0:
688 #if defined(VT0)
689 *b = ((t->c_oflag & VT0) == VT0);
690 return true;
691 #else
692 return false;
693 #endif
694 case ovt1:
695 #if defined(VT1)
696 *b = ((t->c_oflag & VT1) == VT1);
697 return true;
698 #else
699 return false;
700 #endif
701 case b0:
702 #if defined(B0)
703 *b = ((t->c_cflag & B0) == B0);
704 return true;
705 #else
706 return false;
707 #endif
708 case b50:
709 #if defined(B50)
710 *b = ((t->c_cflag & B50) == B50);
711 return true;
712 #else
713 return false;
714 #endif
715 case b75:
716 #if defined(B75)
717 *b = ((t->c_cflag & B75) == B75);
718 return true;
719 #else
720 return false;
721 #endif
722 case b110:
723 #if defined(B110)
724 *b = ((t->c_cflag & B110) == B110);
725 return true;
726 #else
727 return false;
728 #endif
729 case b135:
730 #if defined(B134)
731 *b = ((t->c_cflag & B134) == B134);
732 return true;
733 #else
734 return false;
735 #endif
736 case b150:
737 #if defined(B150)
738 *b = ((t->c_cflag & B150) == B150);
739 return true;
740 #else
741 return false;
742 #endif
743 case b200:
744 #if defined(B200)
745 *b = ((t->c_cflag & B200) == B200);
746 return true;
747 #else
748 return false;
749 #endif
750 case b300:
751 #if defined(B300)
752 *b = ((t->c_cflag & B300) == B300);
753 return true;
754 #else
755 return false;
756 #endif
757 case b600:
758 #if defined(B600)
759 *b = ((t->c_cflag & B600) == B600);
760 return true;
761 #else
762 return false;
763 #endif
764 case b1200:
765 #if defined(B1200)
766 *b = ((t->c_cflag & B1200) == B1200);
767 return true;
768 #else
769 return false;
770 #endif
771 case b1800:
772 #if defined(B1800)
773 *b = ((t->c_cflag & B1800) == B1800);
774 return true;
775 #else
776 return false;
777 #endif
778 case b2400:
779 #if defined(B2400)
780 *b = ((t->c_cflag & B2400) == B2400);
781 return true;
782 #else
783 return false;
784 #endif
785 case b4800:
786 #if defined(B4800)
787 *b = ((t->c_cflag & B4800) == B4800);
788 return true;
789 #else
790 return false;
791 #endif
792 case b9600:
793 #if defined(B9600)
794 *b = ((t->c_cflag & B9600) == B9600);
795 return true;
796 #else
797 return false;
798 #endif
799 case b19200:
800 #if defined(B19200)
801 *b = ((t->c_cflag & B19200) == B19200);
802 return true;
803 #else
804 return false;
805 #endif
806 case b38400:
807 #if defined(B38400)
808 *b = ((t->c_cflag & B38400) == B38400);
809 return true;
810 #else
811 return false;
812 #endif
813 case b57600:
814 #if defined(B57600)
815 *b = ((t->c_cflag & B57600) == B57600);
816 return true;
817 #else
818 return false;
819 #endif
820 case b115200:
821 #if defined(B115200)
822 *b = ((t->c_cflag & B115200) == B115200);
823 return true;
824 #else
825 return false;
826 #endif
827 case b240400:
828 #if defined(B230400)
829 *b = ((t->c_cflag & B230400) == B230400);
830 return true;
831 #else
832 return false;
833 #endif
834 case b460800:
835 #if defined(B460800)
836 *b = ((t->c_cflag & B460800) == B460800);
837 return true;
838 #else
839 return false;
840 #endif
841 case b500000:
842 #if defined(B500000)
843 *b = ((t->c_cflag & B500000) == B500000);
844 return true;
845 #else
846 return false;
847 #endif
848 case b576000:
849 #if defined(B576000)
850 *b = ((t->c_cflag & B576000) == B576000);
851 return true;
852 #else
853 return false;
854 #endif
855 case b921600:
856 #if defined(B921600)
857 *b = ((t->c_cflag & B921600) == B921600);
858 return true;
859 #else
860 return false;
861 #endif
862 case b1000000:
863 #if defined(B1000000)
864 *b = ((t->c_cflag & B1000000) == B1000000);
865 return true;
866 #else
867 return false;
868 #endif
869 case b1152000:
870 #if defined(B1152000)
871 *b = ((t->c_cflag & B1152000) == B1152000);
872 return true;
873 #else
874 return false;
875 #endif
876 case b1500000:
877 #if defined(B1500000)
878 *b = ((t->c_cflag & B1500000) == B1500000);
879 return true;
880 #else
881 return false;
882 #endif
883 case b2000000:
884 #if defined(B2000000)
885 *b = ((t->c_cflag & B2000000) == B2000000);
886 return true;
887 #else
888 return false;
889 #endif
890 case b2500000:
891 #if defined(B2500000)
892 *b = ((t->c_cflag & B2500000) == B2500000);
893 return true;
894 #else
895 return false;
896 #endif
897 case b3000000:
898 #if defined(B3000000)
899 *b = ((t->c_cflag & B3000000) == B3000000);
900 return true;
901 #else
902 return false;
903 #endif
904 case b3500000:
905 #if defined(B3500000)
906 *b = ((t->c_cflag & B3500000) == B3500000);
907 return true;
908 #else
909 return false;
910 #endif
911 case b4000000:
912 #if defined(B4000000)
913 *b = ((t->c_cflag & B4000000) == B4000000);
914 return true;
915 #else
916 return false;
917 #endif
918 case maxbaud:
919 #if defined(MAX)
920 *b = ((t->c_cflag & __MAX_BAUD) == __MAX_BAUD);
921 return true;
922 #else
923 return false;
924 #endif
925 case crtscts:
926 #if defined(CRTSCTS)
927 *b = ((t->c_cflag & CRTSCTS) == CRTSCTS);
928 return true;
929 #else
930 return false;
931 #endif
932 case cs5:
933 #if defined(CS5)
934 *b = ((t->c_cflag & CS5) == CS5);
935 return true;
936 #else
937 return false;
938 #endif
939 case cs6:
940 #if defined(CS6)
941 *b = ((t->c_cflag & CS6) == CS6);
942 return true;
943 #else
944 return false;
945 #endif
946 case cs7:
947 #if defined(CS7)
948 *b = ((t->c_cflag & CS7) == CS7);
949 return true;
950 #else
951 return false;
952 #endif
953 case cs8:
954 #if defined(CS8)
955 *b = ((t->c_cflag & CS8) == CS8);
956 return true;
957 #else
958 return false;
959 #endif
960 case cstopb:
961 #if defined(CSTOPB)
962 *b = ((t->c_cflag & CSTOPB) == CSTOPB);
963 return true;
964 #else
965 return false;
966 #endif
967 case cread:
968 #if defined(CREAD)
969 *b = ((t->c_cflag & CREAD) == CREAD);
970 return true;
971 #else
972 return false;
973 #endif
974 case parenb:
975 #if defined(PARENB)
976 *b = ((t->c_cflag & PARENB) == PARENB);
977 return true;
978 #else
979 return false;
980 #endif
981 case parodd:
982 #if defined(PARODD)
983 *b = ((t->c_cflag & PARODD) == PARODD);
984 return true;
985 #else
986 return false;
987 #endif
988 case hupcl:
989 #if defined(HUPCL)
990 *b = ((t->c_cflag & HUPCL) == HUPCL);
991 return true;
992 #else
993 return false;
994 #endif
995 case clocal:
996 #if defined(CLOCAL)
997 *b = ((t->c_cflag & CLOCAL) == CLOCAL);
998 return true;
999 #else
1000 return false;
1001 #endif
1002 case lisig:
1003 #if defined(ISIG)
1004 *b = ((t->c_lflag & ISIG) == ISIG);
1005 return true;
1006 #else
1007 return false;
1008 #endif
1009 case licanon:
1010 #if defined(ICANON)
1011 *b = ((t->c_lflag & ICANON) == ICANON);
1012 return true;
1013 #else
1014 return false;
1015 #endif
1016 case lxcase:
1017 #if defined(XCASE)
1018 *b = ((t->c_lflag & XCASE) == XCASE);
1019 return true;
1020 #else
1021 return false;
1022 #endif
1023 case lecho:
1024 #if defined(ECHO)
1025 *b = ((t->c_lflag & ECHO) == ECHO);
1026 return true;
1027 #else
1028 return false;
1029 #endif
1030 case lechoe:
1031 #if defined(ECHOE)
1032 *b = ((t->c_lflag & ECHOE) == ECHOE);
1033 return true;
1034 #else
1035 return false;
1036 #endif
1037 case lechok:
1038 #if defined(ECHOK)
1039 *b = ((t->c_lflag & ECHOK) == ECHOK);
1040 return true;
1041 #else
1042 return false;
1043 #endif
1044 case lechonl:
1045 #if defined(ECHONL)
1046 *b = ((t->c_lflag & ECHONL) == ECHONL);
1047 return true;
1048 #else
1049 return false;
1050 #endif
1051 case lnoflsh:
1052 #if defined(NOFLSH)
1053 *b = ((t->c_lflag & NOFLSH) == NOFLSH);
1054 return true;
1055 #else
1056 return false;
1057 #endif
1058 case ltopstop:
1059 #if defined(TOSTOP)
1060 *b = ((t->c_lflag & TOSTOP) == TOSTOP);
1061 return true;
1062 #else
1063 return false;
1064 #endif
1065 case lechoctl:
1066 #if defined(ECHOCTL)
1067 *b = ((t->c_lflag & ECHOCTL) == ECHOCTL);
1068 return true;
1069 #else
1070 return false;
1071 #endif
1072 case lechoprt:
1073 #if defined(ECHOPRT)
1074 *b = ((t->c_lflag & ECHOPRT) == ECHOPRT);
1075 return true;
1076 #else
1077 return false;
1078 #endif
1079 case lechoke:
1080 #if defined(ECHOKE)
1081 *b = ((t->c_lflag & ECHOKE) == ECHOKE);
1082 return true;
1083 #else
1084 return false;
1085 #endif
1086 case lflusho:
1087 #if defined(FLUSHO)
1088 *b = ((t->c_lflag & FLUSHO) == FLUSHO);
1089 return true;
1090 #else
1091 return false;
1092 #endif
1093 case lpendin:
1094 #if defined(PENDIN)
1095 *b = ((t->c_lflag & PENDIN) == PENDIN);
1096 return true;
1097 #else
1098 return false;
1099 #endif
1100 case liexten:
1101 #if defined(IEXTEN)
1102 *b = ((t->c_lflag & IEXTEN) == IEXTEN);
1103 return true;
1104 #else
1105 return false;
1106 #endif
1108 return false;
1111 /* SetFlag sets a flag value in t to b and returns true if this flag
1112 value is supported. */
1114 extern "C" bool
1115 EXPORT (SetFlag) (struct termios *t, Flag f, bool b)
1117 switch (f)
1120 case ignbrk:
1121 #if defined(IGNBRK)
1122 return doSetUnset (&t->c_iflag, IGNBRK, b);
1123 #else
1124 return false;
1125 #endif
1126 case ibrkint:
1127 #if defined(BRKINT)
1128 return doSetUnset (&t->c_iflag, BRKINT, b);
1129 #else
1130 return false;
1131 #endif
1132 case ignpar:
1133 #if defined(IGNPAR)
1134 return doSetUnset (&t->c_iflag, IGNPAR, b);
1135 #else
1136 return false;
1137 #endif
1138 case iparmrk:
1139 #if defined(PARMRK)
1140 return doSetUnset (&t->c_iflag, PARMRK, b);
1141 #else
1142 return false;
1143 #endif
1144 case inpck:
1145 #if defined(INPCK)
1146 return doSetUnset (&t->c_iflag, INPCK, b);
1147 #else
1148 return false;
1149 #endif
1150 case istrip:
1151 #if defined(ISTRIP)
1152 return doSetUnset (&t->c_iflag, ISTRIP, b);
1153 #else
1154 return false;
1155 #endif
1156 case inlcr:
1157 #if defined(INLCR)
1158 return doSetUnset (&t->c_iflag, INLCR, b);
1159 #else
1160 return false;
1161 #endif
1162 case igncr:
1163 #if defined(IGNCR)
1164 return doSetUnset (&t->c_iflag, IGNCR, b);
1165 #else
1166 return false;
1167 #endif
1168 case icrnl:
1169 #if defined(ICRNL)
1170 return doSetUnset (&t->c_iflag, ICRNL, b);
1171 #else
1172 return false;
1173 #endif
1174 case iuclc:
1175 #if defined(IUCLC)
1176 return doSetUnset (&t->c_iflag, IUCLC, b);
1177 #else
1178 return false;
1179 #endif
1180 case ixon:
1181 #if defined(IXON)
1182 return doSetUnset (&t->c_iflag, IXON, b);
1183 #else
1184 return false;
1185 #endif
1186 case ixany:
1187 #if defined(IXANY)
1188 return doSetUnset (&t->c_iflag, IXANY, b);
1189 #else
1190 return false;
1191 #endif
1192 case ixoff:
1193 #if defined(IXOFF)
1194 return doSetUnset (&t->c_iflag, IXOFF, b);
1195 #else
1196 return false;
1197 #endif
1198 case imaxbel:
1199 #if defined(IMAXBEL)
1200 return doSetUnset (&t->c_iflag, IMAXBEL, b);
1201 #else
1202 return false;
1203 #endif
1204 case opost:
1205 #if defined(OPOST)
1206 return doSetUnset (&t->c_oflag, OPOST, b);
1207 #else
1208 return false;
1209 #endif
1210 case olcuc:
1211 #if defined(OLCUC)
1212 return doSetUnset (&t->c_oflag, OLCUC, b);
1213 #else
1214 return false;
1215 #endif
1216 case onlcr:
1217 #if defined(ONLCR)
1218 return doSetUnset (&t->c_oflag, ONLCR, b);
1219 #else
1220 return false;
1221 #endif
1222 case ocrnl:
1223 #if defined(OCRNL)
1224 return doSetUnset (&t->c_oflag, OCRNL, b);
1225 #else
1226 return false;
1227 #endif
1228 case onocr:
1229 #if defined(ONOCR)
1230 return doSetUnset (&t->c_oflag, ONOCR, b);
1231 #else
1232 return false;
1233 #endif
1234 case onlret:
1235 #if defined(ONLRET)
1236 return doSetUnset (&t->c_oflag, ONLRET, b);
1237 #else
1238 return false;
1239 #endif
1240 case ofill:
1241 #if defined(OFILL)
1242 return doSetUnset (&t->c_oflag, OFILL, b);
1243 #else
1244 return false;
1245 #endif
1246 case ofdel:
1247 #if defined(OFDEL)
1248 return doSetUnset (&t->c_oflag, OFDEL, b);
1249 #else
1250 return false;
1251 #endif
1252 case onl0:
1253 #if defined(NL0)
1254 return doSetUnset (&t->c_oflag, NL0, b);
1255 #else
1256 return false;
1257 #endif
1258 case onl1:
1259 #if defined(NL1)
1260 return doSetUnset (&t->c_oflag, NL1, b);
1261 #else
1262 return false;
1263 #endif
1264 case ocr0:
1265 #if defined(CR0)
1266 return doSetUnset (&t->c_oflag, CR0, b);
1267 #else
1268 return false;
1269 #endif
1270 case ocr1:
1271 #if defined(CR1)
1272 return doSetUnset (&t->c_oflag, CR1, b);
1273 #else
1274 return false;
1275 #endif
1276 case ocr2:
1277 #if defined(CR2)
1278 return doSetUnset (&t->c_oflag, CR2, b);
1279 #else
1280 return false;
1281 #endif
1282 case ocr3:
1283 #if defined(CR3)
1284 return doSetUnset (&t->c_oflag, CR3, b);
1285 #else
1286 return false;
1287 #endif
1288 case otab0:
1289 #if defined(TAB0)
1290 return doSetUnset (&t->c_oflag, TAB0, b);
1291 #else
1292 return false;
1293 #endif
1294 case otab1:
1295 #if defined(TAB1)
1296 return doSetUnset (&t->c_oflag, TAB1, b);
1297 #else
1298 return false;
1299 #endif
1300 case otab2:
1301 #if defined(TAB2)
1302 return doSetUnset (&t->c_oflag, TAB2, b);
1303 #else
1304 return false;
1305 #endif
1306 case otab3:
1307 #if defined(TAB3)
1308 return doSetUnset (&t->c_oflag, TAB3, b);
1309 #else
1310 return false;
1311 #endif
1312 case obs0:
1313 #if defined(BS0)
1314 return doSetUnset (&t->c_oflag, BS0, b);
1315 #else
1316 return false;
1317 #endif
1318 case obs1:
1319 #if defined(BS1)
1320 return doSetUnset (&t->c_oflag, BS1, b);
1321 #else
1322 return false;
1323 #endif
1324 case off0:
1325 #if defined(FF0)
1326 return doSetUnset (&t->c_oflag, FF0, b);
1327 #else
1328 return false;
1329 #endif
1330 case off1:
1331 #if defined(FF1)
1332 return doSetUnset (&t->c_oflag, FF1, b);
1333 #else
1334 return false;
1335 #endif
1336 case ovt0:
1337 #if defined(VT0)
1338 return doSetUnset (&t->c_oflag, VT0, b);
1339 #else
1340 return false;
1341 #endif
1342 case ovt1:
1343 #if defined(VT1)
1344 return doSetUnset (&t->c_oflag, VT1, b);
1345 #else
1346 return false;
1347 #endif
1348 case b0:
1349 #if defined(B0)
1350 return doSetUnset (&t->c_cflag, B0, b);
1351 #else
1352 return false;
1353 #endif
1354 case b50:
1355 #if defined(B50)
1356 return doSetUnset (&t->c_cflag, B50, b);
1357 #else
1358 return false;
1359 #endif
1360 case b75:
1361 #if defined(B75)
1362 return doSetUnset (&t->c_cflag, B75, b);
1363 #else
1364 return false;
1365 #endif
1366 case b110:
1367 #if defined(B110)
1368 return doSetUnset (&t->c_cflag, B110, b);
1369 #else
1370 return false;
1371 #endif
1372 case b135:
1373 #if defined(B134)
1374 return doSetUnset (&t->c_cflag, B134, b);
1375 #else
1376 return false;
1377 #endif
1378 case b150:
1379 #if defined(B150)
1380 return doSetUnset (&t->c_cflag, B150, b);
1381 #else
1382 return false;
1383 #endif
1384 case b200:
1385 #if defined(B200)
1386 return doSetUnset (&t->c_cflag, B200, b);
1387 #else
1388 return false;
1389 #endif
1390 case b300:
1391 #if defined(B300)
1392 return doSetUnset (&t->c_cflag, B300, b);
1393 #else
1394 return false;
1395 #endif
1396 case b600:
1397 #if defined(B600)
1398 return doSetUnset (&t->c_cflag, B600, b);
1399 #else
1400 return false;
1401 #endif
1402 case b1200:
1403 #if defined(B1200)
1404 return doSetUnset (&t->c_cflag, B1200, b);
1405 #else
1406 return false;
1407 #endif
1408 case b1800:
1409 #if defined(B1800)
1410 return doSetUnset (&t->c_cflag, B1800, b);
1411 #else
1412 return false;
1413 #endif
1414 case b2400:
1415 #if defined(B2400)
1416 return doSetUnset (&t->c_cflag, B2400, b);
1417 #else
1418 return false;
1419 #endif
1420 case b4800:
1421 #if defined(B4800)
1422 return doSetUnset (&t->c_cflag, B4800, b);
1423 #else
1424 return false;
1425 #endif
1426 case b9600:
1427 #if defined(B9600)
1428 return doSetUnset (&t->c_cflag, B9600, b);
1429 #else
1430 return false;
1431 #endif
1432 case b19200:
1433 #if defined(B19200)
1434 return doSetUnset (&t->c_cflag, B19200, b);
1435 #else
1436 return false;
1437 #endif
1438 case b38400:
1439 #if defined(B38400)
1440 return doSetUnset (&t->c_cflag, B38400, b);
1441 #else
1442 return false;
1443 #endif
1444 case b57600:
1445 #if defined(B57600)
1446 return doSetUnset (&t->c_cflag, B57600, b);
1447 #else
1448 return false;
1449 #endif
1450 case b115200:
1451 #if defined(B115200)
1452 return doSetUnset (&t->c_cflag, B115200, b);
1453 #else
1454 return false;
1455 #endif
1456 case b240400:
1457 #if defined(B230400)
1458 return doSetUnset (&t->c_cflag, B230400, b);
1459 #else
1460 return false;
1461 #endif
1462 case b460800:
1463 #if defined(B460800)
1464 return doSetUnset (&t->c_cflag, B460800, b);
1465 #else
1466 return false;
1467 #endif
1468 case b500000:
1469 #if defined(B500000)
1470 return doSetUnset (&t->c_cflag, B500000, b);
1471 #else
1472 return false;
1473 #endif
1474 case b576000:
1475 #if defined(B576000)
1476 return doSetUnset (&t->c_cflag, B576000, b);
1477 #else
1478 return false;
1479 #endif
1480 case b921600:
1481 #if defined(B921600)
1482 return doSetUnset (&t->c_cflag, B921600, b);
1483 #else
1484 return false;
1485 #endif
1486 case b1000000:
1487 #if defined(B1000000)
1488 return doSetUnset (&t->c_cflag, B1000000, b);
1489 #else
1490 return false;
1491 #endif
1492 case b1152000:
1493 #if defined(B1152000)
1494 return doSetUnset (&t->c_cflag, B1152000, b);
1495 #else
1496 return false;
1497 #endif
1498 case b1500000:
1499 #if defined(B1500000)
1500 return doSetUnset (&t->c_cflag, B1500000, b);
1501 #else
1502 return false;
1503 #endif
1504 case b2000000:
1505 #if defined(B2000000)
1506 return doSetUnset (&t->c_cflag, B2000000, b);
1507 #else
1508 return false;
1509 #endif
1510 case b2500000:
1511 #if defined(B2500000)
1512 return doSetUnset (&t->c_cflag, B2500000, b);
1513 #else
1514 return false;
1515 #endif
1516 case b3000000:
1517 #if defined(B3000000)
1518 return doSetUnset (&t->c_cflag, B3000000, b);
1519 #else
1520 return false;
1521 #endif
1522 case b3500000:
1523 #if defined(B3500000)
1524 return doSetUnset (&t->c_cflag, B3500000, b);
1525 #else
1526 return false;
1527 #endif
1528 case b4000000:
1529 #if defined(B4000000)
1530 return doSetUnset (&t->c_cflag, B4000000, b);
1531 #else
1532 return false;
1533 #endif
1534 case maxbaud:
1535 #if defined(__MAX_BAUD)
1536 return doSetUnset (&t->c_cflag, __MAX_BAUD, b);
1537 #else
1538 return false;
1539 #endif
1540 case crtscts:
1541 #if defined(CRTSCTS)
1542 return doSetUnset (&t->c_cflag, CRTSCTS, b);
1543 #else
1544 return false;
1545 #endif
1546 case cs5:
1547 #if defined(CS5)
1548 return doSetUnset (&t->c_cflag, CS5, b);
1549 #else
1550 return false;
1551 #endif
1552 case cs6:
1553 #if defined(CS6)
1554 return doSetUnset (&t->c_cflag, CS6, b);
1555 #else
1556 return false;
1557 #endif
1558 case cs7:
1559 #if defined(CS7)
1560 return doSetUnset (&t->c_cflag, CS7, b);
1561 #else
1562 return false;
1563 #endif
1564 case cs8:
1565 #if defined(CS8)
1566 return doSetUnset (&t->c_cflag, CS8, b);
1567 #else
1568 return false;
1569 #endif
1570 case cstopb:
1571 #if defined(CSTOPB)
1572 return doSetUnset (&t->c_cflag, CSTOPB, b);
1573 #else
1574 return false;
1575 #endif
1576 case cread:
1577 #if defined(CREAD)
1578 return doSetUnset (&t->c_cflag, CREAD, b);
1579 #else
1580 return false;
1581 #endif
1582 case parenb:
1583 #if defined(PARENB)
1584 return doSetUnset (&t->c_cflag, PARENB, b);
1585 #else
1586 return false;
1587 #endif
1588 case parodd:
1589 #if defined(PARODD)
1590 return doSetUnset (&t->c_cflag, PARODD, b);
1591 #else
1592 return false;
1593 #endif
1594 case hupcl:
1595 #if defined(HUPCL)
1596 return doSetUnset (&t->c_cflag, HUPCL, b);
1597 #else
1598 return false;
1599 #endif
1600 case clocal:
1601 #if defined(CLOCAL)
1602 return doSetUnset (&t->c_cflag, CLOCAL, b);
1603 #else
1604 return false;
1605 #endif
1606 case lisig:
1607 #if defined(ISIG)
1608 return doSetUnset (&t->c_lflag, ISIG, b);
1609 #else
1610 return false;
1611 #endif
1612 case licanon:
1613 #if defined(ICANON)
1614 return doSetUnset (&t->c_lflag, ICANON, b);
1615 #else
1616 return false;
1617 #endif
1618 case lxcase:
1619 #if defined(XCASE)
1620 return doSetUnset (&t->c_lflag, XCASE, b);
1621 #else
1622 return false;
1623 #endif
1624 case lecho:
1625 #if defined(ECHO)
1626 return doSetUnset (&t->c_lflag, ECHO, b);
1627 #else
1628 return false;
1629 #endif
1630 case lechoe:
1631 #if defined(ECHOE)
1632 return doSetUnset (&t->c_lflag, ECHOE, b);
1633 #else
1634 return false;
1635 #endif
1636 case lechok:
1637 #if defined(ECHOK)
1638 return doSetUnset (&t->c_lflag, ECHOK, b);
1639 #else
1640 return false;
1641 #endif
1642 case lechonl:
1643 #if defined(ECHONL)
1644 return doSetUnset (&t->c_lflag, ECHONL, b);
1645 #else
1646 return false;
1647 #endif
1648 case lnoflsh:
1649 #if defined(NOFLSH)
1650 return doSetUnset (&t->c_lflag, NOFLSH, b);
1651 #else
1652 return false;
1653 #endif
1654 case ltopstop:
1655 #if defined(TOSTOP)
1656 return doSetUnset (&t->c_lflag, TOSTOP, b);
1657 #else
1658 return false;
1659 #endif
1660 case lechoctl:
1661 #if defined(ECHOCTL)
1662 return doSetUnset (&t->c_lflag, ECHOCTL, b);
1663 #else
1664 return false;
1665 #endif
1666 case lechoprt:
1667 #if defined(ECHOPRT)
1668 return doSetUnset (&t->c_lflag, ECHOPRT, b);
1669 #else
1670 return false;
1671 #endif
1672 case lechoke:
1673 #if defined(ECHOKE)
1674 return doSetUnset (&t->c_lflag, ECHOKE, b);
1675 #else
1676 return false;
1677 #endif
1678 case lflusho:
1679 #if defined(FLUSHO)
1680 return doSetUnset (&t->c_lflag, FLUSHO, b);
1681 #else
1682 return false;
1683 #endif
1684 case lpendin:
1685 #if defined(PENDIN)
1686 return doSetUnset (&t->c_lflag, PENDIN, b);
1687 #else
1688 return false;
1689 #endif
1690 case liexten:
1691 #if defined(IEXTEN)
1692 return doSetUnset (&t->c_lflag, IEXTEN, b);
1693 #else
1694 return false;
1695 #endif
1697 return false;
1700 /* GetChar sets a CHAR, ch, value from, t, and returns TRUE if
1701 this value is supported. */
1703 extern "C" bool
1704 EXPORT (GetChar) (struct termios *t, ControlChar c, char *ch)
1706 switch (c)
1709 case vintr:
1710 #if defined(VINTR)
1711 *ch = t->c_cc[VINTR];
1712 return true;
1713 #else
1714 return false;
1715 #endif
1716 case vquit:
1717 #if defined(VQUIT)
1718 *ch = t->c_cc[VQUIT];
1719 return true;
1720 #else
1721 return false;
1722 #endif
1723 case verase:
1724 #if defined(VERASE)
1725 *ch = t->c_cc[VERASE];
1726 return true;
1727 #else
1728 return false;
1729 #endif
1730 case vkill:
1731 #if defined(VKILL)
1732 *ch = t->c_cc[VKILL];
1733 return true;
1734 #else
1735 return false;
1736 #endif
1737 case veof:
1738 #if defined(VEOF)
1739 *ch = t->c_cc[VEOF];
1740 return true;
1741 #else
1742 return false;
1743 #endif
1744 case vtime:
1745 #if defined(VTIME)
1746 *ch = t->c_cc[VTIME];
1747 return true;
1748 #else
1749 return false;
1750 #endif
1751 case vmin:
1752 #if defined(VMIN)
1753 *ch = t->c_cc[VMIN];
1754 return true;
1755 #else
1756 return false;
1757 #endif
1758 case vswtc:
1759 #if defined(VSWTC)
1760 *ch = t->c_cc[VSWTC];
1761 return true;
1762 #else
1763 return false;
1764 #endif
1765 case vstart:
1766 #if defined(VSTART)
1767 *ch = t->c_cc[VSTART];
1768 return true;
1769 #else
1770 return false;
1771 #endif
1772 case vstop:
1773 #if defined(VSTOP)
1774 *ch = t->c_cc[VSTOP];
1775 return true;
1776 #else
1777 return false;
1778 #endif
1779 case vsusp:
1780 #if defined(VSUSP)
1781 *ch = t->c_cc[VSUSP];
1782 return true;
1783 #else
1784 return false;
1785 #endif
1786 case veol:
1787 #if defined(VEOL)
1788 *ch = t->c_cc[VEOL];
1789 return true;
1790 #else
1791 return false;
1792 #endif
1793 case vreprint:
1794 #if defined(VREPRINT)
1795 *ch = t->c_cc[VREPRINT];
1796 return true;
1797 #else
1798 return false;
1799 #endif
1800 case vdiscard:
1801 #if defined(VDISCARD)
1802 *ch = t->c_cc[VDISCARD];
1803 return true;
1804 #else
1805 return false;
1806 #endif
1807 case vwerase:
1808 #if defined(VWERASE)
1809 *ch = t->c_cc[VWERASE];
1810 return true;
1811 #else
1812 return false;
1813 #endif
1814 case vlnext:
1815 #if defined(VLNEXT)
1816 *ch = t->c_cc[VLNEXT];
1817 return true;
1818 #else
1819 return false;
1820 #endif
1821 case veol2:
1822 #if defined(VEOL2)
1823 *ch = t->c_cc[VEOL2];
1824 return true;
1825 #else
1826 return false;
1827 #endif
1828 default:
1829 return false;
1833 /* SetChar sets a CHAR value in, t, and returns TRUE if, c,
1834 is supported. */
1836 extern "C" bool
1837 EXPORT (SetChar) (struct termios *t, ControlChar c, char ch)
1839 switch (c)
1842 case vintr:
1843 #if defined(VINTR)
1844 t->c_cc[VINTR] = ch;
1845 return true;
1846 #else
1847 return false;
1848 #endif
1849 case vquit:
1850 #if defined(VQUIT)
1851 t->c_cc[VQUIT] = ch;
1852 return true;
1853 #else
1854 return false;
1855 #endif
1856 case verase:
1857 #if defined(VERASE)
1858 t->c_cc[VERASE] = ch;
1859 return true;
1860 #else
1861 return false;
1862 #endif
1863 case vkill:
1864 #if defined(VKILL)
1865 t->c_cc[VKILL] = ch;
1866 return true;
1867 #else
1868 return false;
1869 #endif
1870 case veof:
1871 #if defined(VEOF)
1872 t->c_cc[VEOF] = ch;
1873 return true;
1874 #else
1875 return false;
1876 #endif
1877 case vtime:
1878 #if defined(VTIME)
1879 t->c_cc[VTIME] = ch;
1880 return true;
1881 #else
1882 return false;
1883 #endif
1884 case vmin:
1885 #if defined(VMIN)
1886 t->c_cc[VMIN] = ch;
1887 return true;
1888 #else
1889 return false;
1890 #endif
1891 case vswtc:
1892 #if defined(VSWTC)
1893 t->c_cc[VSWTC] = ch;
1894 return true;
1895 #else
1896 return false;
1897 #endif
1898 case vstart:
1899 #if defined(VSTART)
1900 t->c_cc[VSTART] = ch;
1901 return true;
1902 #else
1903 return false;
1904 #endif
1905 case vstop:
1906 #if defined(VSTOP)
1907 t->c_cc[VSTOP] = ch;
1908 return true;
1909 #else
1910 return false;
1911 #endif
1912 case vsusp:
1913 #if defined(VSUSP)
1914 t->c_cc[VSUSP] = ch;
1915 return true;
1916 #else
1917 return false;
1918 #endif
1919 case veol:
1920 #if defined(VEOL)
1921 t->c_cc[VEOL] = ch;
1922 return true;
1923 #else
1924 return false;
1925 #endif
1926 case vreprint:
1927 #if defined(VREPRINT)
1928 t->c_cc[VREPRINT] = ch;
1929 return true;
1930 #else
1931 return false;
1932 #endif
1933 case vdiscard:
1934 #if defined(VDISCARD)
1935 t->c_cc[VDISCARD] = ch;
1936 return true;
1937 #else
1938 return false;
1939 #endif
1940 case vwerase:
1941 #if defined(VWERASE)
1942 t->c_cc[VWERASE] = ch;
1943 return true;
1944 #else
1945 return false;
1946 #endif
1947 case vlnext:
1948 #if defined(VLNEXT)
1949 t->c_cc[VLNEXT] = ch;
1950 return true;
1951 #else
1952 return false;
1953 #endif
1954 case veol2:
1955 #if defined(VEOL2)
1956 t->c_cc[VEOL2] = ch;
1957 return true;
1958 #else
1959 return false;
1960 #endif
1961 default:
1962 return false;
1965 #endif
1967 extern "C" void
1968 M2EXPORT(init) (int, char *argv[], char *env[])
1972 extern "C" void
1973 M2EXPORT(fini) (int, char *argv[], char *env[])
1977 extern "C" void
1978 M2EXPORT(dep) (void)
1982 extern "C" void __attribute__((__constructor__))
1983 M2EXPORT(ctor) (void)
1985 m2pim_M2RTS_RegisterModule ("termios", M2LIBNAME,
1986 M2EXPORT(init), M2EXPORT(fini), M2EXPORT(dep));