master
  1/* Copyright (C) 1991-2025 Free Software Foundation, Inc.
  2   This file is part of the GNU C Library.
  3
  4   The GNU C Library is free software; you can redistribute it and/or
  5   modify it under the terms of the GNU Lesser General Public
  6   License as published by the Free Software Foundation; either
  7   version 2.1 of the License, or (at your option) any later version.
  8
  9   The GNU C Library is distributed in the hope that it will be useful,
 10   but WITHOUT ANY WARRANTY; without even the implied warranty of
 11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 12   Lesser General Public License for more details.
 13
 14   You should have received a copy of the GNU Lesser General Public
 15   License along with the GNU C Library; if not, see
 16   <https://www.gnu.org/licenses/>.  */
 17
 18/*
 19 *	POSIX Standard: 7.1-2 General Terminal Interface	<termios.h>
 20 */
 21
 22#ifndef	_TERMIOS_H
 23#define	_TERMIOS_H	1
 24
 25#include <features.h>
 26#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
 27/* We need `pid_t'.  */
 28# include <bits/types.h>
 29# ifndef __pid_t_defined
 30typedef __pid_t pid_t;
 31#  define __pid_t_defined
 32# endif
 33#endif
 34
 35__BEGIN_DECLS
 36
 37/* Get the system-dependent definitions of `struct termios', `tcflag_t',
 38   `cc_t', `speed_t', and all the macros specifying the flag bits.  */
 39#include <bits/termios.h>
 40
 41#ifdef __USE_MISC
 42/* Compare a character C to a value VAL from the `c_cc' array in a
 43   `struct termios'.  If VAL is _POSIX_VDISABLE, no character can match it.  */
 44# define CCEQ(val, c)	((c) == (val) && (val) != _POSIX_VDISABLE)
 45#endif
 46
 47/* Return the output baud rate stored in *TERMIOS_P.  */
 48extern speed_t cfgetospeed (const struct termios *__termios_p) __THROW;
 49
 50/* Return the input baud rate stored in *TERMIOS_P.  */
 51extern speed_t cfgetispeed (const struct termios *__termios_p) __THROW;
 52
 53/* Set the output baud rate stored in *TERMIOS_P to SPEED.  */
 54extern int cfsetospeed (struct termios *__termios_p, speed_t __speed) __THROW;
 55
 56/* Set the input baud rate stored in *TERMIOS_P to SPEED.  */
 57extern int cfsetispeed (struct termios *__termios_p, speed_t __speed) __THROW;
 58
 59#ifdef	__USE_MISC
 60/* Set both the input and output baud rates in *TERMIOS_OP to SPEED.  */
 61extern int cfsetspeed (struct termios *__termios_p, speed_t __speed) __THROW;
 62#endif
 63
 64#ifdef __USE_GNU
 65/* Interfaces that are explicitly numeric representations of baud rates */
 66typedef speed_t baud_t;
 67#define BAUD_MAX SPEED_MAX
 68
 69/* Return the output baud rate stored in *TERMIOS_P.  */
 70extern baud_t cfgetobaud (const struct termios *__termios_p) __THROW;
 71
 72/* Return the input baud rate stored in *TERMIOS_P.  */
 73extern baud_t cfgetibaud (const struct termios *__termios_p) __THROW;
 74
 75/* Set the output baud rate stored in *TERMIOS_P to BAUD.  */
 76extern int cfsetobaud (struct termios *__termios_p, baud_t __baud) __THROW;
 77
 78/* Set the input baud rate stored in *TERMIOS_P to BAUD.  */
 79extern int cfsetibaud (struct termios *__termios_p, baud_t __baud) __THROW;
 80
 81/* Set both the input and output baud rates in *TERMIOS_OP to BAUD.  */
 82extern int cfsetbaud (struct termios *__termios_p, baud_t __baud) __THROW;
 83#endif
 84
 85/* Put the state of FD into *TERMIOS_P.  */
 86extern int tcgetattr (int __fd, struct termios *__termios_p) __THROW;
 87
 88/* Set the state of FD to *TERMIOS_P.
 89   Values for OPTIONAL_ACTIONS (TCSA*) are in <bits/termios.h>.  */
 90extern int tcsetattr (int __fd, int __optional_actions,
 91		      const struct termios *__termios_p) __THROW;
 92
 93
 94#ifdef	__USE_MISC
 95/* Set *TERMIOS_P to indicate raw mode.  */
 96extern void cfmakeraw (struct termios *__termios_p) __THROW;
 97#endif
 98
 99/* Send zero bits on FD.  */
100extern int tcsendbreak (int __fd, int __duration) __THROW;
101
102/* Wait for pending output to be written on FD.
103
104   This function is a cancellation point and therefore not marked with
105   __THROW.  */
106extern int tcdrain (int __fd);
107
108/* Flush pending data on FD.
109   Values for QUEUE_SELECTOR (TC{I,O,IO}FLUSH) are in <bits/termios.h>.  */
110extern int tcflush (int __fd, int __queue_selector) __THROW;
111
112/* Suspend or restart transmission on FD.
113   Values for ACTION (TC[IO]{OFF,ON}) are in <bits/termios.h>.  */
114extern int tcflow (int __fd, int __action) __THROW;
115
116
117#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
118/* Get process group ID for session leader for controlling terminal FD.  */
119extern __pid_t tcgetsid (int __fd) __THROW;
120#endif
121
122
123#ifdef __USE_MISC
124# include <sys/ttydefaults.h>
125#endif
126
127__END_DECLS
128
129#endif /* termios.h  */