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 November 17, 1996 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, usually getty */ 66 char *ty_type; /* terminal type for termcap */ 67#define TTY_ON 0x01 /* enable logins (start ty_getty program) */ 68#define TTY_SECURE 0x02 /* allow uid of 0 to login */ 69 int ty_status; /* status flags */ 70 char *ty_window; /* command to start up window manager */ 71 char *ty_comment; /* comment field */ 72 char *ty_group; /* tty group name */ 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_group 103A group name to which the tty belongs. 104If no group is specified in the ttys description file, 105then the tty is placed in an anonymous group called "none". 106.It Fa ty_comment 107Any trailing comment field, with any leading hash marks (``#'') or 108whitespace removed. 109.El 110.Pp 111If any of the fields pointing to character strings are unspecified, 112they are returned as null pointers. 113The field 114.Fa ty_status 115will be zero if no flag values are specified. 116.Pp 117See 118.Xr ttys 5 119for a more complete discussion of the meaning and usage of the 120fields. 121.Pp 122The 123.Fn getttyent 124function 125reads the next line from the ttys file, opening the file if necessary. 126The 127.Fn setttyent 128function 129rewinds the file if open, or opens the file if it is unopened. 130The 131.Fn endttyent 132function 133closes any open files. 134.Pp 135The 136.Fn getttynam 137function 138searches from the beginning of the file until a matching 139.Fa name 140is found 141(or until 142.Dv EOF 143is encountered). 144.Sh RETURN VALUES 145The routines 146.Fn getttyent 147and 148.Fn getttynam 149return a null pointer on 150.Dv EOF 151or error. 152The 153.Fn setttyent 154function 155and 156.Fn endttyent 157return 0 on failure and 1 on success. 158.Sh FILES 159.Bl -tag -width /etc/ttys -compact 160.It Pa /etc/ttys 161.El 162.Sh SEE ALSO 163.Xr login 1 , 164.Xr ttyslot 3 , 165.Xr gettytab 5 , 166.Xr termcap 5 , 167.Xr ttys 5 , 168.Xr getty 8 , 169.Xr init 8 170.Sh HISTORY 171The 172.Fn getttyent , 173.Fn getttynam , 174.Fn setttyent , 175and 176.Fn endttyent 177functions appeared in 178.Bx 4.3 . 179.Sh BUGS 180These functions use static data storage; 181if the data is needed for future use, it should be 182copied before any subsequent calls overwrite it. 183