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