| PATH(3) | C LIBRARY FUNCTIONS | PATH(3) |
|---|
#include <ast.h>char* pathaccess(char* path, const char* dirs, const char* a, const char* b, int mode); char* pathbin(void); char* pathcanon(char* path, int flags); char* pathcat(char* path, const char* dirs, int sep, const char* a, const char* b); char* pathcd(char* path, const char* home); int pathcheck(const char* package, const char* tool, Pathcheck_t* pc); int pathgetlink(const char* name, char* buf, int siz); char* pathkey(char* key, char* attr, const char* lang, const char* path); char* pathnext(char* path, char* extra, long* visits); char* pathpath(char* path, const char* p, const char* a, int mode); char* pathprobe(char* path, char* attr, const char* lang, const char* tool, const char* proc, int op); char* pathrepl(char* path, const char* match, const char* replace); int pathsetlink(const char* text, char* name); char* pathshell(void); int pathstat(const char* path, struct stat* st); char* pathtemp(char* path, const char* dir, const char* pfx);
pathaccess constructs a path in path to the file a/b with access mode using the : separated directories in dirs. Both a and b may be 0. mode is the inclusive-or of:
pathbin returns a pointer to the : separated list of directories to search for executable commands. The PATH environment variable is first consulted. If not defined then confstr(_CS_PATH,...) is used. A valid string is always returned.
pathcanon
canonicalizes the path
path
in place.
A pointer to the trailing 0 in the canonicalized path is returned.
A canonical path has:
redundant
.
and
/
removed;
..
moved to the front;
/..
preserved for super root hacks;
...
resolved if
0 is returned on error. If an error occurs and either of PATH_DOTDOT or PATH_EXISTS is set then path will contain the components following the failure point.
pathcat concatenates the first sep separated path component in dirs with the path components a and b into path. The path is constructed in path by separating each path component with /. Both a and b may be 0. A pointer to the next sep separated component in dirs is returned, 0 when there are no more components. pathcat is used by pathaccess.
pathcd
sets the current working directory to
path
via
pathcheck
is a stub for license libraries.
See
pathgetlink returns the 0-terminated symbolic link text for path in the buffer bu of size siz. The link text length is returned on success, -1 on error. Weird universe (1) interactions with dynamic symbolic links are handled by converting non-standard dynamic link text to .../$(UNIVERSE)/... pathsetsymlink converts in the other direction.
pathkey
generates in
key
a 14 character lookup key (plus terminating 0) for the language
lang
processor in
path.
A poihter to the key is returned, 0 on error.
If
key == 0
then space is allocated via
pathpath
constructs in
path
a path to
p
with
pathprobe
generates in
path
the full path name of the
tool
specific
0 is returned if the information does not exist and cannot be generated.
pathrepl does an in-place replacement of the first occurrence of /match/ with /replace/ in path.
pathsetlink
creates a symbolic link
text
in the path
name.
See
pathgetlink
above for weird
pathshell returns a pointer to the pathname for the shell for the current process. The SHELL environment variable is first consulted, but is rejected under suspicious ownership/setuid conditions of if it seems to point to csh(1); otherwise confstr(_CS_SHELL,...) is used. A valid string is always returned.
pathstat first tries stat(path,st) and if that fails it tries lstat(path,st). The stat or lstat return value is returned.
pathtemp
generates in
path
a temporary file path name of the form
dir/pfx<pid>.<suf>
where the length of
pfx,
if !=0, is limited to 5, the length of
<pid>
(the base 64 representation of the current process id)
is limited to 3, and
<suf>
(an internally generated suffix that avoid file confilicts)
is limited to 3.
The generated path name conforms to the classic UNIX 14 char and the DOS
8.3
limitations.
Both
dir
and
pfx
may be
0.
| November 07, 2006 |