libpkgconf path module

The path module provides functions for manipulating lists of paths in a cross-platform manner. Notably, it is used by the pkgconf client to parse the PKG_CONFIG_PATH, PKG_CONFIG_LIBDIR and related environment variables.

void pkgconf_path_add(const char *text, pkgconf_list_t *dirlist)

Adds a path node to a path list. If the path is already in the list, do nothing.

Parameters:
  • text (char*) – The path text to add as a path node.
  • dirlist (pkgconf_list_t*) – The path list to add the path node to.
  • filter (bool) – Whether to perform duplicate filtering.
Returns:

nothing

size_t pkgconf_path_split(const char *text, pkgconf_list_t *dirlist)

Splits a given text input and inserts paths into a path list.

Parameters:
  • text (char*) – The path text to split and add as path nodes.
  • dirlist (pkgconf_list_t*) – The path list to have the path nodes added to.
  • filter (bool) – Whether to perform duplicate filtering.
Returns:

number of path nodes added to the path list

Return type:

size_t

size_t pkgconf_path_build_from_environ(const char *environ, const char *fallback, pkgconf_list_t *dirlist)

Adds the paths specified in an environment variable to a path list. If the environment variable is not set, an optional default set of paths is added.

Parameters:
  • environ (char*) – The environment variable to look up.
  • fallback (char*) – The fallback paths to use if the environment variable is not set.
  • dirlist (pkgconf_list_t*) – The path list to add the path nodes to.
  • filter (bool) – Whether to perform duplicate filtering.
Returns:

number of path nodes added to the path list

Return type:

size_t

bool pkgconf_path_match_list(const char *path, const pkgconf_list_t *dirlist)

Checks whether a path has a matching prefix in a path list.

Parameters:
  • path (char*) – The path to check against a path list.
  • dirlist (pkgconf_list_t*) – The path list to check the path against.
Returns:

true if the path list has a matching prefix, otherwise false

Return type:

bool

void pkgconf_path_free(pkgconf_list_t *dirlist)

Releases any path nodes attached to the given path list.

Parameters:
  • dirlist (pkgconf_list_t*) – The path list to clean up.
Returns:

nothing

bool pkgconf_path_relocate(char *buf, size_t buflen)

Relocates a path, possibly calling normpath() or cygwin_conv_path() on it.

Parameters:
  • buf (char*) – The path to relocate.
  • buflen (size_t) – The buffer length the path is contained in.
Returns:

true on success, false on error

Return type:

bool