1pathfind(3GEN)     String Pattern-Matching Library Functions    pathfind(3GEN)
2
3
4

NAME

6       pathfind - search for named file in named directories
7

SYNOPSIS

9       cc [ flag ... ] file ... -lgen [ library ... ]
10       #include <libgen.h>
11
12       char *pathfind(const char *path, const char *name, const char *mode);
13
14

DESCRIPTION

16       The  pathfind() function searches the directories named in path for the
17       file name. The directories named in path are separated by  colons  (:).
18       The  mode  argument  is  a string of option letters chosen from the set
19       [rwxfbcdpugks]:
20
21
22
23
24       ┌─────────────────────────────┬─────────────────────────────┐
25       │          Letter             │          Meaning            │
26       ├─────────────────────────────┼─────────────────────────────┤
27r                            │readable                     │
28       ├─────────────────────────────┼─────────────────────────────┤
29w                            │writable                     │
30       ├─────────────────────────────┼─────────────────────────────┤
31x                            │executable                   │
32       ├─────────────────────────────┼─────────────────────────────┤
33f                            │normal file                  │
34       ├─────────────────────────────┼─────────────────────────────┤
35b                            │block special                │
36       ├─────────────────────────────┼─────────────────────────────┤
37c                            │character special            │
38       ├─────────────────────────────┼─────────────────────────────┤
39d                            │directory                    │
40       ├─────────────────────────────┼─────────────────────────────┤
41p                            │FIFO (pipe)                  │
42       ├─────────────────────────────┼─────────────────────────────┤
43u                            │set user ID bit              │
44       ├─────────────────────────────┼─────────────────────────────┤
45g                            │set group ID bit             │
46       ├─────────────────────────────┼─────────────────────────────┤
47k                            │sticky bit                   │
48       ├─────────────────────────────┼─────────────────────────────┤
49s                            │size non-zero                │
50       └─────────────────────────────┴─────────────────────────────┘
51
52
53       Options read, write, and execute are checked relative to the real  (not
54       the effective) user ID and group ID of the current process.
55
56
57       If  name  begins  with a slash, it is treated as an absolute path name,
58       and path is ignored.
59
60
61       An empty path member is treated as the current directory. A  slash  (/)
62       character  is  not  prepended  at  the  occurrence  of the first match;
63       rather, the unadorned name is returned.
64

EXAMPLES

66       Example 1 Example of finding the ls command using the PATH  environment
67       variable.
68
69
70       To find the ls command using the PATH environment variable:
71
72
73
74       pathfind (getenv ("PATH"), "ls", "rx")
75
76

RETURN VALUES

78       The  pathfind()  function  returns  a (char *) value containing static,
79       thread-specific data that will be overwritten upon the next  call  from
80       the same thread.
81
82
83       If the file name with all characteristics specified by mode is found in
84       any of the directories specified by path,  then  pathfind()  returns  a
85       pointer  to a string containing the member of path, followed by a slash
86       character (/), followed by name.
87
88
89       If no match is found, pathname() returns a null pointer, ((char *) 0).
90

ATTRIBUTES

92       See attributes(5) for descriptions of the following attributes:
93
94
95
96
97       ┌─────────────────────────────┬─────────────────────────────┐
98       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
99       ├─────────────────────────────┼─────────────────────────────┤
100       │MT-Level                     │MT-Safe                      │
101       └─────────────────────────────┴─────────────────────────────┘
102

SEE ALSO

104       sh(1), test(1), access(2), mknod(2), stat(2), getenv(3C), attributes(5)
105

NOTES

107       The string pointed to by the returned pointer is stored in an area that
108       is  reused  on subsequent calls to pathfind(). The string should not be
109       deallocated by the caller.
110
111
112       When compiling multithreaded applications, the _REENTRANT flag must  be
113       defined  on the compile line.  This flag should only be used in  multi‐
114       threadedapplications.
115
116
117
118SunOS 5.11                        10 Mar 1999                   pathfind(3GEN)
Impressum