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