Back to index

glibc  2.9
termios.h
Go to the documentation of this file.
00001 /* termios type and macro definitions.  4.4 BSD/generic GNU version.
00002    Copyright (C) 1993,94,96,97,99,2001 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #ifndef _TERMIOS_H
00021 # error "Never include <bits/termios.h> directly; use <termios.h> instead."
00022 #endif
00023 
00024 /* These macros are also defined in some <bits/ioctls.h> files (with
00025    numerically identical values), but this serves to shut up cpp's
00026    complaining. */
00027 #if defined __USE_MISC || defined __USE_XOPEN
00028 
00029 # ifdef NL0
00030 #  undef NL0
00031 # endif
00032 # ifdef NL1
00033 #  undef NL1
00034 # endif
00035 # ifdef TAB0
00036 #  undef TAB0
00037 # endif
00038 # ifdef TAB1
00039 #  undef TAB1
00040 # endif
00041 # ifdef TAB2
00042 #  undef TAB2
00043 # endif
00044 # ifdef CR0
00045 #  undef CR0
00046 # endif
00047 # ifdef CR1
00048 #  undef CR1
00049 # endif
00050 # ifdef CR2
00051 #  undef CR2
00052 # endif
00053 # ifdef CR3
00054 #  undef CR3
00055 # endif
00056 # ifdef FF0
00057 #  undef FF0
00058 # endif
00059 # ifdef FF1
00060 #  undef FF1
00061 # endif
00062 # ifdef BS0
00063 #  undef BS0
00064 # endif
00065 # ifdef BS1
00066 #  undef BS1
00067 # endif
00068 
00069 #endif /* __USE_MISC || __USE_XOPEN */
00070 
00071 #ifdef __USE_BSD
00072 
00073 # ifdef MDMBUF
00074 #  undef MDMBUF
00075 # endif
00076 # ifdef FLUSHO
00077 #  undef FLUSHO
00078 # endif
00079 # ifdef PENDIN
00080 #  undef PENDIN
00081 # endif
00082 
00083 #endif /* __USE_BSD */
00084 
00085 #ifdef ECHO
00086 # undef ECHO
00087 #endif
00088 #ifdef TOSTOP
00089 # undef TOSTOP
00090 #endif
00091 #ifdef NOFLSH
00092 # undef NOFLSH
00093 #endif
00094 
00095 
00096 /* These definitions match those used by the 4.4 BSD kernel.
00097    If the operating system has termios system calls or ioctls that
00098    correctly implement the POSIX.1 behavior, there should be a
00099    system-dependent version of this file that defines `struct termios',
00100    `tcflag_t', `cc_t', `speed_t' and the `TC*' constants appropriately.  */
00101 
00102 /* Type of terminal control flag masks.  */
00103 typedef unsigned long int tcflag_t;
00104 
00105 /* Type of control characters.  */
00106 typedef unsigned char cc_t;
00107 
00108 /* Type of baud rate specifiers.  */
00109 typedef long int speed_t;
00110 
00111 /* Terminal control structure.  */
00112 struct termios
00113 {
00114   /* Input modes.  */
00115   tcflag_t c_iflag;
00116 #define       IGNBRK (1 << 0)      /* Ignore break condition.  */
00117 #define       BRKINT (1 << 1)      /* Signal interrupt on break.  */
00118 #define       IGNPAR (1 << 2)      /* Ignore characters with parity errors.  */
00119 #define       PARMRK (1 << 3)      /* Mark parity and framing errors.  */
00120 #define       INPCK  (1 << 4)      /* Enable input parity check.  */
00121 #define       ISTRIP (1 << 5)      /* Strip 8th bit off characters.  */
00122 #define       INLCR  (1 << 6)      /* Map NL to CR on input.  */
00123 #define       IGNCR  (1 << 7)      /* Ignore CR.  */
00124 #define       ICRNL  (1 << 8)      /* Map CR to NL on input.  */
00125 #define       IXON   (1 << 9)      /* Enable start/stop output control.  */
00126 #define       IXOFF  (1 << 10)     /* Enable start/stop input control.  */
00127 #ifdef __USE_BSD
00128 # define IXANY       (1 << 11)     /* Any character will restart after stop.  */
00129 # define IMAXBEL (1 << 13)  /* Ring bell when input queue is full.  */
00130 #endif
00131 #ifdef __USE_GNU
00132 # define IUCLC       (1 << 14)     /* Translate upper case input to lower case. */
00133 #endif
00134 
00135   /* Output modes.  */
00136   tcflag_t c_oflag;
00137 #define       OPOST  (1 << 0)      /* Perform output processing.  */
00138 #if defined __USE_BSD || defined __USE_XOPEN
00139 # define ONLCR       (1 << 1)      /* Map NL to CR-NL on output.  */
00140 #endif
00141 #ifdef __USE_BSD
00142 # define OXTABS      TAB3          /* Expand tabs to spaces.  */
00143 # define ONOEOT      (1 << 3)      /* Discard EOT (^D) on output.  */
00144 #endif
00145 #if defined __USE_BSD || defined __USE_XOPEN
00146 # define OCRNL       (1 << 4)      /* Map CR to NL.  */
00147 # define ONOCR       (1 << 5)      /* Discard CR's when on column 0.  */
00148 # define ONLRET      (1 << 6)      /* Move to column 0 on NL.  */
00149 #endif
00150 #if defined __USE_MISC || defined __USE_XOPEN
00151 # define NLDLY       (3 << 8)      /* NL delay.  */
00152 # define NL0  (0 << 8)      /* NL type 0.  */
00153 # define NL1  (1 << 8)      /* NL type 1.  */
00154 # define TABDLY      (3 << 10)     /* TAB delay.  */
00155 # define TAB0 (0 << 10)     /* TAB delay type 0.  */
00156 # define TAB1 (1 << 10)     /* TAB delay type 1.  */
00157 # define TAB2 (2 << 10)     /* TAB delay type 2.  */
00158 # define TAB3 (1 << 2)      /* Expand tabs to spaces.  */
00159 # define CRDLY       (3 << 12)     /* CR delay.  */
00160 # define CR0  (0 << 12)     /* CR delay type 0.  */
00161 # define CR1  (1 << 12)     /* CR delay type 1.  */
00162 # define CR2  (2 << 12)     /* CR delay type 2.  */
00163 # define CR3  (3 << 12)     /* CR delay type 3.  */
00164 # define FFDLY       (1 << 14)     /* FF delay.  */
00165 # define FF0  (0 << 14)     /* FF delay type 0.  */
00166 # define FF1  (1 << 14)     /* FF delay type 1.  */
00167 # define BSDLY       (1 << 15)     /* BS delay.  */
00168 # define BS0  (0 << 15)     /* BS delay type 0.  */
00169 # define BS1  (1 << 15)     /* BS delay type 1.  */
00170 # define VTDLY       (1 << 16)     /* VT delay.  */
00171 # define VT0  (0 << 16)     /* VT delay type 0.  */
00172 # define VT1  (1 << 16)     /* VT delay type 1.  */
00173 #endif /* __USE_MISC || __USE_XOPEN */
00174 #ifdef __USE_GNU
00175 # define OLCUC       (1 << 17)     /* Translate lower case output to upper case */
00176 #endif
00177 #ifdef __USE_XOPEN
00178 # define OFILL       (1 << 18)     /* Send fill characters for delays.  */
00179 #endif
00180 
00181   /* Control modes.  */
00182   tcflag_t c_cflag;
00183 #ifdef __USE_BSD
00184 # define CIGNORE     (1 << 0)      /* Ignore these control flags.  */
00185 #endif
00186 #define       CSIZE  (CS5|CS6|CS7|CS8)    /* Number of bits per byte (mask).  */
00187 #define       CS5    0             /* 5 bits per byte.  */
00188 #define       CS6    (1 << 8)      /* 6 bits per byte.  */
00189 #define       CS7    (1 << 9)      /* 7 bits per byte.  */
00190 #define       CS8    (CS6|CS7)     /* 8 bits per byte.  */
00191 #define       CSTOPB (1 << 10)     /* Two stop bits instead of one.  */
00192 #define       CREAD  (1 << 11)     /* Enable receiver.  */
00193 #define       PARENB (1 << 12)     /* Parity enable.  */
00194 #define       PARODD (1 << 13)     /* Odd parity instead of even.  */
00195 #define       HUPCL  (1 << 14)     /* Hang up on last close.  */
00196 #define       CLOCAL (1 << 15)     /* Ignore modem status lines.  */
00197 #ifdef __USE_BSD
00198 # define CRTSCTS     (1 << 16)     /* RTS/CTS flow control.  */
00199 # define CRTS_IFLOW  CRTSCTS              /* Compatibility.  */
00200 # define CCTS_OFLOW  CRTSCTS              /* Compatibility.  */
00201 # define CDTRCTS     (1 << 17)     /* DTR/CTS flow control.  */
00202 # define MDMBUF             (1 << 20)     /* DTR/DCD flow control.  */
00203 # define CHWFLOW     (MDMBUF|CRTSCTS|CDTRCTS) /* All types of flow control.  */
00204 #endif
00205 
00206   /* Local modes.  */
00207   tcflag_t c_lflag;
00208 #ifdef __USE_BSD
00209 # define ECHOKE      (1 << 0)      /* Visual erase for KILL.  */
00210 #endif
00211 #define       _ECHOE (1 << 1)      /* Visual erase for ERASE.  */
00212 #define       ECHOE  _ECHOE
00213 #define       _ECHOK (1 << 2)      /* Echo NL after KILL.  */
00214 #define       ECHOK  _ECHOK
00215 #define       _ECHO  (1 << 3)      /* Enable echo.  */
00216 #define       ECHO   _ECHO
00217 #define       _ECHONL       (1 << 4)      /* Echo NL even if ECHO is off.  */
00218 #define       ECHONL _ECHONL
00219 #ifdef __USE_BSD
00220 # define ECHOPRT     (1 << 5)      /* Hardcopy visual erase.  */
00221 # define ECHOCTL     (1 << 6)      /* Echo control characters as ^X.  */
00222 #endif
00223 #define       _ISIG  (1 << 7)      /* Enable signals.  */
00224 #define       ISIG   _ISIG
00225 #define       _ICANON       (1 << 8)      /* Do erase and kill processing.  */
00226 #define       ICANON _ICANON
00227 #ifdef __USE_BSD
00228 # define ALTWERASE (1 << 9) /* Alternate WERASE algorithm.  */
00229 #endif
00230 #define       _IEXTEN       (1 << 10)     /* Enable DISCARD and LNEXT.  */
00231 #define       IEXTEN _IEXTEN
00232 #define       EXTPROC       (1 << 11)     /* External processing.  */
00233 #define       _TOSTOP       (1 << 22)     /* Send SIGTTOU for background output.  */
00234 #define       TOSTOP _TOSTOP
00235 #ifdef __USE_BSD
00236 # define FLUSHO      (1 << 23)     /* Output being flushed (state).  */
00237 # define NOKERNINFO (1 << 25)      /* Disable VSTATUS.  */
00238 # define PENDIN      (1 << 29)     /* Retype pending input (state).  */
00239 #endif
00240 #define       _NOFLSH       (1 << 31)     /* Disable flush after interrupt.  */
00241 #define       NOFLSH _NOFLSH
00242 
00243   /* Control characters.  */
00244 #define       VEOF   0             /* End-of-file character [ICANON].  */
00245 #define       VEOL   1             /* End-of-line character [ICANON].  */
00246 #ifdef __USE_BSD
00247 # define VEOL2       2             /* Second EOL character [ICANON].  */
00248 #endif
00249 #define       VERASE 3             /* Erase character [ICANON].  */
00250 #ifdef __USE_BSD
00251 # define VWERASE     4             /* Word-erase character [ICANON].  */
00252 #endif
00253 #define       VKILL  5             /* Kill-line character [ICANON].  */
00254 #ifdef __USE_BSD
00255 # define VREPRINT 6         /* Reprint-line character [ICANON].  */
00256 #endif
00257 #define       VINTR  8             /* Interrupt character [ISIG].  */
00258 #define       VQUIT  9             /* Quit character [ISIG].  */
00259 #define       VSUSP  10            /* Suspend character [ISIG].  */
00260 #ifdef __USE_BSD
00261 # define VDSUSP      11            /* Delayed suspend character [ISIG].  */
00262 #endif
00263 #define       VSTART 12            /* Start (X-ON) character [IXON, IXOFF].  */
00264 #define       VSTOP  13            /* Stop (X-OFF) character [IXON, IXOFF].  */
00265 #ifdef __USE_BSD
00266 # define VLNEXT      14            /* Literal-next character [IEXTEN].  */
00267 # define VDISCARD 15        /* Discard character [IEXTEN].  */
00268 #endif
00269 #define       VMIN   16            /* Minimum number of bytes read at once [!ICANON].  */
00270 #define       VTIME  17            /* Time-out value (tenths of a second) [!ICANON].  */
00271 #ifdef __USE_BSD
00272 # define VSTATUS     18            /* Status character [ICANON].  */
00273 #endif
00274 #define       NCCS   20            /* Value duplicated in <hurd/tioctl.defs>.  */
00275   cc_t c_cc[NCCS];
00276 
00277   /* Input and output baud rates.  */
00278   speed_t __ispeed, __ospeed;
00279 #define       B0     0             /* Hang up.  */
00280 #define       B50    50            /* 50 baud.  */
00281 #define       B75    75            /* 75 baud.  */
00282 #define       B110   110           /* 110 baud.  */
00283 #define       B134   134           /* 134.5 baud.  */
00284 #define       B150   150           /* 150 baud.  */
00285 #define       B200   200           /* 200 baud.  */
00286 #define       B300   300           /* 300 baud.  */
00287 #define       B600   600           /* 600 baud.  */
00288 #define       B1200  1200          /* 1200 baud.  */
00289 #define       B1800  1800          /* 1800 baud.  */
00290 #define       B2400  2400          /* 2400 baud.  */
00291 #define       B4800  4800          /* 4800 baud.  */
00292 #define       B9600  9600          /* 9600 baud.  */
00293 #define       B7200  7200          /* 7200 baud.  */
00294 #define       B14400 14400         /* 14400 baud.  */
00295 #define       B19200 19200         /* 19200 baud.  */
00296 #define       B28800 28800         /* 28800 baud.  */
00297 #define       B38400 38400         /* 38400 baud.  */
00298 #ifdef __USE_MISC
00299 # define EXTA 19200
00300 # define EXTB 38400
00301 #endif
00302 #define       B57600 57600
00303 #define       B76800 76800
00304 #define       B115200       115200
00305 #define       B230400       230400
00306 #define       B460800       460800
00307 #define       B500000       500000
00308 #define       B576000       576000
00309 #define       B921600       921600
00310 #define       B1000000 1000000
00311 #define       B1152000 1152000
00312 #define       B1500000 1500000
00313 #define       B2000000 2000000
00314 #define       B2500000 2500000
00315 #define       B3000000 3000000
00316 #define       B3500000 3500000
00317 #define       B4000000 4000000
00318 };
00319 
00320 #define _IOT_termios /* Hurd ioctl type field.  */ \
00321   _IOT (_IOTS (tcflag_t), 4, _IOTS (cc_t), NCCS, _IOTS (speed_t), 2)
00322 
00323 /* Values for the OPTIONAL_ACTIONS argument to `tcsetattr'.  */
00324 #define       TCSANOW              0      /* Change immediately.  */
00325 #define       TCSADRAIN     1      /* Change when pending output is written.  */
00326 #define       TCSAFLUSH     2      /* Flush pending input before changing.  */
00327 #ifdef __USE_BSD
00328 # define TCSASOFT    0x10   /* Flag: Don't alter hardware state.  */
00329 #endif
00330 
00331 /* Values for the QUEUE_SELECTOR argument to `tcflush'.  */
00332 #define       TCIFLUSH      1      /* Discard data received but not yet read.  */
00333 #define       TCOFLUSH      2      /* Discard data written but not yet sent.  */
00334 #define       TCIOFLUSH     3      /* Discard all pending data.  */
00335 
00336 /* Values for the ACTION argument to `tcflow'.  */
00337 #define       TCOOFF 1             /* Suspend output.  */
00338 #define       TCOON  2             /* Restart suspended output.  */
00339 #define       TCIOFF 3             /* Send a STOP character.  */
00340 #define       TCION  4             /* Send a START character.  */