confstr(3)confstr(3)NAMEconfstr - Determine the current value of a specified system variable
defined by a string value
SYNOPSIS
#include <unistd.h>
size_t confstr(
int name,
char *buf,
size_t len );
LIBRARY
Standard C Library (libc)
STANDARDS
Interfaces documented on this reference page conform to industry stan‐
dards as follows:
confstr(): XPG4, XPG4-UNIX
Refer to the standards(5) reference page for more information about
industry standards and associated tags.
PARAMETERS
Specifies the system variable setting to be returned. Valid values for
the name parameter are defined in the unistd.h header file: Copies a
value for the PATH environment variable that finds all standard utili‐
ties into the buffer. [Tru64 UNIX] Copies the official name of the
installed operating system product into the buffer. [Tru64
UNIX] Copies the official system banner into the buffer. The banner
typically consists of the vendor name followed by the product name.
[Tru64 UNIX] Copies the product version information into the buffer.
[Tru64 UNIX] Copies the official abbreviated company name of the
operating system manufacturer into the buffer. If the abbreviated name
was not specified, copies the full company name (same as _CS_VEN‐
DOR_NAME). [Tru64 UNIX] Copies the official company name of the oper‐
ating system manufacturer into the buffer. Specifies values to be
passed to utilities used in building an application. The name of the
parameter establishes type-size constraints for the environment in
which an application is being built: The int, long, pointer, and off_t
types are treated as 32-bit types. The int, long, and pointer types
are treated as 32-bit types, and the off_t type is treated as a type
with at least 64 bits. The int type is treated as a 32-bit type, and
the long, pointer, and off_t types are treated as 64-bit types. The
int type is treated as a type with at least 32 bits, and the long,
pointer, and off_t types are treated as types with at least 64 bits.
The parameter suffix (id) identifies the component affected by
the type-size constraint: The value of the parameter is the set
of initial options (compilation options) to be given to cc or
c89. The value of the parameter is the set of final options
(loader options) to be given to cc or c89. The value of the
parameter is the set of libraries to be given to cc or c89. The
value of the parameter is the set of checking options to be
given to lint.
In all cases, if
sysconf (_SC_XBS5_ILP32_OFFBIG)
returns -1, the meaning of the passed values is unspecified.
Points to the buffer into which the confstr() function copies
the name value. Specifies the size of the buffer storing the
name value.
DESCRIPTION
The confstr() function allows an application to determine the current
setting of certain system parameters, limits, or options that are
defined by a string value. The function is mainly used by applications
to find the system default value for the PATH environment variable.
If the following conditions are true, then the confstr() function
copies that value into a len-byte buffer pointed to by the buf parame‐
ter: The len parameter is not 0 (zero) The name parameter has a system-
defined value The buf parameter is not a null pointer
If the string to be returned is longer than len bytes, including the
terminating null, then the confstr() function truncates the string to
len-1 bytes and adds a terminating null to the result. The application
can detect that the string was truncated by comparing the value
returned by confstr() with the value of len.
If the value of the len parameter is set to 0 (zero) or the buf value
is NULL, the confstr() function returns the size of the buffer needed
to hold the entire system-defined value, but does not copy the string
value.
RETURN VALUES
If the value specified by the name parameter is system-defined, the
confstr() function returns the size of the buffer needed to hold the
entire value. If this return value is greater than the specified len
value, the string returned as the buf value is truncated.
If the specified name value is invalid, a value of 0 (zero) is
returned, and the errno global variable is set to indicate the error.
If the specified name value does not have a system-defined value, the
confstr() function returns a value of 0 (zero) and leaves errno
unchanged.
ERRORS
The confstr() function sets errno as follows:
The value of the name parameter is invalid.
EXAMPLES
To find out how big a buffer is needed to store the _CS_PATH string
value, enter: confstr(_CS_PATH, NULL, (size_t) 0)
The confstr() function returns the size of the buffer necessary.
FILES
Contains system-defined limits. Contains system-defined environment
variables.
SEE ALSO
Functions: pathconf(2), sysconf(3)
Standards: standards(5)confstr(3)