xref: /freebsd/lib/libc/gen/getttyent.3 (revision e5b786625f7f82a1fa91e41823332459ea5550f9)
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.\"     @(#)getttyent.3	8.1 (Berkeley) 6/4/93
29.\"
30.Dd November 17, 1996
31.Dt GETTTYENT 3
32.Os
33.Sh NAME
34.Nm getttyent ,
35.Nm getttynam ,
36.Nm setttyent ,
37.Nm endttyent ,
38.Nm isdialuptty ,
39.Nm isnettty
40.Nd
41.Xr ttys 5
42file routines
43.Sh LIBRARY
44.Lb libc
45.Sh SYNOPSIS
46.In ttyent.h
47.Ft struct ttyent *
48.Fn getttyent void
49.Ft struct ttyent *
50.Fn getttynam "const char *name"
51.Ft int
52.Fn setttyent void
53.Ft int
54.Fn endttyent void
55.Ft int
56.Fn isdialuptty "const char *name"
57.Ft int
58.Fn isnettty "const char *name"
59.Sh DESCRIPTION
60The
61.Fn getttyent ,
62and
63.Fn getttynam
64functions
65each return a pointer to an object, with the following structure,
66containing the broken-out fields of a line from the tty description
67file.
68.Bd -literal
69struct ttyent {
70	char	*ty_name;	/* terminal device name */
71	char	*ty_getty;	/* command to execute, usually getty */
72	char	*ty_type;	/* terminal type for termcap */
73#define	TTY_ON		0x01	/* enable logins (start ty_getty program) */
74#define	TTY_SECURE	0x02	/* allow uid of 0 to login */
75#define	TTY_DIALUP	0x04	/* is a dialup tty */
76#define	TTY_NETWORK	0x08	/* is a network tty */
77#define	TTY_IFEXISTS	0x10	/* configured as "onifexists" */
78#define	TTY_IFCONSOLE	0x20	/* configured as "onifconsole" */
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.It Dv TTY_IFEXISTS
120Identifies a tty that does not necessarily exist.
121.It Dv TTY_IFCONSOLE
122Identifies a tty that might be a system console.
123.El
124.It Fa ty_window
125The command to execute for a window system associated with the line.
126.It Fa ty_group
127A group name to which the tty belongs.
128If no group is specified in the ttys description file,
129then the tty is placed in an anonymous group called "none".
130.It Fa ty_comment
131Any trailing comment field, with any leading hash marks (``#'') or
132whitespace removed.
133.El
134.Pp
135If any of the fields pointing to character strings are unspecified,
136they are returned as null pointers.
137The field
138.Fa ty_status
139will be zero if no flag values are specified.
140.Pp
141See
142.Xr ttys 5
143for a more complete discussion of the meaning and usage of the
144fields.
145.Pp
146The
147.Fn getttyent
148function
149reads the next line from the ttys file, opening the file if necessary.
150The
151.Fn setttyent
152function
153rewinds the file if open, or opens the file if it is unopened.
154The
155.Fn endttyent
156function
157closes any open files.
158.Pp
159The
160.Fn getttynam
161function
162searches from the beginning of the file until a matching
163.Fa name
164is found
165(or until
166.Dv EOF
167is encountered).
168.Sh RETURN VALUES
169The routines
170.Fn getttyent
171and
172.Fn getttynam
173return a null pointer on
174.Dv EOF
175or error.
176The
177.Fn setttyent
178function
179and
180.Fn endttyent
181return 0 on failure and 1 on success.
182.Pp
183The routines
184.Fn isdialuptty
185and
186.Fn isnettty
187return non-zero if the dialup or network flag is set for the
188tty entry relating to the tty named by the argument, and
189zero otherwise.
190.Sh FILES
191.Bl -tag -width /etc/ttys -compact
192.It Pa /etc/ttys
193.El
194.Sh SEE ALSO
195.Xr login 1 ,
196.Xr gettytab 5 ,
197.Xr termcap 5 ,
198.Xr ttys 5 ,
199.Xr getty 8 ,
200.Xr init 8
201.Sh HISTORY
202The
203.Fn getttyent ,
204.Fn getttynam ,
205.Fn setttyent ,
206and
207.Fn endttyent
208functions appeared in
209.Bx 4.3 .
210.Sh BUGS
211These functions use static data storage;
212if the data is needed for future use, it should be
213copied before any subsequent calls overwrite it.
214