home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue4 / SDL / gcc346 / !gcc / include / unixlib / h / termios < prev    next >
Encoding:
Text File  |  2006-09-17  |  11.6 KB  |  319 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /usr/local/cvsroot/gccsdk/unixlib/source/clib/termios.h,v $
  4.  * $Date: 2004/10/17 16:24:43 $
  5.  * $Revision: 1.6 $
  6.  * $State: Exp $
  7.  * $Author: joty $
  8.  *
  9.  ***************************************************************************/
  10.  
  11. /* termios.h: POSIX Standard 7.1-2 General Terminal Interface.  */
  12.  
  13. #ifndef __TERMIOS_H
  14. #define __TERMIOS_H 1
  15.  
  16. #ifndef __UNIXLIB_FEATURES_H
  17. #include <features.h>
  18. #endif
  19.  
  20. #ifndef __UNIXLIB_TYPES_H
  21. #include <unixlib/types.h>
  22. #endif
  23.  
  24. __BEGIN_DECLS
  25.  
  26. /* Get the system-dependent definitions of `struct termios', `tcflag_t',
  27.    `cc_t', `speed_t', and all the macros specifying the flag bits.  */
  28. typedef __speed_t speed_t;
  29. typedef __tcflag_t tcflag_t;
  30. typedef __cc_t cc_t;
  31.  
  32. /* These macros are also defined in some ioctls.h files (with numerically
  33.    identical values), but this serves to shut up cpp's complaining. */
  34. #ifdef MDMBUF
  35. #undef MDMBUF
  36. #endif
  37. #ifdef FLUSHO
  38. #undef FLUSHO
  39. #endif
  40. #ifdef PENDIN
  41. #undef PENDIN
  42. #endif
  43.  
  44.  
  45. #ifdef ECHO
  46. #undef ECHO
  47. #endif
  48. #ifdef TOSTOP
  49. #undef TOSTOP
  50. #endif
  51. #ifdef NOFLSH
  52. #undef NOFLSH
  53. #endif
  54.  
  55.  
  56. /* These definitions match those used by the 4.4 BSD kernel.
  57.    If the operating system has termios system calls or ioctls that
  58.    correctly implement the POSIX.1 behavior, there should be a
  59.    system-dependent version of this file that defines `struct termios',
  60.    `tcflag_t', `cc_t', `speed_t' and the `TC*' constants appropriately.  */
  61.  
  62.  
  63. /* Input flags - software input processing.  */
  64. #define    IGNBRK    (1 << 0)    /* Ignore break condition.  */
  65. #define    BRKINT    (1 << 1)    /* Signal interrupt on break.  */
  66. #define    IGNPAR    (1 << 2)    /* Ignore characters with parity errors.  */
  67. #define    PARMRK    (1 << 3)    /* Mark parity and framing errors.  */
  68. #define    INPCK    (1 << 4)    /* Enable input parity check.  */
  69. #define    ISTRIP    (1 << 5)    /* Strip 8th bit off characters.  */
  70. #define    INLCR    (1 << 6)    /* Map NL to CR on input.  */
  71. #define    IGNCR    (1 << 7)    /* Ignore CR.  */
  72. #define    ICRNL    (1 << 8)    /* Map CR to NL on input.  */
  73. #define    IXON    (1 << 9)    /* Enable start/stop output control.  */
  74. #define    IXOFF    (1 << 10)    /* Enable start/stop input control.  */
  75. #define    IXANY    (1 << 11)    /* Any character will restart after stop.  */
  76. #define    IMAXBEL    (1 << 13)    /* Ring bell when input queue is full.  */
  77.  
  78. /* Output modes - software output proecssing.  */
  79. #define    OPOST    (1 << 0)    /* Perform output processing.  */
  80. #define    ONLCR    (1 << 1)    /* Map NL to CR-NL on output.  */
  81. #define    OXTABS    (1 << 2)    /* Expand tabs to spaces.  */
  82. #define    ONOEOT    (1 << 3)    /* Discard EOT (^D) on output.  */
  83. #define OCRNL    (1 << 4)    /* Map CR to NL on output.  */
  84. #define ONOCR    (1 << 5)    /* No CR output at column 0.  */
  85. #define ONLRET    (1 << 6)    /* NL performs CR function.  */
  86.  
  87. /* Control flags - hardware control of terminal. */
  88. #define    CIGNORE    (1 << 0)    /* Ignore these control flags.  */
  89. #define    CSIZE    (CS5|CS6|CS7|CS8)    /* Number of bits per byte (mask).  */
  90. #define    CS5    0        /* 5 bits per byte.  */
  91. #define    CS6    (1 << 8)    /* 6 bits per byte.  */
  92. #define    CS7    (1 << 9)    /* 7 bits per byte.  */
  93. #define    CS8    (CS6|CS7)    /* 8 bits per byte.  */
  94. #define    CSTOPB    (1 << 10)    /* Two stop bits instead of one.  */
  95. #define    CREAD    (1 << 11)    /* Enable receiver.  */
  96. #define    PARENB    (1 << 12)    /* Parity enable.  */
  97. #define    PARODD    (1 << 13)    /* Odd parity instead of even.  */
  98. #define    HUPCL    (1 << 14)    /* Hang up on last close.  */
  99. #define    CLOCAL    (1 << 15)    /* Ignore modem status lines.  */
  100. #define    CCTS_OFLOW    (1 << 16)    /* CTS flow control of output.  */
  101. #define    CRTS_IFLOW    (1 << 17)    /* RTS flow control of input.  */
  102. #define CDTR_IFLOW    (1 << 18)    /* DTR flow control of input.  */
  103. #define CDSR_OFLOW    (1 << 19)    /* DSR flow control of output.  */
  104. #define CCAR_OFLOW    (1 << 20)    /* DCD flow control of output.  */
  105. #define    MDMBUF        (1 << 20)    /* Carrier flow control of output.  */
  106.  
  107. /* Local modes.  */
  108. #ifdef __USE_MISC
  109. #define ECHOKE          0x00000001      /* visual erase for line kill */
  110. #endif  /*_POSIX_SOURCE */
  111. #define ECHOE           0x00000002      /* visually erase chars */
  112. #define ECHOK           0x00000004      /* echo NL after line kill */
  113. #define ECHO            0x00000008      /* enable echoing */
  114. #define ECHONL          0x00000010      /* echo NL even if ECHO is off */
  115. #ifdef __USE_MISC
  116. #define ECHOPRT         0x00000020      /* visual erase mode for hardcopy */
  117. #define ECHOCTL         0x00000040      /* echo control chars as ^(Char) */
  118. #endif  /*_POSIX_SOURCE */
  119. #define ISIG            0x00000080      /* enable signals INTR, QUIT, [D]SUSP */
  120. #define ICANON          0x00000100      /* canonicalize input lines */
  121. #ifndef _POSIX_SOURCE
  122. #define ALTWERASE       0x00000200      /* use alternate WERASE algorithm */
  123. #endif  /*_POSIX_SOURCE */
  124. #define IEXTEN          0x00000400      /* enable DISCARD and LNEXT */
  125. #define EXTPROC         0x00000800      /* external processing */
  126. #define XCASE           0x00001000
  127. #define TOSTOP          0x00400000      /* stop background jobs from output */
  128. #ifndef _POSIX_SOURCE
  129. #define FLUSHO          0x00800000      /* output being flushed (state) */
  130. #define NOKERNINFO      0x02000000      /* no kernel output from VSTATUS */
  131. #define PENDIN          0x20000000      /* XXX retype pending input (state) */
  132. #endif  /*_POSIX_SOURCE */
  133. #define NOFLSH          0x80000000      /* don't flush after interrupt */
  134.  
  135. /* Special control characters.  These are indexes into the c_cc[]
  136.    character array.  The [xxx] is the flag that enables this
  137.    control character.  */
  138. #define    VEOF    0    /* End-of-file character [ICANON].  */
  139. #define    VEOL    1    /* End-of-line character [ICANON].  */
  140. #define    VEOL2    2    /* Second EOL character [ICANON].  */
  141. #define    VERASE    3    /* Erase character [ICANON].  */
  142. #define    VWERASE    4    /* Word-erase character [ICANON].  */
  143. #define    VKILL    5    /* Kill-line character [ICANON].  */
  144. #define    VREPRINT 6    /* Reprint-line character [ICANON].  */
  145. #define VERASE2 7    /* Erase character [ICANON].  */
  146.  
  147. #define    VINTR    8    /* Interrupt character [ISIG].  */
  148. #define    VQUIT    9    /* Quit character [ISIG].  */
  149. #define    VSUSP    10    /* Suspend character [ISIG].  */
  150. #define    VDSUSP    11    /* Delayed suspend character [ISIG].  */
  151. #define    VSTART    12    /* Start (X-ON) character [IXON, IXOFF].  */
  152. #define    VSTOP    13    /* Stop (X-OFF) character [IXON, IXOFF].  */
  153. #define    VLNEXT    14    /* Literal-next character [IEXTEN].  */
  154. #define    VDISCARD 15    /* Discard character [IEXTEN].  */
  155. #define    VMIN    16    /* Minimum number of bytes read at once [!ICANON].  */
  156. #define    VTIME    17    /* Time-out value (tenths of a second) [!ICANON].  */
  157. #define    VSTATUS    18    /* Status character [ICANON].  */
  158. #define    NCCS    20    /* Value duplicated in <hurd/tioctl.defs>.  */
  159.  
  160. /* Input and output baud rates.  */
  161. #ifdef __USE_MISC
  162. # define CBAUD        0x0000001F
  163. #endif
  164. #define     B0        0x00000000    /* Hang up.  */
  165. #define     B50        0x00000001    /* 50 baud.  */
  166. #define     B75        0x00000002    /* 75 baud.  */
  167. #define     B110        0x00000003    /* 110 baud.  */
  168. #define     B134        0x00000004    /* 134.5 baud.  */
  169. #define     B150        0x00000005    /* 150 baud.  */
  170. #define     B200        0x00000006    /* 200 baud.  */
  171. #define     B300        0x00000007    /* 300 baud.  */
  172. #define     B600        0x00000008    /* 600 baud.  */
  173. #define     B1200        0x00000009    /* 1200 baud.  */
  174. #define     B1800        0x0000000A    /* 1800 baud.  */
  175. #define     B2400        0x0000000B    /* 2400 baud.  */
  176. #define     B4800        0x0000000C    /* 4800 baud.  */
  177. #define     B9600        0x0000000D    /* 9600 baud.  */
  178. #define     B19200        0x0000000E    /* 19200 baud.  */
  179. #define     B38400        0x0000000F    /* 38400 baud.  */
  180. #ifdef __USE_MISC
  181. # define EXTA        B19200
  182. # define EXTB        B38400
  183. #endif
  184. #ifdef __USE_MISC
  185. # define CBAUDEX    0x00000010
  186. #endif
  187. #define     B7200        0x00000010    /* 7200 baud.  */
  188. #define     B14400        0x00000011    /* 14400 baud.  */
  189. #define     B28800        0x00000012    /* 28800 baud.  */
  190. #define     B57600        0x00000013    /* 57600 baud.  */
  191. #define     B76800        0x00000014    /* 76800 baud.  */
  192. #define     B115200    0x00000015    /* 115200 baud.  */
  193. #define     __MAX_BAUD    B115200
  194.  
  195. #define _IOT_termios /* Hurd ioctl type field.  */ \
  196.   _IOT (_IOTS (tcflag_t), 4, _IOTS (cc_t), NCCS, _IOTS (speed_t), 2)
  197.  
  198. /* Values for the OPTIONAL_ACTIONS argument to `tcsetattr'.  */
  199. #define    TCSANOW        0    /* Change immediately.  */
  200. #define    TCSADRAIN    1    /* Change when pending output is written.  */
  201. #define    TCSAFLUSH    2    /* Flush pending input before changing.  */
  202. #define    TCSASOFT    0x10    /* Flag: Don't alter hardware state.  */
  203.  
  204. /* Values for the QUEUE_SELECTOR argument to `tcflush'.  */
  205. #define    TCIFLUSH    1    /* Discard data received but not yet read.  */
  206. #define    TCOFLUSH    2    /* Discard data written but not yet sent.  */
  207. #define    TCIOFLUSH    3    /* Discard all pending data.  */
  208.  
  209. /* Values for the ACTION argument to `tcflow'.  */
  210. #define    TCOOFF    1        /* Suspend output.  */
  211. #define    TCOON    2        /* Restart suspended output.  */
  212. #define    TCIOFF    3        /* Send a STOP character.  */
  213. #define    TCION    4        /* Send a START character.  */
  214.  
  215. /* Compare a character C to a value VAL from the `c_cc' array in a
  216.    `struct termios'.  If VAL is _POSIX_VDISABLE, no character can match it.  */
  217. #define    CCEQ(val, c)    ((c) == (val) && (val) != _POSIX_VDISABLE)
  218.  
  219.  
  220. /* Defaults on "first" open.  */
  221. #define    TTYDEF_IFLAG    (BRKINT | ISTRIP | ICRNL | IMAXBEL | IXON | IXANY)
  222. #define TTYDEF_OFLAG    (OPOST | ONLCR | OXTABS)
  223. #define TTYDEF_LFLAG    (ECHO | ICANON | ISIG | IEXTEN | ECHOE|ECHOKE|ECHOCTL)
  224. #define TTYDEF_CFLAG    (CREAD | CS7 | PARENB | HUPCL)
  225. #define TTYDEF_SPEED    (B9600)
  226.  
  227. /* Control Character Defaults.  */
  228. #define CTRL(x)    (x&037)
  229. #define    CEOF        CTRL('d')
  230. #define    CEOL        ((unsigned char)'\377')    /* XXX avoid _POSIX_VDISABLE */
  231. #define    CERASE        0177
  232. #define    CINTR        CTRL('c')
  233. #define    CSTATUS        ((unsigned char)'\377')    /* XXX avoid _POSIX_VDISABLE */
  234. #define    CKILL        CTRL('u')
  235. #define    CMIN        1
  236. #define    CQUIT        034        /* FS, ^\ */
  237. #define    CSUSP        CTRL('z')
  238. #define    CTIME        0
  239. #define    CDSUSP        CTRL('y')
  240. #define    CSTART        CTRL('q')
  241. #define    CSTOP        CTRL('s')
  242. #define    CLNEXT        CTRL('v')
  243. #define    CDISCARD     CTRL('o')
  244. #define    CWERASE     CTRL('w')
  245. #define    CREPRINT     CTRL('r')
  246. #define    CEOT        CEOF
  247. /* compat */
  248. #define    CBRK        CEOL
  249. #define CRPRNT        CREPRINT
  250. #define    CFLUSH        CDISCARD
  251.  
  252.  
  253. /* Terminal control structure.  */
  254. struct termios
  255. {
  256.   /* Input modes.  */
  257.   tcflag_t c_iflag;
  258.  
  259.   /* Output modes.  */
  260.   tcflag_t c_oflag;
  261.  
  262.   /* Control modes.  */
  263.   tcflag_t c_cflag;
  264.  
  265.   /* Local modes.  */
  266.   tcflag_t c_lflag;
  267.  
  268.   /* Control characters.  */
  269.   cc_t c_cc[NCCS];
  270.  
  271.   /* Input and output baud rates.  */
  272.   speed_t c_ispeed, c_ospeed;
  273. };
  274.  
  275. /* Return the output baud rate stored in *TERMIOS_P.  */
  276. extern __speed_t cfgetospeed (const struct termios *__termios_p);
  277.  
  278. /* Return the input baud rate stored in *TERMIOS_P.  */
  279. extern __speed_t cfgetispeed (const struct termios *__termios_p);
  280.  
  281. /* Set the output baud rate stored in *TERMIOS_P to SPEED.  */
  282. extern int cfsetospeed (struct termios *__termios_p, __speed_t __speed);
  283.  
  284. /* Set the input baud rate stored in *TERMIOS_P to SPEED.  */
  285. extern int cfsetispeed (struct termios *__termios_p, __speed_t __speed);
  286.  
  287. /* Set both the input and output baud rates in *TERMIOS_OP to SPEED.  */
  288. extern void cfsetspeed (struct termios *__termios_p, __speed_t __speed);
  289.  
  290. /* Put the state of FD into *TERMIOS_P.  */
  291. extern int tcgetattr (int __fd, struct termios *__termios_p);
  292.  
  293. /* Set the state of FD to *TERMIOS_P.
  294.    Values for OPTIONAL_ACTIONS (TCSA*) are in <termbits.h>.  */
  295. extern int tcsetattr (int __fd, int __optional_actions,
  296.               const struct termios *__termios_p);
  297.  
  298.  
  299. /* Set *TERMIOS_P to indicate raw mode.  */
  300. extern void cfmakeraw (struct termios *__termios_p);
  301.  
  302. /* Send zero bits on FD.  */
  303. extern int tcsendbreak (int __fd, int __duration);
  304.  
  305. /* Wait for pending output to be written on FD.  */
  306. extern int tcdrain (int __fd);
  307.  
  308. /* Flush pending data on FD.
  309.    Values for QUEUE_SELECTOR (TC{I,O,IO}FLUSH) are in <termbits.h>.  */
  310. extern int tcflush (int __fd, int __queue_selector);
  311.  
  312. /* Suspend or restart transmission on FD.
  313.    Values for ACTION (TC[IO]{OFF,ON}) are in <termbits.h>.  */
  314. extern int tcflow (int __fd, int __action);
  315.  
  316. __END_DECLS
  317.  
  318. #endif
  319.