1.\" Copyright (c) 1989, 1991 The Regents of the University of California. 2.\" All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 3. All advertising materials mentioning features or use of this software 13.\" must display the following acknowledgement: 14.\" This product includes software developed by the University of 15.\" California, Berkeley and its contributors. 16.\" 4. Neither the name of the University nor the names of its contributors 17.\" may be used to endorse or promote products derived from this software 18.\" without specific prior written permission. 19.\" 20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" SUCH DAMAGE. 31.\" 32.\" from: @(#)getttyent.3 6.7 (Berkeley) 4/19/91 33.\" $Id: getttyent.3,v 1.5 1994/03/30 06:31:02 cgd Exp $ 34.\" 35.Dd April 19, 1991 36.Dt GETTTYENT 3 37.Os BSD 4.3 38.Sh NAME 39.Nm getttyent , 40.Nm getttynam , 41.Nm setttyent , 42.Nm endttyent 43.Nd get ttys file entry 44.Sh SYNOPSIS 45.Fd #include <ttyent.h> 46.Ft struct ttyent * 47.Fn getttyent 48.Ft struct ttyent * 49.Fn getttynam "char *name" 50.Ft int 51.Fn setttyent void 52.Ft int 53.Fn endttyent void 54.Sh DESCRIPTION 55The 56.Fn getttyent , 57and 58.Fn getttynam 59functions 60each return a pointer to an object, with the following structure, 61containing the broken-out fields of a line from the tty description 62file. 63.Bd -literal 64struct ttyent { 65 char *ty_name; /* terminal device name */ 66 char *ty_getty; /* command to execute */ 67 char *ty_type; /* terminal type */ 68#define TTY_ON 0x01 /* enable logins */ 69#define TTY_SECURE 0x02 /* allow uid of 0 to login */ 70#define TTY_LOCAL 0x04 /* set 'CLOCAL' on open (dev. specific) */ 71#define TTY_RTSCTS 0x08 /* set 'CRTSCTS' on open (dev. specific) */ 72#define TTY_SOFTCAR 0x10 /* ignore hardware carrier (dev. spec.) */ 73#define TTY_MDMBUF 0x20 /* set 'MDMBUF' on open (dev. specific) */ 74 int ty_status; /* flag values */ 75 char *ty_window; /* command for window manager */ 76 char *ty_comment; /* comment field */ 77}; 78.Ed 79.Pp 80The fields are as follows: 81.Bl -tag -width ty_comment 82.It Fa ty_name 83The name of the character-special file. 84.It Fa ty_getty 85The name of the command invoked by 86.Xr init 8 87to initialize tty line characteristics. 88.It Fa ty_type 89The name of the default terminal type connected to this tty line. 90.It Fa ty_status 91A mask of bit fields which indicate various actions allowed on this 92tty line. 93The possible flags are as follows: 94.Bl -tag -width TTY_SOFTCAR 95.It Dv TTY_ON 96Enables logins (i.e., 97.Xr init 8 98will start the command referenced by 99.Fa ty_getty 100on this entry). 101.It Dv TTY_SECURE 102Allow users with a uid of 0 to login on this terminal. 103.It Dv TTY_LOCAL 104If the terminal port's driver supports it, cause the line 105to be treated as ``local.'' 106.It Dv TTY_RTSCTS 107If the terminal port's driver supports it, use 108full-duplex RTS/CTS hardware flow control on the line 109by default. 110.It Dv TTY_SOFTCAR 111If the terminal port's driver supports it, ignore hardware 112carrier on the line. 113.El 114.It Fa ty_window 115The command to execute for a window system associated with the line. 116.It Fa ty_comment 117Any trailing comment field, with any leading hash marks (``#'') or 118whitespace removed. 119.El 120.Pp 121If any of the fields pointing to character strings are unspecified, 122they are returned as null pointers. 123The field 124.Fa ty_status 125will be zero if no flag values are specified. 126.Pp 127See 128.Xr ttys 5 129for a more complete discussion of the meaning and usage of the 130fields. 131.Pp 132The 133.Fn getttyent 134function 135reads the next line from the ttys file, opening the file if necessary. 136The 137.Fn setttyent 138function 139rewinds the file if open, or opens the file if it is unopened. 140The 141.Fn endttyent 142function 143closes any open files. 144.Pp 145The 146.Fn getttynam 147function 148searches from the beginning of the file until a matching 149.Fa name 150is found 151(or until 152.Dv EOF 153is encountered). 154.Sh RETURN VALUES 155The routines 156.Fn getttyent 157and 158.Fn getttynam 159return a null pointer on 160.Dv EOF 161or error. 162The 163.Fn setttyent 164function 165and 166.Fn endttyent 167return 0 on failure and 1 on success. 168.Sh FILES 169.Bl -tag -width /etc/ttys -compact 170.It Pa /etc/ttys 171.El 172.Sh SEE ALSO 173.Xr login 1 , 174.Xr ttyslot 3 , 175.Xr gettytab 5 , 176.Xr termcap 5 , 177.Xr ttys 5 , 178.Xr getty 8 , 179.Xr init 8 , 180.Xr ttyflags 8 181.Sh HISTORY 182The 183.Fn getttyent , 184.Fn getttynam , 185.Fn setttyent , 186and 187.Fn endttyent 188functions appeared in 189.Bx 4.3 . 190.Sh BUGS 191These functions use static data storage; 192if the data is needed for future use, it should be 193copied before any subsequent calls overwrite it. 194