termios.h

Go to the documentation of this file.
00001 /* The <termios.h> header is used for controlling tty modes. */
00002 
00003 #ifndef _TERMIOS_H
00004 #define _TERMIOS_H
00005 
00006 typedef unsigned short tcflag_t;
00007 typedef unsigned char cc_t;
00008 typedef unsigned int speed_t;
00009 
00010 #define NCCS               20   /* size of cc_c array, some extra space
00011                                  * for extensions. */
00012 
00013 /* Primary terminal control structure. POSIX Table 7-1. */
00014 struct termios {
00015   tcflag_t c_iflag;             /* input modes */
00016   tcflag_t c_oflag;             /* output modes */
00017   tcflag_t c_cflag;             /* control modes */
00018   tcflag_t c_lflag;             /* local modes */
00019   speed_t  c_ispeed;            /* input speed */
00020   speed_t  c_ospeed;            /* output speed */
00021   cc_t c_cc[NCCS];              /* control characters */
00022 };
00023 
00024 /* Values for termios c_iflag bit map.  POSIX Table 7-2. */
00025 #define BRKINT          0x0001  /* signal interrupt on break */
00026 #define ICRNL           0x0002  /* map CR to NL on input */
00027 #define IGNBRK          0x0004  /* ignore break */
00028 #define IGNCR           0x0008  /* ignore CR */
00029 #define IGNPAR          0x0010  /* ignore characters with parity errors */
00030 #define INLCR           0x0020  /* map NL to CR on input */
00031 #define INPCK           0x0040  /* enable input parity check */
00032 #define ISTRIP          0x0080  /* mask off 8th bit */
00033 #define IXOFF           0x0100  /* enable start/stop input control */
00034 #define IXON            0x0200  /* enable start/stop output control */
00035 #define PARMRK          0x0400  /* mark parity errors in the input queue */
00036 
00037 /* Values for termios c_oflag bit map.  POSIX Sec. 7.1.2.3. */
00038 #define OPOST           0x0001  /* perform output processing */
00039 
00040 /* Values for termios c_cflag bit map.  POSIX Table 7-3. */
00041 #define CLOCAL          0x0001  /* ignore modem status lines */
00042 #define CREAD           0x0002  /* enable receiver */
00043 #define CSIZE           0x000C  /* number of bits per character */
00044 #define         CS5     0x0000  /* if CSIZE is CS5, characters are 5 bits */
00045 #define         CS6     0x0004  /* if CSIZE is CS6, characters are 6 bits */
00046 #define         CS7     0x0008  /* if CSIZE is CS7, characters are 7 bits */
00047 #define         CS8     0x000C  /* if CSIZE is CS8, characters are 8 bits */
00048 #define CSTOPB          0x0010  /* send 2 stop bits if set, else 1 */
00049 #define HUPCL           0x0020  /* hang up on last close */
00050 #define PARENB          0x0040  /* enable parity on output */
00051 #define PARODD          0x0080  /* use odd parity if set, else even */
00052 
00053 /* Values for termios c_lflag bit map.  POSIX Table 7-4. */
00054 #define ECHO            0x0001  /* enable echoing of input characters */
00055 #define ECHOE           0x0002  /* echo ERASE as backspace */
00056 #define ECHOK           0x0004  /* echo KILL */
00057 #define ECHONL          0x0008  /* echo NL */
00058 #define ICANON          0x0010  /* canonical input (erase and kill enabled) */
00059 #define IEXTEN          0x0020  /* enable extended functions */
00060 #define ISIG            0x0040  /* enable signals */
00061 #define NOFLSH          0x0080  /* disable flush after interrupt or quit */
00062 #define TOSTOP          0x0100  /* send SIGTTOU (job control, not implemented*/
00063 
00064 /* Indices into c_cc array.  Default values in parentheses. POSIX Table 7-5. */
00065 #define VEOF                 0  /* cc_c[VEOF] = EOF char (^D) */
00066 #define VEOL                 1  /* cc_c[VEOL] = EOL char (undef) */
00067 #define VERASE               2  /* cc_c[VERASE] = ERASE char (^H) */
00068 #define VINTR                3  /* cc_c[VINTR] = INTR char (DEL) */
00069 #define VKILL                4  /* cc_c[VKILL] = KILL char (^U) */
00070 #define VMIN                 5  /* cc_c[VMIN] = MIN value for timer */
00071 #define VQUIT                6  /* cc_c[VQUIT] = QUIT char (^\) */
00072 #define VTIME                7  /* cc_c[VTIME] = TIME value for timer */
00073 #define VSUSP                8  /* cc_c[VSUSP] = SUSP (^Z, ignored) */
00074 #define VSTART               9  /* cc_c[VSTART] = START char (^S) */
00075 #define VSTOP               10  /* cc_c[VSTOP] = STOP char (^Q) */
00076 
00077 #define _POSIX_VDISABLE   (cc_t)0xFF    /* You can't even generate this 
00078                                          * character with 'normal' keyboards.
00079                                          * But some language specific keyboards
00080                                          * can generate 0xFF. It seems that all
00081                                          * 256 are used, so cc_t should be a
00082                                          * short...
00083                                          */
00084 
00085 /* Values for the baud rate settings.  POSIX Table 7-6. */
00086 #define B0              0x0000  /* hang up the line */
00087 #define B50             0x1000  /* 50 baud */
00088 #define B75             0x2000  /* 75 baud */
00089 #define B110            0x3000  /* 110 baud */
00090 #define B134            0x4000  /* 134.5 baud */
00091 #define B150            0x5000  /* 150 baud */
00092 #define B200            0x6000  /* 200 baud */
00093 #define B300            0x7000  /* 300 baud */
00094 #define B600            0x8000  /* 600 baud */
00095 #define B1200           0x9000  /* 1200 baud */
00096 #define B1800           0xA000  /* 1800 baud */
00097 #define B2400           0xB000  /* 2400 baud */
00098 #define B4800           0xC000  /* 4800 baud */
00099 #define B9600           0xD000  /* 9600 baud */
00100 #define B19200          0xE000  /* 19200 baud */
00101 #define B38400          0xF000  /* 38400 baud */
00102 
00103 /* Optional actions for tcsetattr().  POSIX Sec. 7.2.1.2. */
00104 #define TCSANOW            1    /* changes take effect immediately */
00105 #define TCSADRAIN          2    /* changes take effect after output is done */
00106 #define TCSAFLUSH          3    /* wait for output to finish and flush input */
00107 
00108 /* Queue_selector values for tcflush().  POSIX Sec. 7.2.2.2. */
00109 #define TCIFLUSH           1    /* flush accumulated input data */
00110 #define TCOFLUSH           2    /* flush accumulated output data */
00111 #define TCIOFLUSH          3    /* flush accumulated input and output data */
00112 
00113 /* Action values for tcflow().  POSIX Sec. 7.2.2.2. */
00114 #define TCOOFF             1    /* suspend output */
00115 #define TCOON              2    /* restart suspended output */
00116 #define TCIOFF             3    /* transmit a STOP character on the line */
00117 #define TCION              4    /* transmit a START character on the line */
00118 
00119 /* Function Prototypes. */
00120 #ifndef _ANSI_H
00121 #include <ansi.h>
00122 #endif
00123 
00124 _PROTOTYPE( int tcsendbreak, (int _fildes, int _duration)                    );
00125 _PROTOTYPE( int tcdrain, (int _filedes)                                      );
00126 _PROTOTYPE( int tcflush, (int _filedes, int _queue_selector)                 );
00127 _PROTOTYPE( int tcflow, (int _filedes, int _action)                          );
00128 _PROTOTYPE( speed_t cfgetispeed, (const struct termios *_termios_p)          );
00129 _PROTOTYPE( speed_t cfgetospeed, (const struct termios *_termios_p)          );
00130 _PROTOTYPE( int cfsetispeed, (struct termios *_termios_p, speed_t _speed)    );
00131 _PROTOTYPE( int cfsetospeed, (struct termios *_termios_p, speed_t _speed)    );
00132 _PROTOTYPE( int tcgetattr, (int _filedes, struct termios *_termios_p)        );
00133 _PROTOTYPE( int tcsetattr, \
00134         (int _filedes, int _opt_actions, const struct termios *_termios_p)   );
00135 
00136 #define cfgetispeed(termios_p)          ((termios_p)->c_ispeed)
00137 #define cfgetospeed(termios_p)          ((termios_p)->c_ospeed)
00138 #define cfsetispeed(termios_p, speed)   ((termios_p)->c_ispeed = (speed), 0)
00139 #define cfsetospeed(termios_p, speed)   ((termios_p)->c_ospeed = (speed), 0)
00140 
00141 #ifdef _MINIX
00142 /* Here are the local extensions to the POSIX standard for Minix. Posix
00143  * conforming programs are not able to access these, and therefore they are
00144  * only defined when a Minix program is compiled.
00145  */
00146 
00147 /* Extensions to the termios c_iflag bit map.  */
00148 #define IXANY           0x0800  /* allow any key to continue ouptut */
00149 
00150 /* Extensions to the termios c_oflag bit map. They are only active iff
00151  * OPOST is enabled. */
00152 #define ONLCR           0x0002  /* Map NL to CR-NL on output */
00153 #define XTABS           0x0004  /* Expand tabs to spaces */
00154 #define ONOEOT          0x0008  /* discard EOT's (^D) on output) */
00155 
00156 /* Extensions to the termios c_lflag bit map.  */
00157 #define LFLUSHO         0x0200  /* Flush output. */
00158 
00159 /* Extensions to the c_cc array. */
00160 #define VREPRINT          11    /* cc_c[VREPRINT] (^R) */
00161 #define VLNEXT            12    /* cc_c[VLNEXT] (^V) */
00162 #define VDISCARD          13    /* cc_c[VDISCARD] (^O) */
00163 
00164 /* Extensions to baud rate settings. */
00165 #define B57600          0x0100  /* 57600 baud */
00166 #define B115200         0x0200  /* 115200 baud */
00167 
00168 /* These are the default settings used by the kernel and by 'stty sane' */
00169 
00170 #define TCTRL_DEF       (CREAD | CS8 | HUPCL)
00171 #define TINPUT_DEF      (BRKINT | ICRNL | IXON | IXANY)
00172 #define TOUTPUT_DEF     (OPOST | ONLCR)
00173 #define TLOCAL_DEF      (ISIG | IEXTEN | ICANON | ECHO | ECHOE)
00174 #define TSPEED_DEF      B9600
00175 
00176 #define TEOF_DEF        '\4'    /* ^D */
00177 #define TEOL_DEF        _POSIX_VDISABLE
00178 #define TERASE_DEF      '\10'   /* ^H */
00179 #define TINTR_DEF       '\3'    /* ^C */
00180 #define TKILL_DEF       '\25'   /* ^U */
00181 #define TMIN_DEF        1
00182 #define TQUIT_DEF       '\34'   /* ^\ */
00183 #define TSTART_DEF      '\21'   /* ^Q */
00184 #define TSTOP_DEF       '\23'   /* ^S */
00185 #define TSUSP_DEF       '\32'   /* ^Z */
00186 #define TTIME_DEF       0
00187 #define TREPRINT_DEF    '\22'   /* ^R */
00188 #define TLNEXT_DEF      '\26'   /* ^V */
00189 #define TDISCARD_DEF    '\17'   /* ^O */
00190 
00191 /* Window size. This information is stored in the TTY driver but not used.
00192  * This can be used for screen based applications in a window environment. 
00193  * The ioctls TIOCGWINSZ and TIOCSWINSZ can be used to get and set this 
00194  * information.
00195  */
00196 
00197 struct winsize
00198 {
00199         unsigned short  ws_row;         /* rows, in characters */
00200         unsigned short  ws_col;         /* columns, in characters */
00201         unsigned short  ws_xpixel;      /* horizontal size, pixels */
00202         unsigned short  ws_ypixel;      /* vertical size, pixels */
00203 };
00204 #endif /* _MINIX */
00205 
00206 #endif /* _TERMIOS_H */

Generated on Fri Apr 14 22:57:22 2006 for minix by  doxygen 1.4.6