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.\" $FreeBSD$ 34.\" 35.Dd November 17, 1996 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.Nm isdialuptty , 45.Nm isnettty 46.Nd determine tty type from ttys file entry 47.Sh SYNOPSIS 48.Fd #include <ttyent.h> 49.Ft struct ttyent * 50.Fn getttyent void 51.Ft struct ttyent * 52.Fn getttynam "const char *name" 53.Ft int 54.Fn setttyent void 55.Ft int 56.Fn endttyent void 57.Ft int 58.Fn isdialuptty "const char *name" 59.Ft int 60.Fn isnettty "const char *name" 61.Sh DESCRIPTION 62The 63.Fn getttyent , 64and 65.Fn getttynam 66functions 67each return a pointer to an object, with the following structure, 68containing the broken-out fields of a line from the tty description 69file. 70.Bd -literal 71struct ttyent { 72 char *ty_name; /* terminal device name */ 73 char *ty_getty; /* command to execute, usually getty */ 74 char *ty_type; /* terminal type for termcap */ 75#define TTY_ON 0x01 /* enable logins (start ty_getty program) */ 76#define TTY_SECURE 0x02 /* allow uid of 0 to login */ 77#define TTY_DIALUP 0x04 /* is a dialup tty */ 78#define TTY_NETWORK 0x08 /* is a network tty */ 79 int ty_status; /* status flags */ 80 char *ty_window; /* command to start up window manager */ 81 char *ty_comment; /* comment field */ 82 char *ty_group; /* tty group name */ 83}; 84.Ed 85.Pp 86The fields are as follows: 87.Bl -tag -width ty_comment 88.It Fa ty_name 89The name of the character-special file. 90.It Fa ty_getty 91The name of the command invoked by 92.Xr init 8 93to initialize tty line characteristics. 94.It Fa ty_type 95The name of the default terminal type connected to this tty line. 96.It Fa ty_status 97A mask of bit fields which indicate various actions allowed on this 98tty line. 99The possible flags are as follows: 100.Bl -tag -width TTY_NETWORK 101.It Dv TTY_ON 102Enables logins (i.e., 103.Xr init 8 104will start the command referenced by 105.Fa ty_getty 106on this entry). 107.It Dv TTY_SECURE 108Allow users with a uid of 0 to login on this terminal. 109.It Dv TTY_DIALUP 110Identifies a tty as a dialin line. 111If this flag is set, then 112.Fn isdialuptty 113will return a non-zero value. 114.It Dv TTY_NETWORK 115Identifies a tty used for network connections. 116If this flag is set, then 117.Fn isnettty 118will return a non-zero value. 119.El 120.It Fa ty_window 121The command to execute for a window system associated with the line. 122.It Fa ty_group 123A group name to which the tty belongs. 124If no group is specified in the ttys description file, 125then the tty is placed in an anonymous group called "none". 126.It Fa ty_comment 127Any trailing comment field, with any leading hash marks (``#'') or 128whitespace removed. 129.El 130.Pp 131If any of the fields pointing to character strings are unspecified, 132they are returned as null pointers. 133The field 134.Fa ty_status 135will be zero if no flag values are specified. 136.Pp 137See 138.Xr ttys 5 139for a more complete discussion of the meaning and usage of the 140fields. 141.Pp 142The 143.Fn getttyent 144function 145reads the next line from the ttys file, opening the file if necessary. 146The 147.Fn setttyent 148function 149rewinds the file if open, or opens the file if it is unopened. 150The 151.Fn endttyent 152function 153closes any open files. 154.Pp 155The 156.Fn getttynam 157function 158searches from the beginning of the file until a matching 159.Fa name 160is found 161(or until 162.Dv EOF 163is encountered). 164.Sh RETURN VALUES 165The routines 166.Fn getttyent 167and 168.Fn getttynam 169return a null pointer on 170.Dv EOF 171or error. 172The 173.Fn setttyent 174function 175and 176.Fn endttyent 177return 0 on failure and 1 on success. 178.Pp 179The routines 180.Fn isdialuptty 181and 182.Fn isnettty 183return non-zero if the dialup or network flag is set for the 184tty entry relating to the tty named by the parameter, and 185zero otherwise. 186.Sh FILES 187.Bl -tag -width /etc/ttys -compact 188.It Pa /etc/ttys 189.El 190.Sh SEE ALSO 191.Xr login 1 , 192.Xr ttyslot 3 , 193.Xr gettytab 5 , 194.Xr termcap 5 , 195.Xr ttys 5 , 196.Xr getty 8 , 197.Xr init 8 198.Sh HISTORY 199The 200.Fn getttyent , 201.Fn getttynam , 202.Fn setttyent , 203and 204.Fn endttyent 205functions appeared in 206.Bx 4.3 . 207.Sh BUGS 208These functions use static data storage; 209if the data is needed for future use, it should be 210copied before any subsequent calls overwrite it. 211