Termios.txt 5.3 KB

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