confstr()

get configuration-defined string values 

Function


SYNOPSIS

#include <unistd.h>

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


DESCRIPTION

The confstr() function provides a method for applications to get configuration-defined string values. Its use and purpose are similar to the sysconf() function; however, confstr() is used where string values (rather than numeric values) are returned.

The following system variables may be queried:

_CS_BINDIR 

Returns the directory which contains the most common utility programs.

_CS_CPP 

Returns the path to the C pre-processor command.

_CS_ETCDIR 

Returns the directory where various system-level configuration files are stored.

_CS_LIBDIR 

Returns the directory where various application-level configuration files are stored.

_CS_MANPATH 

Returns the directory where manual pages are located.

_CS_NLSDIR 

Returns the directory where Natural Language Support files are stored.

_CS_NULLDEV 

Returns the path to the null device (for example, /dev/null).

_CS_PATH 

Returns a setting for the PATH environment variable that finds all standard utilities.

_CS_SHELL 

Returns the path to the shell interpreter.

_CS_SPOOLDIR 

Returns the directory which serves as the system spool directory.

_CS_TMPDIR 

Returns the directory where temporary files should be created.

_CS_TTYDEV 

Returns the path to the controlling terminal device (for example, /dev/tty).

_CS_XBS5_ILP32_OFF32_CFLAGS 
_CS_XBS5_ILP32_OFF32_LDFLAGS 
_CS_XBS5_ILP32_OFF32_LIBS 
_CS_XBS5_ILP32_OFF32_LINTFLAGS 

Returns the values for the compile-time flags, link-time flags, link-time libraries, and flags for the lint command, respectively, to build an application using a programming model with 32-bit int, long, pointer and off_t types.

_CS_XBS5_ILP32_OFFBIG_CFLAGS 
_CS_XBS5_ILP32_OFFBIG_LDFLAGS 
_CS_XBS5_ILP32_OFFBIG_LIBS 
_CS_XBS5_ILP32_OFFBIG_LINTFLAGS 

Returns the values for the compile-time flags, link-time flags, link-time libraries, and flags for the lint command, respectively, to build an application using a programming model with 32-bit int, long, and pointer types, and an off_t type that supports at least 64-bit offsets.

_CS_XBS5_LP64_OFF64_CFLAGS 
_CS_XBS5_LP64_OFF64_LDFLAGS 
_CS_XBS5_LP64_OFF64_LIBS 
_CS_XBS5_LP64_OFF64_LINTFLAGS 

Returns the values for the compile-time flags, link-time flags, link-time libraries, and flags for the lint command, respectively, to build an application using a programming model with 64-bit int, long, pointer and off_t types.

_CS_XBS5_LPBIG_OFFBIG_CFLAGS 
_CS_XBS5_LPBIG_OFFBIG_LDFLAGS 
_CS_XBS5_LPBIG_OFFBIG_LIBS 
_CS_XBS5_LPBIG_OFFBIG_LINTFLAGS 

Returns the values for the compile-time flags, link-time flags, link-time libraries, and flags for the lint command, respectively, to build an application using a programming model with an int type supporting at least 32 bits, and long, pointer and off_t types supporting at least 64 bits.

If len is not zero and if name has a configuration-defined value, confstr() copies that value into the len-byte buffer that buf points to. If the string to be returned is longer than len-bytes, including the terminating null character, confstr() truncates the string to len-1 bytes and null-terminates the result. To determine if the string was truncated, compare the value that confstr() returns with len.

If len is zero and buf is NULL, confstr() still returns the integer value but does not return a string.


PARAMETERS

name 

Specifies the system variable to be queried.

buf 

Points to the buffer where len-byte values are stored.

len 

Is the length of the string.


RETURN VALUES

If name does not have a configuration-defined value, confstr() returns a value of zero and does not change errno. If name has a configuration-defined value, confstr() returns the size of buffer that would be needed to hold the entire configuration-defined value. If this return value is greater than len, the string returned in buf has been truncated. On failure, confstr() fails if name is invalid, returning zero and setting errno to EINVAL.


CONFORMANCE

UNIX 98, with exceptions.


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

Several of the values for name listed above are PTC MKS Toolkit UNIX APIs extensions. Because these may not be available on all platforms, to ensure that code is portable, the value should be used in a compile-time check, such as:

#if defined(_CS_TMPDIR)
	ret = confstr(_CS_PATH, buf, buflen);
#else
	strcmp(buf, "/tmp");
#endif

The confstr() function always returns paths in NuTCRACKER Platform format. If you need the return value in other formats (Win32 or MKS), use the _NutConfStr() function, which takes a parameter that specifies the format for the returned path.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
_NutConfStr(), fpathconf(), pathconf(), sysconf()


PTC MKS Toolkit 10.4 Documentation Build 39.