1.\" Copyright (c) 1989, 1991, 1993 2.\" The Regents of the University of California. 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.\" @(#)getttyent.3 8.1 (Berkeley) 6/4/93 33.\" 34.Dd June 4, 1993 35.Dt GETTTYENT 3 36.Os BSD 4.3 37.Sh NAME 38.Nm getttyent , 39.Nm getttynam , 40.Nm setttyent , 41.Nm endttyent 42.Nd get ttys file entry 43.Sh SYNOPSIS 44.Fd #include <ttyent.h> 45.Ft struct ttyent * 46.Fn getttyent 47.Ft struct ttyent * 48.Fn getttynam "char *name" 49.Ft int 50.Fn setttyent void 51.Ft int 52.Fn endttyent void 53.Sh DESCRIPTION 54The 55.Fn getttyent , 56and 57.Fn getttynam 58functions 59each return a pointer to an object, with the following structure, 60containing the broken-out fields of a line from the tty description 61file. 62.Bd -literal 63struct ttyent { 64 char *ty_name; /* terminal device name */ 65 char *ty_getty; /* command to execute */ 66 char *ty_type; /* terminal type */ 67#define TTY_ON 0x01 /* enable logins */ 68#define TTY_SECURE 0x02 /* allow uid of 0 to login */ 69 int ty_status; /* flag values */ 70 char *ty_window; /* command for window manager */ 71 char *ty_comment; /* comment field */ 72}; 73.Ed 74.Pp 75The fields are as follows: 76.Bl -tag -width ty_comment 77.It Fa ty_name 78The name of the character-special file. 79.It Fa ty_getty 80The name of the command invoked by 81.Xr init 8 82to initialize tty line characteristics. 83.It Fa ty_type 84The name of the default terminal type connected to this tty line. 85.It Fa ty_status 86A mask of bit fields which indicate various actions allowed on this 87tty line. 88The possible flags are as follows: 89.Bl -tag -width TTY_SECURE 90.It Dv TTY_ON 91Enables logins (i.e., 92.Xr init 8 93will start the command referenced by 94.Fa ty_getty 95on this entry). 96.It Dv TTY_SECURE 97Allow users with a uid of 0 to login on this terminal. 98.El 99.It Fa ty_window 100The command to execute for a window system associated with the line. 101.It Fa ty_comment 102Any trailing comment field, with any leading hash marks (``#'') or 103whitespace removed. 104.El 105.Pp 106If any of the fields pointing to character strings are unspecified, 107they are returned as null pointers. 108The field 109.Fa ty_status 110will be zero if no flag values are specified. 111.Pp 112See 113.Xr ttys 5 114for a more complete discussion of the meaning and usage of the 115fields. 116.Pp 117The 118.Fn getttyent 119function 120reads the next line from the ttys file, opening the file if necessary. 121The 122.Fn setttyent 123function 124rewinds the file if open, or opens the file if it is unopened. 125The 126.Fn endttyent 127function 128closes any open files. 129.Pp 130The 131.Fn getttynam 132function 133searches from the beginning of the file until a matching 134.Fa name 135is found 136(or until 137.Dv EOF 138is encountered). 139.Sh RETURN VALUES 140The routines 141.Fn getttyent 142and 143.Fn getttynam 144return a null pointer on 145.Dv EOF 146or error. 147The 148.Fn setttyent 149function 150and 151.Fn endttyent 152return 0 on failure and 1 on success. 153.Sh FILES 154.Bl -tag -width /etc/ttys -compact 155.It Pa /etc/ttys 156.El 157.Sh SEE ALSO 158.Xr login 1 , 159.Xr ttyslot 3 , 160.Xr gettytab 5 , 161.Xr termcap 5 , 162.Xr ttys 5 , 163.Xr getty 8 , 164.Xr init 8 165.Sh HISTORY 166The 167.Fn getttyent , 168.Fn getttynam , 169.Fn setttyent , 170and 171.Fn endttyent 172functions appeared in 173.Bx 4.3 . 174.Sh BUGS 175These functions use static data storage; 176if the data is needed for future use, it should be 177copied before any subsequent calls overwrite it. 178