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.2 1993/07/30 08:36:48 mycroft 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 int ty_status; /* flag values */ 71 char *ty_window; /* command for window manager */ 72 char *ty_comment; /* comment field */ 73}; 74.Ed 75.Pp 76The fields are as follows: 77.Bl -tag -width ty_comment 78.It Fa ty_name 79The name of the character-special file. 80.It Fa ty_getty 81The name of the command invoked by 82.Xr init 8 83to initialize tty line characteristics. 84.It Fa ty_type 85The name of the default terminal type connected to this tty line. 86.It Fa ty_status 87A mask of bit fields which indicate various actions allowed on this 88tty line. 89The possible flags are as follows: 90.Bl -tag -width TTY_SECURE 91.It Dv TTY_ON 92Enables logins (i.e., 93.Xr init 8 94will start the command referenced by 95.Fa ty_getty 96on this entry). 97.It Dv TTY_SECURE 98Allow users with a uid of 0 to login on this terminal. 99.El 100.It Fa ty_window 101The command to execute for a window system associated with the line. 102.It Fa ty_comment 103Any trailing comment field, with any leading hash marks (``#'') or 104whitespace removed. 105.El 106.Pp 107If any of the fields pointing to character strings are unspecified, 108they are returned as null pointers. 109The field 110.Fa ty_status 111will be zero if no flag values are specified. 112.Pp 113See 114.Xr ttys 5 115for a more complete discussion of the meaning and usage of the 116fields. 117.Pp 118The 119.Fn getttyent 120function 121reads the next line from the ttys file, opening the file if necessary. 122The 123.Fn setttyent 124function 125rewinds the file if open, or opens the file if it is unopened. 126The 127.Fn endttyent 128function 129closes any open files. 130.Pp 131The 132.Fn getttynam 133function 134searches from the beginning of the file until a matching 135.Fa name 136is found 137(or until 138.Dv EOF 139is encountered). 140.Sh RETURN VALUES 141The routines 142.Fn getttyent 143and 144.Fn getttynam 145return a null pointer on 146.Dv EOF 147or error. 148The 149.Fn setttyent 150function 151and 152.Fn endttyent 153return 0 on failure and 1 on success. 154.Sh FILES 155.Bl -tag -width /etc/ttys -compact 156.It Pa /etc/ttys 157.El 158.Sh SEE ALSO 159.Xr login 1 , 160.Xr ttyslot 3 , 161.Xr gettytab 5 , 162.Xr termcap 5 , 163.Xr ttys 5 , 164.Xr getty 8 , 165.Xr init 8 166.Sh HISTORY 167The 168.Fn getttyent , 169.Fn getttynam , 170.Fn setttyent , 171and 172.Fn endttyent 173functions appeared in 174.Bx 4.3 . 175.Sh BUGS 176These functions use static data storage; 177if the data is needed for future use, it should be 178copied before any subsequent calls overwrite it. 179