libpkgconf tuple module

The tuple module provides key-value mappings backed by a linked list. The key-value mapping is mainly used for variable substitution when parsing .pc files.

There are two sets of mappings: a pkgconf_pkg_t specific mapping, and a global mapping. The tuple module provides convenience wrappers for managing the global mapping, which is attached to a given client object.

void pkgconf_tuple_add_global(pkgconf_client_t *client, const char *key, const char *value)

Defines a global variable, replacing the previous declaration if one was set.

Parameters:
  • client (pkgconf_client_t*) – The pkgconf client object to modify.
  • key (char*) – The key for the mapping (variable name).
  • value (char*) – The value for the mapped entry.
Returns:

nothing

void pkgconf_tuple_find_global(const pkgconf_client_t *client, const char *key)

Looks up a global variable.

Parameters:
  • client (pkgconf_client_t*) – The pkgconf client object to access.
  • key (char*) – The key or variable name to look up.
Returns:

the contents of the variable or NULL

Return type:

char *

void pkgconf_tuple_free_global(pkgconf_client_t *client)

Delete all global variables associated with a pkgconf client object.

Parameters:
  • client (pkgconf_client_t*) – The pkgconf client object to modify.
Returns:

nothing

void pkgconf_tuple_define_global(pkgconf_client_t *client, const char *kv)

Parse and define a global variable.

Parameters:
  • client (pkgconf_client_t*) – The pkgconf client object to modify.
  • kv (char*) – The variable in the form of key=value.
Returns:

nothing

pkgconf_tuple_t *pkgconf_tuple_add(const pkgconf_client_t *client, pkgconf_list_t *list, const char *key, const char *value, bool parse)

Optionally parse and then define a variable.

Parameters:
  • client (pkgconf_client_t*) – The pkgconf client object to access.
  • list (pkgconf_list_t*) – The variable list to add the new variable to.
  • key (char*) – The name of the variable being added.
  • value (char*) – The value of the variable being added.
  • parse (bool) – Whether or not to parse the value for variable substitution.
Returns:

a variable object

Return type:

pkgconf_tuple_t *

char *pkgconf_tuple_find(const pkgconf_client_t *client, pkgconf_list_t *list, const char *key)

Look up a variable in a variable list.

Parameters:
  • client (pkgconf_client_t*) – The pkgconf client object to access.
  • list (pkgconf_list_t*) – The variable list to search.
  • key (char*) – The variable name to search for.
Returns:

the value of the variable or NULL

Return type:

char *

char *pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *vars, const char *value)

Parse an expression for variable substitution.

Parameters:
  • client (pkgconf_client_t*) – The pkgconf client object to access.
  • list (pkgconf_list_t*) – The variable list to search for variables (along side the global variable list).
  • value (char*) – The key=value string to parse.
Returns:

the variable data with any variables substituted

Return type:

char *

void pkgconf_tuple_free_entry(pkgconf_tuple_t *tuple, pkgconf_list_t *list)

Deletes a variable object, removing it from any variable lists and releasing any memory associated with it.

Parameters:
  • tuple (pkgconf_tuple_t*) – The variable object to release.
  • list (pkgconf_list_t*) – The variable list the variable object is attached to.
Returns:

nothing

void pkgconf_tuple_free(pkgconf_list_t *list)

Deletes a variable list and any variables attached to it.

Parameters:
  • list (pkgconf_list_t*) – The variable list to delete.
Returns:

nothing