[pacman-dev] [PATCH 3/5] Make pmdepend_t and pmdepmissing_t public

Dan McGee dan at archlinux.org
Thu Jun 16 13:01:35 EDT 2011


Signed-off-by: Dan McGee <dan at archlinux.org>
---
 lib/libalpm/alpm.h   |   75 +++++++++++++++++++++----------------------------
 lib/libalpm/deps.c   |   38 +------------------------
 lib/libalpm/deps.h   |   15 ----------
 src/pacman/remove.c  |    6 +--
 src/pacman/sync.c    |    6 +--
 src/pacman/upgrade.c |    6 +--
 src/util/pactree.c   |    8 ++--
 src/util/testdb.c    |    5 +--
 8 files changed, 45 insertions(+), 114 deletions(-)

diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 0fd6f37..08a7a1f 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -60,6 +60,22 @@ typedef enum _pmpkgreason_t {
 	PM_PKG_REASON_DEPEND = 1
 } pmpkgreason_t;
 
+/** Types of version constraints in dependency specs. */
+typedef enum _pmdepmod_t {
+  /** No version constraint */
+	PM_DEP_MOD_ANY = 1,
+  /** Test version equality (package=x.y.z) */
+	PM_DEP_MOD_EQ,
+  /** Test for at least a version (package>=x.y.z) */
+	PM_DEP_MOD_GE,
+  /** Test for at most a version (package<=x.y.z) */
+	PM_DEP_MOD_LE,
+  /** Test for greater than some version (package>x.y.z) */
+	PM_DEP_MOD_GT,
+  /** Test for less than some version (package<x.y.z) */
+	PM_DEP_MOD_LT
+} pmdepmod_t;
+
 /**
  * File conflict type.
  * Whether the conflict results from a file existing on the filesystem, or with
@@ -90,8 +106,22 @@ typedef struct __pmpkg_t pmpkg_t;
 typedef struct __pmdelta_t pmdelta_t;
 typedef struct __pmgrp_t pmgrp_t;
 typedef struct __pmtrans_t pmtrans_t;
-typedef struct __pmdepend_t pmdepend_t;
-typedef struct __pmdepmissing_t pmdepmissing_t;
+
+/** Dependency */
+typedef struct _pmdepend_t {
+	char *name;
+	char *version;
+	unsigned long name_hash;
+	pmdepmod_t mod;
+} pmdepend_t;
+
+/** Missing dependency */
+typedef struct _pmdepmissing_t {
+	char *target;
+	pmdepend_t *depend;
+	/* this is used in case of remove dependency error only */
+	char *causingpkg;
+} pmdepmissing_t;
 
 /** Conflict */
 typedef struct _pmconflict_t {
@@ -906,55 +936,14 @@ int alpm_remove_pkg(pmhandle_t *handle, pmpkg_t *pkg);
  * @{
  */
 
-/** Types of version constraints in dependency specs. */
-typedef enum _pmdepmod_t {
-  /** No version constraint */
-	PM_DEP_MOD_ANY = 1,
-  /** Test version equality (package=x.y.z) */
-	PM_DEP_MOD_EQ,
-  /** Test for at least a version (package>=x.y.z) */
-	PM_DEP_MOD_GE,
-  /** Test for at most a version (package<=x.y.z) */
-	PM_DEP_MOD_LE,
-  /** Test for greater than some version (package>x.y.z) */
-	PM_DEP_MOD_GT,
-  /** Test for less than some version (package<x.y.z) */
-	PM_DEP_MOD_LT
-} pmdepmod_t;
-
 alpm_list_t *alpm_checkdeps(pmhandle_t *handle, alpm_list_t *pkglist,
 		alpm_list_t *remove, alpm_list_t *upgrade, int reversedeps);
 pmpkg_t *alpm_find_satisfier(alpm_list_t *pkgs, const char *depstring);
 pmpkg_t *alpm_find_dbs_satisfier(pmhandle_t *handle,
 		alpm_list_t *dbs, const char *depstring);
 
-const char *alpm_miss_get_target(const pmdepmissing_t *miss);
-pmdepend_t *alpm_miss_get_dep(pmdepmissing_t *miss);
-const char *alpm_miss_get_causingpkg(const pmdepmissing_t *miss);
-
 alpm_list_t *alpm_checkconflicts(pmhandle_t *handle, alpm_list_t *pkglist);
 
-/** Returns the type of version constraint.
- * @param dep a dependency info structure
- * @return the type of version constraint (PM_DEP_MOD_ANY if no version
- * is specified).
- */
-pmdepmod_t alpm_dep_get_mod(const pmdepend_t *dep);
-
-/** Returns the package name of a dependency constraint.
- * @param dep a dependency info structure
- * @return a pointer to an internal string.
- */
-const char *alpm_dep_get_name(const pmdepend_t *dep);
-
-/** Returns the version specified by a dependency constraint.
- * The version information is returned as a string in the same format
- * as given by alpm_pkg_get_version().
- * @param dep a dependency info structure
- * @return a pointer to an internal string.
- */
-const char *alpm_dep_get_version(const pmdepend_t *dep);
-
 /** Returns a newly allocated string representing the dependency information.
  * @param dep a dependency info structure
  * @return a formatted string, e.g. "glibc>=2.12"
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index 10c0009..085e6ca 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -719,7 +719,7 @@ int _alpm_resolvedeps(pmhandle_t *handle, alpm_list_t *localpkgs, pmpkg_t *pkg,
 
 		for(j = deps; j; j = j->next) {
 			pmdepmissing_t *miss = j->data;
-			pmdepend_t *missdep = alpm_miss_get_dep(miss);
+			pmdepend_t *missdep = miss->depend;
 			/* check if one of the packages in the [*packages] list already satisfies
 			 * this dependency */
 			if(find_dep_satisfier(*packages, missdep)) {
@@ -764,42 +764,6 @@ int _alpm_resolvedeps(pmhandle_t *handle, alpm_list_t *localpkgs, pmpkg_t *pkg,
 	return ret;
 }
 
-const char SYMEXPORT *alpm_miss_get_target(const pmdepmissing_t *miss)
-{
-	ASSERT(miss != NULL, return NULL);
-	return miss->target;
-}
-
-const char SYMEXPORT *alpm_miss_get_causingpkg(const pmdepmissing_t *miss)
-{
-	ASSERT(miss != NULL, return NULL);
-	return miss->causingpkg;
-}
-
-pmdepend_t SYMEXPORT *alpm_miss_get_dep(pmdepmissing_t *miss)
-{
-	ASSERT(miss != NULL, return NULL);
-	return miss->depend;
-}
-
-pmdepmod_t SYMEXPORT alpm_dep_get_mod(const pmdepend_t *dep)
-{
-	ASSERT(dep != NULL, return -1);
-	return dep->mod;
-}
-
-const char SYMEXPORT *alpm_dep_get_name(const pmdepend_t *dep)
-{
-	ASSERT(dep != NULL, return NULL);
-	return dep->name;
-}
-
-const char SYMEXPORT *alpm_dep_get_version(const pmdepend_t *dep)
-{
-	ASSERT(dep != NULL, return NULL);
-	return dep->version;
-}
-
 /** Reverse of splitdep; make a dep string from a pmdepend_t struct.
  * The string must be freed!
  * @param dep the depend to turn into a string
diff --git a/lib/libalpm/deps.h b/lib/libalpm/deps.h
index 97c0918..ecc3b92 100644
--- a/lib/libalpm/deps.h
+++ b/lib/libalpm/deps.h
@@ -27,21 +27,6 @@
 #include "package.h"
 #include "alpm.h"
 
-/* Dependency */
-struct __pmdepend_t {
-	char *name;
-	char *version;
-	unsigned long name_hash;
-	pmdepmod_t mod;
-};
-
-/* Missing dependency */
-struct __pmdepmissing_t {
-	char *target;
-	pmdepend_t *depend;
-	char *causingpkg; /* this is used in case of remove dependency error only */
-};
-
 void _alpm_dep_free(pmdepend_t *dep);
 pmdepend_t *_alpm_dep_dup(const pmdepend_t *dep);
 void _alpm_depmiss_free(pmdepmissing_t *miss);
diff --git a/src/pacman/remove.c b/src/pacman/remove.c
index a4e1894..2ce33b8 100644
--- a/src/pacman/remove.c
+++ b/src/pacman/remove.c
@@ -115,10 +115,8 @@ int pacman_remove(alpm_list_t *targets)
 			case PM_ERR_UNSATISFIED_DEPS:
 				for(i = data; i; i = alpm_list_next(i)) {
 					pmdepmissing_t *miss = alpm_list_getdata(i);
-					pmdepend_t *dep = alpm_miss_get_dep(miss);
-					char *depstring = alpm_dep_compute_string(dep);
-					printf(_(":: %s: requires %s\n"), alpm_miss_get_target(miss),
-							depstring);
+					char *depstring = alpm_dep_compute_string(miss->depend);
+					printf(_(":: %s: requires %s\n"), miss->target, depstring);
 					free(depstring);
 				}
 				break;
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index 254117a..177eab6 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -785,10 +785,8 @@ static int sync_trans(alpm_list_t *targets)
 			case PM_ERR_UNSATISFIED_DEPS:
 				for(i = data; i; i = alpm_list_next(i)) {
 					pmdepmissing_t *miss = alpm_list_getdata(i);
-					pmdepend_t *dep = alpm_miss_get_dep(miss);
-					char *depstring = alpm_dep_compute_string(dep);
-					printf(_(":: %s: requires %s\n"), alpm_miss_get_target(miss),
-							depstring);
+					char *depstring = alpm_dep_compute_string(miss->depend);
+					printf(_(":: %s: requires %s\n"), miss->target, depstring);
 					free(depstring);
 				}
 				break;
diff --git a/src/pacman/upgrade.c b/src/pacman/upgrade.c
index 0abcbe4..6587671 100644
--- a/src/pacman/upgrade.c
+++ b/src/pacman/upgrade.c
@@ -107,14 +107,12 @@ int pacman_upgrade(alpm_list_t *targets)
 			case PM_ERR_UNSATISFIED_DEPS:
 				for(i = data; i; i = alpm_list_next(i)) {
 					pmdepmissing_t *miss = alpm_list_getdata(i);
-					pmdepend_t *dep = alpm_miss_get_dep(miss);
-					char *depstring = alpm_dep_compute_string(dep);
+					char *depstring = alpm_dep_compute_string(miss->depend);
 
 					/* TODO indicate if the error was a virtual package or not:
 					 *		:: %s: requires %s, provided by %s
 					 */
-					printf(_(":: %s: requires %s\n"), alpm_miss_get_target(miss),
-							depstring);
+					printf(_(":: %s: requires %s\n"), miss->target, depstring);
 					free(depstring);
 				}
 				break;
diff --git a/src/util/pactree.c b/src/util/pactree.c
index 1dee61b..6b29d93 100644
--- a/src/util/pactree.c
+++ b/src/util/pactree.c
@@ -290,7 +290,7 @@ static void walk_deps(pmpkg_t *pkg, int depth)
 	for(i = alpm_pkg_get_depends(pkg); i; i = alpm_list_next(i)) {
 		pmdepend_t *depend = alpm_list_getdata(i);
 		pmpkg_t *provider = alpm_find_satisfier(alpm_db_get_pkgcache(db_local),
-				alpm_dep_get_name(depend));
+				depend->name);
 
 		if(provider) {
 			const char *provname = alpm_pkg_get_name(provider);
@@ -299,15 +299,15 @@ static void walk_deps(pmpkg_t *pkg, int depth)
 				/* if we've already seen this package, don't print in "unique" output
 				 * and don't recurse */
 				if(!unique) {
-					print(alpm_pkg_get_name(pkg), provname, alpm_dep_get_name(depend), depth);
+					print(alpm_pkg_get_name(pkg), provname, depend->name, depth);
 				}
 			} else {
-				print(alpm_pkg_get_name(pkg), provname, alpm_dep_get_name(depend), depth);
+				print(alpm_pkg_get_name(pkg), provname, depend->name, depth);
 				walk_deps(provider, depth + 1);
 			}
 		} else {
 			/* unresolvable package */
-			print(alpm_pkg_get_name(pkg), NULL, alpm_dep_get_name(depend), depth);
+			print(alpm_pkg_get_name(pkg), NULL, depend->name, depth);
 		}
 	}
 }
diff --git a/src/util/testdb.c b/src/util/testdb.c
index aeccdb7..4937480 100644
--- a/src/util/testdb.c
+++ b/src/util/testdb.c
@@ -101,9 +101,8 @@ static int checkdeps(alpm_list_t *pkglist)
 	data = alpm_checkdeps(handle, pkglist, NULL, pkglist, 0);
 	for(i = data; i; i = alpm_list_next(i)) {
 		pmdepmissing_t *miss = alpm_list_getdata(i);
-		pmdepend_t *dep = alpm_miss_get_dep(miss);
-		char *depstring = alpm_dep_compute_string(dep);
-		printf("missing dependency for %s : %s\n", alpm_miss_get_target(miss),
+		char *depstring = alpm_dep_compute_string(miss->depend);
+		printf("missing dependency for %s : %s\n", miss->target,
 				depstring);
 		free(depstring);
 		ret++;
-- 
1.7.5.4



More information about the pacman-dev mailing list