home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 5 / FreshFish_July-August1994.bin / bbs / gnu / ixemul-39.47-env-bin.lha / include / sys / tty.h < prev    next >
C/C++ Source or Header  |  1993-09-05  |  6KB  |  175 lines

  1. /*-
  2.  * Copyright (c) 1982, 1986 The Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice, this list of conditions and the following disclaimer in the
  12.  *    documentation and/or other materials provided with the distribution.
  13.  * 3. All advertising materials mentioning features or use of this software
  14.  *    must display the following acknowledgement:
  15.  *    This product includes software developed by the University of
  16.  *    California, Berkeley and its contributors.
  17.  * 4. Neither the name of the University nor the names of its contributors
  18.  *    may be used to endorse or promote products derived from this software
  19.  *    without specific prior written permission.
  20.  *
  21.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31.  * SUCH DAMAGE.
  32.  *
  33.  *    @(#)tty.h    7.10 (Berkeley) 6/26/91
  34.  */
  35.  
  36. #include <sys/termios.h>
  37.  
  38. /*
  39.  * Clists are character lists, which is a variable length linked list
  40.  * of cblocks, wiht a count of the number of characters in the list.
  41.  */
  42. struct clist {
  43.     int    c_cc;        /* count of characters in queue */
  44.     char    *c_cf;        /* first character/cblock */
  45.     char    *c_cl;        /* last chararacter/cblock */
  46. };
  47.  
  48. /*
  49.  * Per-tty structure.
  50.  *
  51.  * Should be split in two, into device and tty drivers.
  52.  * Glue could be masks of what to echo and circular buffer
  53.  * (low, high, timeout).
  54.  */
  55. struct tty {
  56.     struct    clist t_rawq;        /* queues */
  57.     struct    clist t_canq;
  58.     struct    clist t_outq;
  59.     int    (*t_oproc)();        /* device */
  60.     int    (*t_param)();        /* device */
  61.     struct    proc *t_rsel;        /* tty */
  62.     struct    proc *t_wsel;
  63.     caddr_t    T_LINEP;         /* XXX */
  64.     caddr_t    t_addr;            /* ??? */
  65.     dev_t    t_dev;            /* device */
  66.     int    t_flags;        /* (compat) some of both */
  67.     int    t_state;        /* some of both */
  68.     struct    session *t_session;    /* tty */
  69.     struct    pgrp *t_pgrp;        /* foreground process group */
  70.     char    t_line;            /* glue */
  71.     short    t_col;            /* tty */
  72.     short    t_rocount, t_rocol;    /* tty */
  73.     short    t_hiwat;        /* hi water mark */
  74.     short    t_lowat;        /* low water mark */
  75.     struct    winsize t_winsize;    /* window size */
  76.     struct    termios t_termios;    /* termios state */
  77. #define    t_iflag        t_termios.c_iflag
  78. #define    t_oflag        t_termios.c_oflag
  79. #define    t_cflag        t_termios.c_cflag
  80. #define    t_lflag        t_termios.c_lflag
  81. #define    t_min        t_termios.c_min
  82. #define    t_time        t_termios.c_time
  83. #define    t_cc        t_termios.c_cc
  84. #define t_ispeed    t_termios.c_ispeed
  85. #define t_ospeed    t_termios.c_ospeed
  86.     long    t_cancc;        /* stats */
  87.     long    t_rawcc;
  88.     long    t_outcc;
  89.     short    t_gen;            /* generation number */
  90. };
  91.  
  92. #define    TTIPRI    25            /* sleep priority for tty reads */
  93. #define    TTOPRI    26            /* sleep priority for tty writes */
  94.  
  95. #define    TTMASK    15
  96. #define    OBUFSIZ    100
  97. #define    TTYHOG    1024
  98.  
  99. #ifdef KERNEL
  100. #define TTMAXHIWAT    roundup(2048, CBSIZE)
  101. #define TTMINHIWAT    roundup(100, CBSIZE)
  102. #define TTMAXLOWAT    256
  103. #define TTMINLOWAT    32
  104. extern    struct ttychars ttydefaults;
  105. #endif /* KERNEL */
  106.  
  107. /* internal state bits */
  108. #define    TS_TIMEOUT    0x000001    /* delay timeout in progress */
  109. #define    TS_WOPEN    0x000002    /* waiting for open to complete */
  110. #define    TS_ISOPEN    0x000004    /* device is open */
  111. #define    TS_FLUSH    0x000008    /* outq has been flushed during DMA */
  112. #define    TS_CARR_ON    0x000010    /* software copy of carrier-present */
  113. #define    TS_BUSY        0x000020    /* output in progress */
  114. #define    TS_ASLEEP    0x000040    /* wakeup when output done */
  115. #define    TS_XCLUDE    0x000080    /* exclusive-use flag against open */
  116. #define    TS_TTSTOP    0x000100    /* output stopped by ctl-s */
  117. /* was    TS_HUPCLS    0x000200      * hang up upon last close */
  118. #define    TS_TBLOCK    0x000400    /* tandem queue blocked */
  119. #define    TS_RCOLL    0x000800    /* collision in read select */
  120. #define    TS_WCOLL    0x001000    /* collision in write select */
  121. #define    TS_ASYNC    0x004000    /* tty in async i/o mode */
  122. /* state for intra-line fancy editing work */
  123. #define    TS_BKSL        0x010000    /* state for lowercase \ work */
  124. #define    TS_ERASE    0x040000    /* within a \.../ for PRTRUB */
  125. #define    TS_LNCH        0x080000    /* next character is literal */
  126. #define    TS_TYPEN    0x100000    /* retyping suspended input (PENDIN) */
  127. #define    TS_CNTTB    0x200000    /* counting tab width, ignore FLUSHO */
  128.  
  129. #define    TS_LOCAL    (TS_BKSL|TS_ERASE|TS_LNCH|TS_TYPEN|TS_CNTTB)
  130.  
  131. /* define partab character types */
  132. #define    ORDINARY    0
  133. #define    CONTROL        1
  134. #define    BACKSPACE    2
  135. #define    NEWLINE        3
  136. #define    TAB        4
  137. #define    VTAB        5
  138. #define    RETURN        6
  139.  
  140. struct speedtab {
  141.         int sp_speed;
  142.         int sp_code;
  143. };
  144. /*
  145.  * Flags on character passed to ttyinput
  146.  */
  147. #define TTY_CHARMASK    0x000000ff      /* Character mask */
  148. #define TTY_QUOTE       0x00000100      /* Character quoted */
  149. #define TTY_ERRORMASK   0xff000000      /* Error mask */
  150. #define TTY_FE          0x01000000      /* Framing error or BREAK condition */
  151. #define TTY_PE          0x02000000      /* Parity error */
  152.  
  153. /*
  154.  * Is tp controlling terminal for p
  155.  */
  156. #define isctty(p, tp)    ((p)->p_session == (tp)->t_session && \
  157.              (p)->p_flag&SCTTY)
  158. /*
  159.  * Is p in background of tp
  160.  */
  161. #define isbackground(p, tp)    (isctty((p), (tp)) && \
  162.                 (p)->p_pgrp != (tp)->t_pgrp)
  163. /*
  164.  * Modem control commands (driver).
  165.  */
  166. #define    DMSET        0
  167. #define    DMBIS        1
  168. #define    DMBIC        2
  169. #define    DMGET        3
  170.  
  171. #ifdef KERNEL
  172. /* symbolic sleep message strings */
  173. extern     char ttyin[], ttyout[], ttopen[], ttclos[], ttybg[], ttybuf[];
  174. #endif
  175.