pkg: add pkg_cflags() for calculating a mergemastered list of cflag fragments for a problem set (issue #11)

feature/tap-sh
William Pitcock 2012-05-11 20:13:03 -05:00
parent 40402298ef
commit e6cf8b4021
2 changed files with 23 additions and 0 deletions

22
pkg.c
View File

@ -647,3 +647,25 @@ pkg_traverse(pkg_t *root,
return eflags; 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;
}

1
pkg.h
View File

@ -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); 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); pkg_t *pkg_verify_dependency(pkg_dependency_t *pkgdep, unsigned int flags, unsigned int *eflags);
const char *pkg_get_comparator(pkg_dependency_t *pkgdep); const char *pkg_get_comparator(pkg_dependency_t *pkgdep);
pkg_fragment_t *pkg_cflags(pkg_t *root, int maxdepth, unsigned int flags);
/* parse.c */ /* parse.c */
pkg_t *pkg_new_from_file(const char *path, FILE *f); pkg_t *pkg_new_from_file(const char *path, FILE *f);