search the directories listed in a given environment variable
#include <stdlib.h> void _searchenv( const char *name, const char *env_var, char *buffer );
The _searchenv() function searches for the file specified by name in the list of directories assigned to the environment variable specified by env_var. Common values for env_var are "PATH", "LIB" and "INCLUDE".
The current directory is searched first to find the specified file. If the file isn't found in the current directory, each of the directories specified by the environment variable is searched.
The searchenv() function is similar to _searchenv(), except that searchenv() doesn't search the current directory unless it's included in the env_var. |
The full pathname is placed in the buffer pointed to by the argument buffer. If the specified file can't be found, buffer contains an empty string.
#include <stdio.h> #include <stdlib.h> void display_help( FILE *fp ) { printf( "display_help T.B.I.\n" ); } void main() { FILE *help_file; char full_path[ _MAX_PATH ]; _searchenv( "watcomc.hlp", "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 ); } }
WATCOM
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | Yes |
getenv(), putenv(), searchenv(), setenv(), _splitpath()