HELPLIB.HLB  —  CRTL  confstr
    Determines the current value of a specified system variable
    defined by a string value.

    Format

      #include  <unistd.h>

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

1  –  Arguments

 name

    The system variable setting. Valid values for the name argument
    are the _CS_X names defined in the <unistd.h> header file.

 buf

    Pointer to the buffer where the confstr function copies the name
    value.

 len

    The size of the buffer storing the name value.

2  –  Description

    The confstr function allows an application to determine the
    current setting of certain system parameters, limits, or options
    that are defined by a string value. The function is mainly used
    by applications to find the system default value for the PATH
    environment variable.

    If the following conditions are true, then the confstr function
    copies that value into a len-byte buffer pointed to by buf:

    o  The len argument can be 0 (zero).

    o  The name argument has a system-defined value.

    o  The buf argument is not a NULL pointer.

    If the returned string is longer than len bytes, including the
    terminating null, then the confstr function truncates the string
    to len - 1 bytes and adds a terminating null to the result. The
    application can detect that the string was truncated by comparing
    the value returned by the confstr function with the value of the
    len argument.

    The <limits.h> header file contains system-defined limits. The
    <unistd.h> header file contains system-defined environmental
    variables.

    Also, confstr supports the following three HP-UX symbolic
    constants, which are added to header file <unistd.h>:

    o  _CS_MACHINE_IDENT

    o  _CS_PARTITION_IDENT

    o  _CS_MACHINE_SERIAL

3  –  Example

      To find out how big a buffer is needed to store the string
      value of name, enter:

         confstr(_CS_PATH, NULL, (size_t) 0)

      The confstr function returns the size of the buffer necessary.

4  –  Return Values

    0                  Indicates an error. When the specified name
                       value:

                       o  Is invalid, errno is set to EINVAL.

                       o  Does not have a system-defined value, errno
                          is not set.

    n                  The size of the buffer needed to hold the
                       value.

                       o  When the value of the name argument is
                          system-defined, confstr returns the size of
                          the buffer needed to hold the entire value.
                          If this return value is greater than the
                          len value, the string returned as the buf
                          value is truncated.

                       o  When the value of the len argument is set
                          to 0 or the buf value is NULL, confstr
                          returns the size of the buffer needed to
                          hold the entire system-defined value. The
                          string value is not copied.
Close Help