annotate kpathsea/pathsearch.h @ 1267:69501f98669d

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