33 #include "xbps_api_impl.h"
39 #define _READ_CHUNK 8192
42 _xbps_uncompress_plist_data(
char *xml,
size_t len)
46 char *uncomp_xml = NULL;
48 ssize_t totalsize = 0;
58 strm.next_in = Z_NULL;
61 if (inflateInit2(&strm, 15+16) != Z_OK)
65 strm.next_in = (
unsigned char *)xml;
68 if ((uncomp_xml = malloc(_READ_CHUNK)) == NULL) {
69 (void)inflateEnd(&strm);
74 if ((out = malloc(_READ_CHUNK)) == NULL) {
75 (void)inflateEnd(&strm);
82 strm.avail_out = _READ_CHUNK;
84 rv = inflate(&strm, Z_NO_FLUSH);
92 (void)inflateEnd(&strm);
97 have = _READ_CHUNK - strm.avail_out;
99 uncomp_xml = realloc(uncomp_xml, totalsize);
100 memcpy(uncomp_xml + totalsize - have, out, have);
101 }
while (strm.avail_out == 0);
104 (void)inflateEnd(&strm);
111 prop_dictionary_t HIDDEN
112 xbps_dictionary_from_archive_entry(
struct archive *ar,
113 struct archive_entry *entry)
115 prop_dictionary_t d = NULL;
118 char *buf, *uncomp_buf;
121 assert(entry != NULL);
123 buflen = (size_t)archive_entry_size(entry);
124 buf = malloc(buflen);
128 nbytes = archive_read_data(ar, buf, buflen);
129 if ((
size_t)nbytes != buflen) {
135 d = prop_dictionary_internalize(buf);
136 if (prop_object_type(d) == PROP_TYPE_DICTIONARY)
140 uncomp_buf = _xbps_uncompress_plist_data(buf, buflen);
141 if (uncomp_buf == NULL) {
147 d = prop_dictionary_internalize(uncomp_buf);