#include <stdio.h> #include <fcntl.h> #include <errno.h> char *envpath(envname, file, path) char *envname, *file; char *path; char *envpath2(envname, subdir, file, path) char *envname, *subdir, *file; char *path; int openenv(envname, file, flags) char *envname; char *file; int flags; int statenv(envname, file) char *envname; char *file; FILE *fopenenv(envname, file, flags) char *envname; char *file; char *flags;
These functions form pathnames defined fully or partially by UNIX environment variables, and open the corresponding files.
For all the functions, envname is the name of the UNIX environment variable. If file is NULL, envname is assumed to reference a complete pathname. If file is not null, then envname is assumed to reference a directory containing file. file itself can involve directories.
envpath forms a pathname based on the above rules.
envpath2 is an extended version of envpath that can form any of the following paths:
if subdir <> 0, file <> 0, path = $envname/subdir/file if subdir == 0, file == 0, path = $envname/subdir if subdir == 0, file <> 0, path = $envname/file if subdir == 0, file == 0, path = $envname
openenv opens the path formed using envname and file by calling UNIX open with flags, and returns a file descriptor. Appropriate values for flags are listed in open.
fopenenv opens the path formed using envname and file by calling UNIX fopen with flags, and returns a stream pointer. Appropriate values for flags are listed in fopen.
statenv checks the path formed using envname and file for existence by calling UNIX stat..
envpath and envpath2 return a pointer to the formed path if successful. If envname is undefined, NULL is returned, with UNIX error code errno set to ENOENT.
openenv returns a non-negative file descriptor if successful. Otherwise, it returns -1 with UNIX errno set to the appropriate value.
fopenenv returns a stream pointer if successful. Otherwise, it returns NULL, with UNIX errno set to the appropriate value.
statenv returns 0 if the path can be formed and does exist. Otherwise it returns -1, with UNIX errno set to the appropriate value.
For all of the above functions, if envname is undefined, errno is set to ENOENT.
See open, stat, and fopen for pertinent error codes.
include/envnames.h, /usr/include/errno.h, /usr/include/fcntl.h, /usr/include/stdio.h
open, stat, fopen
Most TeraScan environment variables are listed in include/envnames.h
Last Update: $Date: 1999/05/10 20:56:34 $