From e6cf8b40211840201121786ea81f1f3b9ae72c31 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Fri, 11 May 2012 20:13:03 -0500 Subject: [PATCH] pkg: add pkg_cflags() for calculating a mergemastered list of cflag fragments for a problem set (issue #11) --- pkg.c | 22 ++++++++++++++++++++++ pkg.h | 1 + 2 files changed, 23 insertions(+) diff --git a/pkg.c b/pkg.c index f274118..afd2a75 100644 --- a/pkg.c +++ b/pkg.c @@ -647,3 +647,25 @@ pkg_traverse(pkg_t *root, return eflags; } + +static void +pkg_cflags_collect(pkg_t *pkg, void *data, unsigned int flags) +{ + pkg_fragment_t **list = data; + pkg_fragment_t *frag; + (void) flags; + + PKG_FOREACH_LIST_ENTRY(pkg->cflags, frag) + *list = pkg_fragment_copy(*list, frag); +} + +pkg_fragment_t * +pkg_cflags(pkg_t *root, int maxdepth, unsigned int flags) +{ + pkg_fragment_t *head = NULL; + + pkg_traverse(root, pkg_cflags_collect, &head, maxdepth, flags); + + return head; +} + diff --git a/pkg.h b/pkg.h index 10c3c65..820dc36 100644 --- a/pkg.h +++ b/pkg.h @@ -132,6 +132,7 @@ unsigned int pkg_verify_graph(pkg_t *root, int depth, unsigned int flags); int pkg_compare_version(const char *a, const char *b); pkg_t *pkg_verify_dependency(pkg_dependency_t *pkgdep, unsigned int flags, unsigned int *eflags); const char *pkg_get_comparator(pkg_dependency_t *pkgdep); +pkg_fragment_t *pkg_cflags(pkg_t *root, int maxdepth, unsigned int flags); /* parse.c */ pkg_t *pkg_new_from_file(const char *path, FILE *f);