libpkgconf pkg module¶
The pkg module provides dependency resolution services and the overall .pc file parsing routines.
-
pkgconf_pkg_t *
pkgconf_pkg_new_from_file
(const pkgconf_client_t *client, const char *filename, FILE *f, unsigned int flags)¶ Parse a .pc file into a pkgconf_pkg_t object structure.
Parameters: - client (pkgconf_client_t*) – The pkgconf client object to use for dependency resolution.
- filename (char*) – The filename of the package file (including full path).
- f (FILE*) – The file object to read from.
- flags (uint) – The flags to use when parsing.
Returns: A
pkgconf_pkg_t
object which contains the package data.Return type: pkgconf_pkg_t *
-
void
pkgconf_pkg_free
(pkgconf_client_t *client, pkgconf_pkg_t *pkg)¶ Releases all releases for a given
pkgconf_pkg_t
object.Parameters: - client (pkgconf_client_t*) – The client which owns the
pkgconf_pkg_t
object, pkg. - pkg (pkgconf_pkg_t*) – The package to free.
Returns: nothing
- client (pkgconf_client_t*) – The client which owns the
-
pkgconf_pkg_t *
pkgconf_pkg_ref
(const pkgconf_client_t *client, pkgconf_pkg_t *pkg)¶ Adds an additional reference to the package object.
Parameters: - client (pkgconf_client_t*) – The pkgconf client object which owns the package being referenced.
- pkg (pkgconf_pkg_t*) – The package object being referenced.
Returns: The package itself with an incremented reference count.
Return type: pkgconf_pkg_t *
-
void
pkgconf_pkg_unref
(pkgconf_client_t *client, pkgconf_pkg_t *pkg)¶ Releases a reference on the package object. If the reference count is 0, then also free the package.
Parameters: - client (pkgconf_client_t*) – The pkgconf client object which owns the package being dereferenced.
- pkg (pkgconf_pkg_t*) – The package object being dereferenced.
Returns: nothing
-
pkgconf_pkg_t *
pkgconf_scan_all
(pkgconf_client_t *client, void *data, pkgconf_pkg_iteration_func_t func)¶ Iterates over all packages found in the package directory list, running
func
on them. Iffunc
returns true, then stop iteration and return the last iterated package.Parameters: - client (pkgconf_client_t*) – The pkgconf client object to use for dependency resolution.
- data (void*) – An opaque pointer to data to provide the iteration function with.
- func (pkgconf_pkg_iteration_func_t) – A function which is called for each package to determine if the package matches,
always return
false
to iterate over all packages.
Returns: A package object reference if one is found by the scan function, else
NULL
.Return type: pkgconf_pkg_t *
-
pkgconf_pkg_t *
pkgconf_pkg_find
(pkgconf_client_t *client, const char *name)¶ Search for a package.
Parameters: - client (pkgconf_client_t*) – The pkgconf client object to use for dependency resolution.
- name (char*) – The name of the package atom to use for searching.
Returns: A package object reference if the package was found, else
NULL
.Return type: pkgconf_pkg_t *
-
int
pkgconf_compare_version
(const char *a, const char *b)¶ Compare versions using RPM version comparison rules as described in the LSB.
Parameters: - a (char*) – The first version to compare in the pair.
- b (char*) – The second version to compare in the pair.
Returns: -1 if the first version is less than, 0 if both versions are equal, 1 if the second version is less than.
Return type: int
-
pkgconf_pkg_t *
pkgconf_builtin_pkg_get
(const char *name)¶ Looks up a built-in package. The package should not be freed or dereferenced.
Parameters: - name (char*) – An atom corresponding to a built-in package to search for.
Returns: the built-in package if present, else
NULL
.Return type: pkgconf_pkg_t *
-
const char *
pkgconf_pkg_get_comparator
(const pkgconf_dependency_t *pkgdep)¶ Returns the comparator used in a depgraph dependency node as a string.
Parameters: - pkgdep (pkgconf_dependency_t*) – The depgraph dependency node to return the comparator for.
Returns: A string matching the comparator or
"???"
.Return type: char *
-
pkgconf_pkg_comparator_t
pkgconf_pkg_comparator_lookup_by_name
(const char *name)¶ Look up the appropriate comparator bytecode in the comparator set (defined in
pkg.c
, seepkgconf_pkg_comparator_names
andpkgconf_pkg_comparator_impls
).Parameters: - name (char*) – The comparator to look up by name.
Returns: The comparator bytecode if found, else
PKGCONF_CMP_ANY
.Return type: pkgconf_pkg_comparator_t
-
pkgconf_pkg_t *
pkgconf_pkg_verify_dependency
(pkgconf_client_t *client, pkgconf_dependency_t *pkgdep, unsigned int *eflags)¶ Verify a pkgconf_dependency_t node in the depgraph. If the dependency is solvable, return the appropriate
pkgconf_pkg_t
object, elseNULL
.Parameters: - client (pkgconf_client_t*) – The pkgconf client object to use for dependency resolution.
- pkgdep (pkgconf_dependency_t*) – The dependency graph node to solve.
- eflags (uint*) – An optional pointer that, if set, will be populated with an error code from the resolver.
Returns: On success, the appropriate
pkgconf_pkg_t
object to solve the dependency, elseNULL
.Return type: pkgconf_pkg_t *
-
unsigned int
pkgconf_pkg_verify_graph
(pkgconf_client_t *client, pkgconf_pkg_t *root, int depth)¶ Verify the graph dependency nodes are satisfiable by walking the tree using
pkgconf_pkg_traverse()
.Parameters: - client (pkgconf_client_t*) – The pkgconf client object to use for dependency resolution.
- root (pkgconf_pkg_t*) – The root entry in the package dependency graph which should contain the top-level dependencies to resolve.
- depth (int) – The maximum allowed depth for dependency resolution.
Returns: On success,
PKGCONF_PKG_ERRF_OK
(0), else an error code.Return type: unsigned int
-
unsigned int
pkgconf_pkg_traverse
(pkgconf_client_t *client, pkgconf_pkg_t *root, pkgconf_pkg_traverse_func_t func, void *data, int maxdepth, unsigned int skip_flags)¶ Walk and resolve the dependency graph up to maxdepth levels.
Parameters: - client (pkgconf_client_t*) – The pkgconf client object to use for dependency resolution.
- root (pkgconf_pkg_t*) – The root of the dependency graph.
- func (pkgconf_pkg_traverse_func_t) – A traversal function to call for each resolved node in the dependency graph.
- data (void*) – An opaque pointer to data to be passed to the traversal function.
- maxdepth (int) – The maximum depth to walk the dependency graph for. -1 means infinite recursion.
- skip_flags (uint) – Skip over dependency nodes containing the specified flags. A setting of 0 skips no dependency nodes.
Returns: PKGCONF_PKG_ERRF_OK
on success, else an error code.Return type: unsigned int
-
int
pkgconf_pkg_cflags
(pkgconf_client_t *client, pkgconf_pkg_t *root, pkgconf_list_t *list, int maxdepth)¶ Walks a dependency graph and extracts relevant
CFLAGS
fragments.Parameters: - client (pkgconf_client_t*) – The pkgconf client object to use for dependency resolution.
- root (pkgconf_pkg_t*) – The root of the dependency graph.
- list (pkgconf_list_t*) – The fragment list to add the extracted
CFLAGS
fragments to. - maxdepth (int) – The maximum allowed depth for dependency resolution. -1 means infinite recursion.
Returns: PKGCONF_PKG_ERRF_OK
if successful, otherwise an error code.Return type: unsigned int
-
int
pkgconf_pkg_libs
(pkgconf_client_t *client, pkgconf_pkg_t *root, pkgconf_list_t *list, int maxdepth)¶ Walks a dependency graph and extracts relevant
LIBS
fragments.Parameters: - client (pkgconf_client_t*) – The pkgconf client object to use for dependency resolution.
- root (pkgconf_pkg_t*) – The root of the dependency graph.
- list (pkgconf_list_t*) – The fragment list to add the extracted
LIBS
fragments to. - maxdepth (int) – The maximum allowed depth for dependency resolution. -1 means infinite recursion.
Returns: PKGCONF_PKG_ERRF_OK
if successful, otherwise an error code.Return type: unsigned int