#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "deps.h"
#include "alpm_list.h"
#include "util.h"
#include "log.h"
#include "graph.h"
#include "package.h"
#include "db.h"
#include "cache.h"
#include "handle.h"
void _alpm_dep_free(pmdepend_t *dep)
{
FREE(dep->name);
FREE(dep->version);
FREE(dep);
}
pmdepmissing_t *_alpm_depmiss_new(const char *target, pmdepend_t *dep,
const char *causingpkg)
{
pmdepmissing_t *miss;
ALPM_LOG_FUNC;
MALLOC(miss, sizeof(pmdepmissing_t), RET_ERR(PM_ERR_MEMORY, NULL));
STRDUP(miss->target, target, RET_ERR(PM_ERR_MEMORY, NULL));
miss->depend = _alpm_dep_dup(dep);
STRDUP(miss->causingpkg, causingpkg, RET_ERR(PM_ERR_MEMORY, NULL));
return(miss);
}
void _alpm_depmiss_free(pmdepmissing_t *miss)
{
_alpm_dep_free(miss->depend);
FREE(miss->target);
FREE(miss->causingpkg);
FREE(miss);
}
static alpm_list_t *dep_graph_init(alpm_list_t *targets)
{
alpm_list_t *i, *j;
alpm_list_t *vertices = NULL;
for(i = targets; i; i = i->next) {
pmgraph_t *vertex = _alpm_graph_new();
vertex->data = (void *)i->data;
vertices = alpm_list_add(vertices, vertex);
}
for(i = vertices; i; i = i->next) {
pmgraph_t *vertex_i = i->data;
pmpkg_t *p_i = vertex_i->data;
TODO
for(j = vertices; j; j = j->next) {
pmgraph_t *vertex_j = j->data;
pmpkg_t *p_j = vertex_j->data;
if(_alpm_dep_edge(p_i, p_j)) {
vertex_i->children =
alpm_list_add(vertex_i->children, vertex_j);
}
}
vertex_i->childptr = vertex_i->children;
}
return(vertices);
}
alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, int reverse)
{
alpm_list_t *newtargs = NULL;
alpm_list_t *vertices = NULL;
alpm_list_t *vptr;
pmgraph_t *vertex;
ALPM_LOG_FUNC;
if(targets == NULL) {
return(NULL
|