#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <sys/stat.h>
#include <dirent.h>
#include "conflict.h"
#include "alpm_list.h"
#include "handle.h"
#include "trans.h"
#include "util.h"
#include "log.h"
#include "cache.h"
#include "deps.h"
pmconflict_t *_alpm_conflict_new(const char *package1, const char *package2, const char *reason)
{
pmconflict_t *conflict;
ALPM_LOG_FUNC;
MALLOC(conflict, sizeof(pmconflict_t), RET_ERR(PM_ERR_MEMORY, NULL));
STRDUP(conflict->package1, package1, RET_ERR(PM_ERR_MEMORY, NULL));
STRDUP(conflict->package2, package2, RET_ERR(PM_ERR_MEMORY, NULL));
STRDUP(conflict->reason, reason, RET_ERR(PM_ERR_MEMORY, NULL));
return(conflict);
}
void _alpm_conflict_free(pmconflict_t *conflict)
{
FREE(conflict->package2);
FREE(conflict->package1);
FREE(conflict->reason);
FREE(conflict);
}
pmconflict_t *_alpm_conflict_dup(const pmconflict_t *conflict)
{
pmconflict_t *newconflict;
CALLOC(newconflict, 1, sizeof(pmconflict_t), RET_ERR(PM_ERR_MEMORY, NULL));
STRDUP(newconflict->package1, conflict->package1, RET_ERR(PM_ERR_MEMORY, NULL));
STRDUP(newconflict->package2, conflict->package2, RET_ERR(PM_ERR_MEMORY, NULL));
STRDUP(newconflict->reason, conflict->reason, RET_ERR(PM_ERR_MEMORY, NULL));
return(newconflict);
}
int _alpm_conflict_isin(pmconflict_t *needle, alpm_list_t *haystack)
{
alpm_list_t *i;
ALPM_LOG_FUNC;
for(i = haystack; i; i = i->next) {
pmconflict_t *conflict = i->data;
char *cpkg1 = conflict->package1;
char *cpkg2 = conflict->package2;
char *npkg1 = needle->package1;
char *npkg2 = needle->package2;
if((!strcmp(cpkg1, npkg1) && !strcmp(cpkg2, npkg2))
|| (!strcmp(cpkg1, npkg2) && !strcmp(cpkg2, npkg1))) {
return(1);
}
}
return(0);
}
static int does_conflict(pmpkg_t *pkg1, const char *conflict, pmpkg_t *pkg2)
{
const char *pkg1name = alpm_pkg_get_name(pkg1);
const char *pkg2name = alpm_pkg_get_name(pkg2);
pmdepend_t *conf = _alpm_splitdep(conflict);
int match = 0;
match = alpm_depcmp(pkg2, conf);
|