Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/c/confstr.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/c/confstr.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/c/confstr.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/c/confstr.html on line 8

confstr()

Get configuration-defined string values

Synopsis:

#include <unistd.h>

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

Arguments:

name
The system variable to query; see below.
buf
A pointer to a buffer in which the function can store the value of the system variable.
len
The length of the buffer, in bytes.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The confstr() functions lets applications get or set configuration-defined string values. This is similar to the sysconf() function, but you use it to get string values, rather than numeric values. By default, the function queries and returns values in the system.

The name argument represents the system variable to query. The values are defined in <confname.h>; at least the following name values are valid:

_CS_ARCHITECTURE
The name of the instruction set architecture for this node's CPU(s).
_CS_DOMAIN
The domain name.
_CS_HOSTNAME
The name of this node in the network.

Note: A hostname can consist only of letters, numbers, and hyphens, and must not start or end with a hyphen. For more information, see RFC 952.

_CS_HW_PROVIDER
The name of the hardware manufacturer.
_CS_HW_SERIAL
Serial number associated with the hardware.
_CS_LIBPATH
A value similar to the LD_LIBRARY_PATH environment variable that finds all standard libraries.
_CS_MACHINE
This node's hardware type.
_CS_PATH
A value similar to the PATH environment variable that finds all standard utilities.
_CS_RELEASE
The current OS release level.
_CS_RESOLVE
The contents of the resolv.conf file, excluding the domain name.
_CS_SRPC_DOMAIN
The secure RPC domain.
_CS_SYSNAME
The operating system name.
_CS_TIMEZONE
Time zone string (TZ style)
_CS_VERSION
The current OS version number.

The configuration-defined value is returned in the buffer pointed to by buf, and will be ≤ len bytes long, including the terminating NULL.

To find out the length of a configuration-defined value, call confstr() with buf set to NULL and len set to 0.

To set a configuration value:

Returns:

A nonzero value (if a “get” is done, the value is the length of the configuration-defined value), or 0 if an error occurs (errno is set).

You can compare the confstr() return value against len to see if the configuration-defined value was truncated when retrieving a value, (this can't be done when setting a value).

Errors:

EINVAL
The name argument isn't a valid configuration-defined value.

Examples:

Print information similar to that returned by the uname() function:

#include <unistd.h>
#include <stdio.h>
#include <limits.h>

#define BUFF_SIZE (256 + 1)

int main( void )
{
    char buff[BUFF_SIZE];

    if( confstr( _CS_SYSNAME, buff, BUFF_SIZE ) > 0 ) {
        printf( "System name: %s\n", buff );
    }
    
    if( confstr( _CS_HOSTNAME, buff, BUFF_SIZE ) > 0 ) {
        printf( "Host name: %s\n", buff );
    }
    
    if( confstr( _CS_RELEASE, buff, BUFF_SIZE ) > 0 ) {
        printf( "Release: %s\n", buff );
    }
    
    if( confstr( _CS_VERSION, buff, BUFF_SIZE ) > 0 ) {
        printf( "Version: %s\n", buff );
    }
    
    if( confstr( _CS_MACHINE, buff, BUFF_SIZE ) > 0 ) {
        printf( "Machine: %s\n", buff );
    }

    if( confstr( _CS_SET | _CS_HOSTNAME, "myhostname", 0 ) != 0 ) {
        printf( "Hostname set to: %s\n", "myhostname" );
    }

    return 0;
}

Classification:

POSIX 1003.1

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

Caveats:

The confstr() function is part of a draft standard; its interface and/or behavior may change in the future.

See also:

pathconf(), sysconf()

getconf, setconf in the Utilities Reference

Configuration strings in the Configuring Your Environment chapter of the Neutrino User's Guide


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/c/confstr.html on line 342

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/c/confstr.html on line 342