1267
|
1 /* pathsearch.h: generic path searching. |
|
2 |
|
3 Copyright (C) 1993, 94 Karl Berry. |
|
4 |
|
5 This program is free software; you can redistribute it and/or modify |
|
6 it under the terms of the GNU General Public License as published by |
|
7 the Free Software Foundation; either version 2, or (at your option) |
|
8 any later version. |
|
9 |
|
10 This program 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 |
|
13 GNU General Public License for more details. |
|
14 |
|
15 You should have received a copy of the GNU General Public License |
|
16 along with this program; if not, write to the Free Software |
|
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, 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 |
|
35 /* Given a path element ELT, return a pointer to a NULL-terminated list |
|
36 of the corresponding (existing) directory or directories, with |
|
37 trailing slashes, or NULL. If ELT is the empty string, check the |
|
38 current working directory. |
|
39 |
|
40 It's up to the caller to expand ELT. This is because this routine is |
|
41 most likely only useful to be called from `kpse_path_search', which |
|
42 has already assumed expansion has been done. */ |
|
43 extern str_llist_type *kpse_element_dirs P1H(const_string elt); |
|
44 |
|
45 |
|
46 /* Call `kpse_expand' on NAME. If the result is an absolute or |
|
47 explicitly relative filename, check whether it is a readable |
|
48 (regular) file. |
|
49 |
|
50 Otherwise, look in each of the directories specified in PATH (also do |
|
51 tilde and variable expansion on elements in PATH), using a prebuilt |
|
52 db (see db.h) if it's relevant for a given path element. |
|
53 |
|
54 If the prebuilt db doesn't exist, or if MUST_EXIST is true and NAME |
|
55 isn't found in the prebuilt db, look on the filesystem. (I.e., if |
|
56 MUST_EXIST is false, and NAME isn't found in the db, do *not* look on |
|
57 the filesystem.) |
|
58 |
|
59 The caller must expand PATH. This is because it makes more sense to |
|
60 do this once, in advance, instead of for every search using it. |
|
61 |
|
62 In any case, return the complete filename if found, otherwise NULL. */ |
|
63 extern string kpse_path_search P3H(const_string path, const_string name, |
|
64 boolean must_exist); |
|
65 |
|
66 |
|
67 /* Like `kpse_path_search' with MUST_EXIST true, but return a list of |
|
68 all the filenames (or NULL if none), instead of taking the first. */ |
|
69 extern string *kpse_all_path_search P2H(const_string path, const_string name); |
|
70 |
|
71 #endif /* not KPATHSEA_PATHSEARCH_H */ |