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/s/searchenv.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/s/searchenv.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/s/searchenv.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/s/searchenv.html on line 8

searchenv()

Search the directories listed in an environment variable

Synopsis:

#include <stdlib.h>

void searchenv( const char* name,
                const char* env_var,
                char* buffer );

Arguments:

name
The name of the file that you want to search for.
env_var
The name of an environment variable whose value is a list of directories that you want to search. Common values for env_var are "PATH", "LIB" and "INCLUDE".

Note: The searchenv() function doesn't search the current directory unless it's specified in the environment variable.

buffer
A buffer where the function can store the full path of the file found. This buffer should be PATH_MAX bytes long. If the specified file can't be found, the function stores an empty string in the buffer.

Library:

libc

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

Description:

The searchenv() function searches for the file specified by name in the list of directories assigned to the environment variable specified by env_var.


Note: Use pathfind() or pathfind_r() instead of this function.

Examples:

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

void display_help( FILE *fp )
{
    printf( "display_help T.B.I.\n" );
}

int main( void )
{
    FILE *help_file;
    char full_path[ PATH_MAX ];

    searchenv( "lib_ref.html", "PATH", full_path );
    if( full_path[0] == '\0' ) {
        printf( "Unable to find help file\n" );
    } else {
        help_file = fopen( full_path, "r" );
        display_help( help_file );
        fclose( help_file );
    }
    
    return EXIT_SUCCESS;
}

Classification:

QNX 4

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

Caveats:

The searchenv() function manipulates the environment pointed to by the global environ variable.

See also:

getenv(), pathfind(), pathfind_r(), setenv()


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/s/searchenv.html on line 190

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/s/searchenv.html on line 190