xref: /freebsd/lib/libc/gen/getttyent.3 (revision e0c4386e)
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. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.Dd November 17, 1996
29.Dt GETTTYENT 3
30.Os
31.Sh NAME
32.Nm getttyent ,
33.Nm getttynam ,
34.Nm setttyent ,
35.Nm endttyent ,
36.Nm isdialuptty ,
37.Nm isnettty
38.Nd
39.Xr ttys 5
40file routines
41.Sh LIBRARY
42.Lb libc
43.Sh SYNOPSIS
44.In ttyent.h
45.Ft struct ttyent *
46.Fn getttyent void
47.Ft struct ttyent *
48.Fn getttynam "const char *name"
49.Ft int
50.Fn setttyent void
51.Ft int
52.Fn endttyent void
53.Ft int
54.Fn isdialuptty "const char *name"
55.Ft int
56.Fn isnettty "const char *name"
57.Sh DESCRIPTION
58The
59.Fn getttyent ,
60and
61.Fn getttynam
62functions
63each return a pointer to an object, with the following structure,
64containing the broken-out fields of a line from the tty description
65file.
66.Bd -literal
67struct ttyent {
68	char	*ty_name;	/* terminal device name */
69	char	*ty_getty;	/* command to execute, usually getty */
70	char	*ty_type;	/* terminal type for termcap */
71#define	TTY_ON		0x01	/* enable logins (start ty_getty program) */
72#define	TTY_SECURE	0x02	/* allow uid of 0 to login */
73#define	TTY_DIALUP	0x04	/* is a dialup tty */
74#define	TTY_NETWORK	0x08	/* is a network tty */
75#define	TTY_IFEXISTS	0x10	/* configured as "onifexists" */
76#define	TTY_IFCONSOLE	0x20	/* configured as "onifconsole" */
77	int	ty_status;	/* status flags */
78	char	*ty_window;	/* command to start up window manager */
79	char	*ty_comment;	/* comment field */
80	char	*ty_group;	/* tty group name */
81};
82.Ed
83.Pp
84The fields are as follows:
85.Bl -tag -width ty_comment
86.It Fa ty_name
87The name of the character-special file.
88.It Fa ty_getty
89The name of the command invoked by
90.Xr init 8
91to initialize tty line characteristics.
92.It Fa ty_type
93The name of the default terminal type connected to this tty line.
94.It Fa ty_status
95A mask of bit fields which indicate various actions allowed on this
96tty line.
97The possible flags are as follows:
98.Bl -tag -width TTY_NETWORK
99.It Dv TTY_ON
100Enables logins (i.e.,
101.Xr init 8
102will start the command referenced by
103.Fa ty_getty
104on this entry).
105.It Dv TTY_SECURE
106Allow users with a uid of 0 to login on this terminal.
107.It Dv TTY_DIALUP
108Identifies a tty as a dialin line.
109If this flag is set, then
110.Fn isdialuptty
111will return a non-zero value.
112.It Dv TTY_NETWORK
113Identifies a tty used for network connections.
114If this flag is set, then
115.Fn isnettty
116will return a non-zero value.
117.It Dv TTY_IFEXISTS
118Identifies a tty that does not necessarily exist.
119.It Dv TTY_IFCONSOLE
120Identifies a tty that might be a system console.
121.El
122.It Fa ty_window
123The command to execute for a window system associated with the line.
124.It Fa ty_group
125A group name to which the tty belongs.
126If no group is specified in the ttys description file,
127then the tty is placed in an anonymous group called "none".
128.It Fa ty_comment
129Any trailing comment field, with any leading hash marks (``#'') or
130whitespace removed.
131.El
132.Pp
133If any of the fields pointing to character strings are unspecified,
134they are returned as null pointers.
135The field
136.Fa ty_status
137will be zero if no flag values are specified.
138.Pp
139See
140.Xr ttys 5
141for a more complete discussion of the meaning and usage of the
142fields.
143.Pp
144The
145.Fn getttyent
146function
147reads the next line from the ttys file, opening the file if necessary.
148The
149.Fn setttyent
150function
151rewinds the file if open, or opens the file if it is unopened.
152The
153.Fn endttyent
154function
155closes any open files.
156.Pp
157The
158.Fn getttynam
159function
160searches from the beginning of the file until a matching
161.Fa name
162is found
163(or until
164.Dv EOF
165is encountered).
166.Sh RETURN VALUES
167The routines
168.Fn getttyent
169and
170.Fn getttynam
171return a null pointer on
172.Dv EOF
173or error.
174The
175.Fn setttyent
176function
177and
178.Fn endttyent
179return 0 on failure and 1 on success.
180.Pp
181The routines
182.Fn isdialuptty
183and
184.Fn isnettty
185return non-zero if the dialup or network flag is set for the
186tty entry relating to the tty named by the argument, and
187zero otherwise.
188.Sh FILES
189.Bl -tag -width /etc/ttys -compact
190.It Pa /etc/ttys
191.El
192.Sh SEE ALSO
193.Xr login 1 ,
194.Xr gettytab 5 ,
195.Xr termcap 5 ,
196.Xr ttys 5 ,
197.Xr getty 8 ,
198.Xr init 8
199.Sh HISTORY
200The
201.Fn getttyent ,
202.Fn getttynam ,
203.Fn setttyent ,
204and
205.Fn endttyent
206functions appeared in
207.Bx 4.3 .
208.Sh BUGS
209These functions use static data storage;
210if the data is needed for future use, it should be
211copied before any subsequent calls overwrite it.
212