mirror of https://github.com/mkerrisk/man-pages
This commit is contained in:
parent
dc1ffd7778
commit
3233d66512
180
man3/err.3
180
man3/err.3
|
@ -32,128 +32,132 @@
|
|||
.\" From: @(#)err.3 8.1 (Berkeley) 6/9/93
|
||||
.\" $FreeBSD: src/lib/libc/gen/err.3,v 1.11.2.5 2001/08/17 15:42:32 ru Exp $
|
||||
.\"
|
||||
.Dd November 25, 2007
|
||||
.Dt ERR 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm err ,
|
||||
.Nm verr ,
|
||||
.Nm errx ,
|
||||
.Nm verrx ,
|
||||
.Nm warn ,
|
||||
.Nm vwarn ,
|
||||
.Nm warnx ,
|
||||
.Nm vwarnx ,
|
||||
.Nd formatted error messages
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <err.h>
|
||||
.Ft void
|
||||
.Fn err "int eval" "const char *fmt" "..."
|
||||
.Ft void
|
||||
.Fn errx "int eval" "const char *fmt" "..."
|
||||
.Ft void
|
||||
.Fn warn "const char *fmt" "..."
|
||||
.Ft void
|
||||
.Fn warnx "const char *fmt" "..."
|
||||
.Fd #include <stdarg.h>
|
||||
.Ft void
|
||||
.Fn verr "int eval" "const char *fmt" "va_list args"
|
||||
.Ft void
|
||||
.Fn verrx "int eval" "const char *fmt" "va_list args"
|
||||
.Ft void
|
||||
.Fn vwarn "const char *fmt" "va_list args"
|
||||
.Ft void
|
||||
.Fn vwarnx "const char *fmt" "va_list args"
|
||||
.Sh DESCRIPTION
|
||||
.\" 2007-12-02, mtk, Converted from mdoc to man macros
|
||||
.\"
|
||||
.TH ERR 3 2007-12-02 "Linux" "Linux Programmer's Manual"
|
||||
.SH NAME
|
||||
err, verr, errx, verrx, warn, vwarn, warnx, vwarnx \- formatted error messages
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.B #include <err.h>
|
||||
.sp
|
||||
.BI "void err(int " eval ", const char *" fmt ", ...);"
|
||||
.sp
|
||||
.BI "void errx(int " eval ", const char *" fmt ", ...);"
|
||||
.sp
|
||||
.BI "void warn(const char *" fmt ", ...);"
|
||||
.sp
|
||||
.BI "void warnx(const char *" fmt ", ...);"
|
||||
.sp
|
||||
.B #include <stdarg.h>
|
||||
.sp
|
||||
.BI "void verr(int " eval ", const char *" fmt ", va_list " args );
|
||||
.sp
|
||||
.BI "void verrx(int " eval ", const char *" fmt ", va_list " args );
|
||||
.sp
|
||||
.BI "void vwarn(const char *" fmt ", va_list " args );
|
||||
.sp
|
||||
.BI "void vwarnx(const char *" fmt ", va_list " args );
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
The
|
||||
.Fn err
|
||||
.BR err ()
|
||||
and
|
||||
.Fn warn
|
||||
.BR warn ()
|
||||
family of functions display a formatted error message on the standard
|
||||
error output.
|
||||
In all cases, the last component of the program name, a colon character,
|
||||
and a space are output.
|
||||
If the
|
||||
.Fa fmt
|
||||
.I fmt
|
||||
argument is not NULL, the
|
||||
.Xr printf 3
|
||||
-like formatted error message is output.
|
||||
.BR printf (3)-like
|
||||
formatted error message is output.
|
||||
The output is terminated by a newline character.
|
||||
.Pp
|
||||
.sp
|
||||
The
|
||||
.Fn err ,
|
||||
.Fn verr ,
|
||||
.Fn warn ,
|
||||
.BR err (),
|
||||
.BR verr (),
|
||||
.BR warn (),
|
||||
and
|
||||
.Fn vwarn
|
||||
.BR vwarn ()
|
||||
functions append an error message obtained from
|
||||
.Xr strerror 3
|
||||
.BR strerror (3)
|
||||
based on a code or the global variable
|
||||
.Va errno ,
|
||||
.IR errno ,
|
||||
preceded by another colon and space unless the
|
||||
.Fa fmt
|
||||
.I fmt
|
||||
argument is
|
||||
.Dv NULL .
|
||||
.Pp
|
||||
NULL.
|
||||
.sp
|
||||
The
|
||||
.Fn err ,
|
||||
.Fn verr ,
|
||||
.Fn warn ,
|
||||
.BR err (),
|
||||
.BR verr (),
|
||||
.BR warn (),
|
||||
and
|
||||
.Fn vwarn
|
||||
.BR vwarn ()
|
||||
functions use the global variable
|
||||
.Va errno
|
||||
.I errno
|
||||
to look up the error message.
|
||||
.Pp
|
||||
.sp
|
||||
The
|
||||
.Fn errx
|
||||
.BR errx ()
|
||||
and
|
||||
.Fn warnx
|
||||
.BR warnx ()
|
||||
functions do not append an error message.
|
||||
.Pp
|
||||
.sp
|
||||
The
|
||||
.Fn err ,
|
||||
.Fn verr ,
|
||||
.Fn errx ,
|
||||
.BR err (),
|
||||
.BR verr (),
|
||||
.BR errx (),
|
||||
and
|
||||
.Fn verrx
|
||||
.BR verrx ()
|
||||
functions do not return, but exit with the value of the argument
|
||||
.Fa eval .
|
||||
.Sh EXAMPLES
|
||||
.IR eval .
|
||||
.SH EXAMPLES
|
||||
Display the current errno information string and exit:
|
||||
.Bd -literal -offset indent
|
||||
.in +0.5i
|
||||
.nf
|
||||
|
||||
if ((p = malloc(size)) == NULL)
|
||||
err(1, NULL);
|
||||
err(1, NULL);
|
||||
if ((fd = open(file_name, O_RDONLY, 0)) == \-1)
|
||||
err(1, "%s", file_name);
|
||||
.Ed
|
||||
.Pp
|
||||
err(1, "%s", file_name);
|
||||
.fi
|
||||
.in
|
||||
.sp
|
||||
Display an error message and exit:
|
||||
.Bd -literal -offset indent
|
||||
.in +0.5i
|
||||
.nf
|
||||
|
||||
if (tm.tm_hour < START_TIME)
|
||||
errx(1, "too early, wait until %s", start_time_string);
|
||||
.Ed
|
||||
.Pp
|
||||
errx(1, "too early, wait until %s", start_time_string);
|
||||
.fi
|
||||
.in
|
||||
.sp
|
||||
Warn of an error:
|
||||
.Bd -literal -offset indent
|
||||
.in +0.5i
|
||||
.nf
|
||||
|
||||
if ((fd = open(raw_device, O_RDONLY, 0)) == \-1)
|
||||
warnx("%s: %s: trying the block device",
|
||||
raw_device, strerror(errno));
|
||||
warnx("%s: %s: trying the block device",
|
||||
raw_device, strerror(errno));
|
||||
if ((fd = open(block_device, O_RDONLY, 0)) == \-1)
|
||||
err(1, "%s", block_device);
|
||||
.Ed
|
||||
.Sh "CONFORMING TO"
|
||||
err(1, "%s", block_device);
|
||||
.fi
|
||||
.in
|
||||
.SH "CONFORMING TO"
|
||||
These functions are non-standard BSD extensions.
|
||||
.\" .Sh HISTORY
|
||||
.\" .SH HISTORY
|
||||
.\" The
|
||||
.\" .Fn err
|
||||
.\" .BR err ()
|
||||
.\" and
|
||||
.\" .Fn warn
|
||||
.\" .BR warn ()
|
||||
.\" functions first appeared in
|
||||
.\" .Bx 4.4 .
|
||||
.Sh SEE ALSO
|
||||
.Xr error 3 ,
|
||||
.Xr exit 3 ,
|
||||
.Xr printf 3 ,
|
||||
.Xr perror 3 ,
|
||||
.Xr strerror 3
|
||||
.\" 4.4BSD.
|
||||
.SH SEE ALSO
|
||||
.BR error (3),
|
||||
.BR exit (3),
|
||||
.BR printf (3),
|
||||
.BR perror (3),
|
||||
.BR strerror (3)
|
||||
|
|
738
man3/fts.3
738
man3/fts.3
File diff suppressed because it is too large
Load Diff
|
@ -27,43 +27,44 @@
|
|||
.\"
|
||||
.\" @(#)getloadavg.3 8.1 (Berkeley) 6/4/93
|
||||
.\"
|
||||
.Dd November 25, 2007
|
||||
.Dt GETLOADAVG 3
|
||||
.Os 4.3BSD
|
||||
.Sh NAME
|
||||
.Nm getloadavg
|
||||
.Nd get system load averages
|
||||
.Sh SYNOPSIS
|
||||
.Fd #define _BSD_SOURCE
|
||||
.Fd #include <stdlib.h>
|
||||
.Ft int
|
||||
.Fn getloadavg "double loadavg[]" "int nelem"
|
||||
.Sh DESCRIPTION
|
||||
.\" 2007-12-02, mtk, Converted from mdoc to man macros
|
||||
.\"
|
||||
.TH GETLOADAVG 3 2007-12-02 "Linux" "Linux Programmer's Manual"
|
||||
.SH NAME
|
||||
getloadavg \- get system load averages
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.B #define _BSD_SOURCE
|
||||
.B #include <stdlib.h>
|
||||
.sp
|
||||
.BI "int getloadavg(double " loadavg[] ", int " nelem );
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
The
|
||||
.Fn getloadavg
|
||||
.BR getloadavg ()
|
||||
function returns the number of processes in the system run queue
|
||||
averaged over various periods of time.
|
||||
Up to
|
||||
.Fa nelem
|
||||
.I nelem
|
||||
samples are retrieved and assigned to successive elements of
|
||||
.Fa loadavg Ns Bq .
|
||||
.IR loadavg [].
|
||||
The system imposes a maximum of 3 samples, representing averages
|
||||
over the last 1, 5, and 15 minutes, respectively.
|
||||
.Sh RETURN VALUE
|
||||
.SH RETURN VALUE
|
||||
If the load average was unobtainable, \-1 is returned; otherwise,
|
||||
the number of samples actually retrieved is returned.
|
||||
.\" .Sh HISTORY
|
||||
.\" .SH HISTORY
|
||||
.\" The
|
||||
.\" .Fn getloadavg
|
||||
.\" BR getloadavg ()
|
||||
.\" function appeared in
|
||||
.\" .Bx 4.3 Reno .
|
||||
.Sh VERSIONS
|
||||
.\" 4.3BSD Reno .
|
||||
.SH VERSIONS
|
||||
This function is available in glibc since version 2.2.
|
||||
.Sh "CONFORMING TO"
|
||||
.SH "CONFORMING TO"
|
||||
Not in POSIX.1-2001.
|
||||
Present on the BSDs and Solaris.
|
||||
.\" mdoc seems to have a bug - there must be no newline here
|
||||
.Sh SEE ALSO
|
||||
.Xr uptime 1 ,
|
||||
.Xr proc 5 ,
|
||||
.Xr feature_test_macros 7
|
||||
.SH SEE ALSO
|
||||
.BR uptime (1),
|
||||
.BR proc (5),
|
||||
.BR feature_test_macros (7)
|
||||
|
|
496
man3/queue.3
496
man3/queue.3
|
@ -1,5 +1,5 @@
|
|||
.\" Copyright (c) 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
|
@ -11,8 +11,8 @@
|
|||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\" 3. All advertising materials mentioning features or use of this software
|
||||
.\" must display the following acknowledgement:
|
||||
.\" This product includes software developed by the University of
|
||||
.\" California, Berkeley and its contributors.
|
||||
.\" This product includes software developed by the University of
|
||||
.\" California, Berkeley and its contributors.
|
||||
.\" 4. Neither the name of the University nor the names of its contributors
|
||||
.\" may be used to endorse or promote products derived from this software
|
||||
.\" without specific prior written permission.
|
||||
|
@ -29,141 +29,139 @@
|
|||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)queue.3 8.2 (Berkeley) 1/24/94
|
||||
.\" @(#)queue.3 8.2 (Berkeley) 1/24/94
|
||||
.\"
|
||||
.\" hch, 2002-03-25
|
||||
.Dd January 24, 1994
|
||||
.Dt QUEUE 3
|
||||
.Os 4BSD
|
||||
.Sh NAME
|
||||
.Nm LIST_ENTRY ,
|
||||
.Nm LIST_HEAD ,
|
||||
.Nm LIST_INIT ,
|
||||
.Nm LIST_INSERT_AFTER ,
|
||||
.Nm LIST_INSERT_HEAD ,
|
||||
.Nm LIST_REMOVE ,
|
||||
.Nm TAILQ_ENTRY ,
|
||||
.Nm TAILQ_HEAD ,
|
||||
.Nm TAILQ_INIT ,
|
||||
.Nm TAILQ_INSERT_AFTER ,
|
||||
.Nm TAILQ_INSERT_HEAD ,
|
||||
.Nm TAILQ_INSERT_TAIL ,
|
||||
.Nm TAILQ_REMOVE ,
|
||||
.Nm CIRCLEQ_ENTRY ,
|
||||
.Nm CIRCLEQ_HEAD ,
|
||||
.Nm CIRCLEQ_INIT ,
|
||||
.Nm CIRCLEQ_INSERT_AFTER ,
|
||||
.Nm CIRCLEQ_INSERT_BEFORE ,
|
||||
.Nm CIRCLEQ_INSERT_HEAD ,
|
||||
.Nm CIRCLEQ_INSERT_TAIL ,
|
||||
.Nm CIRCLEQ_REMOVE
|
||||
.Nd implementations of lists, tail queues, and circular queues
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <sys/queue.h>
|
||||
.\" 2007-12-02, mtk, Converted from mdoc to man macros
|
||||
.\"
|
||||
.Fn LIST_ENTRY "TYPE"
|
||||
.Fn LIST_HEAD "HEADNAME" "TYPE"
|
||||
.Fn LIST_INIT "LIST_HEAD *head"
|
||||
.Fn LIST_INSERT_AFTER "LIST_ENTRY *listelm" "TYPE *elm" "LIST_ENTRY NAME"
|
||||
.Fn LIST_INSERT_HEAD "LIST_HEAD *head" "TYPE *elm" "LIST_ENTRY NAME"
|
||||
.Fn LIST_REMOVE "TYPE *elm" "LIST_ENTRY NAME"
|
||||
.\"
|
||||
.Fn TAILQ_ENTRY "TYPE"
|
||||
.Fn TAILQ_HEAD "HEADNAME" "TYPE"
|
||||
.Fn TAILQ_INIT "TAILQ_HEAD *head"
|
||||
.Fn TAILQ_INSERT_AFTER "TAILQ_HEAD *head" "TYPE *listelm" "TYPE *elm" "TAILQ_ENTRY NAME"
|
||||
.Fn TAILQ_INSERT_HEAD "TAILQ_HEAD *head" "TYPE *elm" "TAILQ_ENTRY NAME"
|
||||
.Fn TAILQ_INSERT_TAIL "TAILQ_HEAD *head" "TYPE *elm" "TAILQ_ENTRY NAME"
|
||||
.Fn TAILQ_REMOVE "TAILQ_HEAD *head" "TYPE *elm" "TAILQ_ENTRY NAME"
|
||||
.\"
|
||||
.Fn CIRCLEQ_ENTRY "TYPE"
|
||||
.Fn CIRCLEQ_HEAD "HEADNAME" "TYPE"
|
||||
.Fn CIRCLEQ_INIT "CIRCLEQ_HEAD *head"
|
||||
.Fn CIRCLEQ_INSERT_AFTER "CIRCLEQ_HEAD *head" "TYPE *listelm" "TYPE *elm" "CIRCLEQ_ENTRY NAME"
|
||||
.Fn CIRCLEQ_INSERT_BEFORE "CIRCLEQ_HEAD *head" "TYPE *listelm" "TYPE *elm" "CIRCLEQ_ENTRY NAME"
|
||||
.Fn CIRCLEQ_INSERT_HEAD "CIRCLEQ_HEAD *head" "TYPE *elm" "CIRCLEQ_ENTRY NAME"
|
||||
.Fn CIRCLEQ_INSERT_TAIL "CIRCLEQ_HEAD *head" "TYPE *elm" "CIRCLEQ_ENTRY NAME"
|
||||
.Fn CIRCLEQ_REMOVE "CIRCLEQ_HEAD *head" "TYPE *elm" "CIRCLEQ_ENTRY NAME"
|
||||
.Sh DESCRIPTION
|
||||
.TH QUEUE 3 2007-12-02 "Linux" "Linux Programmer's Manual"
|
||||
.SH NAME
|
||||
LIST_ENTRY, LIST_HEAD, LIST_INIT, LIST_INSERT_AFTER, \
|
||||
LIST_INSERT_HEAD, LIST_REMOVE, TAILQ_ENTRY, TAILQ_HEAD, \
|
||||
TAILQ_INIT, TAILQ_INSERT_AFTER, TAILQ_INSERT_HEAD, TAILQ_INSERT_TAIL, \
|
||||
TAILQ_REMOVE, CIRCLEQ_ENTRY, CIRCLEQ_HEAD, CIRCLEQ_INIT, \
|
||||
CIRCLEQ_INSERT_AFTER, CIRCLEQ_INSERT_BEFORE, \
|
||||
CIRCLEQ_INSERT_HEAD, CIRCLEQ_INSERT_TAIL, \
|
||||
CIRCLEQ_REMOVE \- implementations of lists, tail queues, and circular queues
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.B #include <sys/queue.h>
|
||||
|
||||
.BI "LIST_ENTRY(" TYPE );
|
||||
.BI "LIST_HEAD(" HEADNAME ", " TYPE );
|
||||
.BI "LIST_INIT(LIST_HEAD *" head );
|
||||
.BI "LIST_INSERT_AFTER(LIST_ENTRY *" listelm ", "
|
||||
.BI " TYPE *" elm ", LIST_ENTRY " NAME );
|
||||
.BI "LIST_INSERT_HEAD(LIST_HEAD *" head ", "
|
||||
.BI " TYPE *" elm ", LIST_ENTRY " NAME );
|
||||
.BI "LIST_REMOVE(TYPE *" elm ", LIST_ENTRY " NAME );
|
||||
|
||||
.BI "TAILQ_ENTRY(" TYPE );
|
||||
.BI "TAILQ_HEAD("HEADNAME ", " TYPE );
|
||||
.BI "TAILQ_INIT(TAILQ_HEAD *" head );
|
||||
.BI "TAILQ_INSERT_AFTER(TAILQ_HEAD *" head ", TYPE *" listelm ", "
|
||||
.BI " TYPE *" elm ", TAILQ_ENTRY " NAME );
|
||||
.BI "TAILQ_INSERT_HEAD(TAILQ_HEAD *" head ", "
|
||||
.BI " TYPE *" elm ", TAILQ_ENTRY " NAME );
|
||||
.BI "TAILQ_INSERT_TAIL(TAILQ_HEAD *" head ", "
|
||||
.BI " TYPE *" elm ", TAILQ_ENTRY " NAME );
|
||||
.BI "TAILQ_REMOVE(TAILQ_HEAD *" head ", TYPE *" elm ", TAILQ_ENTRY " NAME );
|
||||
|
||||
.BI CIRCLEQ_ENTRY( TYPE );
|
||||
.BI "CIRCLEQ_HEAD(" HEADNAME ", " TYPE );
|
||||
.BI "CIRCLEQ_INIT(CIRCLEQ_HEAD *" head );
|
||||
.BI "CIRCLEQ_INSERT_AFTER(CIRCLEQ_HEAD *" head ", TYPE *" listelm ", "
|
||||
.BI " TYPE *" elm ", CIRCLEQ_ENTRY " NAME );
|
||||
.BI "CIRCLEQ_INSERT_BEFORE(CIRCLEQ_HEAD *" head ", TYPE *" listelm ", "
|
||||
.BI " TYPE *" elm ", CIRCLEQ_ENTRY " NAME );
|
||||
.BI "CIRCLEQ_INSERT_HEAD(CIRCLEQ_HEAD *" head ", "
|
||||
.BI " TYPE *" elm ", CIRCLEQ_ENTRY " NAME );
|
||||
.BI "CIRCLEQ_INSERT_TAIL(CIRCLEQ_HEAD *" head ", "
|
||||
.BI " TYPE *" elm ", CIRCLEQ_ENTRY " NAME );
|
||||
.BI "CIRCLEQ_REMOVE(CIRCLEQ_HEAD *" head ", "
|
||||
.BI " TYPE *" elm ", CIRCLEQ_ENTRY " NAME );
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
These macros define and operate on three types of data structures:
|
||||
lists, tail queues, and circular queues.
|
||||
All three structures support the following functionality:
|
||||
.Bl -enum -compact -offset indent
|
||||
.It
|
||||
.RS
|
||||
.IP 1. 4
|
||||
Insertion of a new entry at the head of the list.
|
||||
.It
|
||||
.IP 2.
|
||||
Insertion of a new entry after any element in the list.
|
||||
.It
|
||||
.IP 3.
|
||||
Removal of any entry in the list.
|
||||
.It
|
||||
.IP 4.
|
||||
Forward traversal through the list.
|
||||
.El
|
||||
.Pp
|
||||
.RE
|
||||
.PP
|
||||
Lists are the simplest of the three data structures and support
|
||||
only the above functionality.
|
||||
.Pp
|
||||
|
||||
Tail queues add the following functionality:
|
||||
.Bl -enum -compact -offset indent
|
||||
.It
|
||||
.RS
|
||||
.IP 1. 4
|
||||
Entries can be added at the end of a list.
|
||||
.El
|
||||
.RE
|
||||
.PP
|
||||
However:
|
||||
.Bl -enum -compact -offset indent
|
||||
.It
|
||||
.RS
|
||||
.IP 1. 4
|
||||
All list insertions and removals must specify the head of the list.
|
||||
.It
|
||||
.IP 2.
|
||||
Each head entry requires two pointers rather than one.
|
||||
.It
|
||||
.IP 3.
|
||||
Code size is about 15% greater and operations run about 20% slower
|
||||
than lists.
|
||||
.El
|
||||
.Pp
|
||||
.RE
|
||||
.PP
|
||||
Circular queues add the following functionality:
|
||||
.Bl -enum -compact -offset indent
|
||||
.It
|
||||
.RS
|
||||
.IP 1. 4
|
||||
Entries can be added at the end of a list.
|
||||
.It
|
||||
.IP 2.
|
||||
Entries can be added before another entry.
|
||||
.It
|
||||
.IP 3.
|
||||
They may be traversed backwards, from tail to head.
|
||||
.El
|
||||
.RE
|
||||
.PP
|
||||
However:
|
||||
.Bl -enum -compact -offset indent
|
||||
.It
|
||||
.RS
|
||||
.IP 1. 4
|
||||
All list insertions and removals must specify the head of the list.
|
||||
.It
|
||||
.IP 2.
|
||||
Each head entry requires two pointers rather than one.
|
||||
.It
|
||||
.IP 3.
|
||||
The termination condition for traversal is more complex.
|
||||
.It
|
||||
.IP 4.
|
||||
Code size is about 40% greater and operations run about 45% slower
|
||||
than lists.
|
||||
.El
|
||||
.Pp
|
||||
.RE
|
||||
.PP
|
||||
In the macro definitions,
|
||||
.Fa TYPE
|
||||
.I TYPE
|
||||
is the name of a user defined structure,
|
||||
that must contain a field of type
|
||||
.Li LIST_ENTRY ,
|
||||
.Li TAILQ_ENTRY ,
|
||||
.IR "LIST_ENTRY" ,
|
||||
.IR "TAILQ_ENTRY" ,
|
||||
or
|
||||
.Li CIRCLEQ_ENTRY ,
|
||||
.IR "CIRCLEQ_ENTRY" ,
|
||||
named
|
||||
.Fa NAME .
|
||||
.IR NAME .
|
||||
The argument
|
||||
.Fa HEADNAME
|
||||
.I HEADNAME
|
||||
is the name of a user defined structure that must be declared
|
||||
using the macros
|
||||
.Li LIST_HEAD ,
|
||||
.Li TAILQ_HEAD ,
|
||||
.IR "LIST_HEAD" ,
|
||||
.IR "TAILQ_HEAD" ,
|
||||
or
|
||||
.Li CIRCLEQ_HEAD .
|
||||
.IR "CIRCLEQ_HEAD" .
|
||||
See the examples below for further explanation of how these
|
||||
macros are used.
|
||||
.Sh LISTS
|
||||
.SS Lists
|
||||
A list is headed by a structure defined by the
|
||||
.Nm LIST_HEAD
|
||||
macro.
|
||||
LIST_HEAD macro.
|
||||
This structure contains a single pointer to the first element
|
||||
on the list.
|
||||
The elements are doubly linked so that an arbitrary element can be
|
||||
|
@ -171,84 +169,89 @@ removed without traversing the list.
|
|||
New elements can be added to the list after an existing element or
|
||||
at the head of the list.
|
||||
A
|
||||
.Fa LIST_HEAD
|
||||
.I LIST_HEAD
|
||||
structure is declared as follows:
|
||||
.Bd -literal -offset indent
|
||||
.in +0.5i
|
||||
.nf
|
||||
|
||||
LIST_HEAD(HEADNAME, TYPE) head;
|
||||
.Ed
|
||||
.Pp
|
||||
.fi
|
||||
.in
|
||||
.sp
|
||||
where
|
||||
.Fa HEADNAME
|
||||
.I HEADNAME
|
||||
is the name of the structure to be defined, and
|
||||
.Fa TYPE
|
||||
.I TYPE
|
||||
is the type of the elements to be linked into the list.
|
||||
A pointer to the head of the list can later be declared as:
|
||||
.Bd -literal -offset indent
|
||||
.in +0.5i
|
||||
.nf
|
||||
|
||||
struct HEADNAME *headp;
|
||||
.Ed
|
||||
.Pp
|
||||
.fi
|
||||
.in
|
||||
.sp
|
||||
(The names
|
||||
.Li head
|
||||
.IR "head"
|
||||
and
|
||||
.Li headp
|
||||
.IR "headp"
|
||||
are user selectable.)
|
||||
.Pp
|
||||
.sp
|
||||
The macro
|
||||
.Nm LIST_ENTRY
|
||||
.B LIST_ENTRY
|
||||
declares a structure that connects the elements in
|
||||
the list.
|
||||
.Pp
|
||||
.sp
|
||||
The macro
|
||||
.Nm LIST_INIT
|
||||
.B LIST_INIT
|
||||
initializes the list referenced by
|
||||
.Fa head .
|
||||
.Pp
|
||||
.IR head .
|
||||
.sp
|
||||
The macro
|
||||
.Nm LIST_INSERT_HEAD
|
||||
.B LIST_INSERT_HEAD
|
||||
inserts the new element
|
||||
.Fa elm
|
||||
.I elm
|
||||
at the head of the list.
|
||||
.Pp
|
||||
.sp
|
||||
The macro
|
||||
.Nm LIST_INSERT_AFTER
|
||||
.B LIST_INSERT_AFTER
|
||||
inserts the new element
|
||||
.Fa elm
|
||||
.I elm
|
||||
after the element
|
||||
.Fa listelm .
|
||||
.Pp
|
||||
.IR listelm .
|
||||
.sp
|
||||
The macro
|
||||
.Nm LIST_REMOVE
|
||||
.B LIST_REMOVE
|
||||
removes the element
|
||||
.Fa elm
|
||||
.I elm
|
||||
from the list.
|
||||
.Sh LIST EXAMPLE
|
||||
.Bd -literal
|
||||
.SS List Example
|
||||
.nf
|
||||
LIST_HEAD(listhead, entry) head;
|
||||
struct listhead *headp; /* List head. */
|
||||
struct listhead *headp; /* List head. */
|
||||
struct entry {
|
||||
...
|
||||
LIST_ENTRY(entry) entries; /* List. */
|
||||
...
|
||||
...
|
||||
LIST_ENTRY(entry) entries; /* List. */
|
||||
...
|
||||
} *n1, *n2, *np;
|
||||
|
||||
LIST_INIT(&head); /* Initialize the list. */
|
||||
LIST_INIT(&head); /* Initialize the list. */
|
||||
|
||||
n1 = malloc(sizeof(struct entry)); /* Insert at the head. */
|
||||
n1 = malloc(sizeof(struct entry)); /* Insert at the head. */
|
||||
LIST_INSERT_HEAD(&head, n1, entries);
|
||||
|
||||
n2 = malloc(sizeof(struct entry)); /* Insert after. */
|
||||
n2 = malloc(sizeof(struct entry)); /* Insert after. */
|
||||
LIST_INSERT_AFTER(n1, n2, entries);
|
||||
/* Forward traversal. */
|
||||
/* Forward traversal. */
|
||||
for (np = head.lh_first; np != NULL; np = np\->entries.le_next)
|
||||
np\-> ...
|
||||
np\-> ...
|
||||
|
||||
while (head.lh_first != NULL) /* Delete. */
|
||||
LIST_REMOVE(head.lh_first, entries);
|
||||
.Ed
|
||||
.Sh TAIL QUEUES
|
||||
while (head.lh_first != NULL) /* Delete. */
|
||||
LIST_REMOVE(head.lh_first, entries);
|
||||
.fi
|
||||
.SS Tail Queues
|
||||
A tail queue is headed by a structure defined by the
|
||||
.Nm TAILQ_HEAD
|
||||
macro.
|
||||
TAILQ_HEAD macro.
|
||||
This structure contains a pair of pointers,
|
||||
one to the first element in the tail queue and the other to
|
||||
the last element in the tail queue.
|
||||
|
@ -257,93 +260,97 @@ removed without traversing the tail queue.
|
|||
New elements can be added to the tail queue after an existing element,
|
||||
at the head of the tail queue, or at the end of the tail queue.
|
||||
A
|
||||
.Fa TAILQ_HEAD
|
||||
.I TAILQ_HEAD
|
||||
structure is declared as follows:
|
||||
.Bd -literal -offset indent
|
||||
.in +0.5i
|
||||
.nf
|
||||
|
||||
TAILQ_HEAD(HEADNAME, TYPE) head;
|
||||
.Ed
|
||||
.Pp
|
||||
.fi
|
||||
.PP
|
||||
where
|
||||
.Li HEADNAME
|
||||
.IR "HEADNAME"
|
||||
is the name of the structure to be defined, and
|
||||
.Li TYPE
|
||||
.IR "TYPE"
|
||||
is the type of the elements to be linked into the tail queue.
|
||||
A pointer to the head of the tail queue can later be declared as:
|
||||
.Bd -literal -offset indent
|
||||
.in +0.5i
|
||||
.nf
|
||||
|
||||
struct HEADNAME *headp;
|
||||
.Ed
|
||||
.Pp
|
||||
.fi
|
||||
.in
|
||||
.sp
|
||||
(The names
|
||||
.Li head
|
||||
.IR "head"
|
||||
and
|
||||
.Li headp
|
||||
.IR "headp"
|
||||
are user selectable.)
|
||||
.Pp
|
||||
.sp
|
||||
The macro
|
||||
.Nm TAILQ_ENTRY
|
||||
.B TAILQ_ENTRY
|
||||
declares a structure that connects the elements in
|
||||
the tail queue.
|
||||
.Pp
|
||||
.sp
|
||||
The macro
|
||||
.Nm TAILQ_INIT
|
||||
.B TAILQ_INIT
|
||||
initializes the tail queue referenced by
|
||||
.Fa head .
|
||||
.Pp
|
||||
.IR head .
|
||||
.sp
|
||||
The macro
|
||||
.Nm TAILQ_INSERT_HEAD
|
||||
.B TAILQ_INSERT_HEAD
|
||||
inserts the new element
|
||||
.Fa elm
|
||||
.I elm
|
||||
at the head of the tail queue.
|
||||
.Pp
|
||||
.sp
|
||||
The macro
|
||||
.Nm TAILQ_INSERT_TAIL
|
||||
.B TAILQ_INSERT_TAIL
|
||||
inserts the new element
|
||||
.Fa elm
|
||||
.I elm
|
||||
at the end of the tail queue.
|
||||
.Pp
|
||||
.sp
|
||||
The macro
|
||||
.Nm TAILQ_INSERT_AFTER
|
||||
.B TAILQ_INSERT_AFTER
|
||||
inserts the new element
|
||||
.Fa elm
|
||||
.I elm
|
||||
after the element
|
||||
.Fa listelm .
|
||||
.Pp
|
||||
.IR listelm .
|
||||
.sp
|
||||
The macro
|
||||
.Nm TAILQ_REMOVE
|
||||
.B TAILQ_REMOVE
|
||||
removes the element
|
||||
.Fa elm
|
||||
.I elm
|
||||
from the tail queue.
|
||||
.Sh TAIL QUEUE EXAMPLE
|
||||
.Bd -literal
|
||||
.SS Tail Queue Example
|
||||
.nf
|
||||
TAILQ_HEAD(tailhead, entry) head;
|
||||
struct tailhead *headp; /* Tail queue head. */
|
||||
struct tailhead *headp; /* Tail queue head. */
|
||||
struct entry {
|
||||
...
|
||||
TAILQ_ENTRY(entry) entries; /* Tail queue. */
|
||||
...
|
||||
...
|
||||
TAILQ_ENTRY(entry) entries; /* Tail queue. */
|
||||
...
|
||||
} *n1, *n2, *np;
|
||||
|
||||
TAILQ_INIT(&head); /* Initialize the queue. */
|
||||
TAILQ_INIT(&head); /* Initialize the queue. */
|
||||
|
||||
n1 = malloc(sizeof(struct entry)); /* Insert at the head. */
|
||||
n1 = malloc(sizeof(struct entry)); /* Insert at the head. */
|
||||
TAILQ_INSERT_HEAD(&head, n1, entries);
|
||||
|
||||
n1 = malloc(sizeof(struct entry)); /* Insert at the tail. */
|
||||
n1 = malloc(sizeof(struct entry)); /* Insert at the tail. */
|
||||
TAILQ_INSERT_TAIL(&head, n1, entries);
|
||||
|
||||
n2 = malloc(sizeof(struct entry)); /* Insert after. */
|
||||
n2 = malloc(sizeof(struct entry)); /* Insert after. */
|
||||
TAILQ_INSERT_AFTER(&head, n1, n2, entries);
|
||||
/* Forward traversal. */
|
||||
/* Forward traversal. */
|
||||
for (np = head.tqh_first; np != NULL; np = np->entries.tqe_next)
|
||||
np-> ...
|
||||
/* Delete. */
|
||||
np-> ...
|
||||
/* Delete. */
|
||||
while (head.tqh_first != NULL)
|
||||
TAILQ_REMOVE(&head, head.tqh_first, entries);
|
||||
.Ed
|
||||
.Sh CIRCULAR QUEUES
|
||||
TAILQ_REMOVE(&head, head.tqh_first, entries);
|
||||
.fi
|
||||
.SS Circular Queues
|
||||
A circular queue is headed by a structure defined by the
|
||||
.Nm CIRCLEQ_HEAD
|
||||
macro.
|
||||
CIRCLEQ_HEAD macro.
|
||||
This structure contains a pair of pointers,
|
||||
one to the first element in the circular queue and the other to the
|
||||
last element in the circular queue.
|
||||
|
@ -353,106 +360,111 @@ New elements can be added to the queue after an existing element,
|
|||
before an existing element, at the head of the queue, or at the end
|
||||
of the queue.
|
||||
A
|
||||
.Fa CIRCLEQ_HEAD
|
||||
.I CIRCLEQ_HEAD
|
||||
structure is declared as follows:
|
||||
.Bd -literal -offset indent
|
||||
.in +0.5i
|
||||
.nf
|
||||
|
||||
CIRCLEQ_HEAD(HEADNAME, TYPE) head;
|
||||
.Ed
|
||||
.Pp
|
||||
.fi
|
||||
.in
|
||||
.sp
|
||||
where
|
||||
.Li HEADNAME
|
||||
.IR "HEADNAME"
|
||||
is the name of the structure to be defined, and
|
||||
.Li TYPE
|
||||
.IR "TYPE"
|
||||
is the type of the elements to be linked into the circular queue.
|
||||
A pointer to the head of the circular queue can later be declared as:
|
||||
.Bd -literal -offset indent
|
||||
.in +0.5i
|
||||
.nf
|
||||
|
||||
struct HEADNAME *headp;
|
||||
.Ed
|
||||
.Pp
|
||||
.fi
|
||||
.in
|
||||
.sp
|
||||
(The names
|
||||
.Li head
|
||||
.IR "head"
|
||||
and
|
||||
.Li headp
|
||||
.IR "headp"
|
||||
are user selectable.)
|
||||
.Pp
|
||||
.sp
|
||||
The macro
|
||||
.Nm CIRCLEQ_ENTRY
|
||||
.B CIRCLEQ_ENTRY
|
||||
declares a structure that connects the elements in
|
||||
the circular queue.
|
||||
.Pp
|
||||
.sp
|
||||
The macro
|
||||
.Nm CIRCLEQ_INIT
|
||||
.B CIRCLEQ_INIT
|
||||
initializes the circular queue referenced by
|
||||
.Fa head .
|
||||
.Pp
|
||||
.IR head .
|
||||
.sp
|
||||
The macro
|
||||
.Nm CIRCLEQ_INSERT_HEAD
|
||||
.B CIRCLEQ_INSERT_HEAD
|
||||
inserts the new element
|
||||
.Fa elm
|
||||
.I elm
|
||||
at the head of the circular queue.
|
||||
.Pp
|
||||
.sp
|
||||
The macro
|
||||
.Nm CIRCLEQ_INSERT_TAIL
|
||||
.B CIRCLEQ_INSERT_TAIL
|
||||
inserts the new element
|
||||
.Fa elm
|
||||
.I elm
|
||||
at the end of the circular queue.
|
||||
.Pp
|
||||
.sp
|
||||
The macro
|
||||
.Nm CIRCLEQ_INSERT_AFTER
|
||||
.B CIRCLEQ_INSERT_AFTER
|
||||
inserts the new element
|
||||
.Fa elm
|
||||
.I elm
|
||||
after the element
|
||||
.Fa listelm .
|
||||
.Pp
|
||||
.IR listelm .
|
||||
.sp
|
||||
The macro
|
||||
.Nm CIRCLEQ_INSERT_BEFORE
|
||||
.B CIRCLEQ_INSERT_BEFORE
|
||||
inserts the new element
|
||||
.Fa elm
|
||||
.I elm
|
||||
before the element
|
||||
.Fa listelm .
|
||||
.Pp
|
||||
.IR listelm .
|
||||
.sp
|
||||
The macro
|
||||
.Nm CIRCLEQ_REMOVE
|
||||
.B CIRCLEQ_REMOVE
|
||||
removes the element
|
||||
.Fa elm
|
||||
.I elm
|
||||
from the circular queue.
|
||||
.Sh CIRCULAR QUEUE EXAMPLE
|
||||
.Bd -literal
|
||||
.SS Circular Queue Example
|
||||
.nf
|
||||
CIRCLEQ_HEAD(circleq, entry) head;
|
||||
struct circleq *headp; /* Circular queue head. */
|
||||
struct circleq *headp; /* Circular queue head. */
|
||||
struct entry {
|
||||
...
|
||||
CIRCLEQ_ENTRY(entry) entries; /* Circular queue. */
|
||||
...
|
||||
...
|
||||
CIRCLEQ_ENTRY(entry) entries; /* Circular queue. */
|
||||
...
|
||||
} *n1, *n2, *np;
|
||||
|
||||
CIRCLEQ_INIT(&head); /* Initialize the circular queue. */
|
||||
CIRCLEQ_INIT(&head); /* Initialize the circular queue. */
|
||||
|
||||
n1 = malloc(sizeof(struct entry)); /* Insert at the head. */
|
||||
n1 = malloc(sizeof(struct entry)); /* Insert at the head. */
|
||||
CIRCLEQ_INSERT_HEAD(&head, n1, entries);
|
||||
|
||||
n1 = malloc(sizeof(struct entry)); /* Insert at the tail. */
|
||||
n1 = malloc(sizeof(struct entry)); /* Insert at the tail. */
|
||||
CIRCLEQ_INSERT_TAIL(&head, n1, entries);
|
||||
|
||||
n2 = malloc(sizeof(struct entry)); /* Insert after. */
|
||||
n2 = malloc(sizeof(struct entry)); /* Insert after. */
|
||||
CIRCLEQ_INSERT_AFTER(&head, n1, n2, entries);
|
||||
|
||||
n2 = malloc(sizeof(struct entry)); /* Insert before. */
|
||||
n2 = malloc(sizeof(struct entry)); /* Insert before. */
|
||||
CIRCLEQ_INSERT_BEFORE(&head, n1, n2, entries);
|
||||
/* Forward traversal. */
|
||||
/* Forward traversal. */
|
||||
for (np = head.cqh_first; np != (void *)&head; np = np->entries.cqe_next)
|
||||
np-> ...
|
||||
/* Reverse traversal. */
|
||||
np-> ...
|
||||
/* Reverse traversal. */
|
||||
for (np = head.cqh_last; np != (void *)&head; np = np->entries.cqe_prev)
|
||||
np-> ...
|
||||
/* Delete. */
|
||||
np-> ...
|
||||
/* Delete. */
|
||||
while (head.cqh_first != (void *)&head)
|
||||
CIRCLEQ_REMOVE(&head, head.cqh_first, entries);
|
||||
.Ed
|
||||
.Sh "CONFORMING TO"
|
||||
CIRCLEQ_REMOVE(&head, head.cqh_first, entries);
|
||||
.fi
|
||||
.SH "CONFORMING TO"
|
||||
Not in POSIX.1-2001.
|
||||
Present on the BSDs.
|
||||
The
|
||||
.Nm queue
|
||||
functions first appeared in
|
||||
.Bx 4.4 .
|
||||
queue functions first appeared in
|
||||
4.4BSD.
|
||||
|
|
163
man3/rcmd.3
163
man3/rcmd.3
|
@ -35,179 +35,180 @@
|
|||
.\"
|
||||
.\" Contributed as Linux man page by David A. Holland, 970908
|
||||
.\" I have not checked whether the Linux situation is exactly the same.
|
||||
.Dd June 4, 1993
|
||||
.Dt RCMD 3
|
||||
.Os 4.2BSD
|
||||
.Sh NAME
|
||||
.Nm rcmd ,
|
||||
.Nm rresvport ,
|
||||
.Nm iruserok ,
|
||||
.Nm ruserok
|
||||
.Nd routines for returning a stream to a remote command
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <netdb.h> \ \ \fP/* Or <unistd.h> on some systems */
|
||||
.Ft int
|
||||
.Fn rcmd "char **ahost" "int inport" "const char *locuser" "const char *remuser" "const char *cmd" "int *fd2p"
|
||||
.Ft int
|
||||
.Fn rresvport "int *port"
|
||||
.Ft int
|
||||
.Fn iruserok "u_int32_t raddr" "int superuser" "const char *ruser" "const char *luser"
|
||||
.Ft int
|
||||
.Fn ruserok "const char *rhost" "int superuser" "const char *ruser" "const char *luser"
|
||||
.\"
|
||||
.\" 2007-12-02, mtk, Converted from mdoc to man macros
|
||||
.\"
|
||||
.TH RCMD 3 2007-12-02 "Linux" "Linux Programmer's Manual"
|
||||
.SH NAME
|
||||
rcmd, rresvport, iruserok, ruserok \- routines for returning a
|
||||
stream to a remote command
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.B #include <netdb.h> \ \ \fP/* Or <unistd.h> on some systems */
|
||||
.sp
|
||||
.BI "int rcmd(char **" ahost ", int " inport ", const char *" locuser ", "
|
||||
.BI " const char *" remuser ", const char *" cmd ", int *" fd2p )
|
||||
.sp
|
||||
.BI "int rresvport(int *" port );
|
||||
.sp
|
||||
.BI "int iruserok(u_int32_t " raddr ", int " superuser ", "
|
||||
.BI " const char *" ruser ", const char *" luser );
|
||||
.sp
|
||||
.BI "int ruserok(const char *" rhost ", int " superuser ", "
|
||||
.BI " const char *" ruser ", const char *" luser );
|
||||
.\" These functions require _BSD_SOURCE on Linux
|
||||
.\" FIXME . does iruserok() really exist on Linux?
|
||||
.\" It seems to be present in glibc, but isn't declared in glibc headers.
|
||||
.\" Bug filed 25 Nov 2007:
|
||||
.\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=5399
|
||||
.Sh DESCRIPTION
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
The
|
||||
.Fn rcmd
|
||||
.BR rcmd ()
|
||||
function
|
||||
is used by the superuser to execute a command on
|
||||
a remote machine using an authentication scheme based
|
||||
on reserved port numbers.
|
||||
The
|
||||
.Fn rresvport
|
||||
.BR rresvport ()
|
||||
function
|
||||
returns a descriptor to a socket
|
||||
with an address in the privileged port space.
|
||||
The
|
||||
.Fn iruserok
|
||||
.BR iruserok ()
|
||||
and
|
||||
.Fn ruserok
|
||||
.BR ruserok ()
|
||||
functions are used by servers
|
||||
to authenticate clients requesting service with
|
||||
.Fn rcmd .
|
||||
.BR rcmd ().
|
||||
All four functions are present in the same file and are used
|
||||
by the
|
||||
.Xr rshd 8
|
||||
.BR rshd (8)
|
||||
server (among others).
|
||||
.Pp
|
||||
.sp
|
||||
The
|
||||
.Fn rcmd
|
||||
.BR rcmd ()
|
||||
function
|
||||
looks up the host
|
||||
.Fa *ahost
|
||||
.I *ahost
|
||||
using
|
||||
.Xr gethostbyname 3 ,
|
||||
.BR gethostbyname (3),
|
||||
returning \-1 if the host does not exist.
|
||||
Otherwise
|
||||
.Fa *ahost
|
||||
.I *ahost
|
||||
is set to the standard name of the host
|
||||
and a connection is established to a server
|
||||
residing at the well-known Internet port
|
||||
.Fa inport .
|
||||
.Pp
|
||||
.IR inport .
|
||||
.sp
|
||||
If the connection succeeds,
|
||||
a socket in the Internet domain of type
|
||||
.Dv SOCK_STREAM
|
||||
.BR SOCK_STREAM
|
||||
is returned to the caller, and given to the remote
|
||||
command as
|
||||
.Em stdin
|
||||
.IR stdin
|
||||
and
|
||||
.Em stdout .
|
||||
.IR stdout .
|
||||
If
|
||||
.Fa fd2p
|
||||
.I fd2p
|
||||
is non-zero, then an auxiliary channel to a control
|
||||
process will be set up, and a descriptor for it will be placed
|
||||
in
|
||||
.Fa *fd2p .
|
||||
.IR *fd2p .
|
||||
The control process will return diagnostic
|
||||
output from the command (unit 2) on this channel, and will also
|
||||
accept bytes on this channel as being
|
||||
.Tn UNIX
|
||||
signal numbers, to be
|
||||
accept bytes on this channel as being Unix signal numbers, to be
|
||||
forwarded to the process group of the command.
|
||||
If
|
||||
.Fa fd2p
|
||||
.I fd2p
|
||||
is 0, then the
|
||||
.Em stderr
|
||||
.IR stderr
|
||||
(unit 2 of the remote
|
||||
command) will be made the same as the
|
||||
.Em stdout
|
||||
.IR stdout
|
||||
and no
|
||||
provision is made for sending arbitrary signals to the remote process,
|
||||
although you may be able to get its attention by using out-of-band data.
|
||||
.Pp
|
||||
.sp
|
||||
The protocol is described in detail in
|
||||
.Xr rshd 8 .
|
||||
.Pp
|
||||
.BR rshd (8).
|
||||
.sp
|
||||
The
|
||||
.Fn rresvport
|
||||
.BR rresvport ()
|
||||
function is used to obtain a socket with a privileged
|
||||
address bound to it.
|
||||
This socket is suitable for use by
|
||||
.Fn rcmd
|
||||
.BR rcmd ()
|
||||
and several other functions.
|
||||
Privileged Internet ports are those in the range 0 to 1023.
|
||||
Only the superuser is allowed to bind an address of this sort to a socket.
|
||||
.Pp
|
||||
.sp
|
||||
The
|
||||
.Fn iruserok
|
||||
.BR iruserok ()
|
||||
and
|
||||
.Fn ruserok
|
||||
.BR ruserok ()
|
||||
functions take a remote host's IP address or name, respectively,
|
||||
two user names and a flag indicating whether the local user's
|
||||
name is that of the superuser.
|
||||
Then, if the user is
|
||||
.Em NOT
|
||||
.I not
|
||||
the superuser, it checks the
|
||||
.Pa /etc/hosts.equiv
|
||||
.IR /etc/hosts.equiv
|
||||
file.
|
||||
If that lookup is not done, or is unsuccessful, the
|
||||
.Pa .rhosts
|
||||
.IR .rhosts
|
||||
in the local user's home directory is checked to see if the request for
|
||||
service is allowed.
|
||||
.Pp
|
||||
.sp
|
||||
If this file does not exist, is not a regular file, is owned by anyone
|
||||
other than the user or the superuser, or is writable by anyone other
|
||||
than the owner, the check automatically fails.
|
||||
Zero is returned if the machine name is listed in the
|
||||
.Dq Pa hosts.equiv
|
||||
.IR hosts.equiv
|
||||
file, or the host and remote user name are found in the
|
||||
.Dq Pa .rhosts
|
||||
.IR .rhosts
|
||||
file; otherwise
|
||||
.Fn iruserok
|
||||
.BR iruserok ()
|
||||
and
|
||||
.Fn ruserok
|
||||
.BR ruserok ()
|
||||
return \-1.
|
||||
If the local domain (as obtained from
|
||||
.Xr gethostname 2 )
|
||||
.BR gethostname (2)
|
||||
is the same as the remote domain, only the machine name need be specified.
|
||||
.Pp
|
||||
.sp
|
||||
If the IP address of the remote host is known,
|
||||
.Fn iruserok
|
||||
.BR iruserok ()
|
||||
should be used in preference to
|
||||
.Fn ruserok ,
|
||||
.BR ruserok (),
|
||||
as it does not require trusting the DNS server for the remote host's domain.
|
||||
.Sh RETURN VALUE
|
||||
.SH RETURN VALUE
|
||||
The
|
||||
.Fn rcmd
|
||||
.BR rcmd ()
|
||||
function
|
||||
returns a valid socket descriptor on success.
|
||||
It returns \-1 on error and prints a diagnostic message on the standard error.
|
||||
.Pp
|
||||
.sp
|
||||
The
|
||||
.Fn rresvport
|
||||
.BR rresvport ()
|
||||
function
|
||||
returns a valid, bound socket descriptor on success.
|
||||
It returns \-1 on error with the global value
|
||||
.Va errno
|
||||
.I errno
|
||||
set according to the reason for failure.
|
||||
The error code
|
||||
.Dv EAGAIN
|
||||
is overloaded to mean ``All network ports in use.''
|
||||
.Sh "CONFORMING TO"
|
||||
.BR EAGAIN
|
||||
is overloaded to mean "All network ports in use."
|
||||
.SH "CONFORMING TO"
|
||||
Not in POSIX.1-2001.
|
||||
Present on the BSDs, Solaris, and many other systems.
|
||||
These
|
||||
functions appeared in
|
||||
.Bx 4.2 .
|
||||
.Sh SEE ALSO
|
||||
.Xr rlogin 1 ,
|
||||
.Xr rsh 1 ,
|
||||
.Xr intro 2 ,
|
||||
.Xr rexec 3 ,
|
||||
.Xr rexecd 8 ,
|
||||
.Xr rlogind 8 ,
|
||||
.Xr rshd 8
|
||||
4.2BSD.
|
||||
.SH SEE ALSO
|
||||
.BR rlogin (1),
|
||||
.BR rsh (1),
|
||||
.BR intro (2),
|
||||
.BR rexec (3),
|
||||
.BR rexecd (8),
|
||||
.BR rlogind (8),
|
||||
.BR rshd (8)
|
||||
|
|
93
man3/rexec.3
93
man3/rexec.3
|
@ -34,75 +34,72 @@
|
|||
.\"
|
||||
.\" Taken from FreeBSD 5.4; not checked against Linux reality (mtk)
|
||||
.\"
|
||||
.Dd June 4, 1993
|
||||
.Dt REXEC 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm rexec
|
||||
.Nd return stream to a remote command
|
||||
.Sh LIBRARY
|
||||
.Lb libcompat
|
||||
.Sh SYNOPSIS
|
||||
.Ft int
|
||||
.Fn rexec "char **ahost" "int inport" "char *user" "char *passwd" "char *cmd" "int *fd2p"
|
||||
.\" 2007-12-02, mtk, Converted from mdoc to man macros
|
||||
.\"
|
||||
.TH REXEC 3 2007-12-02 "Linux" "Linux Programmer's Manual"
|
||||
.SH NAME
|
||||
rexec \- return stream to a remote command
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.sp
|
||||
.BI "int rexec(char **" ahost ", int " inport ", char *" user ", "
|
||||
.BI " char *" passwd ", char *" cmd ", int *" fd2p );
|
||||
.\" This function requires _BSD_SOURCE on Linux
|
||||
.Sh DESCRIPTION
|
||||
.Bf -symbolic
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
This interface is obsoleted by
|
||||
.Xr rcmd 3 .
|
||||
.Ef
|
||||
.Pp
|
||||
.BR rcmd (3).
|
||||
|
||||
The
|
||||
.Fn rexec
|
||||
.BR rexec ()
|
||||
function
|
||||
looks up the host
|
||||
.Fa *ahost
|
||||
.IR *ahost
|
||||
using
|
||||
.Xr gethostbyname 3 ,
|
||||
.BR gethostbyname (3),
|
||||
returning \-1 if the host does not exist.
|
||||
Otherwise
|
||||
.Fa *ahost
|
||||
.IR *ahost
|
||||
is set to the standard name of the host.
|
||||
If a username and password are both specified, then these
|
||||
are used to authenticate to the foreign host; otherwise
|
||||
the environment and then the user's
|
||||
.Pa .netrc
|
||||
.I .netrc
|
||||
file in his
|
||||
home directory are searched for appropriate information.
|
||||
If all this fails, the user is prompted for the information.
|
||||
.Pp
|
||||
.sp
|
||||
The port
|
||||
.Fa inport
|
||||
specifies which well-known
|
||||
.Tn DARPA
|
||||
.I inport
|
||||
specifies which well-known DARPA
|
||||
Internet port to use for
|
||||
the connection; the call
|
||||
.Fn getservbyname \*qexec\*q \*qtcp\*q
|
||||
.I getservbyname("exec", "tcp")
|
||||
(see
|
||||
.Xr getservent 3 )
|
||||
.BR getservent (3))
|
||||
will return a pointer to a structure, which contains the
|
||||
necessary port.
|
||||
The protocol for connection is described in detail in
|
||||
.Xr rexecd 8 .
|
||||
.Pp
|
||||
.BR rexecd (8).
|
||||
.sp
|
||||
If the connection succeeds,
|
||||
a socket in the Internet domain of type
|
||||
.Dv SOCK_STREAM
|
||||
.BR SOCK_STREAM
|
||||
is returned to
|
||||
the caller, and given to the remote command as
|
||||
.Dv stdin
|
||||
.IR stdin
|
||||
and
|
||||
.Dv stdout .
|
||||
.IR stdout .
|
||||
If
|
||||
.Fa fd2p
|
||||
.I fd2p
|
||||
is non-zero, then an auxiliary channel to a control
|
||||
process will be setup, and a descriptor for it will be placed
|
||||
in
|
||||
.Fa *fd2p .
|
||||
.IR *fd2p .
|
||||
The control process will return diagnostic
|
||||
output from the command (unit 2) on this channel, and will also
|
||||
accept bytes on this channel as being
|
||||
.Ux
|
||||
Unix
|
||||
signal numbers, to be
|
||||
forwarded to the process group of the command.
|
||||
The diagnostic
|
||||
|
@ -110,31 +107,31 @@ information returned does not include remote authorization failure,
|
|||
as the secondary connection is set up after authorization has been
|
||||
verified.
|
||||
If
|
||||
.Fa fd2p
|
||||
.I fd2p
|
||||
is 0, then the
|
||||
.Dv stderr
|
||||
.IR stderr
|
||||
(unit 2 of the remote
|
||||
command) will be made the same as the
|
||||
.Dv stdout
|
||||
.IR stdout
|
||||
and no
|
||||
provision is made for sending arbitrary signals to the remote process,
|
||||
although you may be able to get its attention by using out-of-band data.
|
||||
.Sh "CONFORMING TO"
|
||||
.SH "CONFORMING TO"
|
||||
Not in POSIX.1-2001.
|
||||
Present on the BSDs, Solaris, and many other systems.
|
||||
The
|
||||
.Fn rexec
|
||||
.BR rexec ()
|
||||
function appeared in
|
||||
.Bx 4.2 .
|
||||
.Sh BUGS
|
||||
4.2BSD.
|
||||
.SH BUGS
|
||||
The
|
||||
.Fn rexec
|
||||
.BR rexec ()
|
||||
function sends the unencrypted password across the network.
|
||||
.Pp
|
||||
.sp
|
||||
The underlying service is considered a big security hole and therefore
|
||||
not enabled on many sites, see
|
||||
.Xr rexecd 8
|
||||
.BR rexecd (8)
|
||||
for explanations.
|
||||
.Sh SEE ALSO
|
||||
.Xr rcmd 3 ,
|
||||
.Xr rexecd 8
|
||||
.SH SEE ALSO
|
||||
.BR rcmd (3),
|
||||
.BR rexecd (8)
|
||||
|
|
150
man3/stdin.3
150
man3/stdin.3
|
@ -4,69 +4,73 @@
|
|||
.\" and placed in the Public Domain. Polished a bit by aeb.
|
||||
.\" 2005-06-16 mtk, mentioned freopen()
|
||||
.\"
|
||||
.Dd March 24, 1998
|
||||
.Dt STDIN 3
|
||||
.Os "Linux 2.0"
|
||||
.Sh NAME
|
||||
.Nm stdin ,
|
||||
.Nm stdout ,
|
||||
.Nm stderr
|
||||
.Nd standard I/O streams
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <stdio.h>
|
||||
.Fd extern FILE *stdin;
|
||||
.Fd extern FILE *stdout;
|
||||
.Fd extern FILE *stderr;
|
||||
.Sh DESCRIPTION
|
||||
.\" 2007-12-02, mtk, Converted from mdoc to man macros
|
||||
.\"
|
||||
.TH STDIN 3 2007-12-02 "Linux" "Linux Programmer's Manual"
|
||||
.SH NAME
|
||||
stdin, stdout, stderr \- standard I/O streams
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.B #include <stdio.h>
|
||||
|
||||
.B extern FILE *stdin;
|
||||
.B extern FILE *stdout;
|
||||
.B extern FILE *stderr;
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
Under normal circumstances every Unix program has three streams opened
|
||||
for it when it starts up, one for input, one for output, and one for
|
||||
printing diagnostic or error messages.
|
||||
These are typically attached to
|
||||
the user's terminal (see
|
||||
.Xr tty 4 )
|
||||
.BR tty (4)
|
||||
but might instead refer to files or other devices, depending on what
|
||||
the parent process chose to set up. (See also the ``Redirection'' section of
|
||||
.Xr sh 1 .)
|
||||
.Pp
|
||||
The input stream is referred to as ``standard input''; the output stream is
|
||||
referred to as ``standard output''; and the error stream is referred to
|
||||
as ``standard error''.
|
||||
the parent process chose to set up. (See also the "Redirection" section of
|
||||
.BR sh (1).)
|
||||
.sp
|
||||
The input stream is referred to as "standard input"; the output stream is
|
||||
referred to as "standard output"; and the error stream is referred to
|
||||
as "standard error".
|
||||
These terms are abbreviated to form the symbols
|
||||
used to refer to these files, namely
|
||||
.Nm stdin ,
|
||||
.Nm stdout ,
|
||||
.IR stdin ,
|
||||
.IR stdout ,
|
||||
and
|
||||
.Nm stderr .
|
||||
.Pp
|
||||
.IR stderr .
|
||||
|
||||
Each of these symbols is a
|
||||
.Xr stdio 3
|
||||
.BR stdio (3)
|
||||
macro of type pointer to FILE, and can be used with functions like
|
||||
.Xr fprintf 3
|
||||
.BR fprintf (3)
|
||||
or
|
||||
.Xr fread 3 .
|
||||
.Pp
|
||||
.BR fread (3).
|
||||
.sp
|
||||
Since FILEs are a buffering wrapper around Unix file descriptors, the
|
||||
same underlying files may also be accessed using the raw Unix file
|
||||
interface, that is, the functions like
|
||||
.Xr read 2
|
||||
.BR read (2)
|
||||
and
|
||||
.Xr lseek 2 .
|
||||
.Pp
|
||||
.BR lseek (2).
|
||||
.sp
|
||||
On program startup, the integer file descriptors
|
||||
associated with the streams
|
||||
.Nm stdin ,
|
||||
.Nm stdout ,
|
||||
.IR stdin ,
|
||||
.IR stdout ,
|
||||
and
|
||||
.Nm stderr
|
||||
.I stderr
|
||||
are 0, 1, and 2, respectively.
|
||||
The preprocessor symbols STDIN_FILENO,
|
||||
STDOUT_FILENO, and STDERR_FILENO are defined with these values in
|
||||
The preprocessor symbols
|
||||
.BR STDIN_FILENO ,
|
||||
.BR STDOUT_FILENO ,
|
||||
and
|
||||
.B STDERR_FILENO
|
||||
are defined with these values in
|
||||
\fI<unistd.h>\fP.
|
||||
(Applying
|
||||
.Xr freopen 3
|
||||
.BR freopen (3)
|
||||
to one of these streams can change the file descriptor number
|
||||
associated with the stream.)
|
||||
.Pp
|
||||
.sp
|
||||
Note that mixing use of FILEs and raw file descriptors can produce
|
||||
unexpected results and should generally be avoided.
|
||||
(For the masochistic among you: POSIX.1, section 8.2.3, describes
|
||||
|
@ -74,72 +78,68 @@ in detail how this interaction is supposed to work.)
|
|||
A general rule is that file descriptors are handled in the kernel,
|
||||
while stdio is just a library.
|
||||
This means for example, that after an
|
||||
.Fn exec ,
|
||||
.BR exec (3),
|
||||
the child inherits all open file descriptors, but all old streams
|
||||
have become inaccessible.
|
||||
.Pp
|
||||
.sp
|
||||
Since the symbols
|
||||
.Nm stdin ,
|
||||
.Nm stdout ,
|
||||
.IR stdin ,
|
||||
.IR stdout ,
|
||||
and
|
||||
.Nm stderr
|
||||
.I stderr
|
||||
are specified to be macros, assigning to them is non-portable.
|
||||
The standard streams can be made to refer to different files
|
||||
with help of the library function
|
||||
.Xr freopen 3 ,
|
||||
.BR freopen (3),
|
||||
specially introduced to make it possible to reassign
|
||||
.Nm stdin ,
|
||||
.Nm stdout ,
|
||||
.IR stdin ,
|
||||
.IR stdout ,
|
||||
and
|
||||
.Nm stderr .
|
||||
.IR stderr .
|
||||
The standard streams are closed by a call to
|
||||
.Xr exit 3
|
||||
.BR exit (3)
|
||||
and by normal program termination.
|
||||
.Sh CONSIDERATIONS
|
||||
.SH CONSIDERATIONS
|
||||
The stream
|
||||
.Nm stderr
|
||||
is unbuffered.
|
||||
stderr is unbuffered.
|
||||
The stream
|
||||
.Nm stdout
|
||||
is line-buffered when it points to a terminal.
|
||||
stdout is line-buffered when it points to a terminal.
|
||||
Partial lines will not
|
||||
appear until
|
||||
.Xr fflush 3
|
||||
.BR fflush (3)
|
||||
or
|
||||
.Xr exit 3
|
||||
.BR exit (3)
|
||||
is called, or a newline is printed.
|
||||
This can produce unexpected
|
||||
results, especially with debugging output.
|
||||
The buffering mode of the standard streams (or any other stream)
|
||||
can be changed using the
|
||||
.Xr setbuf 3
|
||||
.BR setbuf (3)
|
||||
or
|
||||
.Xr setvbuf 3
|
||||
.BR setvbuf (3)
|
||||
call.
|
||||
Note that in case
|
||||
.Nm stdin
|
||||
is associated with a terminal, there may also be input buffering
|
||||
stdin is associated with a terminal, there may also be input buffering
|
||||
in the terminal driver, entirely unrelated to stdio buffering.
|
||||
(Indeed, normally terminal input is line buffered in the kernel.)
|
||||
This kernel input handling can be modified using calls like
|
||||
.Xr tcsetattr 3 ;
|
||||
.BR tcsetattr (3);
|
||||
see also
|
||||
.Xr stty 1 ,
|
||||
.BR stty (1),
|
||||
and
|
||||
.Xr termios 3 .
|
||||
.Sh "CONFORMING TO"
|
||||
.BR termios (3).
|
||||
.SH "CONFORMING TO"
|
||||
The
|
||||
.Nm stdin ,
|
||||
.Nm stdout ,
|
||||
.IR stdin ,
|
||||
.IR stdout ,
|
||||
and
|
||||
.Nm stderr
|
||||
macros conform to
|
||||
.St -ansiC ,
|
||||
.I stderr
|
||||
macros conform to C89
|
||||
and this standard also stipulates that these three
|
||||
streams shall be open at program startup.
|
||||
.Sh SEE ALSO
|
||||
.Xr sh 1 ,
|
||||
.Xr csh 1 ,
|
||||
.Xr open 2 ,
|
||||
.Xr fopen 3 ,
|
||||
.Xr stdio 3
|
||||
.SH SEE ALSO
|
||||
.BR sh (1),
|
||||
.BR csh (1),
|
||||
.BR open (2),
|
||||
.BR fopen (3),
|
||||
.BR stdio (3)
|
||||
|
|
1449
man5/elf.5
1449
man5/elf.5
File diff suppressed because it is too large
Load Diff
|
@ -33,33 +33,31 @@
|
|||
.\" Restored automatic formatting from FreeBSD. 2003-08-24
|
||||
.\" Martin Schulze <joey@infodrom.org>
|
||||
.\"
|
||||
.Dd August 24, 2003
|
||||
.Dt OPERATOR 7
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm C operator
|
||||
.Nd C operator precedence and order of evaluation
|
||||
.Sh DESCRIPTION
|
||||
This manual page lists C operators and their precedence in evaluation.
|
||||
.Bd -ragged -offset indent -compact
|
||||
.Bl -column "= += -= *= /= %= <<= >>= &= ^= |="
|
||||
.It Sy "Operator Associativity"
|
||||
.It "-------- -------------"
|
||||
.It "\&() [] -> . left to right"
|
||||
.It "\&! ~ ++ -- + - (type) * & sizeof right to left"
|
||||
.It "\&* / % left to right"
|
||||
.It "\&+ - left to right"
|
||||
.It "\&<< >> left to right"
|
||||
.It "\&< <= > >= left to right"
|
||||
.It "\&== != left to right"
|
||||
.It "\&& left to right"
|
||||
.It "\&^ left to right"
|
||||
.It "\&| left to right"
|
||||
.It "\&&& left to right"
|
||||
.It "\&|| left to right"
|
||||
.It "\&?: right to left"
|
||||
.It "\&= += -= *= /= %= <<= >>= &= ^= |= right to left"
|
||||
.It "\&, left to right"
|
||||
.El
|
||||
.Ed
|
||||
.\" 2007-12-02, mtk, Converted from mdoc to man macros
|
||||
.\"
|
||||
.TH OPERATOR 7 2007-12-02 "Linux" "Linux Programmer's Manual"
|
||||
.SH NAME
|
||||
C operator \- C operator precedence and order of evaluation
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
This manual page lists C operators and their precedence in evaluation.
|
||||
.nf
|
||||
|
||||
.B "Operator Associativity"
|
||||
() [] -> . left to right
|
||||
! ~ ++ -- + - (type) * & sizeof right to left
|
||||
* / % left to right
|
||||
+ - left to right
|
||||
<< >> left to right
|
||||
< <= > >= left to right
|
||||
== != left to right
|
||||
& left to right
|
||||
^ left to right
|
||||
| left to right
|
||||
&& left to right
|
||||
|| left to right
|
||||
?: right to left
|
||||
= += -= *= /= %= <<= >>= &= ^= |= right to left
|
||||
, left to right
|
||||
.fi
|
||||
.\"
|
||||
|
|
Loading…
Reference in New Issue