Make xbps_fetch_file accept a callback to update its progress.

This also makes xbps_unpack_binary_pkg follow this convention by avoiding
static variables.

--HG--
branch : progress_callback
rename : bin/xbps-repo/util.c => bin/xbps-bin/util.c
This commit is contained in:
Juan RP
2011-01-22 12:40:19 +01:00
parent 8c2ccea435
commit 984eae1578
22 changed files with 354 additions and 365 deletions

View File

@@ -2,5 +2,6 @@ TOPDIR = ../..
-include $(TOPDIR)/config.mk
BIN = xbps-uhelper
OBJS = main.o ../xbps-bin/fetch.o
include $(TOPDIR)/prog.mk

View File

@@ -33,6 +33,7 @@
#include <unistd.h>
#include <xbps_api.h>
#include "../xbps-bin/defs.h"
/* error messages in bold/red */
#define MSG_ERROR "\033[1m\033[31m"
@@ -103,6 +104,7 @@ usage(void)
int
main(int argc, char **argv)
{
struct xbps_fetch_progress_data xfpd;
prop_dictionary_t dict;
const char *version;
char *plist, *pkgname, *pkgver, *in_chroot_env, *hash;
@@ -321,7 +323,8 @@ main(int argc, char **argv)
usage();
for (i = 1; i < argc; i++) {
rv = xbps_fetch_file(argv[i], ".", false, "v");
rv = xbps_fetch_file(argv[i], ".", false, "v",
fetch_file_progress_cb, &xfpd);
if (rv == -1) {
printf("%s: %s\n", argv[1],
xbps_fetch_error_string());