dependency: add pkgconf_dependency_add for programmatically adding a dependency object

feature/tap-sh
William Pitcock 2016-08-26 23:40:15 -05:00
parent 21c7355ca8
commit d72ece6a5f
2 changed files with 13 additions and 3 deletions

View File

@ -36,7 +36,7 @@ typedef enum {
#define DEBUG_PARSE 0
static inline pkgconf_dependency_t *
pkgconf_dependency_add(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(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;
@ -53,6 +53,15 @@ pkgconf_dependency_add(pkgconf_list_t *list, const char *package, size_t package
return dep;
}
pkgconf_dependency_t *
pkgconf_dependency_add(pkgconf_list_t *list, const char *package, const char *version, pkgconf_pkg_comparator_t compare)
{
if (version != NULL)
return pkgconf_dependency_addraw(list, package, strlen(package), version, strlen(version), compare);
return pkgconf_dependency_addraw(list, package, strlen(package), NULL, 0, compare);
}
void
pkgconf_dependency_append(pkgconf_list_t *list, pkgconf_dependency_t *tail)
{
@ -146,7 +155,7 @@ pkgconf_dependency_parse_str(pkgconf_list_t *deplist_head, const char *depends)
if (state == OUTSIDE_MODULE)
{
pkgconf_dependency_add(deplist_head, package, package_sz, NULL, 0, compare);
pkgconf_dependency_addraw(deplist_head, package, package_sz, NULL, 0, compare);
compare = PKGCONF_CMP_ANY;
package_sz = 0;
@ -190,7 +199,7 @@ pkgconf_dependency_parse_str(pkgconf_list_t *deplist_head, const char *depends)
version_sz = ptr - vstart;
state = OUTSIDE_MODULE;
pkgconf_dependency_add(deplist_head, package, package_sz, version, version_sz, compare);
pkgconf_dependency_addraw(deplist_head, package, package_sz, version, version_sz, compare);
compare = PKGCONF_CMP_ANY;
cnameptr = cmpname;

View File

@ -168,6 +168,7 @@ void pkgconf_dependency_parse_str(pkgconf_list_t *deplist_head, const char *depe
void pkgconf_dependency_parse(pkgconf_pkg_t *pkg, pkgconf_list_t *deplist_head, const char *depends);
void pkgconf_dependency_append(pkgconf_list_t *list, pkgconf_dependency_t *tail);
void pkgconf_dependency_free(pkgconf_list_t *list);
pkgconf_dependency_t *pkgconf_dependency_add(pkgconf_list_t *list, const char *package, const char *version, pkgconf_pkg_comparator_t compare);
/* argvsplit.c */
int pkgconf_argv_split(const char *src, int *argc, char ***argv);