#include <pakfire/ctx.h>
#include <pakfire/elf.h>
+#include <pakfire/file.h>
#include <pakfire/string.h>
// libelf
return r;
}
+int pakfire_elf_open_file(struct pakfire_elf** elf,
+ struct pakfire_ctx* ctx, struct pakfire_file* file) {
+ const char* path = NULL;
+ int fd = -EBADF;
+ int r;
+
+ // Fetch the path
+ path = pakfire_file_get_path(file);
+
+ // Open the file
+ fd = pakfire_file_open(file, 0);
+ if (fd < 0)
+ return -errno;
+
+ // Open the ELF object
+ r = pakfire_elf_open(elf, ctx, path, fd);
+ if (r < 0)
+ goto ERROR;
+
+ERROR:
+ if (fd >= 0)
+ close(fd);
+
+ return r;
+}
+
struct pakfire_elf* pakfire_elf_ref(struct pakfire_elf* self) {
self->nrefs++;
struct pakfire_elf;
#include <pakfire/ctx.h>
+#include <pakfire/file.h>
int pakfire_elf_open(struct pakfire_elf** elf,
struct pakfire_ctx* ctx, const char* path, int fd);
+int pakfire_elf_open_file(struct pakfire_elf** elf,
+ struct pakfire_ctx* ctx, struct pakfire_file* file);
struct pakfire_elf* pakfire_elf_ref(struct pakfire_elf* self);
struct pakfire_elf* pakfire_elf_unref(struct pakfire_elf* self);