[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions, Volume 1

confstr Subroutine

Purpose

Gets configurable variables.

Library

Standard C library (libc.a)

Syntax

#include <unistd.h>

size_t confstr (int name, char * buf, size_t len );

Description

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.

Parameters

Name Specifies the system variable setting to be returned. Valid values for the Name parameter are defined in the unistd.h file.
Buf Points to the buffer into which the confstr subroutine copies the value of the Name parameter.
Len Specifies the size of the buffer storing the value of the Name parameter.

Return Values

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.

Error Codes

The confstr subroutine will fail if:

EINVAL The value of the name argument is invalid.

Example

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.

Files

/usr/include/limits.h Contains system-defined limits.
/usr/include/unistd.h Contains system-defined environment variables.

Related Information

The pathconf (pathconf or fpathconf Subroutine) subroutine, sysconf subroutine.

The unistd.h header file.

Subroutines, Example Programs, and Libraries in AIX 5L Version 5.2 General Programming Concepts: Writing and Debugging Programs.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]