pkgconf/queue.c

62 lines
1.3 KiB
C
Raw Normal View History

2012-07-29 08:49:56 +00:00
/*
* queue.c
* compilation of a list of packages into a world dependency set
*
* Copyright (c) 2012 pkgconf authors (see AUTHORS).
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* This software is provided 'as is' and without any warranty, express or
* implied. In no event shall the authors be liable for any damages arising
* from the use of this software.
*/
#include "pkg.h"
#include "bsdstubs.h"
pkg_queue_t *
pkg_queue_push(pkg_queue_t *parent, const char *package)
{
pkg_queue_t *pkgq = calloc(sizeof(pkg_queue_t), 1);
pkgq->package = strdup(package);
pkgq->prev = parent;
if (pkgq->prev != NULL)
pkgq->prev->next = pkgq;
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);
}
}