xref: /freebsd/contrib/pkgconf/doc/libpkgconf-path.rst (revision a3cefe7f2b4df0f70ff92d4570ce18e517af43ec)
1
2libpkgconf `path` module
3========================
4
5The `path` module provides functions for manipulating lists of paths in a cross-platform manner.  Notably,
6it is used by the `pkgconf client` to parse the ``PKG_CONFIG_PATH``, ``PKG_CONFIG_LIBDIR`` and related environment
7variables.
8
9.. c:function:: void pkgconf_path_add(const char *text, pkgconf_list_t *dirlist)
10
11   Adds a path node to a path list.  If the path is already in the list, do nothing.
12
13   :param char* text: The path text to add as a path node.
14   :param pkgconf_list_t* dirlist: The path list to add the path node to.
15   :param bool filter: Whether to perform duplicate filtering.
16   :return: nothing
17
18.. c:function:: size_t pkgconf_path_split(const char *text, pkgconf_list_t *dirlist)
19
20   Splits a given text input and inserts paths into a path list.
21
22   :param char* text: The path text to split and add as path nodes.
23   :param pkgconf_list_t* dirlist: The path list to have the path nodes added to.
24   :param bool filter: Whether to perform duplicate filtering.
25   :return: number of path nodes added to the path list
26   :rtype: size_t
27
28.. c:function:: size_t pkgconf_path_build_from_environ(const char *envvarname, const char *fallback, pkgconf_list_t *dirlist)
29
30   Adds the paths specified in an environment variable to a path list.  If the environment variable is not set,
31   an optional default set of paths is added.
32
33   :param char* envvarname: The environment variable to look up.
34   :param char* fallback: The fallback paths to use if the environment variable is not set.
35   :param pkgconf_list_t* dirlist: The path list to add the path nodes to.
36   :param bool filter: Whether to perform duplicate filtering.
37   :return: number of path nodes added to the path list
38   :rtype: size_t
39
40.. c:function:: bool pkgconf_path_match_list(const char *path, const pkgconf_list_t *dirlist)
41
42   Checks whether a path has a matching prefix in a path list.
43
44   :param char* path: The path to check against a path list.
45   :param pkgconf_list_t* dirlist: The path list to check the path against.
46   :return: true if the path list has a matching prefix, otherwise false
47   :rtype: bool
48
49.. c:function:: void pkgconf_path_copy_list(pkgconf_list_t *dst, const pkgconf_list_t *src)
50
51   Copies a path list to another path list.
52
53   :param pkgconf_list_t* dst: The path list to copy to.
54   :param pkgconf_list_t* src: The path list to copy from.
55   :return: nothing
56
57.. c:function:: void pkgconf_path_free(pkgconf_list_t *dirlist)
58
59   Releases any path nodes attached to the given path list.
60
61   :param pkgconf_list_t* dirlist: The path list to clean up.
62   :return: nothing
63
64.. c:function:: bool pkgconf_path_relocate(char *buf, size_t buflen)
65
66   Relocates a path, possibly calling normpath() on it.
67
68   :param char* buf: The path to relocate.
69   :param size_t buflen: The buffer length the path is contained in.
70   :return: true on success, false on error
71   :rtype: bool
72