summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/package.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libalpm/package.c')
-rw-r--r--lib/libalpm/package.c78
1 files changed, 4 insertions, 74 deletions
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index 4f7cc2db..2d0ec010 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -300,50 +300,7 @@ pmdb_t SYMEXPORT *alpm_pkg_get_db(pmpkg_t *pkg)
*/
void SYMEXPORT *alpm_pkg_changelog_open(pmpkg_t *pkg)
{
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(pkg != NULL, return(NULL));
-
- if(pkg->origin == PKG_FROM_FILE) {
- struct archive *archive = NULL;
- struct archive_entry *entry;
- const char *pkgfile = pkg->origin_data.file;
-
- if((archive = archive_read_new()) == NULL) {
- RET_ERR(PM_ERR_LIBARCHIVE, NULL);
- }
-
- archive_read_support_compression_all(archive);
- archive_read_support_format_all(archive);
-
- if (archive_read_open_filename(archive, pkgfile,
- ARCHIVE_DEFAULT_BYTES_PER_BLOCK) != ARCHIVE_OK) {
- RET_ERR(PM_ERR_PKG_OPEN, NULL);
- }
-
- while(archive_read_next_header(archive, &entry) == ARCHIVE_OK) {
- const char *entry_name = archive_entry_pathname(entry);
-
- if(strcmp(entry_name, ".CHANGELOG") == 0) {
- return(archive);
- }
- }
- /* we didn't find a changelog */
- archive_read_finish(archive);
- errno = ENOENT;
- } else {
- char clfile[PATH_MAX];
- snprintf(clfile, PATH_MAX, "%s/%s/%s-%s/changelog",
- alpm_option_get_dbpath(),
- alpm_db_get_name(handle->db_local),
- alpm_pkg_get_name(pkg),
- alpm_pkg_get_version(pkg));
- return fopen(clfile, "r");
- }
-
- return(NULL);
+ return pkg->ops->changelog_open(pkg);
}
/**
@@ -361,34 +318,13 @@ void SYMEXPORT *alpm_pkg_changelog_open(pmpkg_t *pkg)
size_t SYMEXPORT alpm_pkg_changelog_read(void *ptr, size_t size,
const pmpkg_t *pkg, const void *fp)
{
- size_t ret = 0;
-
- if(pkg->origin == PKG_FROM_FILE) {
- ssize_t sret = archive_read_data((struct archive*)fp, ptr, size);
- /* Report error (negative values) */
- if(sret < 0) {
- pm_errno = PM_ERR_LIBARCHIVE;
- ret = 0;
- } else {
- ret = (size_t)sret;
- }
- } else {
- ret = fread(ptr, 1, size, (FILE*)fp);
- }
- return(ret);
+ return pkg->ops->changelog_read(ptr, size, pkg, fp);
}
/*
int SYMEXPORT alpm_pkg_changelog_feof(const pmpkg_t *pkg, void *fp)
{
- int ret = 0;
- if(pkg->origin == PKG_FROM_FILE) {
- // note: this doesn't quite work, no feof in libarchive
- ret = archive_read_data((struct archive*)fp, NULL, 0);
- } else {
- ret = feof((FILE*)fp);
- }
- return(ret);
+ return pkg->ops->changelog_feof(pkg, fp);
}
*/
@@ -402,13 +338,7 @@ int SYMEXPORT alpm_pkg_changelog_feof(const pmpkg_t *pkg, void *fp)
*/
int SYMEXPORT alpm_pkg_changelog_close(const pmpkg_t *pkg, void *fp)
{
- int ret = 0;
- if(pkg->origin == PKG_FROM_FILE) {
- ret = archive_read_finish((struct archive *)fp);
- } else {
- ret = fclose((FILE*)fp);
- }
- return(ret);
+ return pkg->ops->changelog_close(pkg, fp);
}
int SYMEXPORT alpm_pkg_has_scriptlet(pmpkg_t *pkg)