#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <archive.h>
#include <archive_entry.h>
#include "alpm_list.h"
#include "alpm.h"
#include "libarchive-compat.h"
#include "util.h"
#include "log.h"
#include "handle.h"
#include "package.h"
#include "deps.h"
#include "filelist.h"
struct package_changelog {
struct archive *archive;
int fd;
};
static void *_package_changelog_open(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
struct package_changelog *changelog;
struct archive *archive;
struct archive_entry *entry;
const char *pkgfile = pkg->origin_data.file;
struct stat buf;
int fd;
fd = _alpm_open_archive(pkg->handle, pkgfile, &buf,
&archive, ALPM_ERR_PKG_OPEN);
if(fd < 0) {
return NULL;
}
while(archive_read_next_header(archive, &entry) == ARCHIVE_OK) {
const char *entry_name = archive_entry_pathname(entry);
if(strcmp(entry_name, ".CHANGELOG") == 0) {
changelog = malloc(sizeof(struct package_changelog));
if(!changelog) {
pkg->handle->pm_errno = ALPM_ERR_MEMORY;
_alpm_archive_read_free(archive);
CLOSE(fd);
return NULL;
}
changelog->archive = archive;
changelog->fd = fd;
return changelog;
}
}
_alpm_archive_read_free(archive);
CLOSE(fd);
errno = ENOENT;
return NULL;
}
static size_t _package_changelog_read(void *ptr, size_t size,
const alpm_pkg_t UNUSED *pkg, void *fp)
|