xbps-query(8: added --cat=FILE mode support.

- This mode prints to stdout the matching FILE stored in a binary package.
- ABI break: renamed xbps_get_pkg_plist_from_binpkg() xbps_binpkg_get_plist().
- Added xbps_binpkg_get_file() as a generic way to get pkg file contents.
- Removed useless comments from xbps_api_impl.h.
This commit is contained in:
Juan RP
2014-11-17 15:45:46 +01:00
parent 3afb9d709d
commit a6516505e9
13 changed files with 144 additions and 205 deletions

View File

@ -31,10 +31,9 @@
#include "xbps_api_impl.h"
xbps_dictionary_t HIDDEN
xbps_archive_get_dictionary(struct archive *ar, struct archive_entry *entry)
char HIDDEN *
xbps_archive_get_file(struct archive *ar, struct archive_entry *entry)
{
xbps_dictionary_t d = NULL;
size_t buflen;
ssize_t nbytes = -1;
char *buf;
@ -43,7 +42,7 @@ xbps_archive_get_dictionary(struct archive *ar, struct archive_entry *entry)
assert(entry != NULL);
buflen = (size_t)archive_entry_size(entry);
buf = malloc(buflen);
buf = malloc(buflen+1);
if (buf == NULL)
return NULL;
@ -52,14 +51,23 @@ xbps_archive_get_dictionary(struct archive *ar, struct archive_entry *entry)
free(buf);
return NULL;
}
buf[buflen] = '\0';
return buf;
}
xbps_dictionary_t HIDDEN
xbps_archive_get_dictionary(struct archive *ar, struct archive_entry *entry)
{
xbps_dictionary_t d = NULL;
char *buf;
if ((buf = xbps_archive_get_file(ar, entry)) == NULL)
return NULL;
/* If blob is already a dictionary we are done */
d = xbps_dictionary_internalize(buf);
if (xbps_object_type(d) == XBPS_TYPE_DICTIONARY) {
free(buf);
return d;
}
return NULL;
free(buf);
return d;
}
int