* @brief Sets the output baud rate in a termios structure. * @param tio Pointer to a struct termios where the output baud rate will be set. * @param speed Output baud rate to be set. * @return Upon successful completion, returns 0; otherwise, returns -1 and sets errno to indicate the error. * * @note This function sets the output baud rate in the termios structure pointed to by tio.
| 134 | * and sets them to the specified speed value. It then returns 0 to indicate success. |
| 135 | */ |
| 136 | int cfsetospeed(struct termios *tio, speed_t speed) |
| 137 | { |
| 138 | if (speed & ~CBAUD) |
| 139 | { |
| 140 | errno = EINVAL; |
| 141 | return -1; |
| 142 | } |
| 143 | |
| 144 | tio->c_cflag &= ~CBAUD; |
| 145 | tio->c_cflag |= speed; |
| 146 | return 0; |
| 147 | } |
| 148 | |
| 149 | /** |
| 150 | * @brief Sets the input baud rate in a termios structure. |
no outgoing calls