#include <unistd.h>
size_t confstr (int name, char * buf, size_t len );
The confstr subroutine determines the current setting of certain system parameters, limits, or options that are defined by a string value. It is mainly used by applications to find the system default value for the PATH environment variable. Its use and purpose are similar to those of the sysconf subroutine, but it returns string values rather than numeric values.
If the Len parameter is not 0 and the Name parameter has a system-defined value, the confstr subroutine copies that value into a Len-byte buffer pointed to by the Buf parameter. If the string returns a value longer than the value specified by the Len parameter, including the terminating null byte, then the confstr subroutine truncates the string to Len-1 bytes and adds a terminating null byte to the result. The application can detect that the string was truncated by comparing the value returned by the confstr subroutine with the value specified by the Len parameter.
If the value specified by the Name parameter is system-defined, the confstr subroutine returns the size of the buffer needed to hold the entire value. If this return value is greater than the value specified by the Len parameter, the string returned as the Buf parameter is truncated.
If the value of the Len parameter is set to 0 and the Buf parameter is a null value, the confstr subroutine returns the size of the buffer needed to hold the entire system-defined value, but does not copy the string value. If the value of the Len parameter is set to 0 but the Buf parameter is not a null value, the result is unspecified.
The confstr subroutine will fail if:
EINVAL | The value of the name argument is invalid. |
To find out what size buffer is needed to store the string value of the Name parameter, enter:
confstr(_CS_PATH, NULL, (size_t) 0)
The confstr subroutine returns the size of the buffer.
This subroutine is part of Base Operating System (BOS) Runtime.
/usr/include/limits.h | Contains system-defined limits. |
/usr/include/unistd.h | Contains system-defined environment variables. |
The pathconf (pathconf or fpathconf Subroutine) subroutine, sysconf subroutine.
The unistd.h header file.
Subroutines, Example Programs, and Libraries in AIX 5L Version 5.1 General Programming Concepts: Writing and Debugging Programs.