Back to index

glibc  2.9
Defines | Functions
speed.c File Reference
#include <stddef.h>
#include <errno.h>
#include <termios.h>

Go to the source code of this file.

Defines

#define IBAUD0   020000000000

Functions

speed_t cfgetospeed (struct termios *termios_p) const
speed_t cfgetispeed (struct termios *termios_p) const
int cfsetospeed (struct termios *termios_p, speed_t speed)
 libc_hidden_def (cfsetospeed)

Define Documentation

#define IBAUD0   020000000000

Definition at line 34 of file speed.c.


Function Documentation

speed_t cfgetispeed ( struct termios termios_p) const

Definition at line 50 of file speed.c.

{
  return ((termios_p->c_iflag & IBAUD0)
         ? 0 : termios_p->c_cflag & (CBAUD | CBAUDEX));
}
speed_t cfgetospeed ( struct termios termios_p) const

Definition at line 39 of file speed.c.

{
  return termios_p->c_cflag & (CBAUD | CBAUDEX);
}
int cfsetospeed ( struct termios termios_p,
speed_t  speed 
)

Definition at line 59 of file speed.c.

{
  if ((speed & ~CBAUD) != 0
      && (speed < B57600 || speed > __MAX_BAUD))
    {
      __set_errno (EINVAL);
      return -1;
    }

#ifdef _HAVE_STRUCT_TERMIOS_C_OSPEED
  termios_p->c_ospeed = speed;
#endif
  termios_p->c_cflag &= ~(CBAUD | CBAUDEX);
  termios_p->c_cflag |= speed;

  return 0;
}

Definition at line 78 of file speed.c.

{
  if ((speed & ~CBAUD) != 0
      && (speed < B57600 || speed > __MAX_BAUD))
    {
      __set_errno (EINVAL);
      return -1;
    }

#ifdef _HAVE_STRUCT_TERMIOS_C_ISPEED
  termios_p->c_ispeed = speed;
#endif
  if (speed == 0)
    termios_p->c_iflag |= IBAUD0;
  else
    {
      termios_p->c_iflag &= ~IBAUD0;
      termios_p->c_cflag &= ~(CBAUD | CBAUDEX);
      termios_p->c_cflag |= speed;
    }

  return 0;
}