termios.h 11 KB

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