2 .\" Copyright 1989 AT&T Copyright (c) 1999, Sun Microsystems, Inc. All Rights Reserved
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH PATHFIND 3GEN "Mar 10, 1999"
8 pathfind \- search for named file in named directories
12 cc [ \fIflag\fR ... ] \fIfile\fR ... \fB-lgen\fR [ \fIlibrary\fR ... ]
15 \fBchar *\fR\fBpathfind\fR(\fBconst char *\fR\fIpath\fR, \fBconst char *\fR\fIname\fR, \fBconst char *\fR\fImode\fR);
21 The \fBpathfind()\fR function searches the directories named in \fIpath\fR for
22 the file \fIname\fR. The directories named in \fIpath\fR are separated by
23 colons (:). The \fImode\fR argument is a string of option letters chosen from
24 the set \fB[rwxfbcdpugks]:\fR
44 \fBc\fR character special
50 \fBu\fR set user ID bit
52 \fBg\fR set group ID bit
61 Options read, write, and execute are checked relative to the real (not the
62 effective) user \fBID\fR and group \fBID\fR of the current process.
65 If \fIname\fR begins with a slash, it is treated as an absolute path name, and
66 \fIpath\fR is ignored.
69 An empty \fIpath\fR member is treated as the current directory. A slash
70 (\fB/\fR) character is not prepended at the occurrence of the first match;
71 rather, the unadorned \fIname\fR is returned.
74 \fBExample 1 \fRExample of finding the \fBls\fR command using the PATH
78 To find the \fBls\fR command using the \fBPATH\fR environment variable:
82 pathfind (getenv ("PATH"), "ls", "rx")
87 The \fBpathfind()\fR function returns a \fB(char *)\fR value containing static,
88 thread-specific data that will be overwritten upon the next call from the same
92 If the file \fIname\fR with all characteristics specified by \fImode\fR is
93 found in any of the directories specified by \fIpath\fR, then \fBpathfind()\fR
94 returns a pointer to a string containing the member of \fIpath\fR, followed by
95 a slash character (\fB/\fR), followed by \fIname\fR.
98 If no match is found, \fBpathname()\fR returns a null pointer, \fB((char *)
103 See \fBattributes\fR(5) for descriptions of the following attributes:
111 ATTRIBUTE TYPE ATTRIBUTE VALUE
119 \fBsh\fR(1), \fBtest\fR(1), \fBaccess\fR(2), \fBmknod\fR(2), \fBstat\fR(2),
120 \fBgetenv\fR(3C), \fBattributes\fR(5)
124 The string pointed to by the returned pointer is stored in an area that is
125 reused on subsequent calls to \fBpathfind()\fR. The string should not be
126 deallocated by the caller.
129 When compiling multithreaded applications, the \fB_REENTRANT\fR flag must be
130 defined on the compile line. This flag should only be used in
131 multithreadedapplications.