35#include <archive_entry.h>
37#include "xbps_api_impl.h"
46static struct archive *
47open_archive(
const char *url)
52 ar = xbps_archive_read_new();
55 xbps_error_printf(
"failed to open archive: %s: %s\n", url, strerror(-r));
61 r = xbps_archive_read_open_remote(ar, url);
63 r = xbps_archive_read_open(ar, url);
66 xbps_error_printf(
"failed to open archive: %s: %s\n", url, strerror(-r));
67 archive_read_free(ar);
79 struct archive_entry *entry;
85 if ((a = open_archive(url)) == NULL)
88 while ((archive_read_next_header(a, &entry)) == ARCHIVE_OK) {
91 bfile = archive_entry_pathname(entry);
95 if (strcmp(bfile, fname) == 0) {
96 buf = xbps_archive_get_file(a, entry);
99 archive_read_data_skip(a);
101 archive_read_free(a);
110 struct archive_entry *entry;
117 if ((a = open_archive(url)) == NULL)
122 rv = archive_read_next_header(a, &entry);
123 if (rv == ARCHIVE_EOF) {
127 if (rv == ARCHIVE_FATAL) {
128 const char *error = archive_error_string(a);
131 "Reading archive entry from: %s: %s\n",
135 "Reading archive entry from: %s: %s\n",
136 url, strerror(archive_errno(a)));
138 rv = archive_errno(a);
141 bfile = archive_entry_pathname(entry);
145 if (strcmp(bfile, fname) == 0) {
146 rv = archive_read_data_into_fd(a, fd);
147 if (rv != ARCHIVE_OK)
148 rv = archive_errno(a);
151 archive_read_data_skip(a);
153 archive_read_free(a);
167 d = xbps_dictionary_internalize(buf);
char * xbps_archive_fetch_file(const char *url, const char *fname)
xbps_dictionary_t xbps_archive_fetch_plist(const char *url, const char *plistf)
int xbps_archive_fetch_file_into_fd(const char *url, const char *fname, int fd)
bool xbps_repository_is_remote(const char *uri)