libalpm: Add accessors for the base field
This commit adds the necessary accessor functions to get the PKGBASE of a package, forcing the desc file to be parsed. Signed-off-by: Johannes Löthberg <johannes@kyriasis.com> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
9f527d2de4
commit
1f1e53c208
4 changed files with 23 additions and 0 deletions
|
@ -1101,6 +1101,12 @@ int alpm_pkg_should_ignore(alpm_handle_t *handle, alpm_pkg_t *pkg);
|
||||||
*/
|
*/
|
||||||
const char *alpm_pkg_get_filename(alpm_pkg_t *pkg);
|
const char *alpm_pkg_get_filename(alpm_pkg_t *pkg);
|
||||||
|
|
||||||
|
/** Returns the package base name.
|
||||||
|
* @param pkg a pointer to package
|
||||||
|
* @return a reference to an internal string
|
||||||
|
*/
|
||||||
|
const char *alpm_pkg_get_base(alpm_pkg_t *pkg);
|
||||||
|
|
||||||
/** Returns the package name.
|
/** Returns the package name.
|
||||||
* @param pkg a pointer to package
|
* @param pkg a pointer to package
|
||||||
* @return a reference to an internal string
|
* @return a reference to an internal string
|
||||||
|
|
|
@ -63,6 +63,12 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq);
|
||||||
* initialized.
|
* initialized.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static const char *_cache_get_base(alpm_pkg_t *pkg)
|
||||||
|
{
|
||||||
|
LAZY_LOAD(INFRQ_DESC, NULL);
|
||||||
|
return pkg->base;
|
||||||
|
}
|
||||||
|
|
||||||
static const char *_cache_get_desc(alpm_pkg_t *pkg)
|
static const char *_cache_get_desc(alpm_pkg_t *pkg)
|
||||||
{
|
{
|
||||||
LAZY_LOAD(INFRQ_DESC, NULL);
|
LAZY_LOAD(INFRQ_DESC, NULL);
|
||||||
|
@ -297,6 +303,7 @@ static int _cache_force_load(alpm_pkg_t *pkg)
|
||||||
* logic.
|
* logic.
|
||||||
*/
|
*/
|
||||||
static struct pkg_operations local_pkg_ops = {
|
static struct pkg_operations local_pkg_ops = {
|
||||||
|
.get_base = _cache_get_base,
|
||||||
.get_desc = _cache_get_desc,
|
.get_desc = _cache_get_desc,
|
||||||
.get_url = _cache_get_url,
|
.get_url = _cache_get_url,
|
||||||
.get_builddate = _cache_get_builddate,
|
.get_builddate = _cache_get_builddate,
|
||||||
|
|
|
@ -83,6 +83,7 @@ int SYMEXPORT alpm_pkg_checkmd5sum(alpm_pkg_t *pkg)
|
||||||
* backend logic that needs lazy access, such as the local database through
|
* backend logic that needs lazy access, such as the local database through
|
||||||
* a lazy-load cache. However, the defaults will work just fine for fully-
|
* a lazy-load cache. However, the defaults will work just fine for fully-
|
||||||
* populated package structures. */
|
* populated package structures. */
|
||||||
|
static const char *_pkg_get_base(alpm_pkg_t *pkg) { return pkg->base; }
|
||||||
static const char *_pkg_get_desc(alpm_pkg_t *pkg) { return pkg->desc; }
|
static const char *_pkg_get_desc(alpm_pkg_t *pkg) { return pkg->desc; }
|
||||||
static const char *_pkg_get_url(alpm_pkg_t *pkg) { return pkg->url; }
|
static const char *_pkg_get_url(alpm_pkg_t *pkg) { return pkg->url; }
|
||||||
static alpm_time_t _pkg_get_builddate(alpm_pkg_t *pkg) { return pkg->builddate; }
|
static alpm_time_t _pkg_get_builddate(alpm_pkg_t *pkg) { return pkg->builddate; }
|
||||||
|
@ -144,6 +145,7 @@ static int _pkg_force_load(alpm_pkg_t UNUSED *pkg) { return 0; }
|
||||||
* struct itself with no abstraction layer or any type of lazy loading.
|
* struct itself with no abstraction layer or any type of lazy loading.
|
||||||
*/
|
*/
|
||||||
struct pkg_operations default_pkg_ops = {
|
struct pkg_operations default_pkg_ops = {
|
||||||
|
.get_base = _pkg_get_base,
|
||||||
.get_desc = _pkg_get_desc,
|
.get_desc = _pkg_get_desc,
|
||||||
.get_url = _pkg_get_url,
|
.get_url = _pkg_get_url,
|
||||||
.get_builddate = _pkg_get_builddate,
|
.get_builddate = _pkg_get_builddate,
|
||||||
|
@ -186,6 +188,13 @@ const char SYMEXPORT *alpm_pkg_get_filename(alpm_pkg_t *pkg)
|
||||||
return pkg->filename;
|
return pkg->filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char SYMEXPORT *alpm_pkg_get_base(alpm_pkg_t *pkg)
|
||||||
|
{
|
||||||
|
ASSERT(pkg != NULL, return NULL);
|
||||||
|
pkg->handle->pm_errno = 0;
|
||||||
|
return pkg->ops->get_base(pkg);
|
||||||
|
}
|
||||||
|
|
||||||
const char SYMEXPORT *alpm_pkg_get_name(alpm_pkg_t *pkg)
|
const char SYMEXPORT *alpm_pkg_get_name(alpm_pkg_t *pkg)
|
||||||
{
|
{
|
||||||
ASSERT(pkg != NULL, return NULL);
|
ASSERT(pkg != NULL, return NULL);
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
* defined default_pkg_ops struct to work just fine for their needs.
|
* defined default_pkg_ops struct to work just fine for their needs.
|
||||||
*/
|
*/
|
||||||
struct pkg_operations {
|
struct pkg_operations {
|
||||||
|
const char *(*get_base) (alpm_pkg_t *);
|
||||||
const char *(*get_desc) (alpm_pkg_t *);
|
const char *(*get_desc) (alpm_pkg_t *);
|
||||||
const char *(*get_url) (alpm_pkg_t *);
|
const char *(*get_url) (alpm_pkg_t *);
|
||||||
alpm_time_t (*get_builddate) (alpm_pkg_t *);
|
alpm_time_t (*get_builddate) (alpm_pkg_t *);
|
||||||
|
|
Loading…
Add table
Reference in a new issue