From 040083b97fab61c8afc16a1c49a8384d097c272a Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sun, 28 Aug 2011 23:41:17 -0500 Subject: Allow access to package origin data Add new alpm_pkg_get_origin() method, use it in the front end now that the enum constants are publicly available. Signed-off-by: Dan McGee --- lib/libalpm/alpm.h | 5 +++++ lib/libalpm/package.c | 7 +++++++ 2 files changed, 12 insertions(+) (limited to 'lib') diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 2f625658..42e60385 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -598,6 +598,11 @@ const char *alpm_pkg_get_name(alpm_pkg_t *pkg); */ const char *alpm_pkg_get_version(alpm_pkg_t *pkg); +/** Returns the origin of the package. + * @return a #alpm_pkgfrom_t constant, -1 on error + */ +alpm_pkgfrom_t alpm_pkg_get_origin(alpm_pkg_t *pkg); + /** Returns the package description. * @param pkg a pointer to package * @return a reference to an internal string diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index 3d73a433..487b56d9 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -185,6 +185,13 @@ const char SYMEXPORT *alpm_pkg_get_version(alpm_pkg_t *pkg) return pkg->version; } +alpm_pkgfrom_t SYMEXPORT alpm_pkg_get_origin(alpm_pkg_t *pkg) +{ + ASSERT(pkg != NULL, return -1); + pkg->handle->pm_errno = 0; + return pkg->origin; +} + const char SYMEXPORT *alpm_pkg_get_desc(alpm_pkg_t *pkg) { ASSERT(pkg != NULL, return NULL); -- cgit v1.2.3-70-g09d2