libtty.h

Go to the documentation of this file.
00001 /*-
00002  * Copyright (c) 1982, 1986, 1990, 1993, 1994
00003  *      The Regents of the University of California.  All rights reserved.
00004  * (c) UNIX System Laboratories, Inc.
00005  * All or some portions of this file are derived from material licensed
00006  * to the University of California by American Telephone and Telegraph
00007  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
00008  * the permission of UNIX System Laboratories, Inc.
00009  *
00010  * Redistribution and use in source and binary forms, with or without
00011  * modification, are permitted provided that the following conditions
00012  * are met:
00013  * 1. Redistributions of source code must retain the above copyright
00014  *    notice, this list of conditions and the following disclaimer.
00015  * 2. Redistributions in binary form must reproduce the above copyright
00016  *    notice, this list of conditions and the following disclaimer in the
00017  *    documentation and/or other materials provided with the distribution.
00018  * 3. All advertising materials mentioning features or use of this software
00019  *    must display the following acknowledgement:
00020  *      This product includes software developed by the University of
00021  *      California, Berkeley and its contributors.
00022  * 4. Neither the name of the University nor the names of its contributors
00023  *    may be used to endorse or promote products derived from this software
00024  *    without specific prior written permission.
00025  *
00026  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00027  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00029  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00030  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00031  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00032  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00033  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00034  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00035  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00036  * SUCH DAMAGE.
00037  *
00038  *      @(#)ttycom.h    8.1 (Berkeley) 3/28/94
00039  */
00040 #ifndef __LIBTTY_H__
00041 #define __LIBTTY_H__
00042 #include <libc.h>
00043 
00044 /*
00045  * Tty ioctl's except for those supported only for backwards compatibility
00046  * with the old tty driver.
00047  */
00048 
00049 /*
00050  * Window/terminal size structure.  This information is stored by the kernel
00051  * in order to provide a consistent interface, but is not used by the kernel.
00052  */
00053 struct winsize {
00054         unsigned short  ws_row;         /* rows, in characters */
00055         unsigned short  ws_col;         /* columns, in characters */
00056         unsigned short  ws_xpixel;      /* horizontal size, pixels */
00057         unsigned short  ws_ypixel;      /* vertical size, pixels */
00058 };
00059 
00060 #define         TIOCM_LE        0001            /* line enable */
00061 #define         TIOCM_DTR       0002            /* data terminal ready */
00062 #define         TIOCM_RTS       0004            /* request to send */
00063 #define         TIOCM_ST        0010            /* secondary transmit */
00064 #define         TIOCM_SR        0020            /* secondary receive */
00065 #define         TIOCM_CTS       0040            /* clear to send */
00066 #define         TIOCM_CAR       0100            /* carrier detect */
00067 #define         TIOCM_CD        TIOCM_CAR
00068 #define         TIOCM_RNG       0200            /* ring */
00069 #define         TIOCM_RI        TIOCM_RNG
00070 #define         TIOCM_DSR       0400            /* data set ready */
00071                                                 /* 8-10 compat */
00072 #define TIOCEXCL         _IO('t', 13)           /* set exclusive use of tty */
00073 #define TIOCNXCL         _IO('t', 14)           /* reset exclusive use of tty */
00074                                                 /* 15 unused */
00075 #define TIOCFLUSH       _IOW('t', 16, int)      /* flush buffers */
00076                                                 /* 17-18 compat */
00077 #define TIOCGETA        _IOR('t', 19, struct termios) /* get termios struct */
00078 #define TIOCSETA        _IOW('t', 20, struct termios) /* set termios struct */
00079 #define TIOCSETAW       _IOW('t', 21, struct termios) /* drain output, set */
00080 #define TIOCSETAF       _IOW('t', 22, struct termios) /* drn out, fls in, set */
00081 #define TIOCGETD        _IOR('t', 26, int)      /* get line discipline (deprecated) */
00082 #define TIOCSETD        _IOW('t', 27, int)      /* set line discipline (deprecated) */
00083 
00084 /*
00085  * This is the maximum length of a line discipline's name.
00086  */
00087 #define TTLINEDNAMELEN  32
00088 typedef char linedn_t[TTLINEDNAMELEN];
00089 #define TIOCGLINED      _IOR('t', 66, linedn_t) /* get line discipline (new) */
00090 #define TIOCSLINED      _IOW('t', 67, linedn_t) /* set line discipline (new) */
00091                                                 /* 127-124 compat */
00092 #define TIOCSBRK         _IO('t', 123)          /* set break bit */
00093 #define TIOCCBRK         _IO('t', 122)          /* clear break bit */
00094 #define TIOCSDTR         _IO('t', 121)          /* set data terminal ready */
00095 #define TIOCCDTR         _IO('t', 120)          /* clear data terminal ready */
00096 #define TIOCGPGRP       _IOR('t', 119, pid_t)   /* get pgrp of tty */
00097 #define TIOCSPGRP       _IOW('t', 118, pid_t)   /* set pgrp of tty */
00098                                                 /* 117-116 compat */
00099 #define TIOCOUTQ        _IOR('t', 115, int)     /* output queue size */
00100 #define TIOCSTI         _IOW('t', 114, char)    /* simulate terminal input */
00101 #define TIOCNOTTY        _IO('t', 113)          /* void tty association */
00102 #define TIOCPKT         _IOW('t', 112, int)     /* pty: set/clear packet mode */
00103 #define         TIOCPKT_DATA            0x00    /* data packet */
00104 #define         TIOCPKT_FLUSHREAD       0x01    /* flush packet */
00105 #define         TIOCPKT_FLUSHWRITE      0x02    /* flush packet */
00106 #define         TIOCPKT_STOP            0x04    /* stop output */
00107 #define         TIOCPKT_START           0x08    /* start output */
00108 #define         TIOCPKT_NOSTOP          0x10    /* no more ^S, ^Q */
00109 #define         TIOCPKT_DOSTOP          0x20    /* now do ^S ^Q */
00110 #define         TIOCPKT_IOCTL           0x40    /* state change of pty driver */
00111 #define TIOCSTOP         _IO('t', 111)          /* stop output, like ^S */
00112 #define TIOCSTART        _IO('t', 110)          /* start output, like ^Q */
00113 #define TIOCMSET        _IOW('t', 109, int)     /* set all modem bits */
00114 #define TIOCMBIS        _IOW('t', 108, int)     /* bis modem bits */
00115 #define TIOCMBIC        _IOW('t', 107, int)     /* bic modem bits */
00116 #define TIOCMGET        _IOR('t', 106, int)     /* get all modem bits */
00117 #define TIOCREMOTE      _IOW('t', 105, int)     /* remote input editing */
00118 #define TIOCGWINSZ      _IOR('t', 104, struct winsize)  /* get window size */
00119 #define TIOCSWINSZ      _IOW('t', 103, struct winsize)  /* set window size */
00120 #define TIOCUCNTL       _IOW('t', 102, int)     /* pty: set/clr usr cntl mode */
00121 #define TIOCSTAT        _IOW('t', 101, int)     /* generate status message */
00122 #define         UIOCCMD(n)      _IO('u', n)     /* usr cntl op "n" */
00123 #define TIOCGSID        _IOR('t', 99, int)      /* get session id */
00124 #define TIOCCONS        _IOW('t', 98, int)      /* become virtual console */
00125 #define TIOCSCTTY        _IO('t', 97)           /* become controlling tty */
00126 #define TIOCEXT         _IOW('t', 96, int)      /* pty: external processing */
00127 #define TIOCSIG          _IO('t', 95)           /* pty: generate signal */
00128 #define TIOCDRAIN        _IO('t', 94)           /* wait till output drained */
00129 #define TIOCGFLAGS      _IOR('t', 93, int)      /* get device flags */
00130 #define TIOCSFLAGS      _IOW('t', 92, int)      /* set device flags */
00131 #define         TIOCFLAG_SOFTCAR        0x01    /* ignore hardware carrier */
00132 #define         TIOCFLAG_CLOCAL         0x02    /* set clocal on open */
00133 #define         TIOCFLAG_CRTSCTS        0x04    /* set crtscts on open */
00134 #define         TIOCFLAG_MDMBUF         0x08    /* set mdmbuf on open */
00135 #define         TIOCFLAG_CDTRCTS        0x10    /* set cdtrcts on open */
00136 #define TIOCDCDTIMESTAMP _IOR('t', 88, struct timeval) /* get timestamp of last
00137                                                  * Cd rise, stamp next rise */
00138 
00139 #define TIOCRCVFRAME    _IOW('t', 69, struct mbuf *)/* data frame received */
00140 #define TIOCXMTFRAME    _IOW('t', 68, struct mbuf *)/* data frame transmit */
00141 
00142 /*
00143  * lseos tty specific interface
00144  */
00145 #define MAXTTYDEVNAME   15
00146 #define TIOCGNAME       _IOR('t', 200, void *) /* get tty name, must be
00147                                                 MAXTTYDEVNAME+1 length */
00148 
00149 
00150 #define TTYDISC         0               /* termios tty line discipline */
00151 #define TABLDISC        3               /* tablet discipline */
00152 #define SLIPDISC        4               /* serial IP discipline */
00153 #define PPPDISC         5               /* ppp discipline */
00154 #define STRIPDISC       6               /* metricom wireless IP discipline */
00155 #define SUNKBDDISC      7               /* Sun keyboard discipline */
00156 #define SUNMSDISC       8               /* Sun mouse discipline */
00157 #define HDLCDISC        9               /* HDLC discipline */
00158 #define IRFRAMEDISC     10              /* IrDA frame discipline */
00159 
00160 /*
00161  * Special Control Characters
00162  *
00163  * Index into c_cc[] character array.
00164  *
00165  *      Name         Subscript  Enabled by
00166  */
00167 #define VEOF            0       /* ICANON */
00168 #define VEOL            1       /* ICANON */
00169 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
00170 #define VEOL2           2       /* ICANON */
00171 #endif
00172 #define VERASE          3       /* ICANON */
00173 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
00174 #define VWERASE         4       /* ICANON */
00175 #endif
00176 #define VKILL           5       /* ICANON */
00177 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
00178 #define VREPRINT        6       /* ICANON */
00179 #endif
00180 /*                      7          spare 1 */
00181 #define VINTR           8       /* ISIG */
00182 #define VQUIT           9       /* ISIG */
00183 #define VSUSP           10      /* ISIG */
00184 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
00185 #define VDSUSP          11      /* ISIG */
00186 #endif
00187 #define VSTART          12      /* IXON, IXOFF */
00188 #define VSTOP           13      /* IXON, IXOFF */
00189 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
00190 #define VLNEXT          14      /* IEXTEN */
00191 #define VDISCARD        15      /* IEXTEN */
00192 #endif
00193 #define VMIN            16      /* !ICANON */
00194 #define VTIME           17      /* !ICANON */
00195 #ifndef _POSIX_C_SOURCE
00196 #define VSTATUS         18      /* ICANON */
00197 /*                      19         spare 2 */
00198 #endif
00199 #define NCCS            20
00200 
00201 #define _POSIX_VDISABLE ((unsigned char)'\377')
00202 
00203 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
00204 #define CCEQ(val, c)    (c == val ? val != _POSIX_VDISABLE : 0)
00205 #endif
00206 
00207 /*
00208  * Input flags - software input processing
00209  */
00210 #define IGNBRK          0x00000001      /* ignore BREAK condition */
00211 #define BRKINT          0x00000002      /* map BREAK to SIGINTR */
00212 #define IGNPAR          0x00000004      /* ignore (discard) parity errors */
00213 #define PARMRK          0x00000008      /* mark parity and framing errors */
00214 #define INPCK           0x00000010      /* enable checking of parity errors */
00215 #define ISTRIP          0x00000020      /* strip 8th bit off chars */
00216 #define INLCR           0x00000040      /* map NL into CR */
00217 #define IGNCR           0x00000080      /* ignore CR */
00218 #define ICRNL           0x00000100      /* map CR to NL (ala CRMOD) */
00219 #define IXON            0x00000200      /* enable output flow control */
00220 #define IXOFF           0x00000400      /* enable input flow control */
00221 #if !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)
00222 #define IXANY           0x00000800      /* any char will restart after stop */
00223 #endif
00224 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
00225 #define IMAXBEL         0x00002000      /* ring bell on input queue full */
00226 #endif
00227 
00228 /*
00229  * Output flags - software output processing
00230  */
00231 #define OPOST           0x00000001      /* enable following output processing */
00232 #if !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)
00233 #define ONLCR           0x00000002      /* map NL to CR-NL (ala CRMOD) */
00234 #endif
00235 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
00236 #define OXTABS          0x00000004      /* expand tabs to spaces */
00237 #define ONOEOT          0x00000008      /* discard EOT's (^D) on output */
00238 #endif
00239 #if !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)
00240 #define OCRNL           0x00000010      /* map CR to NL */
00241 #define ONOCR           0x00000020      /* discard CR's when on column 0 */
00242 #define ONLRET          0x00000040      /* move to column 0 on CR */
00243 #endif  /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) */
00244 
00245 /*
00246  * Control flags - hardware control of terminal
00247  */
00248 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
00249 #define CIGNORE         0x00000001      /* ignore control flags */
00250 #endif
00251 #define CSIZE           0x00000300      /* character size mask */
00252 #define     CS5             0x00000000      /* 5 bits (pseudo) */
00253 #define     CS6             0x00000100      /* 6 bits */
00254 #define     CS7             0x00000200      /* 7 bits */
00255 #define     CS8             0x00000300      /* 8 bits */
00256 #define CSTOPB          0x00000400      /* send 2 stop bits */
00257 #define CREAD           0x00000800      /* enable receiver */
00258 #define PARENB          0x00001000      /* parity enable */
00259 #define PARODD          0x00002000      /* odd parity, else even */
00260 #define HUPCL           0x00004000      /* hang up on last close */
00261 #define CLOCAL          0x00008000      /* ignore modem status lines */
00262 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
00263 #define CRTSCTS         0x00010000      /* RTS/CTS full-duplex flow control */
00264 #define CRTS_IFLOW      CRTSCTS         /* XXX compat */
00265 #define CCTS_OFLOW      CRTSCTS         /* XXX compat */
00266 #define CDTRCTS         0x00020000      /* DTR/CTS full-duplex flow control */
00267 #define MDMBUF          0x00100000      /* DTR/DCD hardware flow control */
00268 #define CHWFLOW         (MDMBUF|CRTSCTS|CDTRCTS) /* all types of hw flow control */
00269 #endif
00270 
00271 
00272 /*
00273  * "Local" flags - dumping ground for other state
00274  *
00275  * Warning: some flags in this structure begin with
00276  * the letter "I" and look like they belong in the
00277  * input flag.
00278  */
00279 
00280 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
00281 #define ECHOKE          0x00000001      /* visual erase for line kill */
00282 #endif
00283 #define ECHOE           0x00000002      /* visually erase chars */
00284 #define ECHOK           0x00000004      /* echo NL after line kill */
00285 #define ECHO            0x00000008      /* enable echoing */
00286 #define ECHONL          0x00000010      /* echo NL even if ECHO is off */
00287 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
00288 #define ECHOPRT         0x00000020      /* visual erase mode for hardcopy */
00289 #define ECHOCTL         0x00000040      /* echo control chars as ^(Char) */
00290 #endif  /* !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) */
00291 #define ISIG            0x00000080      /* enable signals INTR, QUIT, [D]SUSP */
00292 #define ICANON          0x00000100      /* canonicalize input lines */
00293 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
00294 #define ALTWERASE       0x00000200      /* use alternate WERASE algorithm */
00295 #endif  /* !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) */
00296 #define IEXTEN          0x00000400      /* enable DISCARD and LNEXT */
00297 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
00298 #define EXTPROC         0x00000800      /* external processing */
00299 #endif  /* !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) */
00300 #define TOSTOP          0x00400000      /* stop background jobs on output */
00301 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
00302 #define FLUSHO          0x00800000      /* output being flushed (state) */
00303 #define NOKERNINFO      0x02000000      /* no kernel output from VSTATUS */
00304 #define PENDIN          0x20000000      /* re-echo input buffer at next read */
00305 #endif  /* !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) */
00306 #define NOFLSH          0x80000000      /* don't flush output on signal */
00307 
00308 typedef unsigned int    tcflag_t;
00309 typedef unsigned char   cc_t;
00310 typedef unsigned int    speed_t;
00311 
00312 struct termios {
00313         tcflag_t        c_iflag;        /* input flags */
00314         tcflag_t        c_oflag;        /* output flags */
00315         tcflag_t        c_cflag;        /* control flags */
00316         tcflag_t        c_lflag;        /* local flags */
00317         cc_t            c_cc[NCCS];     /* control chars */
00318         int             c_ispeed;       /* input speed */
00319         int             c_ospeed;       /* output speed */
00320 };
00321 
00322 /*
00323  * Commands passed to tcsetattr() for setting the termios structure.
00324  */
00325 #define TCSANOW         0               /* make change immediate */
00326 #define TCSADRAIN       1               /* drain output, then change */
00327 #define TCSAFLUSH       2               /* drain output, flush input */
00328 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
00329 #define TCSASOFT        0x10            /* flag - don't alter h.w. state */
00330 #endif
00331 
00332 /*
00333  * Standard speeds
00334  */
00335 #define B0      0
00336 #define B50     50
00337 #define B75     75
00338 #define B110    110
00339 #define B134    134
00340 #define B150    150
00341 #define B200    200
00342 #define B300    300
00343 #define B600    600
00344 #define B1200   1200
00345 #define B1800   1800
00346 #define B2400   2400
00347 #define B4800   4800
00348 #define B9600   9600
00349 #define B19200  19200
00350 #define B38400  38400
00351 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
00352 #define B7200   7200
00353 #define B14400  14400
00354 #define B28800  28800
00355 #define B57600  57600
00356 #define B76800  76800
00357 #define B115200 115200
00358 #define B230400 230400
00359 #define EXTA    19200
00360 #define EXTB    38400
00361 #endif  /* !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) */
00362 
00363 
00364 #define TCIFLUSH        1
00365 #define TCOFLUSH        2
00366 #define TCIOFLUSH       3
00367 #define TCOOFF          1
00368 #define TCOON           2
00369 #define TCIOFF          3
00370 #define TCION           4
00371 
00372 #include "termcap.h"
00373 
00374 /* PROTO libtty.c */
00375 /* libtty.c */
00376 int tcsetpgrp(int fd, pid_t pgrp_id);
00377 pid_t tcgetpgrp(int fd);
00378 int tcgetattr(int fd, struct termios *t);
00379 int tcsetattr(int fd, int action, const struct termios *t);
00380 char *getpass(const char *prompt);
00381 int openpty2(int *amaster, int *aslave, char *name, struct termios *termp, struct winsize *winp, int insecure);
00382 char *ttyname(int fd);
00383 void tty_dump(void);
00384 #endif

Generated on Wed May 24 23:05:52 2006 for LSE/OS by  doxygen 1.4.6