libpkgconf: dependency: make dependency_to_str() private, use a caller-supplied buffer for reentrancy
parent
615bab3df9
commit
1252d7ae6a
|
@ -5,14 +5,6 @@ libpkgconf `dependency` module
|
||||||
The `dependency` module provides support for building `dependency lists` (the basic component of the overall `dependency graph`) and
|
The `dependency` module provides support for building `dependency lists` (the basic component of the overall `dependency graph`) and
|
||||||
`dependency nodes` which store dependency information.
|
`dependency nodes` which store dependency information.
|
||||||
|
|
||||||
.. c:function:: const char *pkgconf_dependency_to_str(const pkgconf_dependency_t *dep)
|
|
||||||
|
|
||||||
Renders a dependency to a string.
|
|
||||||
|
|
||||||
:param pkgconf_dependency_t* dep: The dependency to render.
|
|
||||||
:return: The dependency rendered as a string.
|
|
||||||
:rtype: const char *
|
|
||||||
|
|
||||||
.. c:function:: pkgconf_dependency_t *pkgconf_dependency_add(pkgconf_list_t *list, const char *package, const char *version, pkgconf_pkg_comparator_t compare)
|
.. c:function:: pkgconf_dependency_t *pkgconf_dependency_add(pkgconf_list_t *list, const char *package, const char *version, pkgconf_pkg_comparator_t compare)
|
||||||
|
|
||||||
Adds a parsed dependency to a dependency list as a dependency node.
|
Adds a parsed dependency to a dependency list as a dependency node.
|
||||||
|
|
|
@ -36,38 +36,26 @@ typedef enum {
|
||||||
|
|
||||||
#define DEBUG_PARSE 0
|
#define DEBUG_PARSE 0
|
||||||
|
|
||||||
/*
|
static const char *
|
||||||
* !doc
|
dependency_to_str(const pkgconf_dependency_t *dep, char *buf, size_t buflen)
|
||||||
*
|
|
||||||
* .. c:function:: const char *pkgconf_dependency_to_str(const pkgconf_dependency_t *dep)
|
|
||||||
*
|
|
||||||
* Renders a dependency to a string.
|
|
||||||
*
|
|
||||||
* :param pkgconf_dependency_t* dep: The dependency to render.
|
|
||||||
* :return: The dependency rendered as a string.
|
|
||||||
* :rtype: const char *
|
|
||||||
*/
|
|
||||||
const char *
|
|
||||||
pkgconf_dependency_to_str(const pkgconf_dependency_t *dep)
|
|
||||||
{
|
{
|
||||||
static char outbuf[PKGCONF_BUFSIZE];
|
pkgconf_strlcpy(buf, dep->package, buflen);
|
||||||
|
|
||||||
pkgconf_strlcpy(outbuf, dep->package, sizeof outbuf);
|
|
||||||
if (dep->version != NULL)
|
if (dep->version != NULL)
|
||||||
{
|
{
|
||||||
pkgconf_strlcat(outbuf, " ", sizeof outbuf);
|
pkgconf_strlcat(buf, " ", buflen);
|
||||||
pkgconf_strlcat(outbuf, pkgconf_pkg_get_comparator(dep), sizeof outbuf);
|
pkgconf_strlcat(buf, pkgconf_pkg_get_comparator(dep), buflen);
|
||||||
pkgconf_strlcat(outbuf, " ", sizeof outbuf);
|
pkgconf_strlcat(buf, " ", buflen);
|
||||||
pkgconf_strlcat(outbuf, dep->version, sizeof outbuf);
|
pkgconf_strlcat(buf, dep->version, buflen);
|
||||||
}
|
}
|
||||||
|
|
||||||
return outbuf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline pkgconf_dependency_t *
|
static inline pkgconf_dependency_t *
|
||||||
pkgconf_dependency_addraw(const pkgconf_client_t *client, pkgconf_list_t *list, const char *package, size_t package_sz, const char *version, size_t version_sz, pkgconf_pkg_comparator_t compare)
|
pkgconf_dependency_addraw(const pkgconf_client_t *client, pkgconf_list_t *list, const char *package, size_t package_sz, const char *version, size_t version_sz, pkgconf_pkg_comparator_t compare)
|
||||||
{
|
{
|
||||||
pkgconf_dependency_t *dep;
|
pkgconf_dependency_t *dep;
|
||||||
|
char depbuf[PKGCONF_BUFSIZE];
|
||||||
|
|
||||||
dep = calloc(sizeof(pkgconf_dependency_t), 1);
|
dep = calloc(sizeof(pkgconf_dependency_t), 1);
|
||||||
dep->package = pkgconf_strndup(package, package_sz);
|
dep->package = pkgconf_strndup(package, package_sz);
|
||||||
|
@ -77,7 +65,7 @@ pkgconf_dependency_addraw(const pkgconf_client_t *client, pkgconf_list_t *list,
|
||||||
|
|
||||||
dep->compare = compare;
|
dep->compare = compare;
|
||||||
|
|
||||||
PKGCONF_TRACE(client, "added dependency [%s] to list @%p", pkgconf_dependency_to_str(dep), list);
|
PKGCONF_TRACE(client, "added dependency [%s] to list @%p", dependency_to_str(dep, depbuf, sizeof depbuf), list);
|
||||||
pkgconf_node_insert_tail(&dep->iter, dep, list);
|
pkgconf_node_insert_tail(&dep->iter, dep, list);
|
||||||
|
|
||||||
return dep;
|
return dep;
|
||||||
|
|
|
@ -258,7 +258,6 @@ PKGCONF_API void pkgconf_dependency_parse_str(const pkgconf_client_t *client, pk
|
||||||
PKGCONF_API void pkgconf_dependency_parse(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, pkgconf_list_t *deplist_head, const char *depends);
|
PKGCONF_API void pkgconf_dependency_parse(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, pkgconf_list_t *deplist_head, const char *depends);
|
||||||
PKGCONF_API void pkgconf_dependency_append(pkgconf_list_t *list, pkgconf_dependency_t *tail);
|
PKGCONF_API void pkgconf_dependency_append(pkgconf_list_t *list, pkgconf_dependency_t *tail);
|
||||||
PKGCONF_API void pkgconf_dependency_free(pkgconf_list_t *list);
|
PKGCONF_API void pkgconf_dependency_free(pkgconf_list_t *list);
|
||||||
PKGCONF_API const char *pkgconf_dependency_to_str(const pkgconf_dependency_t *dep);
|
|
||||||
PKGCONF_API pkgconf_dependency_t *pkgconf_dependency_add(const pkgconf_client_t *client, pkgconf_list_t *list, const char *package, const char *version, pkgconf_pkg_comparator_t compare);
|
PKGCONF_API pkgconf_dependency_t *pkgconf_dependency_add(const pkgconf_client_t *client, pkgconf_list_t *list, const char *package, const char *version, pkgconf_pkg_comparator_t compare);
|
||||||
|
|
||||||
/* argvsplit.c */
|
/* argvsplit.c */
|
||||||
|
|
Loading…
Reference in New Issue