Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ confstr(3C) — Reliant UNIX 5.44c4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

pathconf(2)

sysconf(3C)

confstr(3C)                                                     confstr(3C)

NAME
     confstr - get configurable variables

SYNOPSIS
     #include <unistd.h>

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

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

     An application can distinguish between an invalid name parameter value
     and one that corresponds to a configurable variable that has no
     configuration-defined value by checking if errno is modified. This
     mirrors the behavior of sysconf().

     The original need for this function was to provide a way of finding
     the configuration-defined default value for the environment variable
     PATH. Since PATH can be modified by the user to include directories
     that could contain utilities replacing XCU specification standard
     utilities, applications need a way to determine the system-supplied
     PATH environment variable value that contains the correct search path
     for the standard utilities.

     An application could use:

     confstr (name, (char *)NULL, (sizet) 0)

     to find out how big a buffer is needed for the string value; use mal-
     loc() to allocate a buffer to hold the string; and call confstr()
     again to get the string. Alternately, it could allocate a fixed,
     static buffer that is big enough to hold most answers (perhaps 512 or
     1024 bytes), but then use malloc() to allocate a larger buffer if it
     finds that this is too small.

     The name argument represents the system variable to be queried. The
     implementation supports the name value of CSPATH, defined in
     unistd.h.

     If len is not 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 terminating null, then confstr() truncates the string to len-1
     bytes and null terminates the result. The application can detect that
     the string was truncated by comparing the value returned by confstr()
     with len.

     If len is zero and buf is a null pointer, then confstr() still returns
     the integer value as defined below, but does not return a string. If



Page 1                       Reliant UNIX 5.44                Printed 11/98

confstr(3C)                                                     confstr(3C)

     len is zero but buf is not a null pointer, the result is unspecified.

     The confstr() function will fail if :

     EINVAL    The value of the name argument is invalid.

RESULT
     If name has a configuration-defined value, the confstr() function
     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 is truncated.

     If name is invalid, confstr() returns zero and sets errno to indicate
     the error.

     If name does not have a configuration-defined value, confstr() returns
     zero and leaves errno unchanged.

SEE ALSO
     pathconf(2), sysconf(3C).


































Page 2                       Reliant UNIX 5.44                Printed 11/98

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026