diff --git a/pkg.h b/pkg.h index 96fd31f..c3f55fe 100644 --- a/pkg.h +++ b/pkg.h @@ -173,5 +173,7 @@ extern FILE *error_msgout; /* queue.c */ pkg_queue_t *pkg_queue_push(pkg_queue_t *parent, const char *package); +bool pkg_queue_compile(pkg_t *world, pkg_queue_t *head); +void pkg_queue_free(pkg_queue_t *head); #endif diff --git a/queue.c b/queue.c index 277b3f9..48fa233 100644 --- a/queue.c +++ b/queue.c @@ -28,3 +28,34 @@ pkg_queue_push(pkg_queue_t *parent, const char *package) return pkgq; } + +bool +pkg_queue_compile(pkg_t *world, pkg_queue_t *head) +{ + pkg_queue_t *pkgq; + + PKG_FOREACH_LIST_ENTRY(head, pkgq) + { + pkg_dependency_t *pkgdep; + + pkgdep = pkg_dependency_parse(world, pkgq->package); + if (pkgdep != NULL) + world->requires = pkg_dependency_append(world->requires, pkgdep); + else + return false; + } + + return true; +} + +void +pkg_queue_free(pkg_queue_t *head) +{ + pkg_queue_t *pkgq, *next_pkgq; + + PKG_FOREACH_LIST_ENTRY_SAFE(head, pkgq, next_pkgq) + { + free(pkgq->package); + free(pkgq); + } +}