get configuration-defined string values


#include <unistd.h>
size_t confstr( int name, 
                char *buf, 
                size_t len );


The confstr() function provides a method for applications to get configuration-defined string values.

The name argument is the system variable to be queried. At least the following variables are available:

A path string that can be assigned to the PATH environment variable, which will find all standard utilities.

If len isn't zero, and if name has a configuration-defined value, confstr() copies that value into the len-byte buffer pointed to by buf. If the string to be returned is longer than len bytes, including the NULL terminator, confstr() truncates the string to len - 1 bytes and NULL-terminates the result. The application can detect that the string has been truncated by comparing the value returned by confstr() with len.

If len is zero, confstr() returns the integer value as defined below, but doesn't return a string.


If name doesn't have a configuration-defined value, the confstr() function returns (1), and buf contains NULL.

If name has a configuration-defined value, the confstr() function returns the size of the buffer that is needed to hold the entire configuration-defined value. If this return value is less than len, the string in buf has been truncated.

If an error occurs, confstr() returns 0, and sets errno accordingly.


The value of the name argument is invalid.


POSIX 1003.2

Interrupt handler Yes
Signal handler Yes, but modifies errno
Thread Yes

See also:

errno, fpathconf(), pathconf(), sysconf()