cgo

[Fork] Gopher Client
git clone https://git.jojolepro.com/cgo.git
Log | Files | Refs | README | LICENSE

commit af08f579c558ed717e70f7a0731581c87d2bd69c
parent f9f0ccb904886b2bac1661db880aa133f0d34637
Author: Sebastian Steinhauer <s.steinhauer@yahoo.de>
Date:   Tue, 14 Oct 2014 14:39:13 +0200

Added simple download progress

Diffstat:
Mcgo.c | 7+++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/cgo.c b/cgo.c @@ -127,8 +127,9 @@ int read_line(int fd, char *buf, size_t buf_len) int download_file(const char *host, const char *port, const char *selector, int fd) { - int srvfd, len; - char buffer[1024]; + int srvfd, len; + unsigned long total = 0; + char buffer[4096]; printf("downloading [%s]...\r", selector); srvfd = dial(host, port, selector); @@ -139,6 +140,8 @@ int download_file(const char *host, const char *port, } while ((len = read(srvfd, buffer, sizeof(buffer))) > 0) { write(fd, buffer, len); + total += len; + printf("downloading [%s] (%ld kb)...\r", selector, total / 1024); } close(fd); close(srvfd);