summaryrefslogtreecommitdiff
path: root/include/pathsrch.h
blob: eb227e6ec3e415b6c8b7d0f2e8d82478f9067a89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* pathsrch.h: environment-variable path searching for files, possibly
   in subdirectories.

Copyright (C) 1992, 2011 Free Software Foundation, Inc.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */

#ifndef PATHSEARCH_H
#define PATHSEARCH_H

#include "types.h"


/* Look for FILENAME in each of the directories given in the DIR_LIST
   array.  (Unless DIR_LIST is null, or FILENAME is absolute or
   explicitly relative, in which case we just look at FILENAME.)  Return
   the complete pathname of the first readable file found, or NULL.  */
extern string find_path_filename P2H(string filename, string *dir_list);

/* Return a NULL-terminated array of all the directory names in the
   value of the environment variable ENV_NAME (or DEFAULT_PATH if it is
   not set).  Each directory in the list ends with the directory separator,
   e.g., `/'.
   
   A leading or trailing path separator (e.g., `:') in the value of
   ENV_NAME is replaced by DEFAULT_PATH.
   
   If any element of the path ends with a double directory separator
   (e.g., `foo//'), it is replaced by all its subdirectories.  */
extern string *initialize_path_list P2H(string env_name, string default_path);

/* Replace a leading or trailing `:' in ENV_PATH with DEFAULT_PATH.  If
   neither is present, return ENV_PATH if that is non-null, else
   DEFAULT_PATH.  */
extern string expand_default P2H(string env_path, string default_path);

/* Replace a leading ~ or ~name in FILENAME with getenv ("HOME") or
   name's home directory.  */
extern string expand_tilde P1H(string filename);

#endif /* not PATHSEARCH_H */