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