xref: /freebsd/contrib/pkgconf/doc/libpkgconf-tuple.rst (revision a3cefe7f2b4df0f70ff92d4570ce18e517af43ec)
1
2libpkgconf `tuple` module
3=========================
4
5The `tuple` module provides key-value mappings backed by a linked list.  The key-value
6mapping is mainly used for variable substitution when parsing .pc files.
7
8There are two sets of mappings: a ``pkgconf_pkg_t`` specific mapping, and a `global` mapping.
9The `tuple` module provides convenience wrappers for managing the `global` mapping, which is
10attached to a given client object.
11
12.. c:function:: void pkgconf_tuple_add_global(pkgconf_client_t *client, const char *key, const char *value)
13
14   Defines a global variable, replacing the previous declaration if one was set.
15
16   :param pkgconf_client_t* client: The pkgconf client object to modify.
17   :param char* key: The key for the mapping (variable name).
18   :param char* value: The value for the mapped entry.
19   :return: nothing
20
21.. c:function:: void pkgconf_tuple_find_global(const pkgconf_client_t *client, const char *key)
22
23   Looks up a global variable.
24
25   :param pkgconf_client_t* client: The pkgconf client object to access.
26   :param char* key: The key or variable name to look up.
27   :return: the contents of the variable or ``NULL``
28   :rtype: char *
29
30.. c:function:: void pkgconf_tuple_free_global(pkgconf_client_t *client)
31
32   Delete all global variables associated with a pkgconf client object.
33
34   :param pkgconf_client_t* client: The pkgconf client object to modify.
35   :return: nothing
36
37.. c:function:: void pkgconf_tuple_define_global(pkgconf_client_t *client, const char *kv)
38
39   Parse and define a global variable.
40
41   :param pkgconf_client_t* client: The pkgconf client object to modify.
42   :param char* kv: The variable in the form of ``key=value``.
43   :return: nothing
44
45.. c:function:: pkgconf_tuple_t *pkgconf_tuple_add(const pkgconf_client_t *client, pkgconf_list_t *list, const char *key, const char *value, bool parse)
46
47   Optionally parse and then define a variable.
48
49   :param pkgconf_client_t* client: The pkgconf client object to access.
50   :param pkgconf_list_t* list: The variable list to add the new variable to.
51   :param char* key: The name of the variable being added.
52   :param char* value: The value of the variable being added.
53   :param bool parse: Whether or not to parse the value for variable substitution.
54   :return: a variable object
55   :rtype: pkgconf_tuple_t *
56
57.. c:function:: char *pkgconf_tuple_find(const pkgconf_client_t *client, pkgconf_list_t *list, const char *key)
58
59   Look up a variable in a variable list.
60
61   :param pkgconf_client_t* client: The pkgconf client object to access.
62   :param pkgconf_list_t* list: The variable list to search.
63   :param char* key: The variable name to search for.
64   :return: the value of the variable or ``NULL``
65   :rtype: char *
66
67.. c:function:: char *pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *vars, const char *value, unsigned int flags)
68
69   Parse an expression for variable substitution.
70
71   :param pkgconf_client_t* client: The pkgconf client object to access.
72   :param pkgconf_list_t* list: The variable list to search for variables (along side the global variable list).
73   :param char* value: The ``key=value`` string to parse.
74   :param uint flags: Any flags to consider while parsing.
75   :return: the variable data with any variables substituted
76   :rtype: char *
77
78.. c:function:: void pkgconf_tuple_free_entry(pkgconf_tuple_t *tuple, pkgconf_list_t *list)
79
80   Deletes a variable object, removing it from any variable lists and releasing any memory associated
81   with it.
82
83   :param pkgconf_tuple_t* tuple: The variable object to release.
84   :param pkgconf_list_t* list: The variable list the variable object is attached to.
85   :return: nothing
86
87.. c:function:: void pkgconf_tuple_free(pkgconf_list_t *list)
88
89   Deletes a variable list and any variables attached to it.
90
91   :param pkgconf_list_t* list: The variable list to delete.
92   :return: nothing
93