Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAurelien Foret <aurelien@archlinux.org>2005-03-29 20:31:03 +0000
committerAurelien Foret <aurelien@archlinux.org>2005-03-29 20:31:03 +0000
commit95ea99e1973c03abe73b7c20ded9a24905420291 (patch)
tree32c7887786916842bf8e9f2dd93b8cd03c44f5d0
parente5389ddc620bb4584a29c8e36ea1d2584f013f7f (diff)
Turned pmdepmissing_t into an opaque structure
-rw-r--r--lib/libalpm/add.c7
-rw-r--r--lib/libalpm/alpm.c25
-rw-r--r--lib/libalpm/alpm.h57
-rw-r--r--lib/libalpm/deps.c71
-rw-r--r--lib/libalpm/deps.h14
5 files changed, 103 insertions, 71 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index 1651304f..034643ef 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -150,14 +150,13 @@ int add_prepare(pmdb_t *db, pmtrans_t *trans, PMList **data)
for(j = lp; j; j = j->next) {
pmdepmissing_t* miss = j->data;
- if(miss->type == PM_DEP_DEPEND || miss->type == PM_DEP_REQUIRED) {
+ if(miss->type == PM_DEP_TYPE_DEPEND || miss->type == PM_DEP_TYPE_REQUIRED) {
if(!errorout) {
errorout = 1;
}
if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) {
FREELIST(lp);
- /* ORE, needed or not ?
- FREELIST(*data);*/
+ FREELIST(*data);
RET_ERR(PM_ERR_MEMORY, -1);
}
*miss = *(pmdepmissing_t*)j->data;
@@ -173,7 +172,7 @@ int add_prepare(pmdb_t *db, pmtrans_t *trans, PMList **data)
_alpm_log(PM_LOG_FLOW2, "looking for conflicts");
for(j = lp; j; j = j->next) {
pmdepmissing_t* miss = (pmdepmissing_t *)j->data;
- if(miss->type == PM_DEP_CONFLICT) {
+ if(miss->type == PM_DEP_TYPE_CONFLICT) {
if(!errorout) {
errorout = 1;
}
diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c
index da879569..e4000911 100644
--- a/lib/libalpm/alpm.c
+++ b/lib/libalpm/alpm.c
@@ -565,6 +565,31 @@ int alpm_trans_release()
}
/*
+ * Dependencies
+ */
+
+void *alpm_dep_getinfo(pmdepmissing_t *miss, unsigned char parm)
+{
+ void *data;
+
+ /* Sanity checks */
+ ASSERT(miss != NULL, return(NULL));
+
+ switch(parm) {
+ case PM_DEP_TARGET: data = (void *)(int)miss->target; break;
+ case PM_DEP_TYPE: data = (void *)(int)miss->type; break;
+ case PM_DEP_MOD: data = (void *)(int)miss->depend.mod; break;
+ case PM_DEP_NAME: data = miss->depend.name; break;
+ case PM_DEP_VERSION: data = miss->depend.version; break;
+ default:
+ data = NULL;
+ break;
+ }
+
+ return(data);
+}
+
+/*
* Log facilities
*/
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 41a36a0d..451196f7 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -38,9 +38,7 @@ typedef struct __pmpkg_t PM_PKG;
typedef struct __pmgrp_t PM_GRP;
typedef struct __pmsync_t PM_SYNC;
typedef struct __pmtrans_t PM_TRANS;
-/* ORE
-typedef struct __pmdepend_t PM_DEP;
-typedef struct __pmdepmissing_t PM_DEPMISS; */
+typedef struct __pmdepmissing_t PM_DEPMISS;
/*
* Library
@@ -226,33 +224,6 @@ enum {
PM_TRANS_TARGETS
};
-/* Dependencies */
-enum {
- PM_DEP_ANY = 1,
- PM_DEP_EQ,
- PM_DEP_GE,
- PM_DEP_LE
-};
-enum {
- PM_DEP_DEPEND = 1,
- PM_DEP_REQUIRED,
- PM_DEP_CONFLICT
-};
-
-/* ORE
-to be deprecated in favor of PM_DEP and PM_DEPMISS (opaque) */
-typedef struct __pmdepend_t {
- unsigned short mod;
- char name[256];
- char version[64];
-} pmdepend_t;
-
-typedef struct __pmdepmissing_t {
- unsigned char type;
- char target[256];
- pmdepend_t depend;
-} pmdepmissing_t;
-
void *alpm_trans_getinfo(unsigned char parm);
int alpm_trans_init(unsigned char type, unsigned char flags, alpm_trans_cb cb);
int alpm_trans_addtarget(char *target);
@@ -261,6 +232,32 @@ int alpm_trans_commit();
int alpm_trans_release();
/*
+ * Dependencies
+ */
+
+enum {
+ PM_DEP_MOD_ANY = 1,
+ PM_DEP_MOD_EQ,
+ PM_DEP_MOD_GE,
+ PM_DEP_MOD_LE
+};
+enum {
+ PM_DEP_TYPE_DEPEND = 1,
+ PM_DEP_TYPE_REQUIRED,
+ PM_DEP_TYPE_CONFLICT
+};
+/* Dependencies parameters */
+enum {
+ PM_DEP_TARGET = 1,
+ PM_DEP_TYPE,
+ PM_DEP_MOD,
+ PM_DEP_NAME,
+ PM_DEP_VERSION
+};
+
+void *alpm_dep_getinfo(PM_DEPMISS *miss, unsigned char parm);
+
+/*
* PM_LIST helpers
*/
PM_LIST *alpm_list_first(PM_LIST *list);
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index 838c7bbe..a0490d42 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -126,7 +126,7 @@ PMList *sortbydeps(PMList *targets, int mode)
* with depmod operators.
*
*/
-PMList *checkdeps(pmdb_t *db, unsigned short op, PMList *packages)
+PMList *checkdeps(pmdb_t *db, unsigned char op, PMList *packages)
{
pmpkg_t *info = NULL;
pmdepend_t depend;
@@ -186,7 +186,7 @@ PMList *checkdeps(pmdb_t *db, unsigned short op, PMList *packages)
FREELISTPTR(provides);
}
found = 0;
- if(depend.mod == PM_DEP_ANY) {
+ if(depend.mod == PM_DEP_MOD_ANY) {
found = 1;
} else {
/* note that we use the version from the NEW package in the check */
@@ -198,15 +198,15 @@ PMList *checkdeps(pmdb_t *db, unsigned short op, PMList *packages)
}
cmp = rpmvercmp(ver, depend.version);
switch(depend.mod) {
- case PM_DEP_EQ: found = (cmp == 0); break;
- case PM_DEP_GE: found = (cmp >= 0); break;
- case PM_DEP_LE: found = (cmp <= 0); break;
+ case PM_DEP_MOD_EQ: found = (cmp == 0); break;
+ case PM_DEP_MOD_GE: found = (cmp >= 0); break;
+ case PM_DEP_MOD_LE: found = (cmp <= 0); break;
}
FREE(ver);
}
if(!found) {
MALLOC(miss, sizeof(pmdepmissing_t));
- miss->type = PM_DEP_REQUIRED;
+ miss->type = PM_DEP_TYPE_REQUIRED;
miss->depend.mod = depend.mod;
STRNCPY(miss->target, p->name, PKG_NAME_LEN);
STRNCPY(miss->depend.name, depend.name, PKG_NAME_LEN);
@@ -234,8 +234,8 @@ PMList *checkdeps(pmdb_t *db, unsigned short op, PMList *packages)
pmpkg_t *dp = (pmpkg_t *)k->data;
if(!strcmp(j->data, dp->name)) {
MALLOC(miss, sizeof(pmdepmissing_t));
- miss->type = PM_DEP_CONFLICT;
- miss->depend.mod = PM_DEP_ANY;
+ miss->type = PM_DEP_TYPE_CONFLICT;
+ miss->depend.mod = PM_DEP_MOD_ANY;
miss->depend.version[0] = '\0';
STRNCPY(miss->target, tp->name, PKG_NAME_LEN);
STRNCPY(miss->depend.name, dp->name, PKG_NAME_LEN);
@@ -249,8 +249,8 @@ PMList *checkdeps(pmdb_t *db, unsigned short op, PMList *packages)
pmpkg_t *a = (pmpkg_t *)k->data;
if(!strcmp(a->name, (char *)j->data)) {
MALLOC(miss, sizeof(pmdepmissing_t));
- miss->type = PM_DEP_CONFLICT;
- miss->depend.mod = PM_DEP_ANY;
+ miss->type = PM_DEP_TYPE_CONFLICT;
+ miss->depend.mod = PM_DEP_MOD_ANY;
miss->depend.version[0] = '\0';
STRNCPY(miss->target, tp->name, PKG_NAME_LEN);
STRNCPY(miss->depend.name, a->name, PKG_NAME_LEN);
@@ -266,8 +266,8 @@ PMList *checkdeps(pmdb_t *db, unsigned short op, PMList *packages)
for(j = info->conflicts; j; j = j->next) {
if(!strcmp((char *)j->data, tp->name)) {
MALLOC(miss, sizeof(pmdepmissing_t));
- miss->type = PM_DEP_CONFLICT;
- miss->depend.mod = PM_DEP_ANY;
+ miss->type = PM_DEP_TYPE_CONFLICT;
+ miss->depend.mod = PM_DEP_MOD_ANY;
miss->depend.version[0] = '\0';
STRNCPY(miss->target, tp->name, PKG_NAME_LEN);
STRNCPY(miss->depend.name, info->name, PKG_NAME_LEN);
@@ -292,8 +292,8 @@ PMList *checkdeps(pmdb_t *db, unsigned short op, PMList *packages)
}
// we treat this just like a conflict
MALLOC(miss, sizeof(pmdepmissing_t));
- miss->type = CONFLICT;
- miss->depend.mod = PM_DEP_ANY;
+ miss->type = PM_DEP_TYPE_CONFLICT;
+ miss->depend.mod = PM_DEP_MOD_ANY;
miss->depend.version[0] = '\0';
STRNCPY(miss->target, tp->name, PKG_NAME_LEN);
STRNCPY(miss->depend.name, k->data, PKG_NAME_LEN);
@@ -314,7 +314,7 @@ PMList *checkdeps(pmdb_t *db, unsigned short op, PMList *packages)
for(k = db_get_pkgcache(db); k && !found; k = k->next) {
pmpkg_t *p = (pmpkg_t *)k->data;
if(!strcmp(p->name, depend.name)) {
- if(depend.mod == PM_DEP_ANY) {
+ if(depend.mod == PM_DEP_MOD_ANY) {
/* accept any version */
found = 1;
} else {
@@ -329,9 +329,9 @@ PMList *checkdeps(pmdb_t *db, unsigned short op, PMList *packages)
}
cmp = rpmvercmp(ver, depend.version);
switch(depend.mod) {
- case PM_DEP_EQ: found = (cmp == 0); break;
- case PM_DEP_GE: found = (cmp >= 0); break;
- case PM_DEP_LE: found = (cmp <= 0); break;
+ case PM_DEP_MOD_EQ: found = (cmp == 0); break;
+ case PM_DEP_MOD_GE: found = (cmp >= 0); break;
+ case PM_DEP_MOD_LE: found = (cmp <= 0); break;
}
FREE(ver);
}
@@ -342,7 +342,7 @@ PMList *checkdeps(pmdb_t *db, unsigned short op, PMList *packages)
pmpkg_t *p = (pmpkg_t *)k->data;
/* see if the package names match OR if p provides depend.name */
if(!strcmp(p->name, depend.name) || pm_list_is_strin(depend.name, p->provides)) {
- if(depend.mod == PM_DEP_ANY) {
+ if(depend.mod == PM_DEP_MOD_ANY) {
/* accept any version */
found = 1;
} else {
@@ -357,9 +357,9 @@ PMList *checkdeps(pmdb_t *db, unsigned short op, PMList *packages)
}
cmp = rpmvercmp(ver, depend.version);
switch(depend.mod) {
- case PM_DEP_EQ: found = (cmp == 0); break;
- case PM_DEP_GE: found = (cmp >= 0); break;
- case PM_DEP_LE: found = (cmp <= 0); break;
+ case PM_DEP_MOD_EQ: found = (cmp == 0); break;
+ case PM_DEP_MOD_GE: found = (cmp >= 0); break;
+ case PM_DEP_MOD_LE: found = (cmp <= 0); break;
}
FREE(ver);
}
@@ -378,7 +378,7 @@ PMList *checkdeps(pmdb_t *db, unsigned short op, PMList *packages)
FREELISTPTR(k);
continue;
}
- if(depend.mod == PM_DEP_ANY) {
+ if(depend.mod == PM_DEP_MOD_ANY) {
/* accept any version */
found = 1;
} else {
@@ -393,9 +393,9 @@ PMList *checkdeps(pmdb_t *db, unsigned short op, PMList *packages)
}
cmp = rpmvercmp(ver, depend.version);
switch(depend.mod) {
- case PM_DEP_EQ: found = (cmp == 0); break;
- case PM_DEP_GE: found = (cmp >= 0); break;
- case PM_DEP_LE: found = (cmp <= 0); break;
+ case PM_DEP_MOD_EQ: found = (cmp == 0); break;
+ case PM_DEP_MOD_GE: found = (cmp >= 0); break;
+ case PM_DEP_MOD_LE: found = (cmp <= 0); break;
}
FREE(ver);
}
@@ -405,7 +405,7 @@ PMList *checkdeps(pmdb_t *db, unsigned short op, PMList *packages)
/* else if still not found... */
if(!found) {
MALLOC(miss, sizeof(pmdepmissing_t));
- miss->type = PM_DEP_DEPEND;
+ miss->type = PM_DEP_TYPE_DEPEND;
miss->depend.mod = depend.mod;
STRNCPY(miss->target, tp->name, PKG_NAME_LEN);
STRNCPY(miss->depend.name, depend.name, PKG_NAME_LEN);
@@ -427,8 +427,8 @@ PMList *checkdeps(pmdb_t *db, unsigned short op, PMList *packages)
for(j = tp->requiredby; j; j = j->next) {
if(!pm_list_is_strin((char *)j->data, packages)) {
MALLOC(miss, sizeof(pmdepmissing_t));
- miss->type = PM_DEP_REQUIRED;
- miss->depend.mod = PM_DEP_ANY;
+ miss->type = PM_DEP_TYPE_REQUIRED;
+ miss->depend.mod = PM_DEP_MOD_ANY;
miss->depend.version[0] = '\0';
STRNCPY(miss->target, tp->name, PKG_NAME_LEN);
STRNCPY(miss->depend.name, (char *)j->data, PKG_NAME_LEN);
@@ -459,16 +459,15 @@ int splitdep(char *depstr, pmdepend_t *depend)
str = strdup(depstr);
if((ptr = strstr(str, ">="))) {
- depend->mod = PM_DEP_GE;
+ depend->mod = PM_DEP_MOD_GE;
} else if((ptr = strstr(str, "<="))) {
- depend->mod = PM_DEP_LE;
+ depend->mod = PM_DEP_MOD_LE;
} else if((ptr = strstr(str, "="))) {
- depend->mod = PM_DEP_EQ;
+ depend->mod = PM_DEP_MOD_EQ;
} else {
/* no version specified - accept any */
- depend->mod = PM_DEP_ANY;
+ depend->mod = PM_DEP_MOD_ANY;
STRNCPY(depend->name, str, PKG_NAME_LEN);
- STRNCPY(depend->version, "", PKG_VERSION_LEN);
}
if(ptr == NULL) {
@@ -478,7 +477,7 @@ int splitdep(char *depstr, pmdepend_t *depend)
*ptr = '\0';
STRNCPY(depend->name, str, PKG_NAME_LEN);
ptr++;
- if(depend->mod != PM_DEP_EQ) {
+ if(depend->mod != PM_DEP_MOD_EQ) {
ptr++;
}
STRNCPY(depend->version, ptr, PKG_VERSION_LEN);
@@ -567,7 +566,7 @@ int resolvedeps(pmdb_t *local, PMList *databases, pmsync_t *sync, PMList *list,
return(1);
} else*/
- if(miss->type == PM_DEP_DEPEND) {
+ if(miss->type == PM_DEP_TYPE_DEPEND) {
pmsync_t *sync = NULL;
/* find the package in one of the repositories */
diff --git a/lib/libalpm/deps.h b/lib/libalpm/deps.h
index 71af64be..b45fa48c 100644
--- a/lib/libalpm/deps.h
+++ b/lib/libalpm/deps.h
@@ -24,8 +24,20 @@
#include "db.h"
#include "sync.h"
+typedef struct __pmdepend_t {
+ unsigned char mod;
+ char name[PKG_NAME_LEN];
+ char version[PKG_VERSION_LEN];
+} pmdepend_t;
+
+typedef struct __pmdepmissing_t {
+ char target[PKG_NAME_LEN];
+ unsigned char type;
+ pmdepend_t depend;
+} pmdepmissing_t;
+
PMList *sortbydeps(PMList *targets, int mode);
-PMList *checkdeps(pmdb_t *db, unsigned short op, PMList *packages);
+PMList *checkdeps(pmdb_t *db, unsigned char op, PMList *packages);
int splitdep(char *depstr, pmdepend_t *depend);
PMList *removedeps(pmdb_t *db, PMList *targs);
int resolvedeps(pmdb_t *local, PMList *databases, pmsync_t *sync, PMList *list, PMList *trail, PMList **data);