2
0

Termios.txt 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. MODULE LinTermios ["libc.so.90"];
  2. (*
  3. A. V. Shiryaev, 2012.11, 2013.08, 2015.09
  4. OpenBSD 6.2
  5. 32-bit
  6. *)
  7. CONST
  8. VEOF* = 0; (* ICANON *)
  9. VEOL* = 1; (* ICANON *)
  10. VERASE* = 3; (* ICANON *)
  11. VKILL* = 5; (* ICANON *)
  12. VINTR* = 8; (* ISIG *)
  13. VQUIT* = 9; (* ISIG *)
  14. VSUSP* = 10; (* ISIG *)
  15. VSTART* = 12; (* IXON, IXOFF *)
  16. VSTOP* = 13; (* IXON, IXOFF *)
  17. VMIN* = 16; (* !ICANON *)
  18. VTIME* = 17; (* !ICANON *)
  19. NCCS* = 20;
  20. IGNBRK* = 00000001H; (* {0} *) (* ignore BREAK condition *)
  21. BRKINT* = 00000002H; (* {1} *) (* map BREAK to SIGINT *)
  22. IGNPAR* = 00000004H; (* {2} *) (* ignore (discard) parity errors *)
  23. PARMRK* = 00000008H; (* {3} *) (* mark parity and framing errors *)
  24. INPCK* = 00000010H; (* {4} *) (* enable checking of parity errors *)
  25. ISTRIP* = 00000020H; (* {5} *) (* strip 8th bit off chars *)
  26. INLCR* = 00000040H; (* {6} *) (* map NL into CR *)
  27. IGNCR* = 00000080H; (* {7} *) (* ignore CR *)
  28. ICRNL* = 00000100H; (* {8} *) (* map CR to NL (ala CRMOD) *)
  29. IXON* = 00000200H; (* {9} *) (* enable output flow control *)
  30. IXOFF* = 00000400H; (* {10} *) (* enable input flow control *)
  31. OPOST* = 00000001H; (* {0} *) (* enable following output processing *)
  32. CSIZE* = 00000300H; (* {8,9} *) (* character size mask *)
  33. CS5* = 00000000H; (* {} *) (* 5 bits (pseudo) *)
  34. CS6* = 00000100H; (* {8} *) (* 6 bits *)
  35. CS7* = 00000200H; (* {9} *) (* 7 bits *)
  36. CS8* = 00000300H; (* {8,9} *) (* 8 bits *)
  37. CSTOPB* = 00000400H; (* {10} *) (* send 2 stop bits *)
  38. CREAD* = 00000800H; (* {11} *) (* enable receiver *)
  39. PARENB* = 00001000H; (* {12} *) (* parity enable *)
  40. PARODD* = 00002000H; (* {13} *) (* odd parity, else even *)
  41. HUPCL* = 00004000H; (* {14} *) (* hang up on last close *)
  42. CLOCAL* = 00008000H; (* {15} *) (* ignore modem status lines *)
  43. ECHOE* = 00000002H; (* {1} *) (* visually erase chars *)
  44. ECHOK* = 00000004H; (* {2} *) (* echo NL after line kill *)
  45. ECHO* = 00000008H; (* {3} *) (* enable echoing *)
  46. ECHONL* = 00000010H; (* {4} *) (* echo NL even if ECHO is off *)
  47. ISIG* = 00000080H; (* {7} *) (* enable signals INTR, QUIT, [D]SUSP *)
  48. ICANON* = 00000100H; (* {8} *) (* canonicalize input lines *)
  49. IEXTEN* = 00000400H; (* {10} *) (* enable DISCARD and LNEXT *)
  50. EXTPROC* = 00000800H; (* {11} *) (* external processing *)
  51. TOSTOP* = 00400000H; (* {22} *) (* stop background jobs from output *)
  52. NOFLSH* = 80000000H; (* {31} *) (* don't flush after interrupt *)
  53. TCSANOW* = 0; (* make change immediate *)
  54. TCSADRAIN* = 1; (* drain output, then change *)
  55. TCSAFLUSH* = 2; (* drain output, flush input *)
  56. B0* = 0;
  57. B50* = 50;
  58. B75* = 75;
  59. B110* = 110;
  60. B134* = 134;
  61. B150* = 150;
  62. B200* = 200;
  63. B300* = 300;
  64. B600* = 600;
  65. B1200* = 1200;
  66. B1800* = 1800;
  67. B2400* = 2400;
  68. B4800* = 4800;
  69. B9600* = 9600;
  70. B19200* = 19200;
  71. B38400* = 38400;
  72. VEOL2* = 2; (* ICANON *)
  73. VWERASE* = 4; (* ICANON *)
  74. VREPRINT* = 6; (* ICANON *)
  75. VDSUSP* = 11; (* ISIG *)
  76. VLNEXT* = 14; (* IEXTEN *)
  77. VDISCARD* = 15; (* IEXTEN *)
  78. VSTATUS* = 18; (* ICANON *)
  79. IXANY* = 00000800H; (* {11} *) (* any char will restart after stop *)
  80. IUCLC* = 00001000H; (* {12} *) (* translate upper to lower case *)
  81. IMAXBEL* = 00002000H; (* {13} *) (* ring bell on input queue full *)
  82. ONLCR* = 00000002H; (* {1} *) (* map NL to CR-NL (ala CRMOD) *)
  83. OXTABS* = 00000004H; (* {2} *) (* expand tabs to spaces *)
  84. ONOEOT* = 00000008H; (* {3} *) (* discard EOT's (^D) on output *)
  85. OCRNL* = 00000010H; (* {4} *) (* map CR to NL *)
  86. OLCUC* = 00000020H; (* {5} *) (* translate lower case to upper case *)
  87. ONOCR* = 00000040H; (* {6} *) (* No CR output at column 0 *)
  88. ONLRET* = 00000080H; (* {7} *) (* NL performs the CR function *)
  89. CIGNORE* = 00000001H; (* {0} *) (* ignore control flags *)
  90. CRTSCTS* = 00010000H; (* {16} *) (* RTS/CTS full-duplex flow control *)
  91. MDMBUF* = 00100000H; (* {20} *) (* DTR/DCD hardware flow control *)
  92. ECHOKE* = 00000001H; (* {0} *) (* visual erase for line kill *)
  93. ECHOPRT* = 00000020H; (* {5} *) (* visual erase mode for hardcopy *)
  94. ECHOCTL* = 00000040H; (* {6} *) (* echo control chars as ^(Char) *)
  95. ALTWERASE* = 00000200H; (* {9} *) (* use alternate WERASE algorithm *)
  96. FLUSHO* = 00800000H; (* {23} *) (* output being flushed (state) *)
  97. XCASE* = 01000000H; (* {24} *) (* canonical upper/lower case *)
  98. NOKERNINFO* = 02000000H; (* {25} *) (* no kernel output from VSTATUS *)
  99. PENDIN* = 20000000H; (* {29} *) (* XXX retype pending input (state) *)
  100. TCSASOFT* = 10H; (* {4} *) (* flag - don't alter h.w. state *)
  101. B7200* = 7200;
  102. B14400* = 14400;
  103. B28800* = 28800;
  104. B57600* = 57600;
  105. B76800* = 76800;
  106. B115200* = 115200;
  107. B230400* = 230400;
  108. EXTA* = 19200;
  109. EXTB* = 38400;
  110. TCIFLUSH* = 1;
  111. TCOFLUSH* = 2;
  112. TCIOFLUSH* = 3;
  113. TCOOFF* = 1;
  114. TCOON* = 2;
  115. TCIOFF* = 3;
  116. TCION* = 4;
  117. TYPE
  118. tcflag_t* = INTEGER; (* unsigned int *)
  119. cc_t* = SHORTCHAR; (* unsigned char *)
  120. speed_t* = INTEGER; (* unsigned int *)
  121. termios* = RECORD [untagged]
  122. c_iflag*: tcflag_t; (* input flags *)
  123. c_oflag*: tcflag_t; (* output flags *)
  124. c_cflag*: tcflag_t; (* control flags *)
  125. c_lflag*: tcflag_t; (* local flags *)
  126. c_cc*: ARRAY [untagged] NCCS OF cc_t; (* control chars *)
  127. c_ispeed*: INTEGER; (* input speed *)
  128. c_ospeed*: INTEGER; (* output speed *)
  129. END;
  130. (* POSIX.1 *)
  131. PROCEDURE [ccall] cfgetispeed* (VAR tp: termios): speed_t;
  132. PROCEDURE [ccall] cfsetispeed* (VAR tp: termios; ispeed: speed_t): INTEGER;
  133. PROCEDURE [ccall] cfgetospeed* (VAR tp: termios): speed_t;
  134. PROCEDURE [ccall] cfsetospeed* (VAR tp: termios; ospeed: speed_t): INTEGER;
  135. PROCEDURE [ccall] tcgetattr* (fd: INTEGER; VAR tp: termios): INTEGER;
  136. PROCEDURE [ccall] tcsetattr* (fd: INTEGER; action: INTEGER; VAR tp: termios): INTEGER;
  137. PROCEDURE [ccall] tcdrain* (fd: INTEGER): INTEGER;
  138. PROCEDURE [ccall] tcflow* (fd: INTEGER; action: INTEGER): INTEGER;
  139. PROCEDURE [ccall] tcflush* (fd: INTEGER; action: INTEGER): INTEGER;
  140. PROCEDURE [ccall] tcsendbreak* (fd: INTEGER; len: INTEGER): INTEGER;
  141. (* extensions *)
  142. (*
  143. PROCEDURE [ccall] cfsetspeed* (VAR tp: termios; speed: speed_t): INTEGER;
  144. PROCEDURE [ccall] cfmakeraw* (VAR tp: termios);
  145. *)
  146. END LinTermios.