2999
|
1 /* pathsearch.h: mostly-generic path searching. |
|
2 |
|
3 Copyright (C) 1993, 94, 96, 97 Karl Berry. |
|
4 |
|
5 This library is free software; you can redistribute it and/or |
|
6 modify it under the terms of the GNU Library General Public |
|
7 License as published by the Free Software Foundation; either |
|
8 version 2 of the License, or (at your option) any later version. |
|
9 |
|
10 This library is distributed in the hope that it will be useful, |
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 Library General Public License for more details. |
|
14 |
|
15 You should have received a copy of the GNU Library General Public |
|
16 License along with this library; if not, write to the Free Software |
|
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
|
18 |
|
19 #ifndef KPATHSEA_PATHSEARCH_H |
|
20 #define KPATHSEA_PATHSEARCH_H |
|
21 |
|
22 #include <kpathsea/c-proto.h> |
|
23 #include <kpathsea/str-llist.h> |
|
24 #include <kpathsea/types.h> |
|
25 |
|
26 /* If PATH is non-null, return its first element (as defined by |
|
27 IS_ENV_SEP). If it's NULL, return the next element in the previous |
|
28 path, a la strtok. Leading, trailing, or doubled colons result in |
|
29 the empty string. When at the end of PATH, return NULL. In any |
|
30 case, return a pointer to an area that may be overwritten on |
|
31 subsequent calls. */ |
|
32 extern string kpse_path_element P1H(const_string path); |
|
33 |
|
34 /* Like `kpse_path_element', but for filename components (using |
|
35 IS_DIR_SEP). Uses same area as `kpse_path_element'. */ |
|
36 extern string kpse_filename_component P1H(const_string path); |
|
37 |
|
38 |
|
39 /* Given a path element ELT, return a pointer to a NULL-terminated list |
|
40 of the corresponding (existing) directory or directories, with |
|
41 trailing slashes, or NULL. If ELT is the empty string, check the |
|
42 current working directory. |
|
43 |
|
44 It's up to the caller to expand ELT. This is because this routine is |
|
45 most likely only useful to be called from `kpse_path_search', which |
|
46 has already assumed expansion has been done. */ |
|
47 extern str_llist_type *kpse_element_dirs P1H(const_string elt); |
|
48 |
|
49 |
|
50 /* Call `kpse_expand' on NAME. If the result is an absolute or |
|
51 explicitly relative filename, check whether it is a readable |
|
52 (regular) file. |
|
53 |
|
54 Otherwise, look in each of the directories specified in PATH (also do |
|
55 tilde and variable expansion on elements in PATH), using a prebuilt |
|
56 db (see db.h) if it's relevant for a given path element. |
|
57 |
|
58 If the prebuilt db doesn't exist, or if MUST_EXIST is true and NAME |
|
59 isn't found in the prebuilt db, look on the filesystem. (I.e., if |
|
60 MUST_EXIST is false, and NAME isn't found in the db, do *not* look on |
|
61 the filesystem.) |
|
62 |
|
63 The caller must expand PATH. This is because it makes more sense to |
|
64 do this once, in advance, instead of for every search using it. |
|
65 |
|
66 In any case, return the complete filename if found, otherwise NULL. */ |
|
67 extern string kpse_path_search P3H(const_string path, const_string name, |
|
68 boolean must_exist); |
|
69 |
|
70 |
|
71 /* Like `kpse_path_search' with MUST_EXIST true, but return a list of |
|
72 all the filenames (or NULL if none), instead of taking the first. */ |
|
73 extern string *kpse_all_path_search P2H(const_string path, const_string name); |
|
74 |
|
75 #endif /* not KPATHSEA_PATHSEARCH_H */ |
|
76 |