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();
61 r = xbps_archive_read_open_remote(ar, url);
63 r = xbps_archive_read_open(ar, url);
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);
97 if (strcmp(bfile, fname) == 0) {
98 buf = xbps_archive_get_file(a, entry);
101 archive_read_data_skip(a);
103 archive_read_free(a);
112 struct archive_entry *entry;
119 if ((a = open_archive(url)) == NULL)
124 rv = archive_read_next_header(a, &entry);
125 if (rv == ARCHIVE_EOF) {
129 if (rv == ARCHIVE_FATAL) {
130 const char *error = archive_error_string(a);
133 "Reading archive entry from: %s: %s\n",
137 "Reading archive entry from: %s: %s\n",
138 url, strerror(xbps_archive_errno(a)));
140 rv = xbps_archive_errno(a);
143 bfile = archive_entry_pathname(entry);
149 if (strcmp(bfile, fname) == 0) {
150 rv = archive_read_data_into_fd(a, fd);
151 if (rv != ARCHIVE_OK)
152 rv = xbps_archive_errno(a);
155 archive_read_data_skip(a);
157 archive_read_free(a);
171 d = xbps_dictionary_internalize(buf);
#define xbps_unreachable()
Log and abort for code that should be unreachable.
void xbps_error_printf(const char *fmt,...)
Prints error messages to stderr.
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)