termios.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. #ifndef __GBLIBC_TERMIOS_H_
  2. #define __GBLIBC_TERMIOS_H_
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #define NCCS 32
  7. typedef unsigned char cc_t;
  8. typedef unsigned int speed_t;
  9. typedef unsigned int tcflag_t;
  10. struct termios {
  11. tcflag_t c_iflag;
  12. tcflag_t c_oflag;
  13. tcflag_t c_cflag;
  14. tcflag_t c_lflag;
  15. cc_t c_line;
  16. cc_t c_cc[NCCS];
  17. speed_t c_ispeed;
  18. speed_t c_ospeed;
  19. };
  20. // taken from linux kernel code
  21. /* c_cc characters */
  22. #define VINTR 0
  23. #define VQUIT 1
  24. #define VERASE 2
  25. #define VKILL 3
  26. #define VEOF 4
  27. #define VTIME 5
  28. #define VMIN 6
  29. #define VSWTC 7
  30. #define VSTART 8
  31. #define VSTOP 9
  32. #define VSUSP 10
  33. #define VEOL 11
  34. #define VREPRINT 12
  35. #define VDISCARD 13
  36. #define VWERASE 14
  37. #define VLNEXT 15
  38. #define VEOL2 16
  39. /* c_iflag bits */
  40. #define IGNBRK 0x0001 /* Ignore break condition */
  41. #define BRKINT 0x0002 /* Signal interrupt on break */
  42. #define IGNPAR 0x0004 /* Ignore characters with parity errors */
  43. #define PARMRK 0x0008 /* Mark parity and framing errors */
  44. #define INPCK 0x0010 /* Enable input parity check */
  45. #define ISTRIP 0x0020 /* Strip 8th bit off characters */
  46. #define INLCR 0x0040 /* Map NL to CR on input */
  47. #define IGNCR 0x0080 /* Ignore CR */
  48. #define ICRNL 0x0100 /* Map CR to NL on input */
  49. #define IUCLC 0x0200
  50. #define IXON 0x0400
  51. #define IXANY 0x0800 /* Any character will restart after stop */
  52. #define IXOFF 0x1000
  53. #define IMAXBEL 0x2000
  54. #define IUTF8 0x4000
  55. /* c_oflag bits */
  56. #define OPOST 0x00001 /* Perform output processing */
  57. #define OLCUC 0x00002
  58. #define ONLCR 0x00004
  59. #define OCRNL 0x00008
  60. #define ONOCR 0x00010
  61. #define ONLRET 0x00020
  62. #define OFILL 0x00040
  63. #define OFDEL 0x00080
  64. #define NLDLY 0x00100
  65. #define NL0 0x00000
  66. #define NL1 0x00100
  67. #define CRDLY 0x00600
  68. #define CR0 0x00000
  69. #define CR1 0x00200
  70. #define CR2 0x00400
  71. #define CR3 0x00600
  72. #define TABDLY 0x01800
  73. #define TAB0 0x00000
  74. #define TAB1 0x00800
  75. #define TAB2 0x01000
  76. #define TAB3 0x01800
  77. #define XTABS 0x01800
  78. #define BSDLY 0x02000
  79. #define BS0 0x00000
  80. #define BS1 0x02000
  81. #define VTDLY 0x04000
  82. #define VT0 0x00000
  83. #define VT1 0x04000
  84. #define FFDLY 0x08000
  85. #define FF0 0x00000
  86. #define FF1 0x08000
  87. /* c_cflag bit meaning */
  88. /* Common CBAUD rates */
  89. #define B0 0x00000000 /* hang up */
  90. #define B50 0x00000001
  91. #define B75 0x00000002
  92. #define B110 0x00000003
  93. #define B134 0x00000004
  94. #define B150 0x00000005
  95. #define B200 0x00000006
  96. #define B300 0x00000007
  97. #define B600 0x00000008
  98. #define B1200 0x00000009
  99. #define B1800 0x0000000a
  100. #define B2400 0x0000000b
  101. #define B4800 0x0000000c
  102. #define B9600 0x0000000d
  103. #define B19200 0x0000000e
  104. #define B38400 0x0000000f
  105. #define EXTA B19200
  106. #define EXTB B38400
  107. #define ADDRB 0x20000000 /* address bit */
  108. #define CMSPAR 0x40000000 /* mark or space (stick) parity */
  109. #define CRTSCTS 0x80000000 /* flow control */
  110. #define IBSHIFT 16 /* Shift from CBAUD to CIBAUD */
  111. #define CBAUD 0x0000100f
  112. #define CSIZE 0x00000030
  113. #define CS5 0x00000000
  114. #define CS6 0x00000010
  115. #define CS7 0x00000020
  116. #define CS8 0x00000030
  117. #define CSTOPB 0x00000040
  118. #define CREAD 0x00000080
  119. #define PARENB 0x00000100
  120. #define PARODD 0x00000200
  121. #define HUPCL 0x00000400
  122. #define CLOCAL 0x00000800
  123. #define CBAUDEX 0x00001000
  124. #define BOTHER 0x00001000
  125. #define B57600 0x00001001
  126. #define B115200 0x00001002
  127. #define B230400 0x00001003
  128. #define B460800 0x00001004
  129. #define B500000 0x00001005
  130. #define B576000 0x00001006
  131. #define B921600 0x00001007
  132. #define B1000000 0x00001008
  133. #define B1152000 0x00001009
  134. #define B1500000 0x0000100a
  135. #define B2000000 0x0000100b
  136. #define B2500000 0x0000100c
  137. #define B3000000 0x0000100d
  138. #define B3500000 0x0000100e
  139. #define B4000000 0x0000100f
  140. #define CIBAUD 0x100f0000 /* input baud rate */
  141. /* c_lflag bits */
  142. #define ISIG 0x00001
  143. #define ICANON 0x00002
  144. #define XCASE 0x00004
  145. #define ECHO 0x00008
  146. #define ECHOE 0x00010
  147. #define ECHOK 0x00020
  148. #define ECHONL 0x00040
  149. #define NOFLSH 0x00080
  150. #define TOSTOP 0x00100
  151. #define ECHOCTL 0x00200
  152. #define ECHOPRT 0x00400
  153. #define ECHOKE 0x00800
  154. #define FLUSHO 0x01000
  155. #define PENDIN 0x04000
  156. #define IEXTEN 0x08000
  157. #define EXTPROC 0x10000
  158. // line disciplines
  159. #define N_TTY 0
  160. #ifdef __cplusplus
  161. }
  162. #endif
  163. #endif