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