|
Packit |
7cfc04 |
'\" et
|
|
Packit |
7cfc04 |
.TH CONFSTR "3P" 2013 "IEEE/The Open Group" "POSIX Programmer's Manual"
|
|
Packit |
7cfc04 |
.SH PROLOG
|
|
Packit |
7cfc04 |
This manual page is part of the POSIX Programmer's Manual.
|
|
Packit |
7cfc04 |
The Linux implementation of this interface may differ (consult
|
|
Packit |
7cfc04 |
the corresponding Linux manual page for details of Linux behavior),
|
|
Packit |
7cfc04 |
or the interface may not be implemented on Linux.
|
|
Packit |
7cfc04 |
|
|
Packit |
7cfc04 |
.SH NAME
|
|
Packit |
7cfc04 |
confstr
|
|
Packit |
7cfc04 |
\(em get configurable variables
|
|
Packit |
7cfc04 |
.SH SYNOPSIS
|
|
Packit |
7cfc04 |
.LP
|
|
Packit |
7cfc04 |
.nf
|
|
Packit |
7cfc04 |
#include <unistd.h>
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
size_t confstr(int \fIname\fP, char *\fIbuf\fP, size_t \fIlen\fP);
|
|
Packit |
7cfc04 |
.fi
|
|
Packit |
7cfc04 |
.SH DESCRIPTION
|
|
Packit |
7cfc04 |
The
|
|
Packit |
7cfc04 |
\fIconfstr\fR()
|
|
Packit |
7cfc04 |
function shall return configuration-defined string values. Its use and
|
|
Packit |
7cfc04 |
purpose are similar to
|
|
Packit |
7cfc04 |
\fIsysconf\fR(),
|
|
Packit |
7cfc04 |
but it is used where string values rather than numeric values are
|
|
Packit |
7cfc04 |
returned.
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
The
|
|
Packit |
7cfc04 |
.IR name
|
|
Packit |
7cfc04 |
argument represents the system variable to be queried. The
|
|
Packit |
7cfc04 |
implementation shall support the following name values, defined in
|
|
Packit |
7cfc04 |
.IR <unistd.h> .
|
|
Packit |
7cfc04 |
It may support others:
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
.nf
|
|
Packit |
7cfc04 |
_CS_PATH
|
|
Packit |
7cfc04 |
_CS_POSIX_V7_ILP32_OFF32_CFLAGS
|
|
Packit |
7cfc04 |
_CS_POSIX_V7_ILP32_OFF32_LDFLAGS
|
|
Packit |
7cfc04 |
_CS_POSIX_V7_ILP32_OFF32_LIBS
|
|
Packit |
7cfc04 |
_CS_POSIX_V7_ILP32_OFFBIG_CFLAGS
|
|
Packit |
7cfc04 |
_CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS
|
|
Packit |
7cfc04 |
_CS_POSIX_V7_ILP32_OFFBIG_LIBS
|
|
Packit |
7cfc04 |
_CS_POSIX_V7_LP64_OFF64_CFLAGS
|
|
Packit |
7cfc04 |
_CS_POSIX_V7_LP64_OFF64_LDFLAGS
|
|
Packit |
7cfc04 |
_CS_POSIX_V7_LP64_OFF64_LIBS
|
|
Packit |
7cfc04 |
_CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS
|
|
Packit |
7cfc04 |
_CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS
|
|
Packit |
7cfc04 |
_CS_POSIX_V7_LPBIG_OFFBIG_LIBS
|
|
Packit |
7cfc04 |
_CS_POSIX_V7_THREADS_CFLAGS
|
|
Packit |
7cfc04 |
_CS_POSIX_V7_THREADS_LDFLAGS
|
|
Packit |
7cfc04 |
_CS_POSIX_V7_WIDTH_RESTRICTED_ENVS
|
|
Packit |
7cfc04 |
_CS_V7_ENV
|
|
Packit |
7cfc04 |
_CS_POSIX_V6_ILP32_OFF32_CFLAGS
|
|
Packit |
7cfc04 |
_CS_POSIX_V6_ILP32_OFF32_LDFLAGS
|
|
Packit |
7cfc04 |
_CS_POSIX_V6_ILP32_OFF32_LIBS
|
|
Packit |
7cfc04 |
_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS
|
|
Packit |
7cfc04 |
_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS
|
|
Packit |
7cfc04 |
_CS_POSIX_V6_ILP32_OFFBIG_LIBS
|
|
Packit |
7cfc04 |
_CS_POSIX_V6_LP64_OFF64_CFLAGS
|
|
Packit |
7cfc04 |
_CS_POSIX_V6_LP64_OFF64_LDFLAGS
|
|
Packit |
7cfc04 |
_CS_POSIX_V6_LP64_OFF64_LIBS
|
|
Packit |
7cfc04 |
_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS
|
|
Packit |
7cfc04 |
_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS
|
|
Packit |
7cfc04 |
_CS_POSIX_V6_LPBIG_OFFBIG_LIBS
|
|
Packit |
7cfc04 |
_CS_POSIX_V6_WIDTH_RESTRICTED_ENVS
|
|
Packit |
7cfc04 |
_CS_V6_ENV
|
|
Packit |
7cfc04 |
.fi
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
If
|
|
Packit |
7cfc04 |
.IR len
|
|
Packit |
7cfc04 |
is not 0, and if
|
|
Packit |
7cfc04 |
.IR name
|
|
Packit |
7cfc04 |
has a configuration-defined value,
|
|
Packit |
7cfc04 |
\fIconfstr\fR()
|
|
Packit |
7cfc04 |
shall copy that value into the
|
|
Packit |
7cfc04 |
.IR len -byte
|
|
Packit |
7cfc04 |
buffer pointed to by
|
|
Packit |
7cfc04 |
.IR buf .
|
|
Packit |
7cfc04 |
If the string to be returned is longer than
|
|
Packit |
7cfc04 |
.IR len
|
|
Packit |
7cfc04 |
bytes, including the terminating null, then
|
|
Packit |
7cfc04 |
\fIconfstr\fR()
|
|
Packit |
7cfc04 |
shall truncate the string to
|
|
Packit |
7cfc04 |
.IR len \(mi1
|
|
Packit |
7cfc04 |
bytes and null-terminate the result. The application can detect that
|
|
Packit |
7cfc04 |
the string was truncated by comparing the value returned by
|
|
Packit |
7cfc04 |
\fIconfstr\fR()
|
|
Packit |
7cfc04 |
with
|
|
Packit |
7cfc04 |
.IR len .
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
If
|
|
Packit |
7cfc04 |
.IR len
|
|
Packit |
7cfc04 |
is 0 and
|
|
Packit |
7cfc04 |
.IR buf
|
|
Packit |
7cfc04 |
is a null pointer, then
|
|
Packit |
7cfc04 |
\fIconfstr\fR()
|
|
Packit |
7cfc04 |
shall still return the integer value as defined below, but shall not
|
|
Packit |
7cfc04 |
return a string. If
|
|
Packit |
7cfc04 |
.IR len
|
|
Packit |
7cfc04 |
is 0 but
|
|
Packit |
7cfc04 |
.IR buf
|
|
Packit |
7cfc04 |
is not a null pointer, the result is unspecified.
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
After a call to:
|
|
Packit |
7cfc04 |
.sp
|
|
Packit |
7cfc04 |
.RS 4
|
|
Packit |
7cfc04 |
.nf
|
|
Packit |
7cfc04 |
\fB
|
|
Packit |
7cfc04 |
confstr(_CS_V7_ENV, buf, sizeof(buf))
|
|
Packit |
7cfc04 |
.fi \fR
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
.RE
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
the string stored in
|
|
Packit |
7cfc04 |
.IR buf
|
|
Packit |
7cfc04 |
will contain the
|
|
Packit |
7cfc04 |
<space>-separated
|
|
Packit |
7cfc04 |
list of variable=value environment variable pairs required by the
|
|
Packit |
7cfc04 |
implementation to create a conforming environment, as described in the
|
|
Packit |
7cfc04 |
implementations' conformance documentation.
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
If the implementation supports the POSIX shell option, the string
|
|
Packit |
7cfc04 |
stored in
|
|
Packit |
7cfc04 |
.IR buf
|
|
Packit |
7cfc04 |
after a call to:
|
|
Packit |
7cfc04 |
.sp
|
|
Packit |
7cfc04 |
.RS 4
|
|
Packit |
7cfc04 |
.nf
|
|
Packit |
7cfc04 |
\fB
|
|
Packit |
7cfc04 |
confstr(_CS_PATH, buf, sizeof(buf))
|
|
Packit |
7cfc04 |
.fi \fR
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
.RE
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
can be used as a value of the
|
|
Packit |
7cfc04 |
.IR PATH
|
|
Packit |
7cfc04 |
environment variable that accesses all of the standard utilities of
|
|
Packit |
7cfc04 |
POSIX.1\(hy2008, if the return value is less than or equal to
|
|
Packit |
7cfc04 |
.IR sizeof (\c
|
|
Packit |
7cfc04 |
.IR buf ).
|
|
Packit |
7cfc04 |
.SH "RETURN VALUE"
|
|
Packit |
7cfc04 |
If
|
|
Packit |
7cfc04 |
.IR name
|
|
Packit |
7cfc04 |
has a configuration-defined value,
|
|
Packit |
7cfc04 |
\fIconfstr\fR()
|
|
Packit |
7cfc04 |
shall return the size of buffer that would be needed to hold the entire
|
|
Packit |
7cfc04 |
configuration-defined value including the terminating null. If this
|
|
Packit |
7cfc04 |
return value is greater than
|
|
Packit |
7cfc04 |
.IR len ,
|
|
Packit |
7cfc04 |
the string returned in
|
|
Packit |
7cfc04 |
.IR buf
|
|
Packit |
7cfc04 |
is truncated.
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
If
|
|
Packit |
7cfc04 |
.IR name
|
|
Packit |
7cfc04 |
is invalid,
|
|
Packit |
7cfc04 |
\fIconfstr\fR()
|
|
Packit |
7cfc04 |
shall return 0 and set
|
|
Packit |
7cfc04 |
.IR errno
|
|
Packit |
7cfc04 |
to indicate the error.
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
If
|
|
Packit |
7cfc04 |
.IR name
|
|
Packit |
7cfc04 |
does not have a configuration-defined value,
|
|
Packit |
7cfc04 |
\fIconfstr\fR()
|
|
Packit |
7cfc04 |
shall return 0 and leave
|
|
Packit |
7cfc04 |
.IR errno
|
|
Packit |
7cfc04 |
unchanged.
|
|
Packit |
7cfc04 |
.SH ERRORS
|
|
Packit |
7cfc04 |
The
|
|
Packit |
7cfc04 |
\fIconfstr\fR()
|
|
Packit |
7cfc04 |
function shall fail if:
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.BR EINVAL
|
|
Packit |
7cfc04 |
The value of the
|
|
Packit |
7cfc04 |
.IR name
|
|
Packit |
7cfc04 |
argument is invalid.
|
|
Packit |
7cfc04 |
.LP
|
|
Packit |
7cfc04 |
.IR "The following sections are informative."
|
|
Packit |
7cfc04 |
.SH EXAMPLES
|
|
Packit |
7cfc04 |
None.
|
|
Packit |
7cfc04 |
.SH "APPLICATION USAGE"
|
|
Packit |
7cfc04 |
An application can distinguish between an invalid
|
|
Packit |
7cfc04 |
.IR name
|
|
Packit |
7cfc04 |
parameter value and one that corresponds to a configurable variable
|
|
Packit |
7cfc04 |
that has no configuration-defined value by checking if
|
|
Packit |
7cfc04 |
.IR errno
|
|
Packit |
7cfc04 |
is modified. This mirrors the behavior of
|
|
Packit |
7cfc04 |
\fIsysconf\fR().
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
The original need for this function was to provide a way of finding the
|
|
Packit |
7cfc04 |
configuration-defined default value for the environment variable
|
|
Packit |
7cfc04 |
.IR PATH .
|
|
Packit |
7cfc04 |
Since
|
|
Packit |
7cfc04 |
.IR PATH
|
|
Packit |
7cfc04 |
can be modified by the user to include directories that could contain
|
|
Packit |
7cfc04 |
utilities replacing the standard utilities in the Shell and Utilities volume of POSIX.1\(hy2008, applications
|
|
Packit |
7cfc04 |
need a way to determine the system-supplied
|
|
Packit |
7cfc04 |
.IR PATH
|
|
Packit |
7cfc04 |
environment variable value that contains the correct search path for
|
|
Packit |
7cfc04 |
the standard utilities.
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
An application could use:
|
|
Packit |
7cfc04 |
.sp
|
|
Packit |
7cfc04 |
.RS 4
|
|
Packit |
7cfc04 |
.nf
|
|
Packit |
7cfc04 |
\fB
|
|
Packit |
7cfc04 |
confstr(name, (char *)NULL, (size_t)0)
|
|
Packit |
7cfc04 |
.fi \fR
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
.RE
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
to find out how big a buffer is needed for the string value; use
|
|
Packit |
7cfc04 |
\fImalloc\fR()
|
|
Packit |
7cfc04 |
to allocate a buffer to hold the string; and call
|
|
Packit |
7cfc04 |
\fIconfstr\fR()
|
|
Packit |
7cfc04 |
again to get the string. Alternately, it could allocate a fixed, static
|
|
Packit |
7cfc04 |
buffer that is big enough to hold most answers (perhaps 512 or 1\|024
|
|
Packit |
7cfc04 |
bytes), but then use
|
|
Packit |
7cfc04 |
\fImalloc\fR()
|
|
Packit |
7cfc04 |
to allocate a larger buffer if it finds that this is too small.
|
|
Packit |
7cfc04 |
.SH RATIONALE
|
|
Packit |
7cfc04 |
Application developers can normally determine any configuration
|
|
Packit |
7cfc04 |
variable by means of reading from the stream opened by a call to:
|
|
Packit |
7cfc04 |
.sp
|
|
Packit |
7cfc04 |
.RS 4
|
|
Packit |
7cfc04 |
.nf
|
|
Packit |
7cfc04 |
\fB
|
|
Packit |
7cfc04 |
popen("command -p getconf variable", "r");
|
|
Packit |
7cfc04 |
.fi \fR
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
.RE
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
The
|
|
Packit |
7cfc04 |
\fIconfstr\fR()
|
|
Packit |
7cfc04 |
function with a
|
|
Packit |
7cfc04 |
.IR name
|
|
Packit |
7cfc04 |
argument of _CS_PATH returns a string that can be used as a
|
|
Packit |
7cfc04 |
.IR PATH
|
|
Packit |
7cfc04 |
environment variable setting that will reference the standard shell and
|
|
Packit |
7cfc04 |
utilities as described in the Shell and Utilities volume of POSIX.1\(hy2008.
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
The
|
|
Packit |
7cfc04 |
\fIconfstr\fR()
|
|
Packit |
7cfc04 |
function copies the returned string into a buffer supplied by the
|
|
Packit |
7cfc04 |
application instead of returning a pointer to a string. This allows a
|
|
Packit |
7cfc04 |
cleaner function in some implementations (such as those with
|
|
Packit |
7cfc04 |
lightweight threads) and resolves questions about when the application
|
|
Packit |
7cfc04 |
must copy the string returned.
|
|
Packit |
7cfc04 |
.SH "FUTURE DIRECTIONS"
|
|
Packit |
7cfc04 |
None.
|
|
Packit |
7cfc04 |
.SH "SEE ALSO"
|
|
Packit |
7cfc04 |
.IR "\fIexec\fR\^",
|
|
Packit |
7cfc04 |
.IR "\fIfpathconf\fR\^(\|)",
|
|
Packit |
7cfc04 |
.IR "\fIsysconf\fR\^(\|)"
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
The Base Definitions volume of POSIX.1\(hy2008,
|
|
Packit |
7cfc04 |
.IR "\fB<unistd.h>\fP"
|
|
Packit |
7cfc04 |
.P
|
|
Packit |
7cfc04 |
The Shell and Utilities volume of POSIX.1\(hy2008,
|
|
Packit |
7cfc04 |
.IR "\fIc99\fR\^"
|
|
Packit |
7cfc04 |
.SH COPYRIGHT
|
|
Packit |
7cfc04 |
Portions of this text are reprinted and reproduced in electronic form
|
|
Packit |
7cfc04 |
from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
|
|
Packit |
7cfc04 |
-- Portable Operating System Interface (POSIX), The Open Group Base
|
|
Packit |
7cfc04 |
Specifications Issue 7, Copyright (C) 2013 by the Institute of
|
|
Packit |
7cfc04 |
Electrical and Electronics Engineers, Inc and The Open Group.
|
|
Packit |
7cfc04 |
(This is POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
|
|
Packit |
7cfc04 |
event of any discrepancy between this version and the original IEEE and
|
|
Packit |
7cfc04 |
The Open Group Standard, the original IEEE and The Open Group Standard
|
|
Packit |
7cfc04 |
is the referee document. The original Standard can be obtained online at
|
|
Packit |
7cfc04 |
http://www.unix.org/online.html .
|
|
Packit |
7cfc04 |
|
|
Packit |
7cfc04 |
Any typographical or formatting errors that appear
|
|
Packit |
7cfc04 |
in this page are most likely
|
|
Packit |
7cfc04 |
to have been introduced during the conversion of the source files to
|
|
Packit |
7cfc04 |
man page format. To report such errors, see
|
|
Packit |
7cfc04 |
https://www.kernel.org/doc/man-pages/reporting_bugs.html .
|