termios.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. /* termios type and macro definitions. 4.4 BSD/generic GNU version.
  2. Copyright (C) 1993-2026 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  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. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <https://www.gnu.org/licenses/>. */
  15. #ifndef _TERMIOS_H
  16. # error "Never include <bits/termios.h> directly; use <termios.h> instead."
  17. #endif
  18. #include <bits/termios-baud.h>
  19. /* These macros are also defined in some <bits/ioctls.h> files (with
  20. numerically identical values), but this serves to shut up cpp's
  21. complaining. */
  22. #if defined __USE_MISC || defined __USE_XOPEN
  23. # ifdef NL0
  24. # undef NL0
  25. # endif
  26. # ifdef NL1
  27. # undef NL1
  28. # endif
  29. # ifdef TAB0
  30. # undef TAB0
  31. # endif
  32. # ifdef TAB1
  33. # undef TAB1
  34. # endif
  35. # ifdef TAB2
  36. # undef TAB2
  37. # endif
  38. # ifdef CR0
  39. # undef CR0
  40. # endif
  41. # ifdef CR1
  42. # undef CR1
  43. # endif
  44. # ifdef CR2
  45. # undef CR2
  46. # endif
  47. # ifdef CR3
  48. # undef CR3
  49. # endif
  50. # ifdef FF0
  51. # undef FF0
  52. # endif
  53. # ifdef FF1
  54. # undef FF1
  55. # endif
  56. # ifdef BS0
  57. # undef BS0
  58. # endif
  59. # ifdef BS1
  60. # undef BS1
  61. # endif
  62. #endif /* __USE_MISC || __USE_XOPEN */
  63. #ifdef __USE_MISC
  64. # ifdef MDMBUF
  65. # undef MDMBUF
  66. # endif
  67. # ifdef FLUSHO
  68. # undef FLUSHO
  69. # endif
  70. # ifdef PENDIN
  71. # undef PENDIN
  72. # endif
  73. #endif /* __USE_MISC */
  74. #ifdef ECHO
  75. # undef ECHO
  76. #endif
  77. #ifdef TOSTOP
  78. # undef TOSTOP
  79. #endif
  80. #ifdef NOFLSH
  81. # undef NOFLSH
  82. #endif
  83. /* These definitions match those used by the 4.4 BSD kernel.
  84. If the operating system has termios system calls or ioctls that
  85. correctly implement the POSIX.1 behavior, there should be a
  86. system-dependent version of this file that defines `struct termios',
  87. `tcflag_t', `cc_t', `speed_t' and the `TC*' constants appropriately. */
  88. /* Type of terminal control flag masks. */
  89. typedef unsigned int tcflag_t;
  90. /* Type of control characters. */
  91. typedef unsigned char cc_t;
  92. /* Type of baud rate specifiers. */
  93. typedef unsigned int speed_t;
  94. /* Terminal control structure. */
  95. struct termios
  96. {
  97. /* Input modes. */
  98. tcflag_t c_iflag;
  99. #define IGNBRK (1 << 0) /* Ignore break condition. */
  100. #define BRKINT (1 << 1) /* Signal interrupt on break. */
  101. #define IGNPAR (1 << 2) /* Ignore characters with parity errors. */
  102. #define PARMRK (1 << 3) /* Mark parity and framing errors. */
  103. #define INPCK (1 << 4) /* Enable input parity check. */
  104. #define ISTRIP (1 << 5) /* Strip 8th bit off characters. */
  105. #define INLCR (1 << 6) /* Map NL to CR on input. */
  106. #define IGNCR (1 << 7) /* Ignore CR. */
  107. #define ICRNL (1 << 8) /* Map CR to NL on input. */
  108. #define IXON (1 << 9) /* Enable start/stop output control. */
  109. #define IXOFF (1 << 10) /* Enable start/stop input control. */
  110. #if defined __USE_MISC || defined __USE_XOPEN || defined __USE_XOPEN2K8
  111. # define IXANY (1 << 11) /* Any character will restart after stop. */
  112. #endif
  113. #ifdef __USE_MISC
  114. # define IMAXBEL (1 << 13) /* Ring bell when input queue is full. */
  115. #endif
  116. #if defined __USE_GNU || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
  117. # define IUCLC (1 << 14) /* Translate upper case input to lower case. */
  118. #endif
  119. /* Output modes. */
  120. tcflag_t c_oflag;
  121. #define OPOST (1 << 0) /* Perform output processing. */
  122. #if defined __USE_MISC || defined __USE_XOPEN
  123. # define ONLCR (1 << 1) /* Map NL to CR-NL on output. */
  124. #endif
  125. #ifdef __USE_MISC
  126. # define OXTABS TAB3 /* Expand tabs to spaces. */
  127. # define ONOEOT (1 << 3) /* Discard EOT (^D) on output. */
  128. #endif
  129. #if defined __USE_MISC || defined __USE_XOPEN
  130. # define OCRNL (1 << 4) /* Map CR to NL. */
  131. # define ONOCR (1 << 5) /* Discard CR's when on column 0. */
  132. # define ONLRET (1 << 6) /* Move to column 0 on NL. */
  133. #endif
  134. #if defined __USE_MISC || defined __USE_XOPEN
  135. # define NLDLY (3 << 8) /* NL delay. */
  136. # define NL0 (0 << 8) /* NL type 0. */
  137. # define NL1 (1 << 8) /* NL type 1. */
  138. # define TABDLY (3 << 10 | 1 << 2) /* TAB delay. */
  139. # define TAB0 (0 << 10) /* TAB delay type 0. */
  140. # define TAB1 (1 << 10) /* TAB delay type 1. */
  141. # define TAB2 (2 << 10) /* TAB delay type 2. */
  142. # define TAB3 (1 << 2) /* Expand tabs to spaces. */
  143. # define CRDLY (3 << 12) /* CR delay. */
  144. # define CR0 (0 << 12) /* CR delay type 0. */
  145. # define CR1 (1 << 12) /* CR delay type 1. */
  146. # define CR2 (2 << 12) /* CR delay type 2. */
  147. # define CR3 (3 << 12) /* CR delay type 3. */
  148. # define FFDLY (1 << 14) /* FF delay. */
  149. # define FF0 (0 << 14) /* FF delay type 0. */
  150. # define FF1 (1 << 14) /* FF delay type 1. */
  151. # define BSDLY (1 << 15) /* BS delay. */
  152. # define BS0 (0 << 15) /* BS delay type 0. */
  153. # define BS1 (1 << 15) /* BS delay type 1. */
  154. # define VTDLY (1 << 16) /* VT delay. */
  155. # define VT0 (0 << 16) /* VT delay type 0. */
  156. # define VT1 (1 << 16) /* VT delay type 1. */
  157. #endif /* __USE_MISC || __USE_XOPEN */
  158. #if defined __USE_GNU || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
  159. # define OLCUC (1 << 17) /* Translate lower case output to upper case */
  160. #endif
  161. #ifdef __USE_XOPEN
  162. # define OFILL (1 << 18) /* Send fill characters for delays. */
  163. # define OFDEL (1 << 19) /* Fill is DEL. */
  164. #endif
  165. /* Control modes. */
  166. tcflag_t c_cflag;
  167. #ifdef __USE_MISC
  168. # define CIGNORE (1 << 0) /* Ignore these control flags. */
  169. #endif
  170. #define CSIZE (CS5|CS6|CS7|CS8) /* Number of bits per byte (mask). */
  171. #define CS5 0 /* 5 bits per byte. */
  172. #define CS6 (1 << 8) /* 6 bits per byte. */
  173. #define CS7 (1 << 9) /* 7 bits per byte. */
  174. #define CS8 (CS6|CS7) /* 8 bits per byte. */
  175. #define CSTOPB (1 << 10) /* Two stop bits instead of one. */
  176. #define CREAD (1 << 11) /* Enable receiver. */
  177. #define PARENB (1 << 12) /* Parity enable. */
  178. #define PARODD (1 << 13) /* Odd parity instead of even. */
  179. #define HUPCL (1 << 14) /* Hang up on last close. */
  180. #define CLOCAL (1 << 15) /* Ignore modem status lines. */
  181. #ifdef __USE_MISC
  182. # define CRTSCTS (1 << 16) /* RTS/CTS flow control. */
  183. # define CRTS_IFLOW CRTSCTS /* Compatibility. */
  184. # define CCTS_OFLOW CRTSCTS /* Compatibility. */
  185. # define CDTRCTS (1 << 17) /* DTR/CTS flow control. */
  186. # define MDMBUF (1 << 20) /* DTR/DCD flow control. */
  187. # define CHWFLOW (MDMBUF|CRTSCTS|CDTRCTS) /* All types of flow control. */
  188. #endif
  189. /* Local modes. */
  190. tcflag_t c_lflag;
  191. #ifdef __USE_MISC
  192. # define ECHOKE (1 << 0) /* Visual erase for KILL. */
  193. #endif
  194. #define _ECHOE (1 << 1) /* Visual erase for ERASE. */
  195. #define ECHOE _ECHOE
  196. #define _ECHOK (1 << 2) /* Echo NL after KILL. */
  197. #define ECHOK _ECHOK
  198. #define _ECHO (1 << 3) /* Enable echo. */
  199. #define ECHO _ECHO
  200. #define _ECHONL (1 << 4) /* Echo NL even if ECHO is off. */
  201. #define ECHONL _ECHONL
  202. #ifdef __USE_MISC
  203. # define ECHOPRT (1 << 5) /* Hardcopy visual erase. */
  204. # define ECHOCTL (1 << 6) /* Echo control characters as ^X. */
  205. #endif
  206. #define _ISIG (1 << 7) /* Enable signals. */
  207. #define ISIG _ISIG
  208. #define _ICANON (1 << 8) /* Do erase and kill processing. */
  209. #define ICANON _ICANON
  210. #ifdef __USE_MISC
  211. # define ALTWERASE (1 << 9) /* Alternate WERASE algorithm. */
  212. #endif
  213. #define _IEXTEN (1 << 10) /* Enable DISCARD and LNEXT. */
  214. #define IEXTEN _IEXTEN
  215. #ifdef __USE_MISC
  216. # define EXTPROC (1 << 11) /* External processing. */
  217. #endif
  218. #define _TOSTOP (1 << 22) /* Send SIGTTOU for background output. */
  219. #define TOSTOP _TOSTOP
  220. #ifdef __USE_MISC
  221. # define FLUSHO (1 << 23) /* Output being flushed (state). */
  222. #endif
  223. #if defined __USE_XOPEN && !defined __USE_XOPEN2K
  224. # define XCASE (1 << 24) /* Canonical upper/lower case. */
  225. #endif
  226. #ifdef __USE_MISC
  227. # define NOKERNINFO (1 << 25) /* Disable VSTATUS. */
  228. # define PENDIN (1 << 29) /* Retype pending input (state). */
  229. #endif
  230. #define _NOFLSH (1U << 31) /* Disable flush after interrupt. */
  231. #define NOFLSH _NOFLSH
  232. /* Control characters. */
  233. #define VEOF 0 /* End-of-file character [ICANON]. */
  234. #define VEOL 1 /* End-of-line character [ICANON]. */
  235. #ifdef __USE_MISC
  236. # define VEOL2 2 /* Second EOL character [ICANON]. */
  237. #endif
  238. #define VERASE 3 /* Erase character [ICANON]. */
  239. #ifdef __USE_MISC
  240. # define VWERASE 4 /* Word-erase character [ICANON]. */
  241. #endif
  242. #define VKILL 5 /* Kill-line character [ICANON]. */
  243. #ifdef __USE_MISC
  244. # define VREPRINT 6 /* Reprint-line character [ICANON]. */
  245. #endif
  246. #define VINTR 8 /* Interrupt character [ISIG]. */
  247. #define VQUIT 9 /* Quit character [ISIG]. */
  248. #define VSUSP 10 /* Suspend character [ISIG]. */
  249. #ifdef __USE_MISC
  250. # define VDSUSP 11 /* Delayed suspend character [ISIG]. */
  251. #endif
  252. #define VSTART 12 /* Start (X-ON) character [IXON, IXOFF]. */
  253. #define VSTOP 13 /* Stop (X-OFF) character [IXON, IXOFF]. */
  254. #ifdef __USE_MISC
  255. # define VLNEXT 14 /* Literal-next character [IEXTEN]. */
  256. # define VDISCARD 15 /* Discard character [IEXTEN]. */
  257. #endif
  258. #define VMIN 16 /* Minimum number of bytes read at once [!ICANON]. */
  259. #define VTIME 17 /* Time-out value (tenths of a second) [!ICANON]. */
  260. #ifdef __USE_MISC
  261. # define VSTATUS 18 /* Status character [ICANON]. */
  262. #endif
  263. #define NCCS 20 /* Value duplicated in <hurd/tioctl.defs>. */
  264. cc_t c_cc[NCCS];
  265. /* Input and output baud rates. */
  266. __extension__ union {
  267. speed_t __ispeed;
  268. speed_t c_ispeed;
  269. };
  270. #define _HAVE_STRUCT_TERMIOS_C_ISPEED 1
  271. __extension__ union {
  272. speed_t __ospeed;
  273. speed_t c_ospeed;
  274. };
  275. #define _HAVE_STRUCT_TERMIOS_C_OSPEED 1
  276. };
  277. #define _IOT_termios /* Hurd ioctl type field. */ \
  278. _IOT (_IOTS (tcflag_t), 4, _IOTS (cc_t), NCCS, _IOTS (speed_t), 2)
  279. /* Values for the OPTIONAL_ACTIONS argument to `tcsetattr'. */
  280. #define TCSANOW 0 /* Change immediately. */
  281. #define TCSADRAIN 1 /* Change when pending output is written. */
  282. #define TCSAFLUSH 2 /* Flush pending input before changing. */
  283. #ifdef __USE_MISC
  284. # define TCSASOFT 0x10 /* Flag: Don't alter hardware state. */
  285. #endif
  286. /* Values for the QUEUE_SELECTOR argument to `tcflush'. */
  287. #define TCIFLUSH 1 /* Discard data received but not yet read. */
  288. #define TCOFLUSH 2 /* Discard data written but not yet sent. */
  289. #define TCIOFLUSH 3 /* Discard all pending data. */
  290. /* Values for the ACTION argument to `tcflow'. */
  291. #define TCOOFF 1 /* Suspend output. */
  292. #define TCOON 2 /* Restart suspended output. */
  293. #define TCIOFF 3 /* Send a STOP character. */
  294. #define TCION 4 /* Send a START character. */