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 full pathname is placed in the buffer pointed to by the argument buffer. If the specified file cannot be found, then buffer contains an empty string.
getenv(), searchenv(), setenv(), _splitpath(), putenv()
#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
All (except Netware, DOS/PM)