termios.h 3.5 KB

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