[pacman-dev] [PATCH 4/8] Add public functions for accessing mtree data

Allan McRae allan at archlinux.org
Sat May 5 05:14:02 EDT 2012


Signed-off-by: Allan McRae <allan at archlinux.org>
---
 lib/libalpm/alpm.h     |   12 ++++++++++++
 lib/libalpm/be_local.c |    2 --
 lib/libalpm/package.c  |   23 +++++++++++++++++++++++
 3 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 023c53e..c2761a5 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -31,6 +31,10 @@ extern "C" {
 #include <sys/types.h> /* off_t */
 #include <stdarg.h>    /* va_list */
 
+/* libarchive */
+#include <archive.h>
+#include <archive_entry.h>
+
 #include <alpm_list.h>
 
 /*
@@ -930,6 +934,14 @@ size_t alpm_pkg_changelog_read(void *ptr, size_t size,
 
 int alpm_pkg_changelog_close(const alpm_pkg_t *pkg, void *fp);
 
+
+struct archive *alpm_pkg_mtree_open(alpm_pkg_t *pkg);
+
+int alpm_pkg_mtree_next(const alpm_pkg_t *pkg, struct archive *archive,
+		struct archive_entry **entry);
+
+int alpm_pkg_mtree_close(const alpm_pkg_t *pkg, struct archive *archive);
+
 /** Returns whether the package has an install scriptlet.
  * @return 0 if FALSE, TRUE otherwise
  */
diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c
index 402637a..3b78b99 100644
--- a/lib/libalpm/be_local.c
+++ b/lib/libalpm/be_local.c
@@ -219,8 +219,6 @@ static struct archive *_cache_mtree_open(alpm_pkg_t *pkg)
 	int r;
 	struct archive *mtree;
 
-	pkg->handle->pm_errno = 0;
-
 	alpm_db_t *db = alpm_pkg_get_db(pkg);
 	char *mtfile = _alpm_local_db_pkgpath(db, pkg, "mtree");
 
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index 3906b0f..bdc2899 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -403,6 +403,29 @@ int SYMEXPORT alpm_pkg_changelog_close(const alpm_pkg_t *pkg, void *fp)
 	return pkg->ops->changelog_close(pkg, fp);
 }
 
+struct archive SYMEXPORT *alpm_pkg_mtree_open(alpm_pkg_t * pkg)
+{
+	ASSERT(pkg != NULL, return NULL);
+	pkg->handle->pm_errno = 0;
+	return pkg->ops->mtree_open(pkg);
+}
+
+int SYMEXPORT alpm_pkg_mtree_next(const alpm_pkg_t * pkg, struct archive *archive,
+	struct archive_entry **entry)
+{
+	ASSERT(pkg != NULL, return -1);
+	pkg->handle->pm_errno = 0;
+	return pkg->ops->mtree_next(pkg, archive, entry);
+}
+
+int SYMEXPORT alpm_pkg_mtree_close(const alpm_pkg_t * pkg, struct archive *archive)
+{
+	ASSERT(pkg != NULL, return -1);
+	pkg->handle->pm_errno = 0;
+	return pkg->ops->mtree_close(pkg, archive);
+}
+
+
 int SYMEXPORT alpm_pkg_has_scriptlet(alpm_pkg_t *pkg)
 {
 	ASSERT(pkg != NULL, return -1);
-- 
1.7.10.1



More information about the pacman-dev mailing list