summaryrefslogtreecommitdiff
path: root/ftp.c
diff options
context:
space:
mode:
authorjbj <devnull@localhost>1999-02-16 02:42:29 +0000
committerjbj <devnull@localhost>1999-02-16 02:42:29 +0000
commit1556aeb600b7d9344faf5990b6f57d78f4a8a46c (patch)
treed56d6b7d6102c8094da30b8e02e3cdd926017096 /ftp.c
parent81f17dd94b4528af653c7bf76a10266c1e8d081e (diff)
downloadrpm-1556aeb600b7d9344faf5990b6f57d78f4a8a46c.tar.gz
rpm-1556aeb600b7d9344faf5990b6f57d78f4a8a46c.tar.bz2
rpm-1556aeb600b7d9344faf5990b6f57d78f4a8a46c.zip
add callbacks for installer updates while doing URL xfers.
CVS patchset: 2796 CVS date: 1999/02/16 02:42:29
Diffstat (limited to 'ftp.c')
-rw-r--r--ftp.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/ftp.c b/ftp.c
index 01a0c909d..db91daad8 100644
--- a/ftp.c
+++ b/ftp.c
@@ -29,6 +29,7 @@ extern int h_errno;
#include <arpa/inet.h>
#include <arpa/telnet.h>
+#include "rpmlib.h"
#include "rpmio.h"
#if !defined(HAVE_INET_ATON)
@@ -53,6 +54,16 @@ static int ftpDebug = 0;
static int ftpTimeoutSecs = TIMEOUT_SECS;
static int httpTimeoutSecs = TIMEOUT_SECS;
+static rpmCallbackFunction urlNotify = NULL;
+static void * urlNotifyData = NULL;
+static int urlNotifyCount = -1;
+
+void urlSetCallback(rpmCallbackFunction notify, void *notifyData, int notifyCount) {
+ urlNotify = notify;
+ urlNotifyData = notifyData;
+ urlNotifyCount = (notifyCount >= 0) ? notifyCount : 4096;
+}
+
static int checkResponse(int fd, int secs, int *ecp, char ** str) {
static char buf[BUFFER_SIZE + 1];
int bufLength = 0;
@@ -406,6 +417,12 @@ static int copyData(FD_t sfd, FD_t tfd) {
int bytesRead;
int bytesCopied = 0;
int rc;
+ int notifier = -1;
+
+ if (urlNotify) {
+ (*urlNotify) (NULL, RPMCALLBACK_INST_OPEN_FILE,
+ 0, 0, NULL, urlNotifyData);
+ }
while (1) {
FD_ZERO(&emptySet);
@@ -435,11 +452,24 @@ static int copyData(FD_t sfd, FD_t tfd) {
break;
}
bytesCopied += bytesRead;
+ if (urlNotify && urlNotifyCount > 0) {
+ int n = bytesCopied/urlNotifyCount;
+ if (n != notifier) {
+ (*urlNotify) (NULL, RPMCALLBACK_INST_PROGRESS,
+ bytesCopied, 0, NULL, urlNotifyData);
+ notifier = n;
+ }
+ }
}
if (ftpDebug)
fprintf(stderr, "++ copied %d bytes: %s\n", bytesCopied, ftpStrerror(rc));
+ if (urlNotify) {
+ (*urlNotify) (NULL, RPMCALLBACK_INST_OPEN_FILE,
+ bytesCopied, bytesCopied, NULL, urlNotifyData);
+ }
+
fdClose(sfd);
return rc;
}