xref: /freebsd/lib/libc/gen/getttyent.3 (revision dc36d6f9bb1753f3808552f3afd30eda9a7b206a)
158f0484fSRodney W. Grimes.\" Copyright (c) 1989, 1991, 1993
258f0484fSRodney W. Grimes.\"	The Regents of the University of California.  All rights reserved.
358f0484fSRodney W. Grimes.\"
458f0484fSRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
558f0484fSRodney W. Grimes.\" modification, are permitted provided that the following conditions
658f0484fSRodney W. Grimes.\" are met:
758f0484fSRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
858f0484fSRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
958f0484fSRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
1058f0484fSRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
1158f0484fSRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
12fbbd9655SWarner Losh.\" 3. Neither the name of the University nor the names of its contributors
1358f0484fSRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
1458f0484fSRodney W. Grimes.\"    without specific prior written permission.
1558f0484fSRodney W. Grimes.\"
1658f0484fSRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1758f0484fSRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1858f0484fSRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1958f0484fSRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2058f0484fSRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2158f0484fSRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2258f0484fSRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2358f0484fSRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2458f0484fSRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2558f0484fSRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2658f0484fSRodney W. Grimes.\" SUCH DAMAGE.
2758f0484fSRodney W. Grimes.\"
284ae89ecdSDavid Nugent.Dd November 17, 1996
2958f0484fSRodney W. Grimes.Dt GETTTYENT 3
30a307d598SRuslan Ermilov.Os
3158f0484fSRodney W. Grimes.Sh NAME
3258f0484fSRodney W. Grimes.Nm getttyent ,
3358f0484fSRodney W. Grimes.Nm getttynam ,
3458f0484fSRodney W. Grimes.Nm setttyent ,
3551f98e58SRuslan Ermilov.Nm endttyent ,
36b06ebb32SDavid Nugent.Nm isdialuptty ,
378023e3ddSBruce Evans.Nm isnettty
3851f98e58SRuslan Ermilov.Nd
3951f98e58SRuslan Ermilov.Xr ttys 5
4051f98e58SRuslan Ermilovfile routines
4125bb73e0SAlexey Zelkin.Sh LIBRARY
4225bb73e0SAlexey Zelkin.Lb libc
4358f0484fSRodney W. Grimes.Sh SYNOPSIS
4432eef9aeSRuslan Ermilov.In ttyent.h
4558f0484fSRodney W. Grimes.Ft struct ttyent *
4669b10155SBruce Evans.Fn getttyent void
4758f0484fSRodney W. Grimes.Ft struct ttyent *
4808398af3SBruce Evans.Fn getttynam "const char *name"
4958f0484fSRodney W. Grimes.Ft int
5058f0484fSRodney W. Grimes.Fn setttyent void
5158f0484fSRodney W. Grimes.Ft int
5258f0484fSRodney W. Grimes.Fn endttyent void
53b06ebb32SDavid Nugent.Ft int
54b06ebb32SDavid Nugent.Fn isdialuptty "const char *name"
55b06ebb32SDavid Nugent.Ft int
568023e3ddSBruce Evans.Fn isnettty "const char *name"
5758f0484fSRodney W. Grimes.Sh DESCRIPTION
5858f0484fSRodney W. GrimesThe
5958f0484fSRodney W. Grimes.Fn getttyent ,
6058f0484fSRodney W. Grimesand
6158f0484fSRodney W. Grimes.Fn getttynam
6258f0484fSRodney W. Grimesfunctions
6358f0484fSRodney W. Grimeseach return a pointer to an object, with the following structure,
6458f0484fSRodney W. Grimescontaining the broken-out fields of a line from the tty description
6558f0484fSRodney W. Grimesfile.
6658f0484fSRodney W. Grimes.Bd -literal
6758f0484fSRodney W. Grimesstruct ttyent {
6858f0484fSRodney W. Grimes	char	*ty_name;	/* terminal device name */
691ffa6450SMike Pritchard	char	*ty_getty;	/* command to execute, usually getty */
701ffa6450SMike Pritchard	char	*ty_type;	/* terminal type for termcap */
711ffa6450SMike Pritchard#define	TTY_ON		0x01	/* enable logins (start ty_getty program) */
7258f0484fSRodney W. Grimes#define	TTY_SECURE	0x02	/* allow uid of 0 to login */
73b06ebb32SDavid Nugent#define	TTY_DIALUP	0x04	/* is a dialup tty */
74b06ebb32SDavid Nugent#define	TTY_NETWORK	0x08	/* is a network tty */
751cde387cSEdward Tomasz Napierala#define	TTY_IFEXISTS	0x10	/* configured as "onifexists" */
761cde387cSEdward Tomasz Napierala#define	TTY_IFCONSOLE	0x20	/* configured as "onifconsole" */
771ffa6450SMike Pritchard	int	ty_status;	/* status flags */
781ffa6450SMike Pritchard	char	*ty_window;	/* command to start up window manager */
7958f0484fSRodney W. Grimes	char	*ty_comment;	/* comment field */
804ae89ecdSDavid Nugent	char	*ty_group;	/* tty group name */
8158f0484fSRodney W. Grimes};
8258f0484fSRodney W. Grimes.Ed
8358f0484fSRodney W. Grimes.Pp
8458f0484fSRodney W. GrimesThe fields are as follows:
8558f0484fSRodney W. Grimes.Bl -tag -width ty_comment
8658f0484fSRodney W. Grimes.It Fa ty_name
8758f0484fSRodney W. GrimesThe name of the character-special file.
8858f0484fSRodney W. Grimes.It Fa ty_getty
8958f0484fSRodney W. GrimesThe name of the command invoked by
9058f0484fSRodney W. Grimes.Xr init 8
9158f0484fSRodney W. Grimesto initialize tty line characteristics.
9258f0484fSRodney W. Grimes.It Fa ty_type
9358f0484fSRodney W. GrimesThe name of the default terminal type connected to this tty line.
9458f0484fSRodney W. Grimes.It Fa ty_status
9558f0484fSRodney W. GrimesA mask of bit fields which indicate various actions allowed on this
9658f0484fSRodney W. Grimestty line.
9758f0484fSRodney W. GrimesThe possible flags are as follows:
98b06ebb32SDavid Nugent.Bl -tag -width TTY_NETWORK
9958f0484fSRodney W. Grimes.It Dv TTY_ON
10058f0484fSRodney W. GrimesEnables logins (i.e.,
10158f0484fSRodney W. Grimes.Xr init 8
10258f0484fSRodney W. Grimeswill start the command referenced by
10358f0484fSRodney W. Grimes.Fa ty_getty
10458f0484fSRodney W. Grimeson this entry).
10558f0484fSRodney W. Grimes.It Dv TTY_SECURE
10658f0484fSRodney W. GrimesAllow users with a uid of 0 to login on this terminal.
107b06ebb32SDavid Nugent.It Dv TTY_DIALUP
108b06ebb32SDavid NugentIdentifies a tty as a dialin line.
109b06ebb32SDavid NugentIf this flag is set, then
110b06ebb32SDavid Nugent.Fn isdialuptty
111b06ebb32SDavid Nugentwill return a non-zero value.
112b06ebb32SDavid Nugent.It Dv TTY_NETWORK
113b06ebb32SDavid NugentIdentifies a tty used for network connections.
114b06ebb32SDavid NugentIf this flag is set, then
1158023e3ddSBruce Evans.Fn isnettty
116b06ebb32SDavid Nugentwill return a non-zero value.
1171cde387cSEdward Tomasz Napierala.It Dv TTY_IFEXISTS
118*61abc6bfSEdward Tomasz NapieralaIdentifies a tty that does not necessarily exist.
1191cde387cSEdward Tomasz Napierala.It Dv TTY_IFCONSOLE
1201cde387cSEdward Tomasz NapieralaIdentifies a tty that might be a system console.
12158f0484fSRodney W. Grimes.El
12258f0484fSRodney W. Grimes.It Fa ty_window
12358f0484fSRodney W. GrimesThe command to execute for a window system associated with the line.
1244ae89ecdSDavid Nugent.It Fa ty_group
1254ae89ecdSDavid NugentA group name to which the tty belongs.
1264ae89ecdSDavid NugentIf no group is specified in the ttys description file,
1274ae89ecdSDavid Nugentthen the tty is placed in an anonymous group called "none".
12858f0484fSRodney W. Grimes.It Fa ty_comment
12958f0484fSRodney W. GrimesAny trailing comment field, with any leading hash marks (``#'') or
13058f0484fSRodney W. Grimeswhitespace removed.
13158f0484fSRodney W. Grimes.El
13258f0484fSRodney W. Grimes.Pp
13358f0484fSRodney W. GrimesIf any of the fields pointing to character strings are unspecified,
13458f0484fSRodney W. Grimesthey are returned as null pointers.
13558f0484fSRodney W. GrimesThe field
13658f0484fSRodney W. Grimes.Fa ty_status
13758f0484fSRodney W. Grimeswill be zero if no flag values are specified.
13858f0484fSRodney W. Grimes.Pp
13958f0484fSRodney W. GrimesSee
14058f0484fSRodney W. Grimes.Xr ttys 5
14158f0484fSRodney W. Grimesfor a more complete discussion of the meaning and usage of the
14258f0484fSRodney W. Grimesfields.
14358f0484fSRodney W. Grimes.Pp
14458f0484fSRodney W. GrimesThe
14558f0484fSRodney W. Grimes.Fn getttyent
14658f0484fSRodney W. Grimesfunction
14758f0484fSRodney W. Grimesreads the next line from the ttys file, opening the file if necessary.
14858f0484fSRodney W. GrimesThe
14958f0484fSRodney W. Grimes.Fn setttyent
15058f0484fSRodney W. Grimesfunction
15158f0484fSRodney W. Grimesrewinds the file if open, or opens the file if it is unopened.
15258f0484fSRodney W. GrimesThe
15358f0484fSRodney W. Grimes.Fn endttyent
15458f0484fSRodney W. Grimesfunction
15558f0484fSRodney W. Grimescloses any open files.
15658f0484fSRodney W. Grimes.Pp
15758f0484fSRodney W. GrimesThe
15858f0484fSRodney W. Grimes.Fn getttynam
15958f0484fSRodney W. Grimesfunction
16058f0484fSRodney W. Grimessearches from the beginning of the file until a matching
16158f0484fSRodney W. Grimes.Fa name
16258f0484fSRodney W. Grimesis found
16358f0484fSRodney W. Grimes(or until
16458f0484fSRodney W. Grimes.Dv EOF
16558f0484fSRodney W. Grimesis encountered).
16658f0484fSRodney W. Grimes.Sh RETURN VALUES
16758f0484fSRodney W. GrimesThe routines
16858f0484fSRodney W. Grimes.Fn getttyent
16958f0484fSRodney W. Grimesand
17058f0484fSRodney W. Grimes.Fn getttynam
17158f0484fSRodney W. Grimesreturn a null pointer on
17258f0484fSRodney W. Grimes.Dv EOF
17358f0484fSRodney W. Grimesor error.
17458f0484fSRodney W. GrimesThe
17558f0484fSRodney W. Grimes.Fn setttyent
17658f0484fSRodney W. Grimesfunction
17758f0484fSRodney W. Grimesand
17858f0484fSRodney W. Grimes.Fn endttyent
17958f0484fSRodney W. Grimesreturn 0 on failure and 1 on success.
180b06ebb32SDavid Nugent.Pp
181b06ebb32SDavid NugentThe routines
182b06ebb32SDavid Nugent.Fn isdialuptty
183b06ebb32SDavid Nugentand
1848023e3ddSBruce Evans.Fn isnettty
185b06ebb32SDavid Nugentreturn non-zero if the dialup or network flag is set for the
1862efeeba5SRuslan Ermilovtty entry relating to the tty named by the argument, and
187b06ebb32SDavid Nugentzero otherwise.
18858f0484fSRodney W. Grimes.Sh FILES
18958f0484fSRodney W. Grimes.Bl -tag -width /etc/ttys -compact
19058f0484fSRodney W. Grimes.It Pa /etc/ttys
19158f0484fSRodney W. Grimes.El
19258f0484fSRodney W. Grimes.Sh SEE ALSO
19358f0484fSRodney W. Grimes.Xr login 1 ,
19458f0484fSRodney W. Grimes.Xr gettytab 5 ,
19558f0484fSRodney W. Grimes.Xr termcap 5 ,
19658f0484fSRodney W. Grimes.Xr ttys 5 ,
19758f0484fSRodney W. Grimes.Xr getty 8 ,
19858f0484fSRodney W. Grimes.Xr init 8
19958f0484fSRodney W. Grimes.Sh HISTORY
20058f0484fSRodney W. GrimesThe
20158f0484fSRodney W. Grimes.Fn getttyent ,
20258f0484fSRodney W. Grimes.Fn getttynam ,
20358f0484fSRodney W. Grimes.Fn setttyent ,
20458f0484fSRodney W. Grimesand
20558f0484fSRodney W. Grimes.Fn endttyent
20658f0484fSRodney W. Grimesfunctions appeared in
20758f0484fSRodney W. Grimes.Bx 4.3 .
20858f0484fSRodney W. Grimes.Sh BUGS
20958f0484fSRodney W. GrimesThese functions use static data storage;
21058f0484fSRodney W. Grimesif the data is needed for future use, it should be
21158f0484fSRodney W. Grimescopied before any subsequent calls overwrite it.
212